From 268a53de823a6750d6256ee1fb1e7707b4b45740 Mon Sep 17 00:00:00 2001 From: Xavier ASUS Date: Fri, 18 Oct 2019 00:31:54 +0200 Subject: sdcc-3.9.0 fork implementing GNU assembler syntax This fork aims to provide better support for stm8-binutils --- support/sdbinutils/binutils/.deps/addr2line.Po | 1 + support/sdbinutils/binutils/.deps/ar.Po | 321 + support/sdbinutils/binutils/.deps/arlex.Po | 232 + support/sdbinutils/binutils/.deps/arparse.Po | 286 + support/sdbinutils/binutils/.deps/arsup.Po | 297 + support/sdbinutils/binutils/.deps/bfdtest1.Po | 284 + support/sdbinutils/binutils/.deps/bfdtest2.Po | 284 + support/sdbinutils/binutils/.deps/bin2c.Po | 1 + support/sdbinutils/binutils/.deps/binemul.Po | 288 + support/sdbinutils/binutils/.deps/bucomm.Po | 312 + support/sdbinutils/binutils/.deps/coffdump.Po | 1 + support/sdbinutils/binutils/.deps/coffgrok.Po | 1 + support/sdbinutils/binutils/.deps/cxxfilt.Po | 302 + support/sdbinutils/binutils/.deps/debug.Po | 298 + support/sdbinutils/binutils/.deps/deflex.Po | 1 + support/sdbinutils/binutils/.deps/defparse.Po | 1 + support/sdbinutils/binutils/.deps/dlltool.Po | 1 + support/sdbinutils/binutils/.deps/dllwrap.Po | 1 + support/sdbinutils/binutils/.deps/dwarf.Po | 1 + support/sdbinutils/binutils/.deps/elfcomm.Po | 1 + support/sdbinutils/binutils/.deps/elfedit.Po | 1 + .../sdbinutils/binutils/.deps/emul_$(EMULATION).Po | 1 + support/sdbinutils/binutils/.deps/emul_aix.Po | 1 + support/sdbinutils/binutils/.deps/emul_vanilla.Po | 288 + support/sdbinutils/binutils/.deps/filemode.Po | 286 + support/sdbinutils/binutils/.deps/ieee.Po | 302 + support/sdbinutils/binutils/.deps/is-ranlib.Po | 3 + support/sdbinutils/binutils/.deps/is-strip.Po | 3 + support/sdbinutils/binutils/.deps/maybe-ranlib.Po | 1 + support/sdbinutils/binutils/.deps/maybe-strip.Po | 1 + support/sdbinutils/binutils/.deps/mclex.Po | 1 + support/sdbinutils/binutils/.deps/mcparse.Po | 1 + support/sdbinutils/binutils/.deps/nlmconv.Po | 1 + support/sdbinutils/binutils/.deps/nlmheader.Po | 1 + support/sdbinutils/binutils/.deps/nm.Po | 344 + support/sdbinutils/binutils/.deps/not-ranlib.Po | 3 + support/sdbinutils/binutils/.deps/not-strip.Po | 3 + support/sdbinutils/binutils/.deps/objcopy.Po | 335 + support/sdbinutils/binutils/.deps/objdump.Po | 1 + support/sdbinutils/binutils/.deps/od-macho.Po | 1 + support/sdbinutils/binutils/.deps/od-xcoff.Po | 1 + support/sdbinutils/binutils/.deps/prdbg.Po | 1 + support/sdbinutils/binutils/.deps/rclex.Po | 1 + support/sdbinutils/binutils/.deps/rcparse.Po | 1 + support/sdbinutils/binutils/.deps/rdcoff.Po | 304 + support/sdbinutils/binutils/.deps/rddbg.Po | 295 + support/sdbinutils/binutils/.deps/readelf.Po | 1 + support/sdbinutils/binutils/.deps/rename.Po | 288 + support/sdbinutils/binutils/.deps/resbin.Po | 1 + support/sdbinutils/binutils/.deps/rescoff.Po | 1 + support/sdbinutils/binutils/.deps/resrc.Po | 1 + support/sdbinutils/binutils/.deps/resres.Po | 1 + support/sdbinutils/binutils/.deps/size.Po | 1 + support/sdbinutils/binutils/.deps/srconv.Po | 1 + support/sdbinutils/binutils/.deps/stabs.Po | 314 + support/sdbinutils/binutils/.deps/strings.Po | 1 + support/sdbinutils/binutils/.deps/sysdump.Po | 1 + support/sdbinutils/binutils/.deps/syslex_wrap.Po | 1 + support/sdbinutils/binutils/.deps/unwind-ia64.Po | 1 + support/sdbinutils/binutils/.deps/version.Po | 286 + support/sdbinutils/binutils/.deps/windmc.Po | 1 + support/sdbinutils/binutils/.deps/windres.Po | 1 + support/sdbinutils/binutils/.deps/winduni.Po | 1 + support/sdbinutils/binutils/.deps/wrstabs.Po | 314 + support/sdbinutils/binutils/BRANCHES | 55 + support/sdbinutils/binutils/ChangeLog | 118 + support/sdbinutils/binutils/ChangeLog-0001 | 2066 ++ support/sdbinutils/binutils/ChangeLog-0203 | 2187 +++ support/sdbinutils/binutils/ChangeLog-2004 | 799 + support/sdbinutils/binutils/ChangeLog-2005 | 1356 ++ support/sdbinutils/binutils/ChangeLog-2006 | 605 + support/sdbinutils/binutils/ChangeLog-2007 | 1171 ++ support/sdbinutils/binutils/ChangeLog-2008 | 880 + support/sdbinutils/binutils/ChangeLog-2009 | 1361 ++ support/sdbinutils/binutils/ChangeLog-2010 | 1083 ++ support/sdbinutils/binutils/ChangeLog-2011 | 936 + support/sdbinutils/binutils/ChangeLog-2012 | 756 + support/sdbinutils/binutils/ChangeLog-2013 | 681 + support/sdbinutils/binutils/ChangeLog-2014 | 960 + support/sdbinutils/binutils/ChangeLog-2015 | 1034 + support/sdbinutils/binutils/ChangeLog-2016 | 988 + support/sdbinutils/binutils/ChangeLog-2017 | 1886 ++ support/sdbinutils/binutils/ChangeLog-9197 | 5223 +++++ support/sdbinutils/binutils/ChangeLog-9899 | 1914 ++ support/sdbinutils/binutils/MAINTAINERS | 304 + support/sdbinutils/binutils/Makefile | 1520 ++ support/sdbinutils/binutils/Makefile.am | 555 + support/sdbinutils/binutils/Makefile.in | 1520 ++ support/sdbinutils/binutils/NEWS | 606 + support/sdbinutils/binutils/README | 299 + .../binutils/README-how-to-make-a-release | 211 + support/sdbinutils/binutils/aclocal.m4 | 1034 + support/sdbinutils/binutils/addr2line.c | 510 + support/sdbinutils/binutils/ar.c | 1507 ++ support/sdbinutils/binutils/arlex.c | 2042 ++ support/sdbinutils/binutils/arlex.l | 90 + support/sdbinutils/binutils/arparse.c | 1689 ++ support/sdbinutils/binutils/arparse.h | 112 + support/sdbinutils/binutils/arparse.y | 203 + support/sdbinutils/binutils/arsup.c | 489 + support/sdbinutils/binutils/arsup.h | 62 + support/sdbinutils/binutils/bfdtest1.c | 70 + support/sdbinutils/binutils/bfdtest2.c | 106 + support/sdbinutils/binutils/bin2c.c | 66 + support/sdbinutils/binutils/binemul.c | 148 + support/sdbinutils/binutils/binemul.h | 71 + support/sdbinutils/binutils/bucomm.c | 667 + support/sdbinutils/binutils/bucomm.h | 81 + support/sdbinutils/binutils/budbg.h | 57 + support/sdbinutils/binutils/coffdump.c | 563 + support/sdbinutils/binutils/coffgrok.c | 905 + support/sdbinutils/binutils/coffgrok.h | 221 + support/sdbinutils/binutils/config.h | 288 + support/sdbinutils/binutils/config.in | 287 + support/sdbinutils/binutils/config.log | 3270 ++++ support/sdbinutils/binutils/config.status | 2248 +++ support/sdbinutils/binutils/configure | 17149 +++++++++++++++++ support/sdbinutils/binutils/configure.ac | 517 + support/sdbinutils/binutils/configure.com | 146 + support/sdbinutils/binutils/configure.tgt | 42 + support/sdbinutils/binutils/cxxfilt.c | 291 + support/sdbinutils/binutils/debug.c | 3371 ++++ support/sdbinutils/binutils/debug.h | 792 + support/sdbinutils/binutils/deflex.c | 2077 ++ support/sdbinutils/binutils/deflex.l | 93 + support/sdbinutils/binutils/defparse.c | 2092 ++ support/sdbinutils/binutils/defparse.h | 134 + support/sdbinutils/binutils/defparse.y | 244 + support/sdbinutils/binutils/dep-in.sed | 20 + support/sdbinutils/binutils/dlltool.c | 4589 +++++ support/sdbinutils/binutils/dlltool.h | 39 + support/sdbinutils/binutils/dllwrap.c | 1254 ++ support/sdbinutils/binutils/doc/Makefile.am | 201 + support/sdbinutils/binutils/doc/Makefile.in | 943 + support/sdbinutils/binutils/doc/addr2line.1 | 311 + support/sdbinutils/binutils/doc/ar.1 | 490 + support/sdbinutils/binutils/doc/binutils.info | 5496 ++++++ support/sdbinutils/binutils/doc/binutils.texi | 5287 +++++ support/sdbinutils/binutils/doc/cxxfilt.man | 341 + support/sdbinutils/binutils/doc/debug.options.texi | 144 + support/sdbinutils/binutils/doc/dlltool.1 | 538 + support/sdbinutils/binutils/doc/elfedit.1 | 238 + support/sdbinutils/binutils/doc/fdl.texi | 506 + support/sdbinutils/binutils/doc/nlmconv.1 | 247 + support/sdbinutils/binutils/doc/nm.1 | 568 + support/sdbinutils/binutils/doc/objcopy.1 | 1203 ++ support/sdbinutils/binutils/doc/objdump.1 | 1234 ++ support/sdbinutils/binutils/doc/ranlib.1 | 223 + support/sdbinutils/binutils/doc/readelf.1 | 688 + support/sdbinutils/binutils/doc/size.1 | 271 + support/sdbinutils/binutils/doc/strings.1 | 311 + support/sdbinutils/binutils/doc/strip.1 | 493 + support/sdbinutils/binutils/doc/windmc.1 | 356 + support/sdbinutils/binutils/doc/windres.1 | 364 + support/sdbinutils/binutils/dwarf-mode.el | 218 + support/sdbinutils/binutils/dwarf.c | 10160 ++++++++++ support/sdbinutils/binutils/dwarf.h | 249 + support/sdbinutils/binutils/elfcomm.c | 929 + support/sdbinutils/binutils/elfcomm.h | 104 + support/sdbinutils/binutils/elfedit.c | 767 + support/sdbinutils/binutils/embedspu.sh | 260 + support/sdbinutils/binutils/emul_aix.c | 140 + support/sdbinutils/binutils/emul_vanilla.c | 30 + support/sdbinutils/binutils/filemode.c | 248 + support/sdbinutils/binutils/ieee.c | 7410 +++++++ support/sdbinutils/binutils/is-ranlib.c | 22 + support/sdbinutils/binutils/is-strip.c | 23 + support/sdbinutils/binutils/libtool | 9129 +++++++++ support/sdbinutils/binutils/makefile.vms | 90 + support/sdbinutils/binutils/maybe-ranlib.c | 23 + support/sdbinutils/binutils/maybe-strip.c | 23 + support/sdbinutils/binutils/mclex.c | 440 + support/sdbinutils/binutils/mcparse.c | 2095 ++ support/sdbinutils/binutils/mcparse.h | 113 + support/sdbinutils/binutils/mcparse.y | 355 + support/sdbinutils/binutils/nlmconv.c | 2166 +++ support/sdbinutils/binutils/nlmconv.h | 86 + support/sdbinutils/binutils/nlmheader.c | 2638 +++ support/sdbinutils/binutils/nlmheader.h | 145 + support/sdbinutils/binutils/nlmheader.y | 959 + support/sdbinutils/binutils/nm.c | 1807 ++ support/sdbinutils/binutils/not-ranlib.c | 22 + support/sdbinutils/binutils/not-strip.c | 23 + support/sdbinutils/binutils/objcopy.c | 5587 ++++++ support/sdbinutils/binutils/objdump.c | 4080 ++++ support/sdbinutils/binutils/objdump.h | 53 + support/sdbinutils/binutils/od-elf32_avr.c | 303 + support/sdbinutils/binutils/od-macho.c | 2214 +++ support/sdbinutils/binutils/od-xcoff.c | 1842 ++ support/sdbinutils/binutils/prdbg.c | 2838 +++ support/sdbinutils/binutils/ranlib.sh | 22 + support/sdbinutils/binutils/rclex.c | 904 + support/sdbinutils/binutils/rcparse.c | 4703 +++++ support/sdbinutils/binutils/rcparse.h | 308 + support/sdbinutils/binutils/rcparse.y | 2013 ++ support/sdbinutils/binutils/rdcoff.c | 880 + support/sdbinutils/binutils/rddbg.c | 465 + support/sdbinutils/binutils/readelf.c | 19150 +++++++++++++++++++ support/sdbinutils/binutils/rename.c | 212 + support/sdbinutils/binutils/resbin.c | 2164 +++ support/sdbinutils/binutils/rescoff.c | 767 + support/sdbinutils/binutils/resrc.c | 3390 ++++ support/sdbinutils/binutils/resres.c | 730 + support/sdbinutils/binutils/sanity.sh | 67 + support/sdbinutils/binutils/size.c | 617 + support/sdbinutils/binutils/srconv.c | 1858 ++ support/sdbinutils/binutils/stabs.c | 5451 ++++++ support/sdbinutils/binutils/stamp-h.in | 1 + support/sdbinutils/binutils/stamp-h1 | 1 + support/sdbinutils/binutils/strings.c | 670 + support/sdbinutils/binutils/sysdep.h | 204 + support/sdbinutils/binutils/sysdump.c | 715 + support/sdbinutils/binutils/sysinfo.c | 1893 ++ support/sdbinutils/binutils/sysinfo.h | 87 + support/sdbinutils/binutils/sysinfo.y | 442 + support/sdbinutils/binutils/syslex.c | 1914 ++ support/sdbinutils/binutils/syslex.l | 81 + support/sdbinutils/binutils/syslex_wrap.c | 25 + support/sdbinutils/binutils/sysroff.h | 684 + support/sdbinutils/binutils/sysroff.info | 504 + support/sdbinutils/binutils/unwind-ia64.c | 1073 ++ support/sdbinutils/binutils/unwind-ia64.h | 32 + support/sdbinutils/binutils/version.c | 40 + support/sdbinutils/binutils/windint.h | 1097 ++ support/sdbinutils/binutils/windmc.c | 1172 ++ support/sdbinutils/binutils/windmc.h | 98 + support/sdbinutils/binutils/windres.c | 1408 ++ support/sdbinutils/binutils/windres.h | 122 + support/sdbinutils/binutils/winduni.c | 907 + support/sdbinutils/binutils/winduni.h | 139 + support/sdbinutils/binutils/wrstabs.c | 2271 +++ 231 files changed, 224346 insertions(+) create mode 100644 support/sdbinutils/binutils/.deps/addr2line.Po create mode 100644 support/sdbinutils/binutils/.deps/ar.Po create mode 100644 support/sdbinutils/binutils/.deps/arlex.Po create mode 100644 support/sdbinutils/binutils/.deps/arparse.Po create mode 100644 support/sdbinutils/binutils/.deps/arsup.Po create mode 100644 support/sdbinutils/binutils/.deps/bfdtest1.Po create mode 100644 support/sdbinutils/binutils/.deps/bfdtest2.Po create mode 100644 support/sdbinutils/binutils/.deps/bin2c.Po create mode 100644 support/sdbinutils/binutils/.deps/binemul.Po create mode 100644 support/sdbinutils/binutils/.deps/bucomm.Po create mode 100644 support/sdbinutils/binutils/.deps/coffdump.Po create mode 100644 support/sdbinutils/binutils/.deps/coffgrok.Po create mode 100644 support/sdbinutils/binutils/.deps/cxxfilt.Po create mode 100644 support/sdbinutils/binutils/.deps/debug.Po create mode 100644 support/sdbinutils/binutils/.deps/deflex.Po create mode 100644 support/sdbinutils/binutils/.deps/defparse.Po create mode 100644 support/sdbinutils/binutils/.deps/dlltool.Po create mode 100644 support/sdbinutils/binutils/.deps/dllwrap.Po create mode 100644 support/sdbinutils/binutils/.deps/dwarf.Po create mode 100644 support/sdbinutils/binutils/.deps/elfcomm.Po create mode 100644 support/sdbinutils/binutils/.deps/elfedit.Po create mode 100644 support/sdbinutils/binutils/.deps/emul_$(EMULATION).Po create mode 100644 support/sdbinutils/binutils/.deps/emul_aix.Po create mode 100644 support/sdbinutils/binutils/.deps/emul_vanilla.Po create mode 100644 support/sdbinutils/binutils/.deps/filemode.Po create mode 100644 support/sdbinutils/binutils/.deps/ieee.Po create mode 100644 support/sdbinutils/binutils/.deps/is-ranlib.Po create mode 100644 support/sdbinutils/binutils/.deps/is-strip.Po create mode 100644 support/sdbinutils/binutils/.deps/maybe-ranlib.Po create mode 100644 support/sdbinutils/binutils/.deps/maybe-strip.Po create mode 100644 support/sdbinutils/binutils/.deps/mclex.Po create mode 100644 support/sdbinutils/binutils/.deps/mcparse.Po create mode 100644 support/sdbinutils/binutils/.deps/nlmconv.Po create mode 100644 support/sdbinutils/binutils/.deps/nlmheader.Po create mode 100644 support/sdbinutils/binutils/.deps/nm.Po create mode 100644 support/sdbinutils/binutils/.deps/not-ranlib.Po create mode 100644 support/sdbinutils/binutils/.deps/not-strip.Po create mode 100644 support/sdbinutils/binutils/.deps/objcopy.Po create mode 100644 support/sdbinutils/binutils/.deps/objdump.Po create mode 100644 support/sdbinutils/binutils/.deps/od-macho.Po create mode 100644 support/sdbinutils/binutils/.deps/od-xcoff.Po create mode 100644 support/sdbinutils/binutils/.deps/prdbg.Po create mode 100644 support/sdbinutils/binutils/.deps/rclex.Po create mode 100644 support/sdbinutils/binutils/.deps/rcparse.Po create mode 100644 support/sdbinutils/binutils/.deps/rdcoff.Po create mode 100644 support/sdbinutils/binutils/.deps/rddbg.Po create mode 100644 support/sdbinutils/binutils/.deps/readelf.Po create mode 100644 support/sdbinutils/binutils/.deps/rename.Po create mode 100644 support/sdbinutils/binutils/.deps/resbin.Po create mode 100644 support/sdbinutils/binutils/.deps/rescoff.Po create mode 100644 support/sdbinutils/binutils/.deps/resrc.Po create mode 100644 support/sdbinutils/binutils/.deps/resres.Po create mode 100644 support/sdbinutils/binutils/.deps/size.Po create mode 100644 support/sdbinutils/binutils/.deps/srconv.Po create mode 100644 support/sdbinutils/binutils/.deps/stabs.Po create mode 100644 support/sdbinutils/binutils/.deps/strings.Po create mode 100644 support/sdbinutils/binutils/.deps/sysdump.Po create mode 100644 support/sdbinutils/binutils/.deps/syslex_wrap.Po create mode 100644 support/sdbinutils/binutils/.deps/unwind-ia64.Po create mode 100644 support/sdbinutils/binutils/.deps/version.Po create mode 100644 support/sdbinutils/binutils/.deps/windmc.Po create mode 100644 support/sdbinutils/binutils/.deps/windres.Po create mode 100644 support/sdbinutils/binutils/.deps/winduni.Po create mode 100644 support/sdbinutils/binutils/.deps/wrstabs.Po create mode 100644 support/sdbinutils/binutils/BRANCHES create mode 100644 support/sdbinutils/binutils/ChangeLog create mode 100644 support/sdbinutils/binutils/ChangeLog-0001 create mode 100644 support/sdbinutils/binutils/ChangeLog-0203 create mode 100644 support/sdbinutils/binutils/ChangeLog-2004 create mode 100644 support/sdbinutils/binutils/ChangeLog-2005 create mode 100644 support/sdbinutils/binutils/ChangeLog-2006 create mode 100644 support/sdbinutils/binutils/ChangeLog-2007 create mode 100644 support/sdbinutils/binutils/ChangeLog-2008 create mode 100644 support/sdbinutils/binutils/ChangeLog-2009 create mode 100644 support/sdbinutils/binutils/ChangeLog-2010 create mode 100644 support/sdbinutils/binutils/ChangeLog-2011 create mode 100644 support/sdbinutils/binutils/ChangeLog-2012 create mode 100644 support/sdbinutils/binutils/ChangeLog-2013 create mode 100644 support/sdbinutils/binutils/ChangeLog-2014 create mode 100644 support/sdbinutils/binutils/ChangeLog-2015 create mode 100644 support/sdbinutils/binutils/ChangeLog-2016 create mode 100644 support/sdbinutils/binutils/ChangeLog-2017 create mode 100644 support/sdbinutils/binutils/ChangeLog-9197 create mode 100644 support/sdbinutils/binutils/ChangeLog-9899 create mode 100644 support/sdbinutils/binutils/MAINTAINERS create mode 100644 support/sdbinutils/binutils/Makefile create mode 100644 support/sdbinutils/binutils/Makefile.am create mode 100644 support/sdbinutils/binutils/Makefile.in create mode 100644 support/sdbinutils/binutils/NEWS create mode 100644 support/sdbinutils/binutils/README create mode 100644 support/sdbinutils/binutils/README-how-to-make-a-release create mode 100644 support/sdbinutils/binutils/aclocal.m4 create mode 100644 support/sdbinutils/binutils/addr2line.c create mode 100644 support/sdbinutils/binutils/ar.c create mode 100644 support/sdbinutils/binutils/arlex.c create mode 100644 support/sdbinutils/binutils/arlex.l create mode 100644 support/sdbinutils/binutils/arparse.c create mode 100644 support/sdbinutils/binutils/arparse.h create mode 100644 support/sdbinutils/binutils/arparse.y create mode 100644 support/sdbinutils/binutils/arsup.c create mode 100644 support/sdbinutils/binutils/arsup.h create mode 100644 support/sdbinutils/binutils/bfdtest1.c create mode 100644 support/sdbinutils/binutils/bfdtest2.c create mode 100644 support/sdbinutils/binutils/bin2c.c create mode 100644 support/sdbinutils/binutils/binemul.c create mode 100644 support/sdbinutils/binutils/binemul.h create mode 100644 support/sdbinutils/binutils/bucomm.c create mode 100644 support/sdbinutils/binutils/bucomm.h create mode 100644 support/sdbinutils/binutils/budbg.h create mode 100644 support/sdbinutils/binutils/coffdump.c create mode 100644 support/sdbinutils/binutils/coffgrok.c create mode 100644 support/sdbinutils/binutils/coffgrok.h create mode 100644 support/sdbinutils/binutils/config.h create mode 100644 support/sdbinutils/binutils/config.in create mode 100644 support/sdbinutils/binutils/config.log create mode 100755 support/sdbinutils/binutils/config.status create mode 100755 support/sdbinutils/binutils/configure create mode 100644 support/sdbinutils/binutils/configure.ac create mode 100644 support/sdbinutils/binutils/configure.com create mode 100644 support/sdbinutils/binutils/configure.tgt create mode 100644 support/sdbinutils/binutils/cxxfilt.c create mode 100644 support/sdbinutils/binutils/debug.c create mode 100644 support/sdbinutils/binutils/debug.h create mode 100644 support/sdbinutils/binutils/deflex.c create mode 100644 support/sdbinutils/binutils/deflex.l create mode 100644 support/sdbinutils/binutils/defparse.c create mode 100644 support/sdbinutils/binutils/defparse.h create mode 100644 support/sdbinutils/binutils/defparse.y create mode 100644 support/sdbinutils/binutils/dep-in.sed create mode 100644 support/sdbinutils/binutils/dlltool.c create mode 100644 support/sdbinutils/binutils/dlltool.h create mode 100644 support/sdbinutils/binutils/dllwrap.c create mode 100644 support/sdbinutils/binutils/doc/Makefile.am create mode 100644 support/sdbinutils/binutils/doc/Makefile.in create mode 100644 support/sdbinutils/binutils/doc/addr2line.1 create mode 100644 support/sdbinutils/binutils/doc/ar.1 create mode 100644 support/sdbinutils/binutils/doc/binutils.info create mode 100644 support/sdbinutils/binutils/doc/binutils.texi create mode 100644 support/sdbinutils/binutils/doc/cxxfilt.man create mode 100644 support/sdbinutils/binutils/doc/debug.options.texi create mode 100644 support/sdbinutils/binutils/doc/dlltool.1 create mode 100644 support/sdbinutils/binutils/doc/elfedit.1 create mode 100644 support/sdbinutils/binutils/doc/fdl.texi create mode 100644 support/sdbinutils/binutils/doc/nlmconv.1 create mode 100644 support/sdbinutils/binutils/doc/nm.1 create mode 100644 support/sdbinutils/binutils/doc/objcopy.1 create mode 100644 support/sdbinutils/binutils/doc/objdump.1 create mode 100644 support/sdbinutils/binutils/doc/ranlib.1 create mode 100644 support/sdbinutils/binutils/doc/readelf.1 create mode 100644 support/sdbinutils/binutils/doc/size.1 create mode 100644 support/sdbinutils/binutils/doc/strings.1 create mode 100644 support/sdbinutils/binutils/doc/strip.1 create mode 100644 support/sdbinutils/binutils/doc/windmc.1 create mode 100644 support/sdbinutils/binutils/doc/windres.1 create mode 100644 support/sdbinutils/binutils/dwarf-mode.el create mode 100644 support/sdbinutils/binutils/dwarf.c create mode 100644 support/sdbinutils/binutils/dwarf.h create mode 100644 support/sdbinutils/binutils/elfcomm.c create mode 100644 support/sdbinutils/binutils/elfcomm.h create mode 100644 support/sdbinutils/binutils/elfedit.c create mode 100755 support/sdbinutils/binutils/embedspu.sh create mode 100644 support/sdbinutils/binutils/emul_aix.c create mode 100644 support/sdbinutils/binutils/emul_vanilla.c create mode 100644 support/sdbinutils/binutils/filemode.c create mode 100644 support/sdbinutils/binutils/ieee.c create mode 100644 support/sdbinutils/binutils/is-ranlib.c create mode 100644 support/sdbinutils/binutils/is-strip.c create mode 100755 support/sdbinutils/binutils/libtool create mode 100644 support/sdbinutils/binutils/makefile.vms create mode 100644 support/sdbinutils/binutils/maybe-ranlib.c create mode 100644 support/sdbinutils/binutils/maybe-strip.c create mode 100644 support/sdbinutils/binutils/mclex.c create mode 100644 support/sdbinutils/binutils/mcparse.c create mode 100644 support/sdbinutils/binutils/mcparse.h create mode 100644 support/sdbinutils/binutils/mcparse.y create mode 100644 support/sdbinutils/binutils/nlmconv.c create mode 100644 support/sdbinutils/binutils/nlmconv.h create mode 100644 support/sdbinutils/binutils/nlmheader.c create mode 100644 support/sdbinutils/binutils/nlmheader.h create mode 100644 support/sdbinutils/binutils/nlmheader.y create mode 100644 support/sdbinutils/binutils/nm.c create mode 100644 support/sdbinutils/binutils/not-ranlib.c create mode 100644 support/sdbinutils/binutils/not-strip.c create mode 100644 support/sdbinutils/binutils/objcopy.c create mode 100644 support/sdbinutils/binutils/objdump.c create mode 100644 support/sdbinutils/binutils/objdump.h create mode 100644 support/sdbinutils/binutils/od-elf32_avr.c create mode 100644 support/sdbinutils/binutils/od-macho.c create mode 100644 support/sdbinutils/binutils/od-xcoff.c create mode 100644 support/sdbinutils/binutils/prdbg.c create mode 100755 support/sdbinutils/binutils/ranlib.sh create mode 100644 support/sdbinutils/binutils/rclex.c create mode 100644 support/sdbinutils/binutils/rcparse.c create mode 100644 support/sdbinutils/binutils/rcparse.h create mode 100644 support/sdbinutils/binutils/rcparse.y create mode 100644 support/sdbinutils/binutils/rdcoff.c create mode 100644 support/sdbinutils/binutils/rddbg.c create mode 100644 support/sdbinutils/binutils/readelf.c create mode 100644 support/sdbinutils/binutils/rename.c create mode 100644 support/sdbinutils/binutils/resbin.c create mode 100644 support/sdbinutils/binutils/rescoff.c create mode 100644 support/sdbinutils/binutils/resrc.c create mode 100644 support/sdbinutils/binutils/resres.c create mode 100755 support/sdbinutils/binutils/sanity.sh create mode 100644 support/sdbinutils/binutils/size.c create mode 100644 support/sdbinutils/binutils/srconv.c create mode 100644 support/sdbinutils/binutils/stabs.c create mode 100644 support/sdbinutils/binutils/stamp-h.in create mode 100644 support/sdbinutils/binutils/stamp-h1 create mode 100644 support/sdbinutils/binutils/strings.c create mode 100644 support/sdbinutils/binutils/sysdep.h create mode 100644 support/sdbinutils/binutils/sysdump.c create mode 100644 support/sdbinutils/binutils/sysinfo.c create mode 100644 support/sdbinutils/binutils/sysinfo.h create mode 100644 support/sdbinutils/binutils/sysinfo.y create mode 100644 support/sdbinutils/binutils/syslex.c create mode 100644 support/sdbinutils/binutils/syslex.l create mode 100644 support/sdbinutils/binutils/syslex_wrap.c create mode 100644 support/sdbinutils/binutils/sysroff.h create mode 100644 support/sdbinutils/binutils/sysroff.info create mode 100644 support/sdbinutils/binutils/unwind-ia64.c create mode 100644 support/sdbinutils/binutils/unwind-ia64.h create mode 100644 support/sdbinutils/binutils/version.c create mode 100644 support/sdbinutils/binutils/windint.h create mode 100644 support/sdbinutils/binutils/windmc.c create mode 100644 support/sdbinutils/binutils/windmc.h create mode 100644 support/sdbinutils/binutils/windres.c create mode 100644 support/sdbinutils/binutils/windres.h create mode 100644 support/sdbinutils/binutils/winduni.c create mode 100644 support/sdbinutils/binutils/winduni.h create mode 100644 support/sdbinutils/binutils/wrstabs.c (limited to 'support/sdbinutils/binutils') diff --git a/support/sdbinutils/binutils/.deps/addr2line.Po b/support/sdbinutils/binutils/.deps/addr2line.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/addr2line.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/ar.Po b/support/sdbinutils/binutils/.deps/ar.Po new file mode 100644 index 0000000..9c25415 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/ar.Po @@ -0,0 +1,321 @@ +ar.o: ar.c /usr/include/stdc-predef.h sysdep.h ../include/alloca-conf.h \ + config.h /usr/include/alloca.h /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h ../include/libiberty.h ../include/ansidecl.h \ + ../include/progress.h ../include/getopt.h ../include/aout/ar.h bucomm.h \ + arsup.h ../include/filenames.h ../include/hashtab.h binemul.h \ + ../include/plugin-api.h /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h \ + /usr/include/stdint.h /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-uintn.h ../bfd/plugin.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +../include/progress.h: + +../include/getopt.h: + +../include/aout/ar.h: + +bucomm.h: + +arsup.h: + +../include/filenames.h: + +../include/hashtab.h: + +binemul.h: + +../include/plugin-api.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h: + +/usr/include/stdint.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h: + +../bfd/plugin.h: diff --git a/support/sdbinutils/binutils/.deps/arlex.Po b/support/sdbinutils/binutils/.deps/arlex.Po new file mode 100644 index 0000000..d4e267e --- /dev/null +++ b/support/sdbinutils/binutils/.deps/arlex.Po @@ -0,0 +1,232 @@ +arlex.o: arlex.c /usr/include/stdc-predef.h /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/errno.h /usr/include/x86_64-linux-gnu/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \ + /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/inttypes.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h /usr/include/stdint.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-uintn.h ../include/ansidecl.h \ + ../include/libiberty.h ../include/ansidecl.h arparse.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h + +/usr/include/stdc-predef.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/inttypes.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h: + +/usr/include/stdint.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h: + +../include/ansidecl.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +arparse.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: diff --git a/support/sdbinutils/binutils/.deps/arparse.Po b/support/sdbinutils/binutils/.deps/arparse.Po new file mode 100644 index 0000000..ab8ac8e --- /dev/null +++ b/support/sdbinutils/binutils/.deps/arparse.Po @@ -0,0 +1,286 @@ +arparse.o: arparse.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h arsup.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +arsup.h: diff --git a/support/sdbinutils/binutils/.deps/arsup.Po b/support/sdbinutils/binutils/.deps/arsup.Po new file mode 100644 index 0000000..bef791d --- /dev/null +++ b/support/sdbinutils/binutils/.deps/arsup.Po @@ -0,0 +1,297 @@ +arsup.o: arsup.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h ../include/libiberty.h ../include/ansidecl.h \ + ../include/filenames.h ../include/hashtab.h bucomm.h arsup.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +../include/filenames.h: + +../include/hashtab.h: + +bucomm.h: + +arsup.h: diff --git a/support/sdbinutils/binutils/.deps/bfdtest1.Po b/support/sdbinutils/binutils/.deps/bfdtest1.Po new file mode 100644 index 0000000..908e24c --- /dev/null +++ b/support/sdbinutils/binutils/.deps/bfdtest1.Po @@ -0,0 +1,284 @@ +bfdtest1.o: bfdtest1.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: diff --git a/support/sdbinutils/binutils/.deps/bfdtest2.Po b/support/sdbinutils/binutils/.deps/bfdtest2.Po new file mode 100644 index 0000000..75108d7 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/bfdtest2.Po @@ -0,0 +1,284 @@ +bfdtest2.o: bfdtest2.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: diff --git a/support/sdbinutils/binutils/.deps/bin2c.Po b/support/sdbinutils/binutils/.deps/bin2c.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/bin2c.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/binemul.Po b/support/sdbinutils/binutils/.deps/binemul.Po new file mode 100644 index 0000000..2949c6e --- /dev/null +++ b/support/sdbinutils/binutils/.deps/binemul.Po @@ -0,0 +1,288 @@ +binemul.o: binemul.c /usr/include/stdc-predef.h binemul.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h bucomm.h + +/usr/include/stdc-predef.h: + +binemul.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +bucomm.h: diff --git a/support/sdbinutils/binutils/.deps/bucomm.Po b/support/sdbinutils/binutils/.deps/bucomm.Po new file mode 100644 index 0000000..23d6bfd --- /dev/null +++ b/support/sdbinutils/binutils/.deps/bucomm.Po @@ -0,0 +1,312 @@ +bucomm.o: bucomm.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h ../include/libiberty.h ../include/ansidecl.h \ + ../include/filenames.h ../include/hashtab.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/timex.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_tm.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h \ + /usr/include/assert.h bucomm.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +../include/filenames.h: + +../include/hashtab.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/timex.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h: + +/usr/include/assert.h: + +bucomm.h: diff --git a/support/sdbinutils/binutils/.deps/coffdump.Po b/support/sdbinutils/binutils/.deps/coffdump.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/coffdump.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/coffgrok.Po b/support/sdbinutils/binutils/.deps/coffgrok.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/coffgrok.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/cxxfilt.Po b/support/sdbinutils/binutils/.deps/cxxfilt.Po new file mode 100644 index 0000000..4d86c9a --- /dev/null +++ b/support/sdbinutils/binutils/.deps/cxxfilt.Po @@ -0,0 +1,302 @@ +cxxfilt.o: cxxfilt.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h ../include/libiberty.h ../include/ansidecl.h \ + ../include/demangle.h ../include/libiberty.h ../include/getopt.h \ + ../include/safe-ctype.h /usr/include/ctype.h bucomm.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +../include/demangle.h: + +../include/libiberty.h: + +../include/getopt.h: + +../include/safe-ctype.h: + +/usr/include/ctype.h: + +bucomm.h: diff --git a/support/sdbinutils/binutils/.deps/debug.Po b/support/sdbinutils/binutils/.deps/debug.Po new file mode 100644 index 0000000..4fa8046 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/debug.Po @@ -0,0 +1,298 @@ +debug.o: debug.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h /usr/include/assert.h \ + ../bfd/bfd.h ../include/symcat.h ../include/libiberty.h \ + ../include/ansidecl.h ../include/filenames.h ../include/hashtab.h \ + debug.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +/usr/include/assert.h: + +../bfd/bfd.h: + +../include/symcat.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +../include/filenames.h: + +../include/hashtab.h: + +debug.h: diff --git a/support/sdbinutils/binutils/.deps/deflex.Po b/support/sdbinutils/binutils/.deps/deflex.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/deflex.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/defparse.Po b/support/sdbinutils/binutils/.deps/defparse.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/defparse.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/dlltool.Po b/support/sdbinutils/binutils/.deps/dlltool.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/dlltool.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/dllwrap.Po b/support/sdbinutils/binutils/.deps/dllwrap.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/dllwrap.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/dwarf.Po b/support/sdbinutils/binutils/.deps/dwarf.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/dwarf.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/elfcomm.Po b/support/sdbinutils/binutils/.deps/elfcomm.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/elfcomm.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/elfedit.Po b/support/sdbinutils/binutils/.deps/elfedit.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/elfedit.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/emul_$(EMULATION).Po b/support/sdbinutils/binutils/.deps/emul_$(EMULATION).Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/emul_$(EMULATION).Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/emul_aix.Po b/support/sdbinutils/binutils/.deps/emul_aix.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/emul_aix.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/emul_vanilla.Po b/support/sdbinutils/binutils/.deps/emul_vanilla.Po new file mode 100644 index 0000000..e208ca9 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/emul_vanilla.Po @@ -0,0 +1,288 @@ +emul_vanilla.o: emul_vanilla.c /usr/include/stdc-predef.h binemul.h \ + sysdep.h ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h bucomm.h + +/usr/include/stdc-predef.h: + +binemul.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +bucomm.h: diff --git a/support/sdbinutils/binutils/.deps/filemode.Po b/support/sdbinutils/binutils/.deps/filemode.Po new file mode 100644 index 0000000..bfb9349 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/filemode.Po @@ -0,0 +1,286 @@ +filemode.o: filemode.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h bucomm.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +bucomm.h: diff --git a/support/sdbinutils/binutils/.deps/ieee.Po b/support/sdbinutils/binutils/.deps/ieee.Po new file mode 100644 index 0000000..9eb0d3b --- /dev/null +++ b/support/sdbinutils/binutils/.deps/ieee.Po @@ -0,0 +1,302 @@ +ieee.o: ieee.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h /usr/include/assert.h \ + ../bfd/bfd.h ../include/symcat.h ../include/ieee.h \ + ../include/libiberty.h ../include/ansidecl.h debug.h budbg.h \ + ../include/filenames.h ../include/hashtab.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +/usr/include/assert.h: + +../bfd/bfd.h: + +../include/symcat.h: + +../include/ieee.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +debug.h: + +budbg.h: + +../include/filenames.h: + +../include/hashtab.h: diff --git a/support/sdbinutils/binutils/.deps/is-ranlib.Po b/support/sdbinutils/binutils/.deps/is-ranlib.Po new file mode 100644 index 0000000..b765a41 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/is-ranlib.Po @@ -0,0 +1,3 @@ +is-ranlib.o: is-ranlib.c /usr/include/stdc-predef.h + +/usr/include/stdc-predef.h: diff --git a/support/sdbinutils/binutils/.deps/is-strip.Po b/support/sdbinutils/binutils/.deps/is-strip.Po new file mode 100644 index 0000000..096b1fd --- /dev/null +++ b/support/sdbinutils/binutils/.deps/is-strip.Po @@ -0,0 +1,3 @@ +is-strip.o: is-strip.c /usr/include/stdc-predef.h + +/usr/include/stdc-predef.h: diff --git a/support/sdbinutils/binutils/.deps/maybe-ranlib.Po b/support/sdbinutils/binutils/.deps/maybe-ranlib.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/maybe-ranlib.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/maybe-strip.Po b/support/sdbinutils/binutils/.deps/maybe-strip.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/maybe-strip.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/mclex.Po b/support/sdbinutils/binutils/.deps/mclex.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/mclex.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/mcparse.Po b/support/sdbinutils/binutils/.deps/mcparse.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/mcparse.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/nlmconv.Po b/support/sdbinutils/binutils/.deps/nlmconv.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/nlmconv.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/nlmheader.Po b/support/sdbinutils/binutils/.deps/nlmheader.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/nlmheader.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/nm.Po b/support/sdbinutils/binutils/.deps/nm.Po new file mode 100644 index 0000000..b1e41b4 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/nm.Po @@ -0,0 +1,344 @@ +nm.o: nm.c /usr/include/stdc-predef.h sysdep.h ../include/alloca-conf.h \ + config.h /usr/include/alloca.h /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h ../include/progress.h ../include/getopt.h \ + ../include/aout/stab_gnu.h ../include/aout/stab.def \ + ../include/aout/ranlib.h ../include/demangle.h ../include/libiberty.h \ + ../include/ansidecl.h ../include/libiberty.h ../bfd/elf-bfd.h \ + ../include/elf/common.h ../include/elf/external.h \ + ../include/elf/internal.h ../include/bfdlink.h \ + ../include/coff/external.h ../include/coff/internal.h ../bfd/libcoff.h \ + ../bfd/coff-bfd.h bucomm.h ../include/plugin-api.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h /usr/include/stdint.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-uintn.h ../bfd/plugin.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +../include/progress.h: + +../include/getopt.h: + +../include/aout/stab_gnu.h: + +../include/aout/stab.def: + +../include/aout/ranlib.h: + +../include/demangle.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +../include/libiberty.h: + +../bfd/elf-bfd.h: + +../include/elf/common.h: + +../include/elf/external.h: + +../include/elf/internal.h: + +../include/bfdlink.h: + +../include/coff/external.h: + +../include/coff/internal.h: + +../bfd/libcoff.h: + +../bfd/coff-bfd.h: + +bucomm.h: + +../include/plugin-api.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h: + +/usr/include/stdint.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h: + +../bfd/plugin.h: diff --git a/support/sdbinutils/binutils/.deps/not-ranlib.Po b/support/sdbinutils/binutils/.deps/not-ranlib.Po new file mode 100644 index 0000000..af0e775 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/not-ranlib.Po @@ -0,0 +1,3 @@ +not-ranlib.o: not-ranlib.c /usr/include/stdc-predef.h + +/usr/include/stdc-predef.h: diff --git a/support/sdbinutils/binutils/.deps/not-strip.Po b/support/sdbinutils/binutils/.deps/not-strip.Po new file mode 100644 index 0000000..371b42b --- /dev/null +++ b/support/sdbinutils/binutils/.deps/not-strip.Po @@ -0,0 +1,3 @@ +not-strip.o: not-strip.c /usr/include/stdc-predef.h + +/usr/include/stdc-predef.h: diff --git a/support/sdbinutils/binutils/.deps/objcopy.Po b/support/sdbinutils/binutils/.deps/objcopy.Po new file mode 100644 index 0000000..0e55f25 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/objcopy.Po @@ -0,0 +1,335 @@ +objcopy.o: objcopy.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h ../include/progress.h ../include/getopt.h \ + ../include/libiberty.h ../include/ansidecl.h bucomm.h budbg.h \ + ../include/filenames.h ../include/hashtab.h ../include/fnmatch.h \ + ../bfd/elf-bfd.h ../include/elf/common.h ../include/elf/external.h \ + ../include/elf/internal.h ../include/bfdlink.h \ + ../include/coff/internal.h ../bfd/libcoff.h ../bfd/coff-bfd.h \ + ../include/safe-ctype.h /usr/include/ctype.h ../include/coff/i386.h \ + ../include/coff/external.h ../include/coff/pe.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +../include/progress.h: + +../include/getopt.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +bucomm.h: + +budbg.h: + +../include/filenames.h: + +../include/hashtab.h: + +../include/fnmatch.h: + +../bfd/elf-bfd.h: + +../include/elf/common.h: + +../include/elf/external.h: + +../include/elf/internal.h: + +../include/bfdlink.h: + +../include/coff/internal.h: + +../bfd/libcoff.h: + +../bfd/coff-bfd.h: + +../include/safe-ctype.h: + +/usr/include/ctype.h: + +../include/coff/i386.h: + +../include/coff/external.h: + +../include/coff/pe.h: diff --git a/support/sdbinutils/binutils/.deps/objdump.Po b/support/sdbinutils/binutils/.deps/objdump.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/objdump.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/od-macho.Po b/support/sdbinutils/binutils/.deps/od-macho.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/od-macho.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/od-xcoff.Po b/support/sdbinutils/binutils/.deps/od-xcoff.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/od-xcoff.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/prdbg.Po b/support/sdbinutils/binutils/.deps/prdbg.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/prdbg.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/rclex.Po b/support/sdbinutils/binutils/.deps/rclex.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/rclex.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/rcparse.Po b/support/sdbinutils/binutils/.deps/rcparse.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/rcparse.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/rdcoff.Po b/support/sdbinutils/binutils/.deps/rdcoff.Po new file mode 100644 index 0000000..906304c --- /dev/null +++ b/support/sdbinutils/binutils/.deps/rdcoff.Po @@ -0,0 +1,304 @@ +rdcoff.o: rdcoff.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h ../include/coff/internal.h ../include/libiberty.h \ + ../include/ansidecl.h bucomm.h debug.h budbg.h ../bfd/libcoff.h \ + ../include/bfdlink.h ../bfd/coff-bfd.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +../include/coff/internal.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +bucomm.h: + +debug.h: + +budbg.h: + +../bfd/libcoff.h: + +../include/bfdlink.h: + +../bfd/coff-bfd.h: diff --git a/support/sdbinutils/binutils/.deps/rddbg.Po b/support/sdbinutils/binutils/.deps/rddbg.Po new file mode 100644 index 0000000..00dad89 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/rddbg.Po @@ -0,0 +1,295 @@ +rddbg.o: rddbg.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h ../include/libiberty.h ../include/ansidecl.h \ + bucomm.h debug.h budbg.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +bucomm.h: + +debug.h: + +budbg.h: diff --git a/support/sdbinutils/binutils/.deps/readelf.Po b/support/sdbinutils/binutils/.deps/readelf.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/readelf.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/rename.Po b/support/sdbinutils/binutils/.deps/rename.Po new file mode 100644 index 0000000..0d6d781 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/rename.Po @@ -0,0 +1,288 @@ +rename.o: rename.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h bucomm.h /usr/include/utime.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +bucomm.h: + +/usr/include/utime.h: diff --git a/support/sdbinutils/binutils/.deps/resbin.Po b/support/sdbinutils/binutils/.deps/resbin.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/resbin.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/rescoff.Po b/support/sdbinutils/binutils/.deps/rescoff.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/rescoff.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/resrc.Po b/support/sdbinutils/binutils/.deps/resrc.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/resrc.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/resres.Po b/support/sdbinutils/binutils/.deps/resres.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/resres.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/size.Po b/support/sdbinutils/binutils/.deps/size.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/size.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/srconv.Po b/support/sdbinutils/binutils/.deps/srconv.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/srconv.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/stabs.Po b/support/sdbinutils/binutils/.deps/stabs.Po new file mode 100644 index 0000000..0bf2bd3 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/stabs.Po @@ -0,0 +1,314 @@ +stabs.o: stabs.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h ../include/libiberty.h ../include/ansidecl.h \ + ../include/safe-ctype.h /usr/include/ctype.h ../include/demangle.h \ + ../include/libiberty.h debug.h budbg.h ../include/filenames.h \ + ../include/hashtab.h ../include/aout/aout64.h ../include/aout/stab_gnu.h \ + ../include/aout/stab.def + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +../include/safe-ctype.h: + +/usr/include/ctype.h: + +../include/demangle.h: + +../include/libiberty.h: + +debug.h: + +budbg.h: + +../include/filenames.h: + +../include/hashtab.h: + +../include/aout/aout64.h: + +../include/aout/stab_gnu.h: + +../include/aout/stab.def: diff --git a/support/sdbinutils/binutils/.deps/strings.Po b/support/sdbinutils/binutils/.deps/strings.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/strings.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/sysdump.Po b/support/sdbinutils/binutils/.deps/sysdump.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/sysdump.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/syslex_wrap.Po b/support/sdbinutils/binutils/.deps/syslex_wrap.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/syslex_wrap.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/unwind-ia64.Po b/support/sdbinutils/binutils/.deps/unwind-ia64.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/unwind-ia64.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/version.Po b/support/sdbinutils/binutils/.deps/version.Po new file mode 100644 index 0000000..af15821 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/version.Po @@ -0,0 +1,286 @@ +version.o: version.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h ../bfd/bfd.h \ + ../include/symcat.h bucomm.h + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +../bfd/bfd.h: + +../include/symcat.h: + +bucomm.h: diff --git a/support/sdbinutils/binutils/.deps/windmc.Po b/support/sdbinutils/binutils/.deps/windmc.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/windmc.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/windres.Po b/support/sdbinutils/binutils/.deps/windres.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/windres.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/winduni.Po b/support/sdbinutils/binutils/.deps/winduni.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/winduni.Po @@ -0,0 +1 @@ +# dummy diff --git a/support/sdbinutils/binutils/.deps/wrstabs.Po b/support/sdbinutils/binutils/.deps/wrstabs.Po new file mode 100644 index 0000000..5ca44a2 --- /dev/null +++ b/support/sdbinutils/binutils/.deps/wrstabs.Po @@ -0,0 +1,314 @@ +wrstabs.o: wrstabs.c /usr/include/stdc-predef.h sysdep.h \ + ../include/alloca-conf.h config.h /usr/include/alloca.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h ../include/ansidecl.h \ + /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/libio.h \ + /usr/include/x86_64-linux-gnu/bits/_G_config.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h ../bfd/bfdver.h \ + ../include/fopen-same.h /usr/include/errno.h \ + /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/x86_64-linux-gnu/asm/errno.h \ + /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \ + /usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \ + /usr/include/strings.h \ + /usr/include/x86_64-linux-gnu/bits/strings_fortified.h \ + /usr/include/x86_64-linux-gnu/bits/string_fortified.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/bits/floatn.h \ + /usr/include/x86_64-linux-gnu/bits/floatn-common.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \ + /usr/include/linux/falloc.h /usr/include/x86_64-linux-gnu/bits/stat.h \ + /usr/include/x86_64-linux-gnu/bits/fcntl2.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h ../include/binary-io.h \ + /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h \ + /usr/include/x86_64-linux-gnu/bits/uio_lim.h /usr/include/assert.h \ + ../bfd/bfd.h ../include/symcat.h ../include/libiberty.h \ + ../include/ansidecl.h ../include/filenames.h ../include/hashtab.h \ + ../include/safe-ctype.h /usr/include/ctype.h bucomm.h debug.h budbg.h \ + ../include/aout/aout64.h ../include/aout/stab_gnu.h \ + ../include/aout/stab.def + +/usr/include/stdc-predef.h: + +sysdep.h: + +../include/alloca-conf.h: + +config.h: + +/usr/include/alloca.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/bits/long-double.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h: + +../include/ansidecl.h: + +/usr/include/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h: + +/usr/include/x86_64-linux-gnu/bits/types/FILE.h: + +/usr/include/x86_64-linux-gnu/bits/libio.h: + +/usr/include/x86_64-linux-gnu/bits/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/bits/types/clock_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/time_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/timer_t.h: + +/usr/include/x86_64-linux-gnu/bits/stdint-intn.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/bits/uintn-identity.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h: + +../bfd/bfdver.h: + +../include/fopen-same.h: + +/usr/include/errno.h: + +/usr/include/x86_64-linux-gnu/bits/errno.h: + +/usr/include/linux/errno.h: + +/usr/include/x86_64-linux-gnu/asm/errno.h: + +/usr/include/asm-generic/errno.h: + +/usr/include/asm-generic/errno-base.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/types/locale_t.h: + +/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h: + +/usr/include/strings.h: + +/usr/include/x86_64-linux-gnu/bits/strings_fortified.h: + +/usr/include/x86_64-linux-gnu/bits/string_fortified.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/bits/floatn.h: + +/usr/include/x86_64-linux-gnu/bits/floatn-common.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h: + +/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h: + +/usr/include/linux/falloc.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +/usr/include/x86_64-linux-gnu/bits/fcntl2.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +../include/binary-io.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/x86_64-linux-gnu/bits/uio_lim.h: + +/usr/include/assert.h: + +../bfd/bfd.h: + +../include/symcat.h: + +../include/libiberty.h: + +../include/ansidecl.h: + +../include/filenames.h: + +../include/hashtab.h: + +../include/safe-ctype.h: + +/usr/include/ctype.h: + +bucomm.h: + +debug.h: + +budbg.h: + +../include/aout/aout64.h: + +../include/aout/stab_gnu.h: + +../include/aout/stab.def: diff --git a/support/sdbinutils/binutils/BRANCHES b/support/sdbinutils/binutils/BRANCHES new file mode 100644 index 0000000..53e0883 --- /dev/null +++ b/support/sdbinutils/binutils/BRANCHES @@ -0,0 +1,55 @@ +Please keep the following tables alphabetical. + +Organization Tag Organization Name +---------------- ----------------- +csl CodeSourcery, LLC + +This table lists branches created by particular organizations. Please +include the branch name, and a description of the branch. The branch +description should name the owner of the branch (i.e., the person to +contact regarding the branch) and a description of the commit policy +for the branch (e.g., "no commits without permission of X or Y"). + +Organization Branches Description +--------------------- ----------- +binutils-csl-arm-2005q1-branch + CodeSourcery toolchain release branches. + Please do not commit to these branches without + permission from a CodeSourcery developer. + +binutils-csl-gxxpro-3_4-branch +binutils-csl-2_17-branch + CodeSourcery branded GNU Toolchain release branches. + Please do not commit to this branch without + permission from a CodeSourcery developer. + +Release Branches +---------------- +binutils-2_10-branch +binutils-2_11-branch +binutils-2_12-branch +binutils-2_13-branch +binutils-2_14-branch +binutils-2_15-branch +binutils-2_16-branch +binutils-2_17-branch +binutils-2_18-branch +binutils-2_19-branch +binutils-2_20-branch +binutils-2_21-branch +binutils-2_22-branch +binutils-2_23-branch +binutils-2_24-branch +binutils-2_25-branch +binutils-2_26-branch +binutils-2_27-branch +binutils-2_28-branch +binutils-2_29-branch +binutils-2_30-branch + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. +binutils-2_30-branch diff --git a/support/sdbinutils/binutils/ChangeLog b/support/sdbinutils/binutils/ChangeLog new file mode 100644 index 0000000..03f4fd3 --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog @@ -0,0 +1,118 @@ +2018-01-27 Nick Clifton + + This is the 2.30 release: + + * configure: Regenerate. + +2018-01-23 Nick Clifton + + * configure: Regenerate. + +2018-01-22 Maciej W. Rozycki + + * doc/binutils.texi (objcopy): Fix a typo in `--rename-section' + option description. + +2018-01-22 Maciej W. Rozycki + + * MAINTAINERS: Update my company e-mail address. + +2018-01-22 Nick Clifton + + * po/sv.po: Updated Swedish translation. + +2018-01-18 Nick Clifton + + * po/bg.po: Updated Bulgarian translation. + +2018-01-16 Nick Clifton + + * po/fr.po: Updated French translation. + +2018-01-15 Nick Clifton + + * po/uk.po: Updated Ukranian translation. + +2018-01-13 Nick Clifton + + * po/binutils.pot: Regenerate. + * configure: Regenerate. + +2018-01-13 Nick Clifton + + 2.30 branch created. + * NEWS: Add marker for 2.30. + +2018-01-12 Nick Clifton + + * README-how-to-make-a-release: Add notes on how to make the + branch and prelease snapshot. + * BRANCHES: Add binutils-2_29-branch. + +2018-01-10 Nick Clifton + + * MAINTAINERS: Note that it is now the configure.ac file and not + the configure.in file that needs to be kept in sync with gcc. + Add a note about sending patches for libiberty to gcc. + +2018-01-03 Nick Clifton + + * objcopy.c (merge_gnu_build_notes): Add cast to maximum address + constants. + +2018-01-03 Nick Clifton + + * objcopy.c (objcopy_internal_note): New structure. + (gap_exists): New function. + (is_open_note): New function. + (is_func_note): New function. + (is_64bit): New function. + (merge_gnu_build_notes): Handle v3 notes. Do not merge + if there are relocations against the notes. + * readelf.c (get_note_type): Use short names for build attribute + notes. + (print_symbol_for_build_attribute): Rename to + get_symbol_for_build_attribute. Returns the found symbol rather + than printing it. + (print_gnu_build_attribute_description): Maintain address ranges + for function notes as well as global notes. Handle v3 notes. + (print_gnu_build_attribute_name): Use more space for printing the + name in wide mode. + * testsuite/binutils-all/note-2-32.s: Use .dc.l instead of .word. + Eliminate symbol references in order to remove the need for + relocations. + * testsuite/binutils-all/note-2-64.s: Likewise. + * testsuite/binutils-all/note-3-32.s: Add a size to the note_1 + symbol. + * testsuite/binutils-all/note-3-64.s: Likewise. + * testsuite/binutils-all/mips/mips-note-2r-n32.d: Update expected + output. + * testsuite/binutils-all/mips/mips-note-2r-n64.d: Likewise. + * testsuite/binutils-all/mips/mips-note-2r.d: Likewise. + * testsuite/binutils-all/note-2-32.d: Likewise. + * testsuite/binutils-all/note-2-64.d: Likewise. + * testsuite/binutils-all/note-3-32.d: Likewise. + * testsuite/binutils-all/note-3-64.d: Likewise. + * testsuite/binutils-all/note-4-64.s: New test. Checks v3 notes. + * testsuite/binutils-all/note-4-32.s: New test. + * testsuite/binutils-all/note-4-64.d: New test result file. + * testsuite/binutils-all/note-4-32.d: New test result file. + +2018-01-03 Alan Modra + + Update year range in copyright notice of all files. + +For older changes see ChangeLog-2017 + +Copyright (C) 2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-0001 b/support/sdbinutils/binutils/ChangeLog-0001 new file mode 100644 index 0000000..f8b0f7e --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-0001 @@ -0,0 +1,2066 @@ +2001-12-20 Julian v. Bock + + * readelf.c (print_symbol): New function: Print a formatted symbol + name. If --wide is specified do not truncate it. + (dump_relocations): Use print_symbol() to print symbol names. + (process_symbol_table): Likewise. + (process_syminfo): Likewise. + (process_mips_specific): Likewise. + (usage): Document new feature of --wide switch. + * doc/binutils.texi (objdump): Document additional behaviour of + --wide. + +2001-12-18 Michael Snyder + + * objcopy.c (copy_file): Accept corefiles (format bfd_core). + (copy_object): Don't set the start address or flags of a core file. + (copy_section): Don't relocate a core file. Don't copy contents + if the input section has the contents flag set, but the output + section does not (which happens with the fake 'note' pseudo- + sections that BFD creates for corefiles). + +2001-12-18 Thiemo Seufer + + * readelf.c (get_machine_flags): Recognize header flags for ABI and + ASE extensions. More robust code for ISA checking. Ignore empty fields + in header flags for GNU extensions. + +2001-12-18 Alan Modra + + * objcopy.c (copy_archive): Set output bfd format outside the loop. + +2001-12-18 Nick Clifton + + * po/ja.po: Import from translation project. + * configure.in (ALL_LINGUAS): Add ja. + * configure: Regenerate. + +2001-12-18 Thiemo Seufer + + * addr2line.c (main): Protoype. + * ar.c (main): Protoype. + * nm.c (main): Protoype. + * objcopy.c (main): Protoype. + * objdump.c (main): Protoype. + * size.c (main): Protoype. + * strings.c (main): Protoype. + +2001-12-17 Alan Modra + + * readelf.c (symtab_shndx_hdr): New global. + (SECTION_HEADER_INDEX): Define. + (SECTION_HEADER_NUM): Define. + (SECTION_HEADER): Define. + (GET_ELF_SYMBOLS): Pass two params rather than three. + (get_32bit_elf_symbols): Take file and section args. Read and + use SHT_SYMTAB_SHNDX. + (get_64bit_elf_symbols): Likewise. + (dump_relocations): Use SECTION_HEADER to index "section_headers". + (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. + Remember symtab_shdx_hdr. + (process_program_headers): Scan from index 1 for segment map. + (slurp_ia64_unwind_table): Use SECTION_HEADER to index + "section_headers". + (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. + (process_unwind): Likewise. + (process_version_sections): Likewise. + (process_symbol_table): Likewise. + (display_debug_info): Likewise. + (process_dynamic_segment): Fake up a symtab section for changed + GET_ELF_SYMBOLS. + (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. + (process_program_headers): Kill signed/unsigned warning. + (load_debug_str): Likewise. + (display_debug_info): Likewise. + +2001-12-13 Jakub Jelinek + + * readelf.c (get_segment_type): Support PT_GNU_EH_FRAME. + +2001-12-11 Alan Modra + + * readelf.c (process_file_header): Print extended e_shnum and + e_shdtrndx values. Set elf_header values for same. + (get_32bit_section_headers): Add "num" arg to read "num" headers. + (get_64bit_section_headers): Likewise. + (process_section_headers): Update calls. + (get_file_header): Call get_32bit_section_headers or 64bit variant. + +2001-12-10 Jakub Jelinek + + * objcopy.c (setup_section): Copy entsize. + +2001-12-07 Geoffrey Keating + + * readelf.c (guess_is_rela): Add support for stormy16. + (dump_relocations): Likewise. + (get_machine_name): Likewise. + +2001-12-05 Nick Clifton + + * dllwrap.c (main) Replace multiple strings describing a + single error with a single, newline escaped sentence to permit + better translation into foreign languages. + + * readelf.c (get_elf_class): Remove internalionalisation of ELF + class names. + +2001-12-04 Thiemo Seufer + + * strings.c (get_char): Initialize value. + +2001-12-04 Thiemo Seufer + + * arlex.l: Silence compile warnings. + * arsup.h: Likewise. Fix formatting. + +2001-12-04 Jakub Jelinek + + * strings.c: Include config.h before bfd.h. + (file_off): New type. + (file_open): Define. + (print_strings): Use file_off instead of file_ptr. Print addresses + which don't fit into long correctly. + (get_char): Use file_off instead of file_ptr. Use getc_unlocked if + available. + (strings_file): Use file_off instead of file_ptr. Use file_open. + * configure.in: Check for getc_unlocked. + Check for fopen64 and whether _LARGEFILE64_SOURCE needs to + be defined for it. + * configure: Rebuilt. + * config.h.in: Rebuilt. + +2001-11-29 H.J. Lu + + * bucomm.c (make_tempname): Revert the changes made on + 2001-11-14 and 2001-11-12. They won't work with directories. + +2001-11-23 John David Anglin + + * binutils/Makefile.am (check-DEJAGNU): Pass CC_FOR_TARGET and + CFLAGS_FOR_TARGET to runtest in environment. + * Makefile.in: Rebuild. + * doc/Makefile.in: Rebuild. + +2001-11-28 Mike Stump + + * objcopy.c (setup_section): Preserve SEC_RELOC when + --set-section-flags is used. + +2001-11-19 Nick Clifton + + * readelf.c (do_debug_str): New variable. + (display_debug_str): New function: Display the contents of a + .debug_str section. + (load_debug_str): New function: Load in the contents of a + .debug_str section. + (free_debug_str): New function: Free the memory used by + load_debug_str(). + (fetch_indirect_string): Retrieve a string from the .debug_str + section. + (usage): Add -ws. + (parse_args): Accept -ws. + (process_section_headers): Allow the display of the .debug_str + section. + (read_and_display_attr_value): Use fetch_indirect_string. Show + offset into .debug_str section. + (display_debug_info): Use load_debug_str and free_debug_str. + (debug_displays): Add .debug_str. + * doc/binutils.texi: Document -ws. + +2001-11-19 Andreas Jaeger + + * testsuite/binutils-all/objdump.exp: Add x86-64. + +2001-11-15 Andreas Schwab + + * readelf.c: Fix warnings without terminating newline. + +2001-11-15 Alan Modra + + * doc/binutils.texi (objdump): Document ppc -M options. + +2001-11-14 Andreas Jaeger + + * doc/binutils.texi (objdump): Fix description to use x86-64. + +2001-11-14 Nick Clifton + + * bucomm.c (make_tempname): Use mkstemps instead of mkstemp, since + not all systems provide mkstemp. + +2001-11-14 Alan Modra + + * doc/binutils.texi (objdump): Document x86 -M options. + +2001-11-13 Keith Walker + + * readelf.c (read_and_display_attr_value): New function to + handle DW_FORM_indirect. + (read_and_display_attr): Use it. + +2001-11-13 Geoffrey Keating + + * readelf.c (display_debug_lines): Deal with unknown standard + opcodes. Handle DW_LNS_set_prologue_end, DW_LNS_set_epilogue_begin, + DW_LNS_set_isa. + +2001-11-13 Timothy Wall + + * MAINTAINERS: Add self as tic54x maintainer. This target + includes the IBM C54XDSP clone. + +2001-11-12 * Steven J. Hill + + * bucomm.c (make_tempname): Use mkstemp in place of mktemp. + +2001-11-09 Jeffrey A Law (law@cygnus.com) + + * unwind-ia64.c (unw_print_brmask): Fix ISO C portability glitch. + (unw_print_grmask, unw_print_frmask, unw_print_abreg): Likewise. + (unw_print_xyreg, unw_decode_x1, unw_decode_x2): Likewise. + (unw_decode_x3, unw_decode_r1, unw_decode_r2): Likewise. + (unw_decode_r3, unw_decode_p1, unw_decode_p2_p5): Likewise. + (unw_decode_p6, unw_decode_p7_p10, unw_decode_b1): Likewise. + (unw_decode_b2, unw_decode_b3_b4): Likewise. + + * readelf.c (get_elf_class): Fix ISO portability glitch. + (get_data_encoding, get_osabi_name, request_dump): Likewise. + +2001-11-07 Jakub Jelinek + + * readelf.c (debug_str, debug_str_size): New. + (display_debug_abbrev): If no abbrevs were read, skip the CU. + Call free_abbrevs. + (read_and_display_addr): Handle DW_FORM_strp. + (display_debug_info): Read .debug_str section if present, + so that DW_FORM_strp can be handled. + Fix test for non-existant .debug_abbrev section. + +2001-11-05 Jakub Jelinek + + * arlex.l: Accept `\' in filenames. Patch by . + + * arsup.c (ar_open): Prepend tmp- to basename, not whole path. + +2001-11-05 Martin Schwidefsky + + * MAINTAINERS: Add self as s390/s390x maintainer. + +2001-11-02 Tom Rix + + * MAINTAINERS: Add self as PPC XCOFF maintainer. + +2001-11-02 Nick Clifton + + * configure.in (ALL_LINGUAS): Add "fr" and "tr". + * configure: Regernate. + * po/fr.po: New file. + * po/tr.po: New file. + +2001-10-30 Hans-Peter Nilsson + + * MAINTAINERS: Add self as MMIX port maintainer. + * readelf.c: Include elf/mmix.h. + (guess_is_rela): MMIX is RELA. + (dump_relocations): Handle MMIX relocations. + * Makefile.am: Regenerate dependencies. + * Makefile.in: Regenerate. + +2001-10-13 Nick Clifton + + * readelf.c (parse_args): Handle multiple options to the -w + switch. + +2001-10-12 Jakub Jelinek + + * readelf.c (get_section_type_name): Don't print SHT_ prefix for + LOPROC, LOOS and LOUSER. + +2001-10-11 J"orn Rennecke + + * MAINTAINERS: Update my email address. + +2001-10-03 Alan Modra + + * doc/Makefile.in: Regenerate. + * configure: Regenerate. + +2001-10-02 Nick Clifton + + * readelf.c (display_debug_line, display_debug_pubnames, + display_debug_info, display_debug_frames): Detect and warn + about 64-bit format entries. + (display_debug_aranges): Reword 64-bit warning. + (debug_displays): Add .debug_pubtypes as a known, but not yet + supported, debug section. + +2001-10-02 Alan Modra + + * coffdump.c (PROGRAM_VERSION): Delete. + (main <'V'>): Call print_version. + * srconv.c: Likewise. + * sysdump.c: Likewise. + * version.c (program_version): Remove. + (print_version): Use BFD_VERSION_STRING. Just print the current + year in copyright message. + * addr2line.c (program_version): Remove unused declaration. + * objdump.c (display_target_tables): Use BFD_VERSION_STRING in + place of BFD_VERSION. + * Makefile.am (Makefile): Depend on bfd/configure.in. + (cplus-dem.o): Depend on Makefile. + Run "make dep-am". + * Makefile.in: Regenerate. + +2001-10-01 Nick Clifton + + * readelf.c (display_debug_aranges): Detect and warn about DWARF64 + format .debug_arange sections. + (main): Add missing prototype. + +2001-09-30 Hans-Peter Nilsson + + * Makefile.am: Update dependencies with "make dep-am". + * Makefile.in: Regenerate. + +2001-09-28 Richard Henderson + + * objdump.c (dump_section_header): Dump SEC_ARCH_BIT_0. + +2001-09-26 Alan Modra + + * bucomm.c (fatal): Define using VPARAMS, VA_OPEN, VA_FIXEDARG, + VA_CLOSE. + (non_fatal): Likewise. + * objdump.c (objdump_sprintf): Likewise. + * readelf.c (error): Likewise. + (warn): Likewise. + +2001-09-25 Jakub Jelinek + + * readelf.c (do_wide): New. + (options): Add --wide. + (usage, parse_args): Likewise. + (process_program_headers): Put each segment on a single line if + --wide is given. + (process_section_headers): Put each section on a single line if + --wide is given. + * doc/binutils.texi: Document it. + * NEWS: Likewise. + +2001-09-25 Alan Modra + + * readelf.c (print_vma): Print 8 digits of low hex value. + +2001-09-24 Andreas Jaeger + + * nlmconv.c: Fix warnings about unused attributes and function + prototypes. + + * strings.c: Add prototype for get_char. + +2000-09-19 H.J. Lu + + * doc/Makefile.am ($(DEMANGLER_NAME).1): Try cxxfilt.man and + $(srcdir)/cxxfilt.man. + * doc/Makefile.in: Rebuild. + +2001-09-19 Alan Modra + + * objcopy.c (copy_main): Correct rename-section string parsing. + Consolidate new_name parsing, and error messages. + +2001-09-18 Bruno Haible + + * addr2line.c: Don't include . + (main): For gettext, also set the LC_CTYPE locate facet. + * ar.c (main): Likewise. + * coffdump.c (main): Likewise. + * dlltool.c: Include "safe-ctype.h" instead of . + (main): For gettext, also set the LC_CTYPE locate facet. + Use ISALNUM instead of isalpha/isdigit. + * dllwrap.c: Don't include . + (main): For gettext, also set the LC_CTYPE locate facet. + * nlmconv.c: Include "safe-ctype.h" instead of . + (main): For gettext, also set the LC_CTYPE locate facet. + Use TOUPPER instead of islower/toupper. + * nlmheader.y: Include "safe-ctype.h" instead of . + (yylex): Use ISSPACE/ISALNUM instead of isspace/isalnum. + Use TOUPPER instead of islower/toupper. + * nm.c (main): For gettext, also set the LC_CTYPE locate facet. + * objcopy.c (main): Likewise. + * objdump.c: Include "safe-ctype.h" instead of . + (disassemble_bytes): Use ISPRINT instead of isprint. + (dump_section_stabs): Use ISDIGIT instead of isdigit. + (dump_data): Use ISPRINT instead of isprint. + (main): For gettext, also set the LC_CTYPE locate facet. + * rclex.l: Include "safe-ctype.h" instead of . + (cpp_line, handle_quotes): Use ISSPACE instead of isspace. + * rcparse.y: Include "safe-ctype.h" instead of . + Use TOUPPER instead of islower/toupper. + * readelf.c (main): For gettext, also set the LC_CTYPE locate facet. + * resrc.c: Include "safe-ctype.h" instead of . + (write_rc_accelerators): Use ISPRINT instead of isprint. + (write_rc_rcdata): Likewise. + * size.c (main): For gettext, also set the LC_CTYPE locate facet. + * srconv.c (main): Likewise. + * stabs.c: Include "safe-ctype.h" instead of . + (parse_number): Use ISDIGIT/ISUPPER/ISLOWER instead of + isdigit/isupper/islower. + (parse_stab_string, parse_stab_type, parse_stab_argtypes, + parse_stab_array_type, stab_demangle_count, stab_demangle_get_count, + stab_demangle_prefix, stab_demangle_qualified, + stab_demangle_template, stab_demangle_type, + stab_demangle_fund_type): Use ISDIGIT instead of isdigit. + * strings.c: Include "safe-ctype.h" instead of . + (isgraphic): Use ISPRINT instead of isascii/isprint. + (main): Remove HAVE_LC_MESSAGES dependency. + * sysdump.c: Include "safe-ctype.h" instead of . + (pbarray): Use ISPRINT instead of isprint. + (main): For gettext, also set the LC_CTYPE locate facet. + * windres.c: Include "safe-ctype.h" instead of . + (format_from_filename): Use ISPRINT instead of isprint. + (main): For gettext, also set the LC_CTYPE locate facet. + * winduni.c: Include "safe-ctype.h" instead of . + (unicode_print): Use ISPRINT instead of isprint. + * wrstabs.c: Include "safe-ctype.h" instead of . + (stab_variable): Use ISDIGIT instead of isdigit. + +2001-09-18 Alan Modra + + * ar.c (print_contents): Cast args of bfd_seek to the right types. + Replace bfd_read call with call to bfd_bread. + (extract_file): Likewise. + + * objdump.c (dump_section_header): Cast section->filepos to + unsigned long to suit printf format string. + * readelf.c (process_section_headers): Similarly for sh_offset. + (process_unwind): Likewise. + +2001-09-14 Nick Clifton + + * strings.c (encoding, encoding_bytes): New variables. + (long_options): Add --encoding. + (main): Accept -e and --encoding. + (get_char): New function. Read a, possibly wide, character from + the input stream. + (print_strings): Use get_char(). + (usage): Document new command line option. + * doc/binutils.texi: Document new command line option. + * NEWS: Announce new command line option. + +2001-09-12 Alexandre Oliva + + * readelf.c (guess_is_rela, dump_relocations, get_machine_name, + get_machine_flags): Added EM_M32R, EM_D10V, EM_V850, EM_D30V, + EM_MN10200, EM_MN10300, EM_FR30, EM_AVR_OLD and EM_PJ_OLD. + Removed EM_CYGNUS_ARC. + +2001-09-04 Jeffrey A Law (law@cygnus.com) + + * readelf.c: Include elf/h8 for H8 series definitions. + (guess_is_rela): H8 series if RELA. + (dump_relocations): Handle H8 series relocations. + +2001-08-31 Eric Christopher + + * readelf.c (get_machine_flags): Remove E_MIPS_MACH_MIPS32_4K. + +2001-08-29 Peter Targett + + * MAINTAINERS: Include ARC Maintainer. + +2001-08-29 Ben Elliston + + * stabs.c (stab_demangle_template): Initialise s4. + +2001-08-27 Alan Modra + + * readelf.c (dump_relocations): Recognise EM_PPC64. + +2001-08-26 Thiemo Seufer + + * readelf.c (get_machine_flags): Add detection of EF_MIPS_32BITMODE. + +2001-08-25 H.J. Lu + + * nm.c (print_width): New. + (display_rel_file): Set `print_width' according to + bfd_sprintf_vma. + (print_symbol_info_bsd): Check `print_width' instead of BFD64. + +2001-08-24 Alexandre Oliva + + * objcopy.c (use_alt_mach_code): New variable. + (OPTION_ALT_MACH_CODE): Define. + (copy_options): Added --alt-machine-code. + (copy_main): Handle it. + (copy_object): Switch to alternate machine code if requested. + * doc/binutils.texi: Document new option. + * NEWS: Likewise. + +2001-08-22 Thiemo Seufer + + * readelf.c (get_machine_flags): Add detection of EF_MIPS_UCODE. + +2001-08-21 H.J. Lu + + * readelf.c (dump_relocations): Support ELF64 on 32bit hosts. + (display_debug_info): Cast for 64bit hosts. + (display_debug_frames): Likewise. + (process_mips_specific): Likewise. + +2001-08-21 Andreas Jaeger + + * coffgrok.h: Add missing parameter for prototype of coff_grok. + + * sysdump.c: Add missing prototypes. + * srconv.c: Likewise. + * unwind-ia64.c: Likewise. + * coffdump.c: Likewise. + + * sysinfo.y: Print prototypes, include . + + * coffgrok.c: Add missing prototypes, include libiberty.h instead + of declaring xcalloc. + +2001-08-10 H.J. Lu + + * nm.c (print_value): Add one arg, bfd *. + (print_value): Replace fprintf_vma with bfd_fprintf_vma. + (print_symbol_info_bsd): Also pass `abfd' to print_value (). + (print_symbol_info_sysv): Likewise. + (print_symbol_info_posix): Likewise. + + * objdump.c (dump_section_header): Replace printf_vma with + bfd_printf_vma. + (print_section_stabs): Likewise. + (dump_bfd_header): Likewise. + (objdump_print_value): Replace sprintf_vma with + bfd_sprintf_vma. + (disassemble_bytes): Likewise. + (dump_reloc_set): Likewise. + +2001-08-10 Andreas Jaeger + + * configure.in: Add -Wstrict-prototypes and -Wmissing-prototypes + to build warnings. + * configure: Regenerate. + +2001-08-09 Alan Modra + + * readelf.c: Add missing prototypes. + * objdump.c: Likewise. Format existing prototypes. + +2001-08-08 Alexandre Oliva + + * readelf.c (display_debug_info): Add to abbrev_offset the addend + of any RELA relocation for the abbrev_offset memory location that + refers to the .debug_abbrev section symbol. + +2001-08-07 H.J. Lu + + * readelf.c (process_file): Return 0 if OK, otherwise return 1. + (main): Return process_file (). + +2001-08-05 Philip Blundell + + * doc/binutils.texi: Use "Thumb" not "THUMB". + +2001-08-03 John Healy + + Patch suggested by Frank Eigler . + * objdump.c (disassemble_data): Fill in section member of the + disasm_info structure. + +2001-08-03 Tom Walsh + + * configure.in: Added --with-windres option. + * configure: Regenerated. + +2001-07-11 Stephane Carrez + + * doc/binutils.texi: Use @command{name} for commands; + use @option{-opt} for options; use @table @env for list of options; + remove spaces arround [ | ] in synopsis. + + * doc/Makefile.am (POD2MAN): Use 'GNU Development Tools' for the + center title. + +2001-07-31 Nick Clifton + + * objcopy.c: Fix formatting. + (section_rename): New structure. + (OPTION_RENAME_SECTION): New switch. + (copy_usage): Document new switch. + (add_section_rename): New function: Add a node to the section + rename list. + (find_section_rename): New function: Find the new name and + flags for a section. + (setup_section): Call find_section_name to determine the name + of the output section. + (copy_main): Handle OPTION_RENAME_SECTION. + * binutils.texi: Document new switch. + * NEWS: Mention new switch. + +2001-07-30 Nick Clifton + + * README: Rename bug-gnu-utils@gcc.org to bug-binutils@gcc.org. + * MAINTAINERS: Rename bug-gnu-utils@gcc.org to + bug-binutils@gcc.org. + +2001-07-28 Matthias Kramm + + * bucomm.c (list_supported_architectures): New function. + * bucomm.h (list_supported_architectures): Declare. + * objdump.c (usage): Call the above. + +2001-07-25 Dave Brolley + + * objdump.c (SKIP_ZEROES): Only define it if it is not already defined. + (SKIP_ZEROES_AT_END): Only define it if it is not already defined. + +2001-07-19 Nick Clifton + + * README: Update for 2.11. Change bug reporting email address. + * MAINTAINERS: Tidy up. Change bug reporting email address. + +2001-07-16 DJ Delorie + + * resres.c (write_res_header): Align header size. + (res_align_file): Calculate alignment correctly. + + * rcparse.y (styles): use SUBLANG_SHIFT instead of 8 (or the more + correct 10). + * resrc.c (write_rc_resource): Likewise. + * windres.h (SUBLANG_SHIFT): Define - as 10. + +2001-07-15 Nick Clifton + + * MAINTAINERS: Add Christian Groessler as maintainer for z8k port. + +2001-07-11 Nick Clifton + + * MAINTAINERS: Add notes about branch checkins. + +2001-07-05 Daniel Berlin + + * readelf.c (display_debug_macinfo): New function, display + .debug_macinfo section. + (do_debug_macinfo): New variable. + (parse_args): Handle "-w[mM]" to mean display macro info. + (process_section_headers): Handle debug_macinfo. + (debug_displays): Replace unsupported function with macinfo + function for .debug_macinfo display. + * doc/binutils.texi: Document new command line switch. + * NEWS: Document new feature of readelf. + +2001-07-05 H.J. Lu + + * objcopy.c (filter_symbols): Don't turn undefined symbols + into local. + +2001-07-03 H.J. Lu + + * doc/Makefile.am (addr2line.1): Use addr2line.pod instead of + $@.pod. + (ar.1): Likewise. + (dlltool.1): Likewise. + (nlmconv.1): Likewise. + (nm.1): Likewise. + (objcopy.1): Likewise. + (objdump.1): Likewise. + (ranlib.1): Likewise. + (readelf.1): Likewise. + (size.1): Likewise. + (strings.1): Likewise. + (strip.1): Likewise. + (windres.1): Likewise. + (cxxfilt.man): Use $(DEMANGLER_NAME).pod instead of $@.pod. + ($(DEMANGLER_NAME).1): Also substitute cxxfilt with + $(DEMANGLER_NAME). + (as.1): Removed. + * doc/Makefile.in: Regenerated. + +2001-07-03 Nick Clifton + + * MAINTAINERS: Change MIPS maintainer to Eric Christopher. + +2001-07-01 Daniel Berlin + + * readelf.c: Support DWARF 2.1 tags, encodings, languages. + +2001-06-29 James Cownie + + * readelf.c: Support DWARF 2.1 attributes. + +2001-06-28 Alan Modra + + * readelf.c (GET_DATA_ALLOC): Remove. + (GET_DATA): Remove. + (get_data): New function combining above macros, with an extra + test for zero size. + (slurp_rela_relocs): Use get_data, and catch error return. + (slurp_rel_relocs): Likewise. + (get_32bit_program_headers): Likewise. + (get_64bit_program_headers): Likewise. + (get_32bit_section_headers): Likewise. + (get_64bit_section_headers): Likewise. + (get_32bit_elf_symbols): Likewise. + (get_64bit_elf_symbols): Likewise. + (process_section_headers): Likewise. + (process_relocs): Likewise. + (slurp_ia64_unwind_table): Likewise. + (process_unwind): Likewise. + (get_32bit_dynamic_segment): Likewise. + (get_64bit_dynamic_segment): Likewise. + (process_dynamic_segment): Likewise. + (process_version_sections): Likewise. + (process_symbol_table): Likewise. + (dump_section): Likewise. + (display_debug_info): Likewise. + (display_debug_section): Likewise. + (process_section_contents): Likewise. + (process_corefile_note_segment): Likewise. + (process_mips_specific): Likewise. Also free econf32, econf64. + +2001-06-25 Alan Modra + + * readelf.c (dump_relocations): Print "bad symbol index" if + symtab == NULL with non-zero symtab_index. + (process_relocs): Don't bomb if reloc section has no symsec. + +2001-06-24 H.J. Lu + + * objcopy.c (strip_main): Revert the change made on 2001-05-30 + by accident. + (copy_main): Apply the change made to strip_main on + 2001-05-30 by accident. + +2001-06-23 Andreas Jaeger + + * unwind-ia64.c (unw_decode_x1): Add unused attribute for + parameter 'code'. + (unw_decode_x2): Likewise. + (unw_decode_x3): Likewise. + (unw_decode_x4): Likewise. + +2001-06-23 Ben Elliston + + * MAINTAINERS: Add myself as M88k maintainer. + +2001-06-22 Jocelyn Mayer + + * objcopy.c (strip_main): Support -o or --output-file command lien + switch. + +2001-06-19 H.J. Lu + + * doc/Makefile.in: Regenerated. + +2001-06-19 Nick Clifton + + * readelf.c: Restore formatting. + +2001-06-18 H.J. Lu & Nick Clifton + + * Makefile.am: Move documentation into doc subdirectory. + * Makefile.in: Regenerated. + * binutils.texi: Move into doc subdirectory. + * addr2line.1: Removed. + * ar.1: Likewise. + * dlltool.1: Likewise. + * nlmconv.1: Likewise. + * nm.1: Likewise. + * objcopy.1: Likewise. + * objdump.1: Likewise. + * ranlib.1: Likewise. + * readelf.1: Likewise. + * size.1: Likewise. + * strings.1: Likewise. + * strip.1: Likewise. + * windres.1: Likewise. + * cxxfilt.man: Likewise. + * doc: New Directory. + * doc/Makefile.am: New file. + * doc/Makefile.in: Generate. + +2001-06-09 Alan Modra + + * NEWS: Fix a typo. Mention hppa64-elf. Add binutils-2.11 marker. + +2001-06-01 Alan Modra + + * MAINTAINERS: Update my email address. + +2001-05-30 Honda Hiroki + + * objcopy.c: Add new switches: --keep-global-symbol, + --keep-symbols, --localize-symbols, --keep-global-symbols and + --weaken-symbols. + * binutils.texi: Document new switches. + * objcopy.1: Regenerate. + * NEWS: Announce new feature. + +2001-05-28 Andreas Jaeger + + * readelf.c (display_debug_frames): Fix warnings: Remove unused + variables, fix format strings. + +2001-05-28 Nick Clifton + + * objdump.c (disassemble_bytes): Remove section VMA adjustment + when computing the address of the line to show. + +2001-05-16 Richard Henderson + + * readelf.c (do_debug_frames_interp): New. + (byte_get_little_endian): If BFD64, always read entire 8-byte fields. + (byte_get_big_endian): Likewise. + (parse_args) ['F']: Set do_debug_frames_interp. + (Frame_Chunk): Make data_factor signed, add fde_encoding. + (frame_display_row): Don't trunc pc_begin to int. + (size_of_encoded_value): New. + (display_debug_frames): Handle 64-bit targets. Print raw data + unless do_debug_frames_interp. + (debug_displays): Remove duplicate .debug_frame. + +2001-05-15 Ralf Baechle + + * readelf.c: Replace uses of EM_MIPS_RS4_BE with EM_MIPS_RS3_LE. + The former constant was never in active use and is used otherwise + by the ABI. + +2001-05-11 Jakub Jelinek + + * readelf.c (process_unwind): Print all unwind sections, not just + one. + +2001-05-07 Thiemo Seufer + + * readelf.c (process_unwind): Remove const specifier. + +2001-04-27 Michal Svec + + * strings.c (isgraphic): Do not use isascii() unless it is needed + for isprint() to work. + (main): Set the locale domain to LC_ALL not just LC_MESSAGES. + +2001-04-27 Johan Rydberg + + * NEWS: Announce support for OpenRISC. + +2001-04-17 Danny Smith + + * dlltool.c (do_default_excludes): Initialise to true. + +2001-04-10 Alan Modra + + * MAINTAINERS: Update my email address + * nm.c (print_symbol_info_bsd): Use a simple printf string. + +2001-04-05 Hans-Peter Nilsson + + * readelf.c (display_debug_lines): Fix typo for "Prologue". + +2001-03-30 H.J. Lu + + * readelf.c (process_unwind): Just return if do_unwind is 0. + +2001-03-28 Roger Sayle + + * dlltool.c (make_one_lib_file): Fix section flags for + .text, .data and .bss in stub ds*.o files to match those + generated by gas. + +2001-03-29 H.J. Lu + + * readelf.c (process_unwind): Only do unwind sections for + IA64. + +2001-03-28 H.J. Lu + + * Makefile.am ($(srcdir)/dlltool.1): Remove the extra target. + * Makefile.in: Regenerate. + +2001-03-26 Andreas Jaeger + + * binutils.texi (nm): Fix texi syntax. + +2001-03-25 Stephane Carrez + + * binutils.texi: Put @c man begin and @c man end indications + to generate man pages using texi2pod and pod2man. Put @c man title + to identify each man. Add SEEALSO entries. + * Makefile.am (MANCONF, TEXI2POD, POD2MAN): New variable. + (man_MANS): Add dlltool.1, nlmconv.1, readelf.1, windres.1, + sort the list. + (*.1): Build the man pages from binutils.texi. + * Makefile.in: Regenerate. + +2001-03-13 Eric Kohl + + * defparse.y (opt_equal_name): allow "." in name. + * dlltool.c (def_exports): Added ability to generate forwarded exports. + (gen_exp_file): Likewise. + +2001-03-12 Stefan Geuken + + * NEWS: Document addition of -B switch to objcopy. + * binutils.texi: Document addition of -B switch to objcopy. + * objcopy.c: (copy_options): Add --binary-architecture. + (copy_usage): Document -B/--binary-architecture. + (copy_main): Support -B/--binary-architecture. Set + bfd_external_binary_architecture. + +2001-03-11 Andreas Jaeger + + * readelf.c (guess_is_rela): Handle EM_S390_OLD. + (dump_relocations): Likewise. + (get_machine_name): Likewise. + +2001-02-28 Nick Clifton + + * readelf.c: (struct unw_aux_info): Remove const modifier for + 'strtab' field. + (process_unwind): Remove non-K&R compliant LHS type cast in call + to GET_DATA_ALLOC macro. + +2001-02-28 Philip Blundell + + * readelf.c (decode_ARM_machine_flags): Explicitly mention which + ABI is in use; remove ambiguity between the "unknown" EABI and + unrecognised ABIs. Handle version 2 ARM EABI. Update uses of + renamed EF_xx constants. + +2001-02-27 Alan Modra + + * configure.in (BFD_VERSION): New. + (AM_INIT_AUTOMAKE): Use $BFD_VERSION. + * configure: Regenerate. + * Makefile.am: Run "make dep-am" + * Makefile.in: Regenerate. + +2001-02-14 Nick Clifton + + * MAINTAINERS: Add "Obvious Fix" rule. + +2001-02-11 Michael Sokolov + + * unwind-ia64.c: Don't use ANSI C preprocessor stringisation and string + literal concatenation. + +2001-02-11 Michael Sokolov + + * readelf.c (struct unw_aux_info): Remove const from the info member. + (process_unwind): Don't type-cast the third argument to the + GET_DATA_ALLOC macro. + +2001-02-11 Nick Clifton + + * readelf.c (dump_relocations): Free corrected allocated + array. + (process_unwind): Fix compile time warning. + +2001-02-10 Nick Clifton + + * binutils.texi: Document new --unwind option to readelf. + +2001-02-09 Martin Schwidefsky + + * readelf.c: Add linux target for S/390. + +2001-02-10 Alan Modra + + * nm.c (print_symbol_info_bsd): Don't #ifdef inside printf in case + printf is a macro. + +2001-02-08 Hans-Peter Nilsson + + * acinclude.m4 (AM_PROG_LEX): Override installed definition. + * aclocal.m4: Regenerate. + * configure: Regenerate. + +2001-02-07 Todd Vierling + + * bucomm.c (bfd_target_vector): Change extern array to pointer. + * objdump.c (bfd_target_vector): Likewise. + +2001-02-07 David Mosberger + + * readelf.c (process_unwind): New function. + (slurp_ia64_unwind_table): Ditto. + (dump_ia64_unwind): Ditto. + (find_symbol_for_address): Ditto. + (slurp_rela_relocs): New function (split off from dump_relocations()). + (slurp_rel_relocs): Ditto. + (parse_args): Handle '-u' option. + + * unwind-ia64.c: New file. + * unwind-ia64.h: New file. + * Makefile.am: Include unwind-ia64.c in readelf build. + * Makefile.in: Regenerate. + * po/binutils.pot: Regenerate. + +2001-02-04 Philip Blundell + + * configure.in (OBJDUMP_DEFS): Match `arm*-*', not just `arm-*'. + * configure: Regenerate. + +2001-01-31 Steve deRosier + + * ieee.c (ieee_add_bb11): Don't check for backslashes + unless HAVE_DOS_BASED_FILE_SYSTEM is defined. + +2001-01-24 Mark Elbrecht + + * ieee.c: Update copyright. + (ieee_start_compilation_unit): Don't check for backslashes + unless HAVE_DOS_BASED_FILE_SYSTEM is defined. + + * stabs.c: Update copyright. Include "filenames.h". + (parse_stab): Use IS_ABSOLUTE_PATH. Ignore N_WARNING stabs. + +2001-01-23 Jakub Jelinek + + * readelf.c (process_version_sections): Check if VERDEF or VERNEED + sections are present before using them. Remove code duplication. + (process_symbol_table): Check if VERDEF or VERNEED sections are + present before using them. + +2001-01-17 Nick Clifton + + * objcopy.c (copy_object): Fail if attempting to convert the + endianness of the input object file. + + * binutils.texi: Explain that objcopy cannot convert endianness. + +2001-01-16 Nick Clifton + + * readelf.c (string_table_length): New variable. + (SECTION_NAME): Catch out of range indices and missing section + pointers. + (process_section_headers): Delete useless local variable + string_table_offset. Set the value of string_table_length + after loading the string table. + (process_mips_specific): Use SECTION_NAME macro. + (process_file): Set string_table_length to 0 when it is freed. + +2001-01-12 Nick Clifton + + * version.c (print_version): Update copyright date. + +2001-01-11 Peter Targett + + * readelf.c (dump_relocations): Include selection with EM_ARC. + (get_machine_name) Update name to "ARC". + +2001-01-09 Nick Clifton + + * Makefile.am: Add rule to build objdump.o from objdump.c and + using OBJDUMP_DEFS. + * Makefile.in: Regenerate. + + * configure.in: Define OBJDUMP_DEFS. Default to empty. + (arm, xscale, d10v): For these targets define OBJDUMP_DEFS to + -DDISASSEMBLER_NEEDS_RELOCS. + * configure: Regenerate. + + * objdump.c (disassemble_bytes): If DISASSEMBLER_NEEDS_RELOCS + is defined read in the relocs even if dump_reloc_info is + false. + +2001-01-07 Philip Blundell + + * binutils.texi (Bug Reporting): Replace `bug-gnu-utils' with + `bug-binutils'. + * README: Likewise. + +2000-12-19 Nick Clifton + + * dlltool.c: Add missing support for arm-epoc-pe. + * configure.in: Add missing support for arm-epoc-pe. + * configure: Regenerate. + +2000-12-15 Nick Clifton + + * MAINTAINERS: Add Diego Novillo as a maintainer for the Intel + Mode parts of the x86 port. + +2000-12-04 Andreas Jaeger + + * readelf.c (guess_is_rela): Add EM_X86_64. + (dump_relocations): Add EM_X86_64. + (get_machine_name): Add EM_X86_64. + Include "elf/x86-64.h". + +2000-12-12 Nick Clifton + + * readelf.c: Fix formatting. + +2000-12-11 Jan Hubicka + + * MAINTAINERS: Add myself and Andreas Jaeger as x86_64 maintainer. + +2000-12-07 Andrew Haley + + * readelf.c (display_debug_frames): Only display columns that are + referenced by the frame debug info. + +2000-12-05 Nick Clifton + + * MAINTAINERS: Add Jason Merrill as DWARF2 maintainer. + +2000-12-04 Jason Merrill + + * readelf.c (process_section_headers): Handle linkonce.wi sections. + (display_debug_section): Likewise. + (display_debug_info): Display CU header before bailing. + +2000-12-01 Chris Demetriou + + * readelf.c (get_machine_flags): Recognize MIPS32 ISA in + EF_MIPS_ARCH. Replace use of E_MIPS_MACH_MIPS32 with + E_MIPS_MACH_MIPS32_4K and adjust printed CPU name similarly. + + * readelf.c (get_machine_flags): Add cases for E_MIPS_ARCH_5, + and E_MIPS_ARCH_64. + + * readelf.c (get_machine_flags): Add case for + E_MIPS_MACH_SB1. + +2000-11-30 Richard Earnshaw + + * readelf.c (frame_display_row): Output 's' for DW_CFA_same_value. + +2000-11-28 Hans-Peter Nilsson + + * MAINTAINERS: Add Jörn Rennecke and self as SH maintainers. + Change sourceware.cygnus.com to sources.redhat.com. + Fix typo for "amongst". + +2000-11-28 Nick Clifton + + * strip.1 (COPYING): Mention that the GNU Free Documentation + License is present in the sources, but not the output, and + also available from the GNU website. + (GNU Free Documentation License): Comment out this section. + * strings.1: Ditto. + * size.1: Ditto. + * ranlib.1: Ditto. + * objdump.1: Ditto. + * objcopy.1: Ditto. + * nm.1: Ditto. + * nlmconv.1: Ditto. + * ar.1: Ditto. + * addr2line.1: Ditto. + +2000-11-27 DJ Delorie + + * readelf.c (usage): Add -wf (--debug-dump=frames) option. + (parse_args): Support -wf option. + (process_section_headers): Ditto. + (debug_displays): Ditto. + (display_debug_frames): New, dump *_frame sections. + (frame_need_space): Support for above. + (frame_display_row): Ditto. + * binutils.texi: Document it. + +2000-11-24 Nick Clifton + + * NEWS: Announce support for v5t, v5te and XScale. + +2000-11-22 Nick Clifton + + * readelf.c (get_machine_name): Add EM_JAVELIN, EM_FIREPATH, + EM_ZSP, EM_MMIX, EM_HUANY, EM_PRISM. + (get_section_type_name): Add SHT_GROUP and SHT_SYMTAB_SHNDX. + (get_elf_section_flags: Add SHF_GROUP. + (process_section_headers): Adjust output for 32-bit binaries + to look nice on an 80 column terminal. + +2000-11-20 H.J. Lu + + * readelf.c (get_osabi_name): Change ELFOSABI_MONTEREY to + ELFOSABI_AIX. + +2000-11-17 Richard Henderson + + * readelf.c (display_debug_lines): Adjust last change to + use sizeof (external->li_length). + +2000-11-17 Richard Henderson + + * readelf.c (display_debug_lines): Fix section length check + and end_of_sequence computation. + +2000-11-06 Nick Clifton + + * binutils.texi: Add GNU Free Documentation License. + * objcopy.1: Add GNU Free Documentation License. + * objdump.1: Add GNU Free Documentation License. + * addr2line.1: Add GNU Free Documentation License. + * ar.1: Add GNU Free Documentation License. + * nlmconv.1: Add GNU Free Documentation License. + * nm.1: Add GNU Free Documentation License. + * ranlib.1: Add GNU Free Documentation License. + * size.1: Add GNU Free Documentation License. + * strings.1: Add GNU Free Documentation License. + * strip.1: Add GNU Free Documentation License. + +2000-10-06 Luciano Gemme + + * objcopy.c (--srec-len=nn): New parameter to set the + maximum length of generated Srecords. + (--srec-forceS3): New parameter that restricts the generation of + Srecords to type S3 only. + * binutils.texi: Document new command line switches. + * objcopy.1: Docuemnt the new command line switches. + * NEWS: Announce the existence of the new command line switches. + +2000-10-31 Nick Clifton + + * MAINTAINERS: Add Jim Wilson as the maintainer for the IA64 + code. Add Eric Chrisopher as maintainer of MN10300 port. + +2000-10-12 Roger Sayle + + * Make comma after string after icon/control optional. + +2000-09-13 Anders Norlander + + * readelf.c (get_machine_flags): Also print EF_MIPS_MACH field. + + * NEWS: Mention support for MIPS32. + +2000-09-08 Nick Clifton + + * MAINTAINERS: Add Stephane Carrez as maintainer for 68HC[11|12]. + +2000-09-07 H.J. Lu + + * configure.in (AC_ISC_POSIX): Put after AC_CANONICAL_SYSTEM. + * configure: Rebuild. + +2000-09-06 Alexandre Oliva + + * configure: Rebuilt with new libtool.m4. + +2000-09-05 Nick Clifton + + * aclocal.m4: Regenerate. + * config.in: Regenerate. + * configure: Regenerate. + +2000-09-04 Todd Vierling + + * strip.1: Fix stray '\' in -o formatting. + +2000-09-02 Nick Clifton + + * configure.in: Increase version number to 2.10.91. + * configure: Regenerate. + * aclocal.m4: Regenerate. + * config.in: Regenerate. + * po/binutils.pot: Regenerate. + +2000-08-31 Alexandre Oliva + + * acinclude.m4: Include libtool and gettext macros from the + top level. + * aclocal.m4, configure: Rebuilt. + +2000-08-30 Jamie Guinan + + * resrc.c (close_input_stream): Delete extraneous logic + +2000-08-24 Hans-Peter Nilsson + + * NEWS: Mention support for CRIS. + +2000-08-21 Nick Clifton + + * addr2line.c: Changed email address for Ulrich Lauther. + +2000-08-17 Christopher C. Chimelis + + * objdump.c (LONGEST_ARCH): Set to sizeof("powerpc:common"). + +2000-08-17 Nick Clifton + + * readelf.c (display_debug_pubnames): Only issue warning + message once. Terminate message with a new line. + (display_debug_aranges): Only display version 2 debug info. + +2000-08-14 Todd Vierling + + * objcopy.c (strip_main): Silently accept -d as an alias for -g + for compatibility with old BSD systems. + +2000-08-14 Jason Eckhardt + + * NEWS: Mention i860 support. + +2000-08-11 Carlo Wood + + * addr2line.c (main): Add const to char *. + +2000-08-11 Geoff Keating + + * ar.c (main): Don't crash if called with no arguments + or only '-X32_64' as an argument. + +2000-08-08 DJ Delorie + + * resrc.c: use "gcc -xc" instead of -xc-header + +2000-08-05 Jason Eckhardt + + * readelf.c (elf/i860.h): Include. + (dump_relocations): Add recognition of i860 architecture. + (guess_is_rela): Add recognition of i860 architecture. + +2000-08-03 Nick Clifton + + * MAINTAINERS: Add information about CGEN maintainers. + +2000-07-26 Geoff Keating + + * nm.c (main): Ignore '-X32_64' as an option. + * ar.c (main): Likewise. + * binutils.texi (nm): Document new option. + (ar): Likewise. + +2000-07-23 Michael Sokolov + + * rdcoff.c (external_coff_symbol_p): K&R-ise. + +2000-07-20 H.J. Lu + + * binutils.texi: Put back "@end table" deleted by + accident. + +2000-07-05 Kenneth Block + + * nm.c: Add optional style to demangle switch. + * objdump.c: Add optional style to demangle switch. + * addr2line.c: Add optional style to demangle switch. + * binutils.texi: Document optional style to demangle + switch. + +2000-07-20 Hans-Peter Nilsson + + * MAINTAINERS: Add self as CRIS port maintainer. + * readelf.c: Include elf/cris.h. + (guess_is_rela): Handle EM_CRIS. + (dump_relocations): Ditto. + (get_machine_name): Ditto. + * Makefile.am: Rebuild dependencies. + * Makefile.in: Regenerate. + * po/binutils.pot: Regenerate. + +2000-07-19 H.J. Lu + + * readelf.c (get_dynamic_type): Change "AUXILARY" to + "AUXILIARY". + (process_dynamic_segment): Print out strings for DT_CONFIG, + DT_DEPAUDIT, DT_AUDIT and DT_RUNPATH. + +2000-07-19 Mark Kettenis + + * nm.c (usage): Change output of `nm --help' to include a + description of the purpose of the program and a detailed + description of the accepted options. + +2000-07-19 H.J. Lu + + * readelf.c (process_dynamic_segment): Change DF_1_NODEPLIB + to DF_1_NODEFLIB. + +2000-07-19 H.J. Lu + + * readelf.c (get_dynamic_type): Fix DT_CHECKSUM. + +2000-07-19 H.J. Lu + + * readelf.c (get_dynamic_type): Change DT_FEATURE_1 to + DT_FEATURE. + (process_dynamic_segment): Likewise. + + * readelf.c (get_dynamic_type): Handle DT_CONFIG, DT_DEPAUDIT, + DT_AUDIT, DT_PLTPAD, DT_MOVETAB and DT_CHECKSUM. + (process_dynamic_segment): Handle DTF_1_CONFEXP, DF_1_NODEPLIB, + DF_1_NODUMP and DF_1_CONLFAT. + +2000-07-18 Nick Clifton + + * binutils.texi (readelf): Fix spelling typo. + +2000-07-11 Mark Kettenis + + * objdump.c (usage): Make output of `objdump --help' more + consistent with the rest of the GNU world. Add a line describing + the purpose of the program. + +2000-07-10 David Huggins-Daines + + * stabs.c (parse_stab_range_type): Cast to proper type to fix + warning. + +2000-07-10 Ryan Bradetich + + * readelf.c (get_dynamic_data): Add casts and use unsigned chars + to fix warnings. + (process_symbol_table): Ditto. + (procesS_extended_line_op): Ditto. + (display_debug_lines): Ditto. + (display_debug_pubnames): Ditto. + (read_and_display_attr): Ditto. + +2000-07-09 Nick Clifton + + * MAINTAINERS: Add several more port specific maintainers. + +2000-07-05 Nick Clifton + + * MAINTAINERS: Add blanket write privs for Michael Meissner. + +2000-06-05 DJ Delorie + + * MAINTAINERS: New. + +2000-07-01 Eric Fifer + + * dllwrap.c: Changed mistaken dyn_string_append() calls + to dyn_string_append_cstr(). + +2000-07-01 Alexander Aganichev + + * stabs.c (parse_stab_type): Divide size in bits by 8 as binutils + struct debug_type stores size in bytes. + +2000-07-01 Alan Modra + + * Makefile.am (DEP): Fix 2000-06-22. grep after running dep.sed + (CLEANFILES): Add DEPA. + * Makefile.in: Regenerate. + +2000-06-27 Alan Modra + + * ar.c: Revert incorrect 2000-06-25 patch. + * bucomm.c: Likewise. + +2000-06-25 Mark Elbrecht + + * rdcoff (parse_coff_symbol): Treat GNU weak symbols as external. + (external_coff_symbol_p): New function. + (parse_coff): Use it. + +2000-06-25 Alexander Aganichev + + * ar.c (normalize): Advance past both characters in a DOS based + : filepath prefix. + (main): Likewise. + * bucomm.c (make_tempname): Likewise. + +2000-06-24 Nick Clifton + + * objdump.c (usage): Fix description of --stabs switch. + +2000-06-22 Alan Modra + + * Makefile.am (DEP): grep for leading `/' in DEP1, and fail if we + find one. + * Makefile.in: Regenerate. + +2000-06-20 Alexander Aganichev + + * ar.c (normalize): Correct pointer comparison when checking for + backslashes. + (main): Likewise. + * bucomm.c (make_tempname): Likewise. + + * ieee.c (ieee_start_compilation_unit): Correct pointer comparison + and search for backslashes in the original pathname. + (ieee_add_bb11): Likewise. + +2000-06-18 Nick Clifton + + * ar.c (print_contents): Improve verbose message. + +2000-06-15 H.J. Lu + + * dyn-string.c: Removed. Not needed with dyn-string.c in + libiberty. + * dyn-string.h: Likewise. + + * Makefile.am: Remove references to dyn-string.c and + dyn-string.h. Rebuild dependency. + * Makefile.in: Rebuild. + +2000-06-15 H.J. Lu + + * binutils.texi: Put a warning on copying relocatable object + files between two different formats. + +2000-06-13 DJ Delorie + + * rcparse.y (control): ICON controls take an id as the first + parameter, not an optional string. Also, call new convenience + function that takes res_id's. + * resrc.c (define_control): missing text means zero-length string, + not zero ID. + (define_icon_control): New. + * windres.h: declare define_icon_control. + +2000-06-13 H.J. Lu + + * configure: Regenerate. + +2000-06-08 David O'Brien + + * configure.in (VERSION): Update to show this is the CVS mainline. + +2000-06-02 David O'Brien + + * strings.c (isgraphic): Interpret as a printable character, + analogous to . + +2000-05-30 Alan Modra + + * objdump.c (display_target_list): Use bfd_close_all_done, not + bfd_close to fix crash caused by 2000-05-24 change. + +2000-05-25 DJ Delorie + + * resrc.c (close_input_stream): zero out cpp_pipe after closing it. + +2000-05-26 Alan Modra + + * Makefile.am: Update dependencies with "make dep-am" + * Makefile.in: Regenerate. + +2000-05-26 Eli Zaretskii + + * ar.c: Include filenames.h. + (normalize) [HAVE_DOS_BASED_FILE_SYSTEM]: Support backslashes + and drive letters in file names. + (main): Support backslashes and drive letters in argv[0]. Drop + the .exe suffix, if any, in argv[0] if is_ranlib is negative. Use + FILENAME_CMP instead of strcmp to compare file names. + (open_inarch) [__GO32__]: Don't ifdef errno != ENOENT test for + DJGPP v2. + (do_quick_append) [__GO32__]: Ditto. + (get_pos_bfd, delete_members, move_members, replace_members): + Compare file names with FILENAME_CMP. + + * bucomm.c: Include filenames.h. + (make_tempname) [HAVE_DOS_BASED_FILE_SYSTEM]: Support mixed + forward/backward slashes and drive letters in file names. + + * ieee.c (ieee_start_compilation_unit, ieee_add_bb11): Support + mixed forward/backward slashes and drive letters in file names. + + * strings.c (O_BINARY, setmode, SET_BINARY): Define. + (main) [SET_BINARY]: Use SET_BINARY to switch stdin into binary + mode. + + * objcopy.c: Include filenames.h. + (main) [HAVE_DOS_BASED_FILE_SYSTEM]: Drop the .exe suffix + before comparing to "strip". + Use FILENAME_CMP to compare file names. + + * arsup.c: Include filenames.h. + (map_over_list, ar_delete, ar_replace, ar_extract): Use + FILENAME_CMP to compare file names. + (ar_open): Prepend "tmp-" instead of appending "-tmp", to create + the temporary file name. + + * configure.in: Check for setmode. + * configure: Regenerate. + +2000-05-24 Alan Modra + + * objdump.c (display_target_list): Close the bfd. + (display_info_table): Likewise. + +2000-05-14 H.J. Lu (hjl@gnu.org) + + * objcopy.c (filter_symbols): Don't strip global symbols in + relocatable object files. + +2000-05-14 Alan Modra + + * size.c (usage): Associate short options with corresponding long + option to give a clue as to their function. + +2000-05-14 Philippe De Muyter + + * size.c (main): Accept and ignore `-f' option. + +2000-05-13 Alan Modra + + * bucomm.h (gettext, dgettext, dcgettext, textdomain, + bindtextdomain): Replace defines with those from intl/libgettext.h + to quieten gcc warnings. + +2000-05-12 H.J. Lu + + * nlmconv.c (temp_filename): Removed. + + * nlmconv.c (link_inputs): Use make_temp_file () instead of + choose_temp_base (). + * objdump.c (display_target_list): Likewise. + (display_info_table): Likewise. + +2000-05-08 Alan Modra + + * objcopy.c (setup_section): Add const and gettext calls for err. + +2000-05-02 H.J. Lu + + * readelf.c (get_osabi_name): Handle ELFOSABI_NONE instead of + ELFOSABI_SYSV. Also handle ELFOSABI_NETBSD, ELFOSABI_HURD, + ELFOSABI_SOLARIS, ELFOSABI_MONTEREY, ELFOSABI_IRIX, + ELFOSABI_FREEBSD, ELFOSABI_TRU64, ELFOSABI_MODESTO + and ELFOSABI_OPENBSD. + +2000-05-02 Kazu Hirata + + * coffgrok.c: Add ATTRIBUTE_UNUSED as appropriate. + * srconv.c: Likewise. + * sysdump.c: Likewise. + +2000-04-23 Denis Chertykov + + * readelf.c (guess_is_rela): AVR uses RELA relocations. + (get_machine_name): machine name for EM_AVR added. + +2000-04-21 Richard Henderson + David Mosberger + + * Makefile.am (readelf.o): Add elf/ia64.h. + * Makefile.in: Rebuild. + * readelf.c: Include elf/ia64.h. + (guess_is_rela, dump_relocations): Handle EM_IA_64. + +2000-04-17 Timothy Wall + + * objdump.c (disassemble_data): Set octets per byte *after* + resolving arch/mach for binary files. + +2000-04-14 Michael Sokolov + + * arlex.l: Add directives to increase lex buffer size. + + * objdump.c, readelf.c: Don't include strarg.h or varargs.h. They are + already included by bucomm.h. + +2000-04-10 Philippe De Muyter + + * readelf.c (dynamic_segment_mips_val): Call `sprintf', not + `strftime' since strftime is not available on all systems. + (process_mips_specific): Ditto. + +2000-04-07 Andrew Cagney + + * configure.in (WARN_CFLAGS): Set to -W -Wall by default. Add + --enable-build-warnings option. + * Makefile.am (AM_CFLAGS, WARN_CFLAGS): Add definitions. + * Makefile.in, configure: Re-generate. + +2000-04-06 Alan Modra + + * addr2line.c: Update copyright. + * objcopy.1: Likewise, and title. + * strings.1: Likewise. + + * version.c (print_version): Add 2000. + + * rddbg.c (read_section_stabs_debugging_info): Don't use + bfd_size_type for strx to avoid printf problems if BFD64. + + * bucomm.c: (report): Remove `static'. + Move inclusion of stdarg.h/vararg.h from here. + * bucomm.h: To here. + (CONST): Change all occurences to const. + (report): Declare it. + (bfd_fatal): Add ATTRIBUTE_NORETURN. + (fatal): Add ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN. + (non_fatal): Add ATTRIBUTE_PRINTF_1. + + * ar.c (main): Use fatal or non_fatal instead of fprintf. + Correct a typo in an error message. + (do_quick_append): Use non_fatal instead of fprintf. + (move_members): Use fatal instead of fprintf, exit. + * coffdump.c (main): Same here. + + * dlltool.c (display): Delete. + (warn): Delete. + (inform): Use `report' instead of `display'. + (rvaafter): Remove trailing \n from fatal error msg. + (rvabefore): Ditto. + (asm_prefix): Ditto. + (yyerror): Replace `warn' with `non_fatal', and remove \n. + (def_name): Likewise. + (run): Likewise. + (scan_all_symbols): Likewise. + (gen_lib_file): Likewise. + (def_library): Likewise. Remove extra program_name too. + (run): Remove \n from inform strings. + (scan_drectve_symbols): Likewise. + (add_excludes): Likewise. + (scan_open_obj_file): Likewise. + (gen_exp_file): Likewise. + (gen_lib_file): Likewise. + (process_duplicates): Likewise. + + * Makefile.am (dllwrap_SOURCES): Add version.c. + * dllwrap.c (program_version): Delete. + (print_version): Delete. + (display): Always print trailing \n. + (warn): New. + (delete_temp_files): Use warn instead of fprintf. Use gettext. + (run): Here too. + (main): And here. + (usage): gettext'ify. + (long_options): Add missing initialisers. + + * nlmconv.c (main): Use fatal/non_fatal instead of fprintf. + (select_output_format): Likewise. + (powerpc_mangle_relocs): Likewise. + (link_inputs): Likewise. + + * nm.c (set_print_radix): Use fatal instead of fprintf, exit. + (set_output_format): Likewise. + (main): Use non_fatal instead of fprintf. + (display_rel_file): Likewise. + + * objdump.c (slurp_symtab): Use non_fatal instead of fprintf. + (slurp_dynamic_symtab): Same here. + (disassemble_data): And here. + (read_section_stabs): And here. + (read_section_stabs): And here. + (dump_bfd): And here. + (main): And here. + (objdump_sprintf): Use fatal instead of fprintf, exit. + (disassemble_data): Same here. + + * rdcoff.c (parse_coff_type): Use non_fatal instead of fprintf. + (parse_coff_struct_type): Same here. + (parse_coff_enum_type): And here. + (parse_coff): And here. + * rddbg.c (read_debugging_info): And here. + * size.c (main): And here. + * windres.c (format_from_name): And here. + * wrstabs.c (stab_write_symbol): Here too. + (write_stabs_in_sections_debugging_info): And here. + (stab_int_type): And here. + (stab_struct_field): And here. + (stab_typdef): And here. + + * rescoff.c (read_coff_rsrc): Use fatal instead of fprintf, exit. + * srconv.c (main): Same here. + * strings.c (main): And here. + (integer_arg): And here. + * sysdump.c (main): And here. + +2000-04-06 Timothy Wall + + * objdump.c (dump_section_header): Print CLINK and BLOCK flags. + +2000-04-06 Jason Merrill + + * readelf.c (decode_location_expression): Loop through multiple + operations. + (read_and_display_attr): Pass in length. + + * readelf.c (read_and_display_attr): Add CU offset to references. + (display_debug_info): Pass it in. + +2000-04-06 Nick Clifton + + * readelf.c (decode_ARM_machine_flags): New function. + (get_machine_flags): Call decode_ARM_machine_flags for ARM + targets. + + (get_machine_name): Catch EM_AVR + +2000-04-05 Alan Modra + + * binutils.texi: Remove optional `=' from long options that have + an `=' in the argument. + * objcopy.1: Here too. Remove extra space on discard-all. + + * binutils.texi (objcopy): Mention --redefine-sym. + * objcopy.1: Here too. + * NEWS: And here. + + * objcopy.c (parse_flags): Split off flag names from error message + gettext as they are not translated. + (copy_main): Similarly split off option name for --add-section, + --set-section-flags, --change-section-vma, --change-section-lma + error messages. + Some white space changes. + + from Matthew Benjamin + * objcopy.c (struct redefine_node): New. + (redefine_sym_list): New. + (redefine_list_append): New. + (lookup_sym_redefinition): New. + (OPTION_REDEFINE_SYM): New. + (copy_options): Add --redefine-sym option. + (copy_usage): Mention it. + (filter_symbols): Rename symbols on redefine_sym_list. + (copy_object): Call filter_symbols if redefine_sym_list != NULL. + (copy_main): Handle OPTION_REDEFINE_SYM. + +2000-04-04 H.J. Lu + + * readelf.c (process_symbol_table): Correctly read in symbol + versioning information. + +2000-04-04 Alan Modra + + * po/binutils.pot: Regenerate. + + * addr2line.c (usage): Restore translated part of bug string. + * ar.c (usage): Likewise. + * nlmconv.c (show_usage): Likewise. + * nm.c (usage): Likewise. + * objcopy.c (copy_usage): Likewise. + (strip_usage): Likewise. + * objdump.c (usage): Likewise. + * readelf.c (usage): Likewise. + * size.c (usage): Likewise. + * strings.c (usage): Likewise. + * windres.c (usage): Likewise. + + * Makefile.am (MKDEP): Use gcc -MM rather than mkdep. + (DEP): Quote when passing vars to sub-make. Add warning + message to end. + (DEP1): Rewrite for "gcc -MM". + (CLEANFILES): Add DEP2. + Update dependencies. + * Makefile.in: Regenerate. + +2000-04-04 H.J. Lu + + * Makefile.am (GENERATED_HFILES): Add rcparse.h + (arparse.h): Depend on arparse.c + (defparse.h, nlmheader.h, rcparse.h, sysinfo.h): Similarly. + +2000-04-03 H.J. Lu (hjl@gnu.org) + + * size.c (usage): Use REPORT_BUGS_TO. + +2000-04-03 Alan Modra + + * bucomm.h: #include "bin-bugs.h" + * addr2line.c (usage): Use REPORT_BUGS_TO. + * ar.c (usage): Likewise. + * nlmconv.c (show_usage): Likewise. + * nm.c (usage): Likewise. + (OPTION_TARGET): Define. + (long_options): Use OPTION_TARGET rather than 200. + (main): Likewise. + + * objcopy.c (copy_usage): Use REPORT_BUGS_TO. + (strip_usage): Likewise. + * objdump.c (usage): Likewise. + * readelf.c (usage): Likewise. + * strings.c (usage): Likewise. + * windres.c (usage): Likewise. + +2000-03-31 John David Anglin + + * readelf.c: Include sys/types.h before sys/stat.h for ultrix. + +2000-03-27 Nick Clifton + + * rddbg.c (read_section_stabs_debugging_info): Catch out of range + string offsets in corrupt stabs entries. + +2000-03-27 Alan Modra + + * readelf.c: Include elf/avr.h + (dump_relocations): Add EM_AVR case. + +2000-03-09 Tim Waugh + + * strings.1: Correct '-bytes' to '--bytes'. + +2000-03-08 H.J. Lu + + * Makefile.am (install-exec-local): Depend on + install-binPROGRAMS for parallel make. + * Makefile.in: Regenerated. + +2000-02-27 Ian Lance Taylor + + From Brad Lucier : + * readelf.c (process_dynamic_segment): Add cast to make sure + argument to %* is int. + +2000-02-25 H.J. Lu + + * configure.in (AC_SEARCH_LIBS): Pass m, not -lm. + +2000-02-24 Nick Clifton + + * configure.in: Add arm-wince, mips-pe and sh-pe targets. + * configure: Regenerate. + + * dlltool.c: Add support for sh-pe and mips-pe targets. + * rescoff.c: Add support for sh-pe and mips-pe targets. + +2000-02-23 H.J. Lu + + * readelf.c (get_osabi_name): Handle ELFOSABI_LINUX. + +2000-02-22 Nick Clifton + + * readelf.c (process_symbol_table): Remove use of ELF_ST_OTHER. + +2000-02-22 Ian Lance Taylor + + From Brad Lucier : + * readelf.c (process_version_sections): Add casts to make sure + argument to %* is an int. + (process_mips_specific): Add casts to make printf arguments match + format. + +2000-02-21 Alan Modra + + * objdump.c (dump_section_header): Change `opb' to unsigned. + (find_symbol_for_address): Same here. + (disassemble_data): And here. Change `addr_offset', + `stop_offset', `nextstop_offset' to unsigned long. + (dump_data): Change opb to unsigned. + +2000-02-18 Frank Ch. Eigler + + * resrc.c: Remove unmatched #if for cygwin. + +2000-02-14 Fernando Nasser + + * binutils.texi: Document the change of flavor name from atpcs-special + to special-atpcs to prevent name conflict in gdb. + +2000-02-08 Timothy Wall + + * objdump.c (show_line): Fix bug preventing printing of the very + first line (line zero) of a file when interlisting source and + assembly. Added option to print entire context from start of file + when the first line from that file is encountered. + +2000-02-03 Timothy Wall + + * objdump.c (dump_section_header, find_symbol_for_address, + show_line, disassemble_bytes, disassemble_data, dump_data): + distinguish between octets and bytes. + +2000-01-27 Thomas de Lellis + + * nm.c (print_symbol_info_bsd): Use bfd_is_undefined_symclass to + check to unresolved symbols. + (print_symbol_info_sysv): Ditto. + (print_symbol_info_posix): Ditto. + + * binutils.texi: Document new 'V' symclass flag for nm. + +2000-01-27 Nick Clifton + + * binutils.texi (objdump): Document new ARM specific + disassembler options. + + * objdump.c (usage): Call disassembler_usage(). + +2000-01-27 Alan Modra + + * readelf.c (get_dynamic_flags): Return buff. + (process_dynamic_segment): Don't pass error strings to printf + as format arg. + (read_and_display_attr): Use lx and ld to print longs. + (process_corefile_note_segment): Cast bfd_vma to unsigned long + before printing. + Update copyright. + +2000-01-17 Nick Clifton + + * readelf.c (get_osabi_name): Recognise ELFOSABI_ARM. + +2000-01-15 Alan Modra + + * debug.c (debug_name_type): Return DEBUG_TYPE_NULL rather than + false. + (debug_tag_type): Here too. + * ieee.c (ieee_builtin_type): And here. + * stabs.c (parse_stab_type, parse_stab_array_type): And here. + +2000-01-13 Nick Clifton + + * readelf.c (get_machine_name): Change EM_S370 to return "IBM + System/370". + +2000-01-11 Nick Clifton + + * readelf.c (get_dynamic_type): Remove DT_ENCODING. + +2000-01-10 Nick Clifton + + * readelf.c (get_note_type): Display NT_WIN32PSTATUS notes. + +2000-01-07 Mumit Khan + + * windres.c (long_options): Add --use-temp-file and + --no-use-temp-file options. + (usage): Document. + (main): Handle. + + * windres.h: Update read_rc_file prototype. + + * resrc.c (cpp_temp_file): New static variable. + (istream_type): New static variable. + (close_pipe): Delete function. + (run_cmd): New static function. + (open_input_stream): New static function. + (close_input_stream): New static function. + (look_for_default): Handle DOS directory separator. Use + open_input_stream instead of popen. + (read_rc_file): Likewise. + + * binutils.texi: Document --use-temp-file, --no-use-temp-file + options. + +2000-01-04 Mumit Khan + + * dlltool.c (create_compat_implib): New variable. + (gen_exp_file): Use. + (make_one_lib_file): Use. + (long_options): Add --compat-implib option. + (usage): Handle. + (main): Handle. + + * dllwrap.c (enum target_type): Rename MINGW32_TARGET to MINGW_TARGET. + (main): Use. Don't look for "32" in cygwin and mingw target names. + +2000-01-03 Nick Clifton + + * binutils.texi: Document new, ARM specific disassembler + command line switch "-M force-thumb". + +For older changes see ChangeLog-9899 + +Copyright (C) 2000-2001 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-0203 b/support/sdbinutils/binutils/ChangeLog-0203 new file mode 100644 index 0000000..5b1a37a --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-0203 @@ -0,0 +1,2187 @@ +2003-12-31 Daniel Jacobowitz + + * MAINTAINERS: Rename CONFIGURE to BUILD SYSTEM and add myself. + +2003-12-29 Nick Clifton + + * readelf.c (debug_line_pointer_size): Replace with an array + called 'debug_line_pointer_sizes'. + (num_debug_line_pointer_sizes): New variable. + (display_debug_lines): Extract pointer size from the + debug_line_pointer_sizes array. + (display_debug_loc): Likewise. + (prescan_debug_info): Fill in the debug_line_pointer_sizes + array. + +2003-12-23 Ralf Baechle + Maciej W. Rozycki + + * objcopy.c (bfd_flags_to_set, bfd_flags_to_clear): New variables + to handle flags for tweaking. + (copy_options): New options: impure, pure, readonly-text, + writable-text. + (copy_usage, copy_object, command_line_switch): Handle the new + options. + * doc/binutils.texi: Document the new options. + +2003-12-22 Jakub Jelinek + + * objdump.c (disassemble_bytes): Subtract rel_offset from printed + reloc address. + (disassemble_section): Set rel_offset to section->vma instead of + pinfo->buffer_vma. + +2003-12-19 Kazuhiro Inaoka + + * readelf.c (guess_is_rela): Changed m32r's default type to RELA. + +2003-12-11 Nick Clifton + + * objcopy.c (strip_usage): Add --only-keep-debug. + (copy_usage): Likewise. + +2003-12-04 Nick Clifton + + * objcopy.c (copy_object): Do not copy the object if the + output file's format cannot be set to that of the input file. + If the input file's format is unknown, fail. + +2003-11-28 Ian Lance Taylor + + * cxxfilt.c (usage): Mention new -p/--no-params options. + +2003-11-28 Alan Modra + + * Makefile.am (install-exec-local): Remove common term from string + comparison. + * Makefile.in: Regenerate. + * doc/Makefile.am: Don't use $<. + * doc/Makefile.in: Regenerate. + +2003-11-27 Nick Clifton + + * rename.c (smart_rename): Make sure that we have write + permission on the destination file before renaming. + +2003-11-26 Daniel Jacobowitz + Nick Clifton + + * readelf.c: Add a comment describing the difference between + readelf and objdump. + * doc/binutils.texi (readelf): Likewise. + +2003-11-25 Danny Smith + + * doc/binutils.texi (dlltool): Document dlltool --temp-prefix + option. + * dlltool.c (usage): Likewise. + +2003-11-22 Ian Lance Taylor + + * cxxfilt.c (long_options): Add --no-params. + (main): Handle -p/--no-params. + * doc/binutils.texi (c++filt): Document -p/--no-params. + +2003-11-19 Alan Modra + + * objdump.c: Wrap long lines, init vars separately from decl. + (disassemble_section): Reset require_sec after call to + find_symbol_for_address. + +2003-11-14 Nick Clifton + + * objdump.c (find_symbol_for_address): Change parameters so + that the entire disassemble_info structure is passed, not just + a few fields. Use the symbol_is_valid field to check the + validity of located symbols and continue searching if they are + not valid. + (objdump_print_addr): Alter parameters passed to + find_symbol_for_address. + (objdump_symbol_at_address): Likewise. + (disassemble_section): Likewise. Also use symbol_is_valid + function to check the validity of located symbols. + +2003-11-13 Tobias Burnus + + * ar.c (open_inarch): Emit a warning when an archive is created + (only shown with -v) in order to confrom to POSIX specification. + +2003-11-11 Wang Li + + * objcopy.c (wildcard): New variable. True if wildcard pattern + matching is allowed in symbol names. + (strip_options): Add -w option to enable wildcard pattern + matching. + (copy_options): Likewise. + (copy_usage): Mention new switch. + (strip_usage): Likewise. + (is_specified_symbol): If performing wildcard matches use fnmatch + to compare symbol names with entries on the symbol list. + (strip_main): Accept -w switch. + (copy_main): Likewise. + * Makefile.am: Add dependency on fnmatch.h for objcopy.c + * Makefile.in: Regenerate. + * doc/binutils.texi: Document new switch. + * NEWS: Mention new switch. + +2003-11-11 Alan Modra + + * objdump.c: Revert rev 1.81 commit. + +2003-11-10 Tobias Burnus + + * ar.c (print_contents): Remove "member" from verbose output in + order to conform to POSIX specification. + +2003-11-10 Alan Modra + + * README: Expand bug reporting information. + +2003-11-07 Jonathan R. Grant + + * bucomm,c (get_file_size): New function. Returns the size of a + file. + * bucomm.h: Add prototype for get_file_size. + * addr2line.c (process_file): Use new function. + * ar.c (main, ranlib_only, ranlib_touch): Likewise. + * nm.c (display_file): Likewise. + * objcopy.c (add_specific_symbols, copy_file, strip_main, + copy_main): Likewise. + * objdump.c (display_file): Likewise. + * size.c (display_file): Likewise. + * strings.c (strings_file): Likewise. + * readelf.c (process_file): Use similar code to get_file_size. + +2003-11-06 Bruno Rohee + + * ieee.c: Fix "the the" typo. + * stabs.c: Likewise. + +2003-10-30 Marshall T. Vandegrift + + * readelf.c (dump_section): Do not dump the contents of SHT_NOBITS + sections - they have no file space assigned to their contents. + +2003-10-28 Segher Boessenkool + + * readelf.c (dump_section): Don't display DEL characters. + +2003-10-27 Kazu Hirata + + * ChangeLog: Fix typos. + * ChangeLog-9197: Likewise. + * ChangeLog-9899: Likewise. + * NEWS: Likewise. + * ar.c: Fix comment typos. + * arsup.c: Likewise. + * coffgrok.c: Likewise. + * debug.c: Likewise. + * debug.h: Likewise. + * dlltool.c: Likewise. + * ieee.c: Likewise. + * nm.c: Likewise. + * objdump.c: Likewise. + * prdbg.c: Likewise. + * readelf.c: Likewise. + * resrc.c: Likewise. + * sysinfo.y: Likewise. + * windres.c: Likewise. + +2003-10-27 Nick Clifton + + * objcopy.c (copy_section): Do not complain when a target does not + support relocations. + (mark_symbols_used_in_relocations): Likewise. + +2003-10-14 Anil Paranjpe + + * objcopy.c (copy_main): Reads machine flags from arch_info + structure. + +2003-10-20 Andrew Cagney + + * coffgrok.h (coff_section): Replace 'struct sec" with "struct + bfd_section". + +2003-10-07 Nathan Sidwell + + * objdump.c (read_section_stabs): Just read one section, return + pointer to it. Add size parameter. + (print_section_stabs): Add string offset parameter. Adjust. + (struct stab_section_names): Add string offset member. + (find_stabs_sections): Correct check for split section suffix, + adjust read_section_stabs and print_section_stabs calls. + (dump_stabs_section): Clear string_offset, free string table. + +2003-10-01 Martin Fuchs + + * resrc.c (define_icon): Fix storage of color attributes 'planes' and + 'bit count' in icon groups. + +2003-09-30 Chris Demetriou + + * NEWS: Add an indication of the cutoff for 2.14. + +2003-09-30 Chris Demetriou + + * readelf.c (get_machine_flags): Handle E_MIPS_ARCH_64R2. + +2003-09-29 H.J. Lu + + * readelf.c (dump_relocations): Support SHN_IA_64_ANSI_COMMON. + (get_symbol_index_type): Likewise. + +2003-09-25 H.J. Lu + + * readelf.c (process_version_sections): Indent version names. + +2003-09-15 Anthony Green + + * dlltool.c (prefix_encode): Fix ISO C90 conversion. + (dlltmp): Ditto. + (dtab): Ditto. + +2003-09-14 Andreas Jaeger + + * addr2line.c: Convert to ISO C90 prototypes, change PTR, remove + unneeded (void *) casts. + * ar.c: Likewise. + * arlex.l: Likewise. + * arparse.y: Likewise. + * arsup.c: Likewise. + * binemul.c: Likewise. + * binemul.h: Likewise. + * bucomm.c: Likewise. + * bucomm.h: Likewise. + * budbg.h: Likewise. + * budemang.c: Likewise. + * budemang.h: Likewise. + * coffdump.c: Likewise. + * coffgrok.c: Likewise. + * cxxfilt.c: Likewise. + * debug.c: Likewise. + * debug.h: Likewise. + * deflex.l: Likewise. + * dlltool.c: Likewise. + * dlltool.h: Likewise. + * dllwrap.c: Likewise. + * emul_aix.c: Likewise. + * filemode.c: Likewise. + * ieee.c: Likewise. + * nlmconv.c: Likewise. + * nlmconv.h: Likewise. + * nlmheader.y: Likewise. + * nm.c: Likewise. + * prdbg.c: Likewise. + * rclex.l: Likewise. + * rcparse.y: Likewise. + * rdcoff.c: Likewise. + * rddbg.c: Likewise. + * rename.c: Likewise. + * resbin.c: Likewise. + * rescoff.c: Likewise. + * resrc.c: Likewise. + * size.c: Likewise. + * srconv.c: Likewise. + * stabs.c: Likewise. + * strings.c: Likewise. + * sysdump.c: Likewise. + * sysinfo.y: Likewise. + * syslex.l: Likewise. + * unwind-ia64.c: Likewise. + * unwind-ia64.h: Likewise. + * version.c: Likewise. + * windres.c: Likewise. + * windres.h: Likewise. + * winduni.c: Likewise. + * wrstabs.c: Likewise. + +2003-09-10 James E Wilson + + * MAINTAINERS: Update my e-mail address. + +2003-09-09 Ian Lance Taylor + + * MAINTAINERS: Update my e-mail address. + +2003-09-04 Nick Clifton + + * MAINTAINERS: Make it clear what should be done with patches to + the top level configure files (other than config.guess and + config.sub). Add binutils@sources.redhat.com as an address to + which patches can be sent. + +2003-09-04 Nick Clifton + + * readelf.c (get_machine_flags): Recognise V850E1 machine type. + +2003-09-03 Andrew Cagney + + * objdump.c: Refer to init_disassemble_info in comments. + (disassemble_data): Replace INIT_DISASSEMBLE_INFO with + init_disassemble_info. + +2003-09-03 Nick Clifton + + * objdump.c (struct objdump_disasm_info): Add new fields + 'dynrelbuf', 'dynrelcount' and 'disassemble_fn'. + (process_section_p): New function: Returns TRUE if a section + can be dumped. + (disassemble_section): New function: Contains the body of + disassemble_data(), but just for one section. + (disassemble_data): Use bfd_map_over_sections to walk section + chain. + (find_stabs_section): New function: Find a stabs containing + section and then dump it. + (dump_stabs_section): New function: Use bfd_map_over_sections + to find the section to dump. + (dump_stabs): Use dump_stabs_section. + (dump_section): New function: Display the contents of a + section. + (dump_data): Use bfd_map_over_sections to display section + contents. + (dump_relocs_in_section): Display the relocs in a given section. + (dump_relocs): Use bfd_map_over_sections to display relocs. + (adjust_addresses): New function: Adjust the vma and lma of + sections. + (dump_bfd): Use bfd_map_over_sections. + * doc/binutils.texi: Document the "objdump -s" (no longer) + dumps empty sections. + +2003-08-24 Jonathan R. Grant + + * objdump.c: Improve comments/documentation. + dump_data: Eliminate duplicate function calls to bfd_section_size. + +2003-09-02 Alan Modra + + * MAINTAINERS: Move Dave Anglin's entry to where it belongs. + +2003-08-21 Nick Clifton + + * po/tr.po: Updated Turkish translation. + +2003-08-14 Alan Modra + + * dep-in.sed: Remove libintl.h. + * Makefile.am (POTFILES.in): Unset LC_COLLATE. + Run "make dep-am". + * Makefile.in: Regenerate. + +2003-08-11 Ian Lance Taylor + + * readelf.c (process_archive): Fix error handling. Remove memory + leak. + + * readelf.c: Add ability to read archives. + (archive_file_offset): New variable. + (archive_file_size): New variable. + (get_data): Include archive_file_offset in file offset + calculation when fseeking. + (process_program_headers): Likewise. + (process_symbol_table): Likewise. + (process_dynamic_segment): Handle computation of end of file + position when the file is in an archive. + (process_object): New function. Contains the body of + process_file(). + (process_archive): New function. Call process_object on each + member of an archive. + (process_file): Detect archives and handle appropriately. + * Makefile.am: Add dependency on aout/ar.h for readelf.c + * Makefile.in: Regenerate. + * NEWS: Document readelf's new ability. + * doc/binutils: Alter text to say that readelf supports archives + and 64-bit ELF files. + +2003-08-08 Nick Clifton + + * po/fr.po: Updated French translation. + +2003-08-05 Alan Modra + + * objcopy.c: Remove unnecessary prototypes and casts. + * objdump.c: Remove unnecessary casts. + * readelf.c: Convert to C90. Remove unnecessary prototypes and casts. + (get_osabi_name): Move so we don't need a forward declaration. + +2003-08-04 Bradley Harrington + Alan Modra + + * objdump.c (include_paths, include_path_count): New vars. + (usage): Describe --include. + (long_options): Add "include". + (add_include_path): New function. + (struct print_file_list): Make filename const. Add modname. + (try_print_file_open, update_source_path): New functions. + (show_line): Use them. + (main): Handle 'I' option. Don't check for NULL xrealloc arg. + +2003-07-30 Alan Modra + + * objdump.c: Remove unnecessary prototypes. + (disassemble_bytes): Add rel_offset parameter. Simplify reloc skipping + code, and print relocs when dump_dynamic_reloc_info. + (disassemble_data): Read and handle dynamic relocs. Correct reloc + skip code. Formatting. + (dump_bfd): Don't dump dynamic relocs when disassembling. + +2003-07-29 Ben Elliston + + * MAINTAINERS: Remove self as M88k maintainer. Future M88k + maintenance defaults to the blanket write privilege maintainers. + +2003-07-29 Michael Meissner + + * MAINTAINERS: Updated my email address. + +2003-07-29 Nick Clifton + + * objdump.c: Update to ISO C. + +2003-07-24 Nick Clifton + + * objdump.c (disassemble_data): Do not ignore sections without the + LOAD flag when disassemble_all is true. Only print a message + about disassembling a section if it contains some data. + + * po/fr.po: Updated French translation. + +2003-07-23 Nick Clifton + + * objcopy.c: Switch to ISO C. Remove debugging code accidentally + left in. Some formatting tidy ups. + +2003-07-22 Salvador Eduardo Tropea + + * objdump.c: New command line option --debugging-tags. + * doc/binutils.texi: Document new command line option. + * prdbg.c: Code to print the debug info as tags compatible + with ctags. + * budbg.h: Adjust prototype. + * NEWS: Mention new switch + +2003-07-18 Nick Clifton + + * objdump.c (main) :Accept multiple -M switch. + * doc/binutils.texi: Document that multiple -M switches are + accepted and that a single -M switch can contain comma + separated options. + +2003-07-17 Nick Clifton + + * objdump.c (main): Issue a warning message if multiple -M + switches are used. + + * doc/binutils.texi (objdump): Update documentation about -M + option. + +2003-07-17 Nick Clifton + + * po/es.po: New Spanish translation. + +2003-07-11 Alan Modra + + * po/binutils.pot: Regenerate. + +2003-07-05 Christopher Faylor + + * dlltool.c (prefix_encode): Use a fixed length for alpha. + +2003-07-04 Christopher Faylor + + * dlltool.c (prefix_encode): New function. Encode temp file prefix + from pid. + (dlltmp): Pass address of pointer being alloced or suffer neverending + mallocs. + (make_one_lib_file): Allocate enough space for new longer stub names. + (gen_lib_file): Ditto. + (main): Generate the temp file prefix from the pid if prefix was not + specified on the command line. + +2003-07-04 Nick Clifton + + * readelf.c (get_data): Print (unsigned) hex values for size and + offset in error messages. + (process_section_headers): If the string table could not be + allocated, do not continue. + +2003-07-01 Jakub Jelinek + + * readelf.c (dynamic_segment_ia64_val): Print address and newline + for sections by default. Comment fix. + +2003-06-28 Danny Smith + + * rcparse.y (res_text_field): New res_id variable. + (res_null_text): New static const struct res_id object, + with empty unicode name field. + (control): Pop parsing of optresidc up one level. Set + res_text_field to $2 except for controls which do not accept + a text field. Set res_text_field to res_null_text for the + special cases (viz. COMBOBOX, EDITTEXT, LISTBOX, SCROLLBAR). + (control_params): Adjust to use res_text_field rather + than optresidc. + (COMBOBOX): Add comment about discrepency between documented + vs. observed default style. + * resrc.c (define_control): Make first param const. + * windres.h (define_control): Adjust prototype. + +2003-06-27 Nick Clifton + + * objcopy.c (copy_object): Replace call to + bfd_create_gnu_debuglink_section with separate calls to + bfd_add_gnu_debuglink_section and + bfd_fill_in_gnu_debuglink_section, separated by a walk over the + symbol tables. + +2003-06-26 Roland McGrath + + * readelf.c (loadaddr): Variable removed. + (dynamic_info, version_info): Fix type long -> bfd_vma. + (program_headers): New variable. + (get_program_headers): New function, broken out of + process_program_headers. + (process_program_headers): Call it. Don't set `loadaddr'. + (slurp_ia64_unwind_table): Use get_program_headers. + (process_corefile_note_segments): Likewise. + (offset_from_vma): New function. + (process_relocs, process_dynamic_segment): Call that instead of + subtracting `loadaddr'. + (process_version_sections, process_symbol_table): Likewise. + (process_mips_specific): Likewise. + +2003-06-26 Nick Clifton + + * objcopy (enum strip_action): Add STRIP_NONDEBUG. + (OPTION_ONLY_KEEP_DEBUG): New. + (strip_options): Add --only-keep-debug. + (copy_options): Likewise. + (is_strip_section): Invert return value if STRIP_NONDEBUG is + active. + (copy_object): Do not copy private data when STRIP_NONDEBUG is + active. + (setup_section): Likewise. + (strip_main): Handle --only-keep-debug. + (copy_main): Likewise. + * NEWS: Mention new switch + * doc/binutils.texi: Document new switch. + +2003-06-25 Alan Modra + + * NEWS: Correct spelling of "relocatable". + * objdump.c: Likewise. + * sysroff.info: Likewise. + +2003-06-19 Nick Clifton + + * readelf.c (print_vma): When printing DEC_5 values, if the + number is bigger than 99999 switch to using hexadecimal + notation. + +2003-06-11 Nick Clifton + + * objcopy.c (gnu_debuglink_filename): New variable. + (OPTION_ADD_GNU_DEBUGLINK): New switch + (copy_options): Describe --add-gnu-debuglink switch. + Mention that --strip-debug removes sections as well. + (is_strip_section): Process the sections removed and kept + lists before checking for debugging sections. + (add_redefine_syms_file): Make function static. + (copy_object): Use is_strip_section. + Check to see if a .gnu_debuglink section should be added. If + so, call bfd_add_gnu_debuglink. + (setup_section): Use is_strip_section. + (copy_section): Use is_strip_section. + (copy_main): Handle OPTION_ADD_GNU_DEBUGLINK. + * NEWS: Mention new objcopy switch. + * doc/binutils.texi: Document new switch. + +2003-06-11 H.J. Lu + + * po/Make-in (DESTDIR): New. + (install-data-yes): Support $(DESTDIR). + (uninstall): Likewise. + +2003-06-11 Alan Modra + + * Makefile.in: Regenerate. + +2003-05-23 Jakub Jelinek + + * readelf.c (get_segment_type): Handle PT_GNU_STACK. + +2003-06-03 Elias Athanasopoulos + + * NEWS: Document the new BSD/POSIX single-character mapping for + .comment/.note sections. + +2003-06-02 Chris Demetriou + Jason Thorpe + + * objcopy.c (redefine_list_append): Add an argument that + indicates the context from which this function is being + called. Change all callers. + (copy_options): Add a new option, --redefine-syms. + (copy_usage): Document new option. + (copy_main): Handle the --redefine-syms option. + * doc/binutils.text (objcopy): Document new option. + +2003-05-31 Richard Henderson + + * readelf.c (byte_get_signed): New. + (get_encoded_value): New. + (display_debug_frames): Use it. Always pre-process opcodes. + +2003-05-20 Michal Ludvig + + * readelf.c (display_debug_frames): Print both registers + for DW_CFA_register. + +2003-05-16 Kelley Cook + + * configure.in: Accept i[3-7]86 variants. Escape '[]' for + i[3-7]86-*-interix. + * configure.in: Regenerate. + +2003-05-13 Michael Eager + + * objcopy.c: Treat identical src/dst file names as if only one + entered. One Windows creating an output file of the same name as + the input file will delete the input file before it is read. + +2003-05-12 Salvador Eduardo Tropea + + * debug.c (debug_get_real_type): Extend test for circular debug + references. + +2003-05-12 Nick Clifton + + * configure.in (ALL_LINGUAS): Add zh_CN. + * configure: Regenerate. + * po/zh_CN.po: New file: Chinese (simplified) translation. + +2003-05-11 Jason Eckhardt + + * MAINTAINERS: Update my mail address. + +2003-05-07 H.J. Lu + + * readelf.c (dump_relocations): Enlarge the type field in wide + mode by one character. + +2003-05-03 Richard Henderson + + * readelf.c (struct Frame_Chunk): Add cfa_exp. + (frame_display_row): Just print "exp" for cfa or register + defined by a location expression. + (display_debug_frames): Handle DW_CFA_def_cfa_expression, + DW_CFA_expression, DW_CFA_MIPS_advance_loc8. + +2003-04-30 H.J. Lu + + * objdump.c (only): Change it to char **. + (only_size): New. + (only_used): New. + (disassemble_data): Check only as an array. + (dump_data): Likewise. + (dump_relocs): Likewise. + (main): Treat only as an array. + +2003-04-24 Dimitrie O. Paun + + * doc/binutils.texi: Fix the documentation for the -fo option. + +2003-04-23 J"orn Rennecke + + * readelf.c (get_machine_name) : Amend return value + to refer to SuperH. + + * readelf.c (decode_location_expression): Don't add a trailing ';'. + +2003-04-23 Dimitrie O. Paun + Nick Clifton + + * windres.c (long_options): Move close to main, where it is used. + Add 'input' and 'output' long options. + (main): Accept "-fo" as an alias for "-o". This is for rc + comptibility. + * doc/binutils.texi: Mention that -fo is accepted as an alias for + -o, but discourage its use. + +2003-04-22 Dimitrie O. Paun + + * windres.c (format_from_name): Make the exit on error + behaviour optional. + (main): Rename the -I option to -J. Introduce -I as a synonym + for --include-dir. For backwards compatibility also support the + old -I behaviour, but issue a deprecation warning. + * doc/binutils.texi: Rename -I to -J. Document the new behaviour + of the -I option. + +2003-04-22 Kazuhiro Inaoka + + * readelf.c: Replace references to Mitsubishi M32R with + references to Renesas M32R. + +2003-04-15 Rohit Kumar Srivastava + + * readelf.c: Replace occurrances of 'Hitachi' with 'Renesas'. + +2003-04-09 Alexandre Oliva + + * doc/binutils.texi (objdump) [--debugging]: Suggest readelf -w + for debugging information types not supported by objdump. + +2003-04-09 Bernd Jendrissek + + * configure.in: Recognize canonical form of i[3-6]86-pe*. + * configure: Regenerate. + +2003-04-09 Alexandre Oliva + + * readelf.c (display_debug_info): Apply RELA relocations on the + entire section. + (byte_put_little_endian, byte_put_big_endian): New functions. + (byte_put): New variable. + (get_file_header): Initialize it. + +2003-04-05 Dimitrie O. Paun + + * windres.c: Add -l for compatibility with wrc, and rc. + Use the short option as a key for long options that have + a synonymous short option. + * doc/binutils.texi: Added -l to the list of options. + +2003-04-03 Dimitrie O. Paun + + * windres.c: Add -U for compatibility with wrc, rc, and cpp. + (main): Just pass the -U option down to the preprocessor. + * doc/binutils.texi: Added -U to the list of options. + +2003-04-01 Dimitrie O. Paun + + * windres.c (usage): Report -r option. + (main): Ignore the -r option. + * doc/binutils.texi: Add -r to the list of options. + +2003-04-01 Bob Wilson + + * MAINTAINERS: Add myself as Xtensa maintainer. + +2003-04-01 Bob Wilson + + * readelf.c: Include "elf/xtensa.h". + (guess_is_rela): Add EM_XTENSA and EM_XTENSA_OLD to list of + targets that use RELA relocations. + (dump_relocations): Call elf_xtensa_reloc_type for + EM_XTENSA and EM_XTENSA_OLD. + (get_machine_name): Handle EM_XTENSA and EM_XTENSA_OLD. + +2003-04-01 Nick Clifton + + * configure.in: Change "arm-pe*" to "arm-*-pe*". Similarly for + thumb-pe*, mcore-pe and mcore-*elf. + * configure: Regenerate. + +2003-03-31 Alexandre Oliva + + * objdump.c (dump_data): Don't truncate the address to long; make + the width large enough, and uniform for all entries in a section. + +2003-03-31 H.J. Lu + + * readelf.c: Include "libiberty.h". + (dynamic_relocations): New. + (process_relocs): Properly handle dynamic relocation. + (process_dynamic_segment): Fill relocation elements in + dynamic_info. + +2003-03-31 Kevin Buettner + + * readelf.c (read_and_display_attr, read_and_display_attr_value): + Add new arguments ``offset_size'' and ``dwarf_version''. Adjust + all callers. + (display_debug_lines, display_debug_pubnames, display_debug_info) + (display_debug_aranges, display_debug_frames, read_and_display_attr) + (read_and_display_attr_value): Add 64-bit DWARF support. + +2003-03-31 Ian Lance Taylor + + * rcparse.y: Replace uses of 'optstringrc' with 'optresid'. + (optresid): Handle a resource id that can be a string or a number. + * resrc.c (define_control): Replace 'text' parameter with 'iid' a + struct res_id. + (define_icon_control): Pass a struct res_id to define_control. + * windres.h (define_control): Change prototype. + +2003-03-24 Elias Athanasopoulos + + * objcopy (OPTION_FORMATS_INFO): Define. + (strip_options): Add "info"/OPTION_FORMATS_INFO option. + (copy_options): Likewise. + (strip_usage): Add "--info" to usage. + (copy_usage): Likewise. + (strip_main): Declare formats_info. Iniatilize it to FALSE. + Handle "info". + (copy_main). Likewise. + * doc/binutils.texi. Document the "--info" option for + objcopy/strip. + * NEWS: Mention the new command line switch. + + * objdump.c (endian_string): Move to bucomm.c. + (display_info): Likewise. + (display_target_list): Likewise. + (display_info_table): Likewise. + (display_target_tables): Likewise. + (main): Assign the return value of display_info to exit_status. + * bucomm.c: Include bfdver.h and libbfd.h + (display_target_list): Call bfd_nonfatal instead of nonfatal and + return 0 on a non-fatal error, 1 on success. + (display_info_table): Likewise. + * bucomm.h (display_info): Provide a prototype. + * Makefile.am (bucomm.o): Add dependencies on bfdver.h and + libbfd.h. + * Makefile.in: Regenerate. + +2003-03-22 Danny Smith + + * dlltool.c (gen_def_file): Put demangled name comments on + own line preceding export name. + +2003-03-17 Nick Clifton + + * objdump.c (disassemble_data): Use disasm_info.fprintf_func not + printf for emitting new lines. + +2003-03-16 Elias Athanasopoulos + + * nm.c (print_symbol_info_bsd): Print the symbol's size instead of + the symbol's value when --size-sort is used, unless -S is used. + doc/binutils.texi (--size-sort): For non-bsd formats both the + value and size of the symbols are displayed. + +2003-03-13 Nick Clifton + + * po/da.po: Update. + +2003-03-12 Nick Clifton + + * MAINTAINERS: Remove Peter Targett as ARC maintainer. + +2003-03-10 Ben Elliston + + * MAINTAINERS: Update my mail address. + +2003-03-06 Elias Athanasopoulos + + * stabs.c (BYTES_IN_WORD): Remove definition. + * wrstabs.c (BYTES_IN_WORD): Likewise. + +2003-03-04 Nick Clifton + + * nm.c (main): Print a warning message if --size-sort and + --undefined-only are used together. + +2003-03-04 Elias Athanasopoulos + + * nm.c (print_symbol): Remove check for undefined_only. + +2003-03-03 Nick Clifton + + * po/da.po: Installed latest translation. + +2003-02-24 Nick Clifton + + * README: Update binutils references to 2.13. + Add paragraph about using --disable-nls. + +2003-02-24 Elias Athanasopoulos + + * doc/binutils.texi (nm --size-sort): Update. + +2003-02-21 James E Wilson + + * MAINTAINERS: Update email address. + +2003-02-21 Ian Wienand + + * readelf.c (get_ia64_dynamic_type): New function. + (dynamic_segment_ia64_val): New function. + (get_dynamic_type): If machine type is EM_IA_64 call + get_ia64_dynamic_val. + (get_ia64_section_type_name): Handle sections with types in the + SHT_IA_64_LOPSREG to SHT_IA_64_HIPSREG range. + (get_dynamic_flags): If machine type is EM_IA_64 call + dynamic_segment_ia64_val. + +2003-02-21 Bob Wilson + + * doc/binutils.texi: Fix typos and obvious texinfo mistakes. Make + section title capitalization more consistent. Update descriptions + of various options to be consistent with the code. Fix errors and + incomplete list in the description of c++filt format options. Remove + information about the linker. Change to be more polite about poor + bug reports. Replace FDL appendix with include of fdl.texi. + * doc/fdl.texi: New file. + +2003-02-21 Roger Sayle + + * objcopy.c (filter_symbols): Fix compilation problems with + HP-UX's C compiler. + +2003-02-19 Christopher Faylor + + * rclex.l (handle_quotes): Fix minor formatting problems introduced in + previous change. + +2003-02-19 Mark Blackburn + + * rclex.l (handle_quotes): Handle strings spanning more than one line. + +2003-02-12 Bob Wilson + + * nm.c (usage): Add `java' and `gnat' demangle styles and make + quotes consistent. + * objdump.c (usage): Ditto. Also fix some typos. + + * readelf.c (parse_args): Include 'H' option in call to getopt_long. + + * debug.c (debug_record_variable): Handle global register variables. + + * stabs.c (parse_stab): For N_SLINE only include + function_start_offset if the symbol is within a function; + otherwise, the value is absolute. + +2003-02-10 Nick Clifton + + * readelf.c (decode_ARM_machine_flags): Handle the + EF_ARM_MAVERICK_FLOAT flag. + +2003-02-04 Andreas Schwab + + * rddbg.c (read_section_stabs_debugging_info): Cast ptrdiff_t to + long and use %ld in printf format. + +2003-01-28 Richard Sandiford + + * readelf.c (dump_relocations): Reorder the r_info field for + little-endian mips elf64. Move #ifdef BFD64 to cover the new code. + +2003-01-21 Daniel Berlin + + * readelf.c (display_debug_loc): Skip address base changes. + +2003-01-17 Fabio Alemagna + + * readelf.c (get_osabi_name): Handle ELFOSABI_AROS, ELFOSABI_OPENVMS + and ELFOSABI_NSK. + +2003-01-16 Alan Modra + + * readelf.c: Include elf/ppc64.h. + (dump_relocations ): Use elf_ppc64_reloc_type. + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + +2003-01-02 Ben Elliston + + * readelf.c (guess_is_rela): Handle EM_IQ2000. + (get_machine_name): Likewise. + (dump_relocations): Likewise. + * NEWS: Mention IQ2000 support. + +2003-01-02 Richard Sandiford + + * readelf.c (get_machine_flags): Handle E_MIPS_ARCH_32R2. + +2002-12-30 Chris Demetriou + + * doc/binutils.texi (objdump): Note MIPS HWR (Hardware Register) + changes in MIPS -M options. + +2002-12-30 Dmitry Diky + + * Makefile.am: Add msp430 target. + * Makefile.in: Regenerate. + * readelf.c: Add support for msp430 target. + +2002-12-27 Chris Demetriou + + * doc/binutils.texi (objdump): Document MIPS -M options. + +2002-12-23 Andreas Schwab + + * readelf.c (main): Reset dump request after each file. + +2002-12-23 Nick Clifton + + * nlmconv.c (main): Pass TRUE as third argument to + bfd_arch_get_compatible. + +2002-12-23 Nick Clifton + + * strings.c (isgraphic): Replace definition with STRING_ISGRAPHIC + macro. Handle 'S' encoding, accepting 8-bit characters. + (main): Parse 'S' encoding. + (get_char): Accept 'S' encoding. + (print_strings): Use STRING_ISGRAPHIC. + (usage): Document support of 'S' encoding. + * doc/binutils.texi: Document support of 'S' encoding/ + * NEWS: Mention new feature. + +2002-12-20 Alan Modra + + * README : Don't use libibery's needed_list or + required_list, instead link libiberty/*.o. + +2002-12-19 Kazu Hirata + + * doc/binutils.texi: Fix typos. + +2002-12-14 John David Anglin + + * doc/binutils.texi: Add missing parenthesis. + +2002-12-15 Nick Kelsey + + * objcopy.c: Add --prefix-symbols= option to rename all + symbols by adding the given prefix to the begining of the symbol + name. This is useful to provide name space separation regardless + of how the object file was created. Added --prefix-sections= + and --prefix-alloc-sections= options to rename all + sections (or all sections with the alloc flag set) by adding the given + prefix to the begining of the symbol name. + * NEWS: Mention this new feature. + * doc/binutils.texi: Document this new feature. + +2002-12-13 Alan Modra + + * dlltool.c (mcore_elf_gen_out_file): Replace all occurrences of + dyn_string_append with dyn_string_append_cstr. + + * emul_aix.c (ar_emul_aix_create): Remove unused function. + +2002-12-10 James Cownie + + * readelf.h (get_TAG_name, get_AT_name, + read_and_display_attr_value): Add support for UPC extensions to + DWARF2 spec. + * NEWS: Mention this new support. + +2002-12-08 Alan Modra + + * NEWS: Mention that bfd no longer declares a "boolean" type. + +2002-12-07 Alan Modra + + * readelf.c (process_program_headers): When setting loadaddr, don't + assume segment size is 4k. Use p_align instead. + (loadaddr): Change from int to long. + (dynamic_addr, dynamic_info, version_info): Likewise. + (process_dynamic_segment ): Likewise. + (process_dynamic_segment): Adjust print format string. + (rela_addr, rela_size): Delete. + (process_relocs): Formatting. + +2002-12-05 Jim Wilson + + * configure.in (OBJDUMP_DEFS): Define SKIP_ZEROES as 16 for IA-64. + * configure: Regenerate. + +2002-12-04 Ian Lance Taylor + + * MAINTAINERS: Change e-mail address back to airs.com. + +2002-12-04 Aldy Hernandez + + * MAINTAINERS: Add self. + +2002-11-30 Alan Modra + + * addr2line.c, ar.c, arsup.c, binemul.c, binemul.h, bucomm.c, bucomm.h, + budbg.h, debug.c, debug.h, dlltool.c, emul_aix.c, ieee.c, nlmconv.c, + nlmconv.h, nlmheader.y, nm.c, objcopy.c, objdump.c, prdbg.c, rdcoff.c, + rddbg.c, readelf.c, rename.c, size.c, stabs.c, strings.c, + unwind-ia64.h, wrstabs.c: Replace boolean with bfd_boolean, true with + TRUE, false with FALSE. Simplify comparisons of bfd_boolean vars + with TRUE/FALSE. Formatting. + +2002-11-29 Jakub Jelinek + + * readelf.c Replace occurrences of Elf32_Internal_* and + Elf64_Internal_* with Elf_Internal_*. + (slurp_rel_relocs): Change Elf_Internal_Rel to Elf_Internal_Rela. + Zero r_addend fields. + (dump_relocations): Remove relas variable, change Elf_Internal_Rel to + Elf_Internal_Rela. + +2002-11-23 Nick Clifton + + * size.c (usage): Fix typo describing switch for hex format. + +2002-11-18 Svein E. Seldal + + * testsuite/binutils-all/objcopy.exp: Disable tic4x from test + * testsuite/binutils-all/objdump.exp: Setup proper values for tic4x + testcase + +2002-11-14 Nick Clifton + + * readelf.c (process_program_headers): Add comment about return + value. Ensure that 0 is returned if the headers are not loaded. + (process_file): If process_section_headers failed to load the + headers disable any tests that rely upon them. Similarly for + process_program_headers. + +2002-11-12 Nick Clifton + + * po/da.po: Updated Danish translation. + +2002-11-12 Klee Dienes + + * rddbg.c (read_section_stabs_debugging_info): Also recognize + LC_SYMTAB.stab/LC_SYMTAB.stabstr as a valid pair of sections. + +2002-11-11 Christopher Faylor + + * MAINTAINERS: Reinstate DJ Delorie as COFF maintainer. Drop COFF from + cgf maintainership. + +2002-11-11 Christopher Faylor + + * MAINTAINERS: Replace DJ Delorie as PE/COFF maintainer. + +2002-11-07 Nick Clifton + + * configure.in (ALL_LINGUAS): Add 'da'. + * configure: Regenerate. + * po/da.po: New Danish translation. + + * readelf.c (get_symbol_index_type): Revert part of previous + patch: Display unknown symbol types in decimal, not hex. + +2002-11-07 Danny Smith + + * dlltool.c (add_excludes): Don't prefix excluded fastcall + symbols with underscore. + (xlate): Ignore add_underscore for decorated fastcall symbols. + +2002-11-07 Eric Kohl + + * deflex.l: Accept '@' as first character of an ID. + * dlltool.c (gen_exp_file): Use existing '@' prefix rather than + ASM_PREFIX for fastcall symbols. + (scan_drectve_symbols): Handle fastcall symbols when generating + undecorated aliases for symbols in drectve section. + (scan_filtered_symbols): Likewise, with export-all. + (xlate): Likewise, with --kill-at. + (make_imp_label): New function to handle fastcall symbols + correctly. + (make_one_lib_file): Use make_imp_label instead of make_label + for imp symbols. + +2002-11-06 Svein E. Seldal + + * MAINTAINERS: Add self as TIC4X maintainer. + +2002-11-06 Hiroyuki Machida + + * readelf.c (get_symbol_index_type): Add hex number to + PROCESSOR-specific, OS-specific, reserved and unknown symbol + types. + +2002-11-04 Alan Modra + + * readelf.c (byte_get_little_endian): Comment typo fix. + (print_symbol): Constify "symbol" arg. Don't pass "symbol" to printf + as the format string. + (dump_relocations): Correct section sym names. + (process_section_headers): Clear symtab_shndx_hdr. + (read_and_display_attr_value): Don't pass indirect string to printf + as the format string. + (display_debug_frames): Indicate when zero terminator found. Decode + DW_EH_PE_pcrel addresses. + +2002-10-23 Svein E. Seldal + + * configure.in: Define SKIP_ZEROES as 32 for tic4x target in + order to ensure proper disassembly of the valid 0-value opcode. + * configure: Regenerate. + * aclocal.m4: Regenerate. + * config.in: Regenerate. + * configure.in: Regenerate. + * doc/Makefile.in: Regenerate. + * po/binutils.pot: Regenerate. + +2002-10-23 Kaz Kojima + + * MAINTAINERS: Add self as SH maintainer. + +2002-10-23 Ben Elliston + + * doc/binutils.texi (objdump): Document -z and move the entry for + --disassemble-zeroes to the end of the options section (for `z'). + +2002-10-21 Nick Clifton + + * MAINTAINERS: Discontinue Hans-Peter Nilsson as SH maintainer. + +2002-10-21 Svein E. Seldal + + * objdump.c (dump_data): Correct addr_offset for opb != 1. + +2002-10-15 Alan Modra + + * bucomm.c (list_supported_targets): Use bfd_target_list. + + * objcopy.c (copy_file): Report ambiguous bfd_object matches, and + other object errors in preference to bfd_core errors. + +2002-10-14 Alan Modra + + * Makefile.am: Run "make dep-am". + * objdump.c: #include "bfdver.h". + * version.c: Likewise. + * Makefile.in: Regenerate. + * config.in: Regenerate. + * configure: Regenerate. + * po/POTFILES.in: Regenerate. + +2002-10-09 Daniel Jacobowitz + + * readelf.c (display_debug_info): Ignore empty .rela.debug_info + sections. Allow relocations against the absolute symbol. Don't + use the value in compunit.cu_abbrev_offset if we found a RELA + relocation. + +2002-10-07 Gordon Chaffee + + * addr2line.c (slurp_symtab): Read in dynamic symbols if no + ordinary ones are available. + +2002-09-30 H.J. Lu + + * readelf.c (get_machine_flags): Handle E_MIPS_MACH_4120, + E_MIPS_MACH_5400 and E_MIPS_MACH_5500. + +2002-09-17 Zack Weinberg + + * Makefile.am (CFILES): Add cxxfilt.c. + (cxxfilt_SOURCES): Now just cxxfilt.c $(BULIBS). + (cxxfilt_LDADD): Delete. + Remove all references to underscore.c. + Regen dependencies. + * configure.in: Define TARGET_PREPENDS_UNDERSCORE in + config.h from $UNDERSCORE, rather than AC_SUBSTing it. + * binutils/cxxfilt.c: Moved here from gcc/cp, minor + adjustments to fit into binutils framework. + * configure, config.in, Makefile.in, doc/Makefile.in: Regenerate. + +2002-09-12 Roland McGrath + + * readelf.c (decode_location_expression): DW_OP_calli -> DW_OP_call_ref + Handle DW_OP_GNU_push_tls_address. + +2002-09-11 Nick Clifton + + * po/tr.po: Updated Turkish translation. + +2002-09-10 Nick Clifton + + * MAINTAINERS: Add Ben Elliston as a maintainer for configure and + testsuite changes. Add paragraphs about testsuite and config + patches. + +2002-08-29 Nick Clifton + + * readelf.c (get_machine_flags): Remove redundant reference to + E_V850EA_ARCH. + +2002-08-28 Alan Modra + + * objdump.c (dump_bfd): Restore lines accidentally deleted in + last commit. + +2002-08-28 Michael Hayes + + * objdump.c (dump_headers): Add printing of HAS_LOAD_PAGE flag. + (dump_bfd_header): Likewise. + +2002-08-27 Alan Modra + + * nm.c: Revert last change. + +2002-08-26 Alan Modra + + * nm.c (display_rel_file): Don't report "no symbols" as an error. + * objdump.c (slurp_symtab): Likewise. + (slurp_dynamic_symtab): Likewise. + (dump_symbols): Likewise. Do print "no symbols" to stdout. + +2002-08-24 Geoffrey Keating + + * MAINTAINERS: Change my mailing address. + +2002-08-23 John David Anglin + + * MAINTAINERS: Add Dave Anglin as HPPA co-maintainer. + +2002-08-22 Nick Clifton + + * MAINTAINERS: Add Jeff Law as (maintainance) maintainer for + HPPA. + +2002-08-21 John David Anglin + + * readelf.c (parse_args): Change debug_dump_opt to static. + +2002-08-16 Sivaguru Sankaridurg + + * stabs.c (parse_stab_argtype): Pass length of physname to + stab_demangle_argtypes. + (stab_demangle_argtypes): Add new parameter - length of physname. + Pass length of physname on to stab_demangle_prefix. + (stab_demangle_prefix): Add new parameter - length of physname. + Use length of physname (if supplied) to compute end of function + name. + +2002-08-15 Alan Modra + + * readelf.c: Include elf/i370.h. + (dump_relocations): Handle EM_S370. + (dynamic_segment_parisc_val): Print \n. + (process_dynamic_segment ): Here too. + +2002-08-14 Nick Clifton + + * nm.c (usage): Change 'gnu-new-abi' to 'gnu-v3'. + * objdump.c (usage): Likewise. + * doc/binutils.texi: Likewise. + +2002-08-14 Luke Dunstan + + * rcparse.y (acc_entry): Don't warn about ALT use with + non-VIRTKEY. + +2002-08-13 H.J. Lu + + * objcopy.c (copy_object): Don't warn about the unsupported + architecture unless the input target is defaulted or the + output architecture is different from the input. + +2002-08-09 Nick Clifton + + * po/sv.po: Updated Swedish translation. + +2002-08-05 Alan Modra + + * prdbg.c (pr_fix_visibility): Remove assert. + +2002-07-31 Nick Clifton + + * addr2line.c (process_file): Rename parameter 'filename' to + 'file_name' in order to avoid shadowing global symbol of the + same name. + (main): Likewise. + +2002-07-30 Jakub Jelinek + + * readelf.c (OPTION_DEBUG_DUMP): Define. + (options): Use it. + (usage): Update help. + (parse_args): Handle --debug-dump separately from -w. + * doc/binutils.texi (readelf): Update documentation. + +2002-07-25 Nick Clifton + + * po/es.po: Updated Spanish translation. + * po/fr.po: Updated French translation. + +2002-07-24 Nick Clifton + + * po/es.po: Updated Spanish translation. + +2002-07-23 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + +2002-07-23 Nick Clifton + + * po/fr.po: Updated French translation. + +2002-07-23 Eric S. Raymond + + * doc/binutils.texi (addr2line ): Correct brackets. + +2002-07-20 Alan Modra + + * budemang.c: Include config.h and string.h/strings.h. + +2002-07-18 Denis Chertykov + Frank Ch. Eigler + + * readelf.c: Include "elf/ip2k.h". + (guess_is_rela): Add support for EM_IP2K and EM_IP2K_OLD. + (dump_relocations): Likewise. + (get_machine_name): Likewise. + * NEWS: Mention IP2K support. + +2002-07-16 Nick Clifton + + * NEWS: Add 'Changes in 2.13'. + +2002-07-10 Jakub Jelinek + + * readelf.c (get_dynamic_type): Handle DT_GNU_PRELINKED, + DT_GNU_CONFLICT* and DT_GNU_LIBLISZ*. + (get_section_type_name): Handle SHT_GNU_LIBLIST. + (process_dynamic_segment): Handle DT_GNU_CONFLICTSZ, + DT_GNU_LIBLISTSZ and DT_GNU_PRELINKED. + (process_gnu_liblist): New. + (process_file): Call it. + +2002-07-03 Alan Modra + + * Makefile.am (check-DEJAGNU): Revert 2002-06-25 change. + * Makefile.in: Regenerate. + +2002-07-02 Alan Modra + + * budemang.c: New file, "demangle" function. + * budemang.h: New file. + * addr2line.c (translate_addresses): Use "demangle". + * nm.c (print_symname): Likewise. + * objdump.c (objdump_print_symname): Likewise. + (dump_symbols): Likewise. Also, don't use bfd_asymbol_name macro + here since that obfuscates. + * rdcoff.c: Don't #include demangle.h. + * Makefile.am (CFILES): Add budemang.c, emul_aix.c, + emul_vanilla.c. Remove emul_$(EMULATION).c. Sort. + (HFILES): Add budemang.h. Sort. + (nm_new_SOURCES, objdump_SOURCES, addr2line_SOURCES): Add budemang.c. + Run "make dep-am". + * Makefile.in: Regenerate. + +2002-07-01 Matt Thomas + + * readelf.c: Include "elf/vax.h". + (guess_is_rela): Move EM_VAX from unknown to RELA case. + (dump_relocations): Handle VAX relocations. + (get_machine_flags): Handle VAX machine flags. + +2002-06-29 Stephane Carrez + + * readelf.c (dump_relocations): Handle 68HC11/68HC12 relocations. + +2002-06-26 Nick Clifton + + * MAINTAINERS: Remove Tom Rix from d10v and pcc maintainerships. + +2002-06-26 Alan Modra + + * nm.c (print_symname): When demangling, strip leading dots from + symbol names to avoid confusing the demangler. + +2002-06-25 H.J. Lu + + * Makefile.am (check-DEJAGNU): Set LC_ALL=C and export it. + * Makefile.in: Regenerated. + +2002-06-21 Igor Schein + + * configure.in: Quote bu_cv_have_fopen64. + * configure: Regenerate. + +2002-06-21 Mitsru Chinen + + * configure.in: Check for strcoll. + * configure: Regenerate. + * config.in: Regenerate. + * nm.c (main): Set locale for LC_COLLATE category. + (non_numeric_forward): Use strcoll if available. + +2002-06-20 Dave Brolley + + * MAINTAINERS: Add self as fr30 and frv maintainer. + +2002-06-18 H.J. Lu (hjl@gnu.org) + + * nm.c: Include "elf/common.h". + (extended_symbol_info): Add elfinfo, a pointer to + elf_symbol_type. + (SYM_SIZE): Use elfinfo if it is not NULL. + (get_symbol_type): New function. + (display_archive): Set print_width for each archive member. + (display_file): Likewise. + (display_rel_file): Don't set print_width here. + (print_object_filename_sysv): Handle print_width. + (print_archive_member_sysv): Likewise. + (print_symbols): Pass (bfd_vma) 0 to print_symbol. + (print_symbol): Set the elfinfo field in extended_symbol_info + for ELF. + (print_object_filename_sysv): Fix the output format. + (print_symbol_info_sysv): Print type and section for ELF. + +2002-06-18 Elias Athanasopoulos + + * nm.c (print_size_symbols): Remove assignment, which makes + the symbol's size equal to its value when --size-sort is + used. + +2002-06-18 Dave Brolley + + From Catherine Moore: + * readelf.c (elf/frv.h): #include it. + (guess_is_rela): Support EM_CYGNUS_FRV. + (dump_relocations): Ditto. + (get_machine_name): Ditto. + * Makefile.am (readelf.o): add dependency on $(INCDIR)/elf/frv.h. + +2002-06-18 Jakub Jelinek + + * readelf.c (get_file_header): Only read the first section header if + e_shoff is non-zero. + +2002-06-15 H.J. Lu (hjl@gnu.org) + + * nm.c (print_size): New variable. Initialize to 0. + (long_options): Add 'S'/"print-size". + (main): Handle 'S'. + (print_symbol_info_bsd): Print size only if print_size is not + 0. + + * doc/binutils.texi: Document -S/--print-size. + +2002-6-13 Elias Athanasopoulos + + * nm.c (struct extended_symbol_info): New structure: Add the size + of the symbols to the information provided by the symbol_info + structure. + (print_symbols): Pass the symbol size to print_symbol. + (print_size_symbols): Pass the symbol size to print_symbol. + (print_symbol): Extra argument: The size of the symbol. Store + this in the extended_symbol_info structure. + (print_symbol_info): Change type of info parameter to + extended_symbol_info. Display the size, if known. + (print_symbol_info_posix): Likewise. + (print_symbol_info_sysv): Likewise. + +2002-06-08 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + * doc/Makefile.in: Regnerate. + + * bucomm.c: Replace CONST with const. + * nm.c: Likewise. + * objdump.c: Likewise. + +2002-06-07 H.J. Lu + + * readelf.c (DW_CFA_GNU_args_size): Don't define. + (DW_CFA_GNU_negative_offset_extended): Likewise. + (DW_CFA_GNU_window_save): Likewise. + (display_debug_frames): Handle DW_CFA_offset_extended_sf, + DW_CFA_def_cfa_sf and DW_CFA_def_cfa_offset_sf. + +2002-06-07 Elias Athanasopoulos + + * nm.c: When computing size of symbols for an ELF target use the + internal size field. + +2002-06-06 John David Anglin + + * testsuite/binutils-all/objcopy.exp: clear xfail for + "hppa*64*-*-hpux*". + * testsuite/binutils-all/hppa/objdump.exp: Return if + "*64*-*-*". + +2002-06-05 Alan Modra + + * objcopy.c (copy_section): Don't copy SEC_GROUP sections. + +2002-06-03 Elias Athanasopoulos + + * objdump.c: Fix formatting. + +2002-05-29 Ben Elliston + + * MAINTAINERS: Add self as M68k maintainer. + +2002-05-28 Kuang Hwa Lin + + * readelf.c: Modified/Added DLX elf support. + +2002-05-27 Nick Clifton + + * arsup.c: Fix formatting. + * debug.c (debug_record_label): Add missing colon to error + message. + * ieee.c (parse_ieee_ty): Fix spelling typo. + * readelf.c (process_program_headers): Remove English assumption + about making a plural word. + (process_section_headers): Likewise. + (process_relocs): Allow quotes to be translated. + (process_unwind): Likewise, + (process_mips_specific): Improve error message. + (get_note_type): Fix spelling typo. + + * configure.in (ALL_LINGUAS): Add sv + * po/sv.po: New file. + +2002-05-27 Alan Modra + + * unwind-ia64.c (unw_print_brmask): Don't use sprintf. + (unw_print_grmask): Likewise. + (unw_print_frmask): Likewise. + +2002-05-26 Kazu Hirata + + * arsup.c: Remove ARGSUSED. + * debug.c: Likewise. + * ieee.c: Likewise. + * nlmconv.c: Likewise. + * prdbg.c: Likewise. + * stabs.c: Likewise. + * wrstabs.c: Likewise. + +2002-05-25 Alan Modra + + * arlex.l: Use #include "" instead of <> for local header files. + * coffdump.c: Likewise. + * coffgrok.c: Likewise. + * nlmconv.c: Likewise. + * nlmheader.y: Likewise. + * srconv.c: Likewise. + * strings.c: Likewise. + * sysdump.c: Likewise. + * unwind-ia64.h: Likewise. + * windres.h: Likewise. + * winduni.h: Likewise. + +2002-05-24 Tom Rix + + * MAINTAINERS: Add self as the d10v maintainer. + +2002-05-24 TAMURA Kent + + * configure.in: Builds dlltool for i386-netbsdpe. + * configure: Regenerate. + +2002-05-23 Kazu Hirata + + * size.c: Fix formatting. + * srconv.c: Likewise. + * stabs.c: Likewise. + * sysdump.c: Likewise. + * unwind-ia64.c: Likewise. + * wrstabs.c: Likewise. + +2002-05-23 Jakub Jelinek + + * readelf.c (get_segment_type): Add PT_TLS. + (get_elf_section_flags): Add SHF_TLS. + (get_dynamic_flags): Optimize. Add DF_STATIC_TLS. + (process_dynamic_segment): Use puts instead of printf. + (get_symbol_type): Support STT_TLS. + * objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT, + SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS. + Add SEC_THREAD_LOCAL. + +2002-05-23 Kazu Hirata + + * rdcoff.c: Fix formatting. + * rddbg.c: Likewise. + * readelf.c: Likewise. + * rename.c: Likewise. + * resbin.c: Likewise. + * resrc.c: Likewise. + * resres.c: Likewise. + +2002-05-21 Kazu Hirata + + * filemode.c: Fix formatting. + * ieee.c: Likewise. + * is-ranlib.c: Likewise. + * is-strip.c: Likewise. + * maybe-ranlib.c: Likewise. + * maybe-strip.c: Likewise. + * nlmconv.c: Likewise. + * nm.c: Likewise. + * not-ranlib.c: Likewise. + * not-strip.c: Likewise. + * objcopy.c: Likewise. + * objdump.c: Likewise. + +2002-05-21 Thiemo Seufer + + * objdump.c (dump_headers): Fix output formatting for ELF32 + architectures in a BFD64 enabled toolchain. + +2002-05-20 Kazu Hirata + + * debug.c: Fix formatting. + * debug.h: Likewise. + * dlltool.c: Likewise. + * dllwrap.c: Likewise. + * emul_aix.c: Likewise. + * emul_vanilla.c: Likewise. + +2002-05-19 Kazu Hirata + + * addr2line.c: Fix formatting. + * ar.c: Likewise. + * arsup.c: Likewise. + * arsup.h: Likewise. + * binemul.c: Likewise. + * binemul.h: Likewise. + * bucomm.c: Likewise. + * coffdump.c: Likewise. + * coffgrok.c: Likewise. + * coffgrok.h: Likewise. + +2002-05-16 Marek Michalkiewicz + + * MAINTAINERS: Add myself as the second AVR port maintainer. + +2002-05-16 Stephane Carrez + + * MAINTAINERS: Update my email address. + +2002-05-09 Nick Clifton + + * MAINTAINERS: Add Jason Thorpe as VAX maintainer. + +2002-05-09 Alan Modra + + * configure.in: Replace `*pe' with `pe' throughout. + * configure: Regenerate. + +2002-05-07 Federico G. Schwindt + + * Makefile.am: Honour DESTDIR. + * Makefile.in: Regenerate. + +2002-05-06 Alan Modra + + * dlltool.c (process_def_file): Add missing prototype. + (new_directive, assemble_file, main): Likewise. + (process_def_file, new_directive): Make static. + (inform): Rewrite using VA_FIXEDARG. + * dllwrap.c (mybasename): Add missing prototype. + (strhash, main): Likewise. + (inform): Rewrite using VA_FIXEDARG. + (warn): Likewise. + (cleanup_and_exit): Use old style function definition. + (strhash): Likewise. + * windres.c (define_resource): Use one memset to clear all of + struct res_resource. + + * rcparse.y: Remove newcmd rule. Move rcparse_discard_strings + call to rules that need no lookahead. Check for no lookahead. + +2002-05-06 Borut Razem + + * rclex.l (get_string): Correct "strings" list handling. + * resrc.c (read_rc_file): Discard strings. + +2002-05-04 Alan Modra + + * ar.c (replace_members): Remove unused var. Formatting fix. + * binemul.c (ar_emul_default_parse_arg): Add ATTRIBUTE_UNUSED. + + * MAINTAINERS: Sort port maintainers by CPU. + +2002-05-04 Bob Byrnes + + * size.c (display_archive): Add last_arfile and code to close archives. + +2002-05-01 Alan Modra + + * nm.c (print_symbol): Check returned filename from + bfd_find_nearest_line is non-NULL. + +2002-04-25 Elena Zannoni + + * readelf.c (get_AT_name): Handle DW_AT_GNU_vector. + +2002-04-24 Christian Groessler + + * MAINTAINERS: Changed my email address. + +2002-04-17 Thiemo Seufer + + * arparse.y: Fix syntax warning. + +2002-04-16 Nick Clifton + + * readelf.c (fetch_location_list): Remove unused function. + + * readelf.c (process_corefile_note_segment): Catch corrupt notes + and display a warning message, then exit the loop. + + * rcparse.y: Set MEMFLAG_DISCARDABLE by default. + +2002-04-15 Nick Clifton + + * resrc.c (write_rc_dialog): If charset is non-default value + display all of the DIALOGEX parameters. + +2002-04-15 Eric Kohl + + * rcparse.y: Allow two to five parameter in FONT statement of + DIALOGEX resources. + * resbin.c (bin_to_res_dialog): Fixed read/write code for dialogex + resource data. + (res_to_bin_dialog): Likewise. + * windres.h: Added misssing charset variable to dialog_ex + structure. + +2002-04-10 Nick Clifton + + * rcparse.y: Set MEMFLAG_PURE by default. + +2002-04-09 Bernd Herd + + * rcparse.y: CLASS definitions in DIALOG resources + are quoted. + Fix typo in BEDIT warning. + Don't add default dialog style when explicit style specified. + Add WS_CAPTION dialog style if CAPTION is specified. + + * rclex.l (handle_quotes): "\xhex" encoding in strings corrected. + (handle_quotes) "\a" escape (used for right justified key + definitions in menus) is encodes as binary 8. + + * resrc.c (write_rc_dialog): Print style even if it is 0. + (write_rc_directory): Fix overlooked sublang shift bug. + (bin_to_res_dialog): Don't print empty dialog caption. + + * resbin.c (bin_to_res_dialog): Use signature to identify + DIALOGEX. + + * windres.c (main): Set default LANGUAGE to english/us. + +2002-04-09 Gunnar Degnbol + + * resrc.c: print CLASS names in quotes + +2002-04-09 J"orn Rennecke + + * MAINTAINERS: Update my email address. + +2002-04-04 Alan Modra + + * dep-in.sed: Cope with absolute paths. + * Makefile.am (dep.sed): Subst TOPDIR. + Run "make dep-am". + * Makefile.in: Regenerate. + +2002-03-27 Peter Targett + + * MAINTAINERS: Update my email address. + +2002-03-21 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + * doc/Makefile.in: Regenerate. + * po/POTFILES.in: Regenerate. + * aclocal.m4: Regenerate. + * config.in: Regenerate. + * configure: Regenerate. + +2002-03-20 Daniel Berlin + + * readelf.c: Add support for displaying dwarf2 location lists. + (do_debug_loc, debug_loc_section, debug_loc_size): New. + (parse_args): Use 'O' as shorthand for displaying location list + section. + (process_section_headers): Handle debug_loc as well. + (load_debug_loc): New. + (free_debug_loc): New. + (fetch_location_list): New. + (display_debug_loc): New. + (display_debug_info): Call load_debug_loc and free_debug_loc. + (debug_displays): We can display .debug_loc now, too. + (usage): Update usage string. + (read_and_display_attr_value): Note location lists, but don't + display them inline. + +2002-03-18 Tom Rix + + * Makefile.am: Add binutils emulation support. + * configure.in: Same. + * configure.tgt: New file. Same. + * ar.c (main): Use ar_emul_parse_arg. + (usage): Use ar_emul_usage. + (replace_members): Use ar_emul_replace, ar_emul_append. + * binemul.c: New file. Define the binutils emulation + layer. Define default methods. + * binemul.h: New file. Binutils emulation layer header file. + * emul_aix.c: New file. AIX binutils emulation. + * emul_vanilla.c: New file. Default binutils emulation. + * Makefile.in: Regenerate. + * configure: Same. + +2002-03-18 Nick Clifton + + * po/fr.po: Updated version. + +2002-03-13 Nick Clifton + + * po/fr.po: Updated version. + +2002-03-07 Daniel Jacobowitz + + * README: Update some version numbers. + +2002-03-07 Daniel Jacobowitz + + * doc/binutils.texi (Target Selection): Fix LD crossreferences. + (Architecture Selection): Likewise. + +2002-03-01 Dmitry Timoshkov + + * dlltool.c (gen_exp_file): Take into account --kill-at (-k) while + generating .exp file. + +2002-02-21 Nick Clifton + + * readelf.c (dump_relocations): Fix typo. + +2002-02-20 Nick Clifton + + * NEWS: Mark 2.12 branch. + +2002-02-18 Timothy Daly + + * readelf.c (dump_relocations): Display 2nd and 3rd reloc + types for 64-bit MIPS. Narrow some fields for 80-char + output. + (dump_relocations): Change spelling from 'unrecognised' + to 'unrecognized'. + (decode_ARM_machine_flags): Likewise. + (parse_args): Likewise. + (read_and_display_attr_value): Likewise. + (display_debug_section): Likewise. + +2002-02-15 Hans-Peter Nilsson + + * NEWS: Mention support for MMIX. + +2002-02-13 Matt Fredette + + * readelf.c (get_machine_flags): Recognize EF_M68000. + +2002-02-12 Alexandre Oliva + + * MAINTAINERS: Added self as MN10300 co-maintainer. + +2002-02-12 Alan Modra + + * readelf.c (get_ppc64_dynamic_type): Handle DT_PPC64_OPD and + DT_PPC64_OPDSZ. + +2002-02-11 Daniel Jacobowitz + + * MAINTAINERS: List myself as branch maintainer. + +2002-02-11 Alan Modra + + * configure: Regenerate. + * objcopy.c: Update copyright date. + * doc/Makefile.in: Regenerate. + +2002-02-10 Daniel Jacobowitz + + * nlmconv.c: Back out localtime PARAMS change. + +2002-02-11 Alan Modra + + * objcopy.c (MKDIR): Define. + (copy_archive): Make name_list.name const. Use MKDIR. + Handle duplicate files in archives by making more temp dirs. + +2002-02-10 Daniel Jacobowitz + + * coffdump.c: Include "getopt.h" after "bucomm.h" + so that macros are defined correctly. + * nlmconv.c: Add PARAMS ((const time_t *)) to localtime + prototype. Prototype main. + * nlmheader.y: Add PARAMS ((int)) to strerror prototype. + +2002-02-06 Alexandre Oliva + + * MAINTAINERS: Added self as SH co-maintainer. + +2002-02-05 Nick Clifton + + * po/tr.po: Updated translation. + +2002-02-01 Alan Modra + + * Makefile.am: Run "make dep-am" + * Makefile.in: Regenerate. + +2002-01-29 Daniel Jacobowitz + + * nm.c (print_value): Mark abfd unused. + +2002-01-29 Daniel Jacobowitz + + * unwind-ia64.c (unw_decoder): Change second argument + to unsigned int, to match function prototypes. + +2002-01-29 Daniel Jacobowitz + + * objdump.c: Include "getopt.h" after "bucomm.h" so that + __GNU_LIBRARY__ will be defined. + * size.c: Likewise. + +2002-01-27 Daniel Jacobowitz + + * configure: Regenerated. + +2002-01-26 Hans-Peter Nilsson + + * doc/Makefile.am (install): Depend on install-info. + * doc/Makefile.in: Regenerate. + +2002-01-25 Jason R. Thorpe + + * objcopy.c (strip_usage): Document -d as an alias + --strip-debug. + + * size.c (usage): Document [-t | --totals] options. + (long_options): Add --totals option. + (main): If the [-t | --totals] option is specified and + the output format is Berkeley-style, print the total + text, data, and bss sizes of all objects listed. + (print_berkeley_format): If the [-t | --totals] option + is specified, track the total text, data, and bss + sizes. + * doc/binutils.texi (size): Document [-t | --totals] options. + (strip): Document -d as an alias for --strip-debug. + * NEWS: Mention new feature of size. + +2002-01-25 Nick Clifton + + * po/fr.po: Updated version. + * po/es.po: Updated version. + +2002-01-23 Nick Clifton + + * addr2line.c (usage): Update text to provide verbose + description of the command line options. + * ar.c (usage): Update text to provide verbose + description of the command line options. + (main): Accept -h and -H when running as ranlib. + * coffdump.c (show_usage): Update text to provide verbose + description of the command line options. + * dlltool.c (main): Accept -H as an alias for --help. + * nlmconv.c (show_usage): Update text to provide verbose + description of the command line options. + * nm.c (usage): Replace OPTIONS with option(s). + (main): Accept -H as an alias for --help. + * objcopy.c (strip_main): Accept -H as an alias for --help. + * objdump.c (main): Accept -v as an alias for --verbose. + * readelf.c (usage): Adjust format to match style used in + other binutils. + * size.c (usage): Update text to provide verbose description + of the command line options. + (main): Accept -v, -h and -H as command line options. + * srconv.c (show_usage): Update text to provide verbose + description of the command line options. + * strings.c (main): Accept -H and -v as command line options. + (usage): Update text to provide verbose description of the + command line options. + * sysdump.c (show_usage): Update text to provide verbose + description of the command line options. + * windres.c (usage): Adjust format to match style used in + other binutils. + + * coffdump.c: Fix formatting. + * nlmconv.c: Fix formatting. + * srconv.c: Fix formatting. + * sysdump.c: Fix formatting. + +2002-01-22 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + +2002-01-18 Andreas Jaeger + + * version.c (print_version): Update year. + +2002-01-17 Alan Modra + + * readelf.c (get_machine_name): Handle EM_PPC64. + (guess_is_rela): Here too. + +2002-01-17 Nick Clifton + + * po/binutils.pot: Regenerate. + * po/fr.po: Regenerate. + * po/tr.po: Regenerate. + +2002-01-16 Nick Clifton + + * po/tr.po: Import new version. + +2002-01-16 Alan Modra + + * readelf.c (get_ppc64_dynamic_type): New. + (get_dynamic_type): Call it. + +2002-01-15 Nick Clifton + + * objcopy.c (copy_usage): Use "options" instead of "switches". + (strip_usage): Use "options" instead of "switches". + * doc/binutils.texi (dlltool): Refer to "options" instead of + "switches". + +2002-01-14 Richard Earnshaw + + * MAINTAINERS: Add self as co-maintainer for the ARM code. + +2001-12-18 Nick Clifton + + * po/es.po: Import from translation project. + * configure.in (ALL_LINGUAS): Add es. + * configure: Regenerate. + +2002-01-09 Jason Thorpe + + * readelf.c (get_netbsd_elfcore_note_type): Use + NT_NETBSDCORE_PROCINFO and NT_NETBSDCORE_FIRSTMACH. + +2002-01-09 Jason Thorpe + + * readelf.c: Update copyright years. + (get_note_type): Return a const char *. + (get_netbsd_elfcore_note_type): New function. + (process_note): Use get_netbsd_elfcore_note_type to get + the note type string for NetBSD ELF core files. + +2002-01-06 Steve Ellcey + + * readelf.c (get_ia64_segment_type): Add support for macros. + (get_segment_type): Add support for IA64 specific macros. + +For older changes see ChangeLog-0001 + +Copyright (C) 2002-2003 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2004 b/support/sdbinutils/binutils/ChangeLog-2004 new file mode 100644 index 0000000..d3644ac --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2004 @@ -0,0 +1,799 @@ +2004-12-31 Alan Modra + + * objdump.c (remove_useless_symbols): Discard section symbols. + +2004-12-27 H.J. Lu + + * readelf.c (read_leb128): Support 64bit host. + +2004-12-23 Nick Clifton + + PR binutils/616 + * readelf.c (debug_info): Add 'cu_offset' field. + (get+pointer_size_of_comp_unit): Rename to + 'get_pointer_size_and_offset_of_comp_unit'. Add code to return + the offset of the comp_unit if requested. + (get_debug_info): Record comp_unit offsets as well. + (display_debug_lines): Call get_pointer_size_of_comp_unit. + (decode_location_expression): Add an extra parameter - the offset + of the current comp-unit. Use this when decoding the DW_OP_call2 + and DW_OP_call4 operators. + (display_debug_loc): Call get_pointer_size_of_comp_unit, pass the + comp_unit offset on the decode_location_expression. + (read_and_display_attr_value): Pass the comp_unit offset on the + decode_location_expression. + (display_debug_frames): Pass 0 as the comp_unit offset to + decode_location_expression. + +2004-12-22 Nick Clifton + + * readelf.c (last_pointer_size, warned_about_missing_comp_units): + New variables associated with obtaining the pointer size for a + comp_unit. + (get_pointer_size_of_comp_unit): Add an extra parameter - the name + of the section requesting the pointer size. Use this name in + error messages. If there are not enough comp_units available + produce a warning message, but return the last known pointer size + so that section dumping can continue. + (get_debug_info): Reset the new variables. + (display_debug_lines): Add extra parameter to invocation of + get_pointer_size_of_comp_unit and remove error message when it + returns 0. + (display_debug_loc): Likewise. + +2004-12-15 Jan Beulich + + * doc/binutils.texi: Document --strip-unneeded-symbol and + --strip-unneeded-symbols. + * objcopy.c (strip_unneeded_list): New. + (enum command_line_switch): Add OPTION_STRIP_UNNEEDED_SYMBOL + and OPTION_STRIP_UNNEEDED_SYMBOLS. + (copy_options): Add --strip-unneeded-symbol and + --strip-unneeded-symbols. + (copy_usage): Likewise. + (filter_symbols): Suppress copying of symbol if in strip_unneeded_list + and the symbol is not needed. + (copy_main): Handle OPTION_STRIP_UNNEEDED_SYMBOL and + OPTION_STRIP_UNNEEDED_SYMBOLS. + +2004-12-09 Ian Lance Taylor + + * readelf.c (get_machine_flags): Handle E_MIPS_MACH_9000. + +2004-12-08 Ben Elliston + + * arlex.l: Fix formatting. + +2004-12-08 Ben Elliston + + * doc/Makefile.am (config.texi): Emit a @set UPDATED command to + config.texi whose value is the current month and year. + * doc/Makefile.in: Rebuild. + * doc/binutils.texi: Set the document subtitle to be the value of + the Texinfo UPDATED variable (obtained from config.texi). + +2004-12-07 Ben Elliston + + PR binutils/249 + * doc/binutils.texi (def file format): New node. + (dlltool): Use the tool name as the @chapter name, like all the + other binutils. Use @file{.def} throughout for consistency. + +2004-12-06 Ben Elliston + + * dlltool.c: Comment fix. + +2004-12-06 Ben Elliston + + * doc/binutils.texi: Update copyright years. + +2004-12-03 Richard Sandiford + + * MAINTAINERS: Remove mention of config.if. + +2004-11-30 Tero Niemela + + * Makefile.am: Change LOCALEDIR to $(datadir)/share. + * Makefile.in: Regenerate. + +2004-11-10 Ian Lance Taylor + + PR binutils/536 + * stabs.c (stab_demangle_template): Call stab_demangle_count + rather than stab_demangle_get_count to get the length of a pointer + target. + +2004-11-10 Danny Smith + + * defparse.y: Remove unnecessary commas from token list. + +2004-11-08 Aaron W. LaFramboise + + * doc/binutils.texi (nm): Update description of weak symbols. + +2004-11-03 Nick Clifton + + * readelf.c (do_debug_ranges): New variable. + (usage): Document new switch: -wR or --debug-dump=Ranges. + (parse_args): Handle new switch. Replace switch statement for the + long options with a more compact table structure. + (process_section_headers): Allow the dumping of .debug_ranges + sections if so requested. + (debug_displays): Likewise. + (load_debug_range): New function: Grabs the contents of a + .debug_ranges section. + (free_debug_range): New function: Releases the grabbed + .debug_ranges section. + (decode_64bit_range): New function: Displays a 64-bit range in a + .debug_ranges section. + (decode_range): New function: Displays a 32-bit range in a + .debug_ranges section. + (read_and_display_attr_value): Record the value of DW_AT_low_pc + attributes. Use decode_ranges() to display a DW_AT_ranges + attribute. + (display_debug_info): Use load_debug_range() and + free_debug_range(). + (display_64bit_debug_ranges): New function. Displays the contents + of a 64-bit format .debug_ranges section. + (display_debug_ranges): New function: Displays the contents of a + 32-bit .debug_ranges section. + + (main): Move cmdline_dump_sects and num_cmdline_dump_sects into the + global scope. + (process_object): Initialise the dump_sects array from the + cmdline_dump_sects array before processing each object file. + + (streq, strneq): New macros. Use them to replace occurrences of + strcmp() and strncmp(). + + (debug_information): New structure array to replace + debug_line_pointer_sizes array. + (num_debug_info_entries): New variable to replace + num_debug_line_pointers. + (get_pointer_size_of_comp_unit): New function: Returns the pointer + size of a given compilation unit. + (get_debug_info): New function to replace + get_debug_line_pointer_sizes. + (display_debug_lines): Use the new functions. + (display_debug_loc): Likewise. + + (disassemble_section): Change return type to int. + (display_debug_lines): Move local variables to their + innermost scope. + (display_debug_section): Likewise. Also record the return value + of functions called and pass this back to the parent. Also only + warn about undumped sections when the user explicitly requested + their dumping. + + (debug_apply_rela_addends): Allow relocations against STT_OBJECT + types as well. + + * NEWS: Mention the support for decoding .debug_ranges sections. + * doc/binutils.texi: Document the new command line switch to + readelf. + +2004-11-03 Randolph Chung + + * readelf.c (ia64_unw_aux_info, ia64_unw_table_entry): Rename from + unw_aux_info and unw_table_entry. + (find_symbol_for_address): Pass symtab and strtab info explicitly. + (dump_ia64_unwind): Rename unw_{aux_info,table_entry} with ia64_ + prefix. + (slurp_ia64_unwind_table): Likewise. + (ia64_process_unwind): Rename from old process_unwind. + (hppa_unw_aux_info): New. + (dump_hppa_unwind): New. + (slurp_hppa_unwind_table): New. + (hppa_process_unwind): New. + (process_unwind): Factor out common unwinding checks; dispatch to + unwind handler based on machine type. + +2004-11-02 Nick Clifton + + * readelf.c (display_debug_lines): Fix typo in error message. + +2004-10-26 Mark Mitchell + + * readelf.c (get_note_type): Handle notes not in core files. + (process_note_sections): New function. + (process_corefile_contents): Rename to ... + (process_notes): ... this. + (process_object): Call process_notes, not + process_corefile_contents. + * doc/binutils.texi: Update readelf -n documentation. + +2004-10-26 Jakub Jelinek + + * ar.c (extract_file): Set atime to mtime for ar xo. + +2004-10-25 Ian Lance Taylor + + * stabs.c (stab_demangle_v3_arglist): New static function, broken + out of stab_demangle_v3_argtypes. + (stab_demangle_v3_argtypes): Call it. + (stab_demangle_v3_arg): Handle DEMANGLE_COMPONENT_FUNCTION_TYPE. + If we find an unrecognized component, print out its number. + +2004-10-25 David Mosberger + + * readelf.c (slurp_ia64_unwind_table): Support relocations against + non-section symbols by adding in the symbol value. + +2004-10-25 Nick Clifton + + PR 465 + * readelf.c (dynamic_strings_length): New global variable. + (VALID_DYNAMIC_NAME, GET_DYNAMIC_NAME): New macros for accessing + strings in the dynamic string table. + (process_section_headers): Initialise dynamic_strings_length. + (process_dynamic_section): Likewise. + (process_object): Reset dynamic_string_length when the buffer is freed. + (dynamic_sections_mips_val): Use the new macros. + (process_dynamic_section): Likewise. + (process_version_sections): Likewise. + (process_symbol_table): Likewise. + (process_syminfo): Likewise. + (process_mips_specific): Likewise. + (dump_relocations): Add a new parameter 'strtablen' and use this + to verify that string offset in a given reloc is valid. Print a + suitable error message otherwise. + (process_relocs): Pass the new argument to dump_relocations. + +2004-10-23 Aaron W. LaFramboise + + * dlltool.c: Include . + (PREFIX_ALIAS_BASE): Define. + (struct export): Add member import_name; + (def_exports): Set import_name. + (make_one_lib_file): Remove prefix alias code, use import_name + in .idata$6. + (gen_lib_file): Create and delete aliases. + +2004-10-19 H.J. Lu + + * readelf.c (process_section_groups): Free symtab after use. + +2004-10-18 Tommy Pettersson + Nick Clifton + + * strings.c (usage): Place radix values for -t option into the + correct order. + + * objcopy.c (add_redefine_syms_file): Change error messages to use + :: format for easier parsing by automatic + tools. + + * srconv.c (show_usage): Fix spelling typo. + + * windres.c (format_from_filename): Suggest the use of -J instead + of -I if the file type cannot be determined. + +2004-10-18 Aaron W. LaFramboise + + * strings.c: Include . + +2004-10-18 Alan Modra + + * budemang.c (demangle): Fix thinko. + + * budemang.c (demangle): Handle "@plt" suffix. + +2004-10-14 Nick Clifton + + * nm.c (usage): Fix description of --special-syms switch. + +2004-10-13 Jakub Jelinek + + * strings.c (statbuf): New typedef. + (file_stat): Define. + (strings_object_file): Avoid using get_file_size, instead do the + checks here, using file_stat. + * configure.in (HAVE_STAT64): New test. + * configure: Rebuilt. + * config.in: Rebuilt. + +2004-10-12 Paul Brook + + * readelf.c (decode_ARM_machine_flags): Support EABI version 4. + +2004-10-11 Alan Modra + + * objdump.c (dump_symbols): Fix thinko last change. Improve error + messages. + +2004-10-08 Nick Clifton + + * nm.c: Add a new switch --special-syms which, if enabled, will + include the ARM Mapping symbols in nm's output. + (usage): Mention the switch. + (filter_symbols): Handle the switch. + * objdump.c: Add a similar switch. + (usage): Mention the switch. + (dump_symbols): Handle the switch. + * doc/binutils.texi: Document the new switches. + * NEWS: Mention the new switches. + +2004-10-08 Daniel Jacobowitz + + * readelf.c (get_x86_64_section_type_name): New function. + (get_section_type_name): Use it. + +2004-10-08 Aaron W. LaFramboise + + * dlltool.c (make_one_lib_file): Revert 2004-09-02 and 2004-09-04 + patches. + * doc/binutils.texi (dlltool): Revert 2004-09-06 patch. + +2004-10-07 Alexandre Oliva + + * readelf.c (get_machine_flags): Don't fall through into m68k cpu + types. + +2004-10-01 Paul Brook + + * readelf.c (get_arm_section_type_name): New function. + (get_section_type_name): Use it. + +2004-09-28 Nick Clifton + + * nm.c: Reorder functions to eliminate most of the static function + prototypes. + +2004-09-22 Alan Modra + + * readelf.c (process_program_headers): Don't include .tbss in non-TLS + segments. + +2004-09-17 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + * config.in: Regenerate. + * configure: Regenerate. + * doc/Makefile.in: Regenerate. + * po/binutils.pot: Regenerate. + +2004-09-12 Alan Modra + + * readelf.c (decode_location_expression): Sign extend value for + DW_OP_const1s, DW_OP_const2s, DW_OP_const4s, DW_OP_bra, DW_OP_skip. + +2004-09-09 Nick Clifton + + PR 363 + * ar.c (replace_members): Do not use get_file_size as + ar_emul_append correctly handles missing files. + +2004-09-07 H.J. Lu + + * configure: Regenerated with autconfig 2.13. + +2004-09-06 Danny Smith + + * doc/binutils.texi (dlltool): Update --add-underscore, --kill-at + documentation. + +2004-09-06 Michael Wardle + + * doc/binutils.texi (objdump): Document that the -x switch includes + the effect of the -p switch. + +2004-09-04 Danny Smith + + * dlltool.c (make_one_lib_file): Test if internal_name was + specified by user before using it. + +2004-09-02 Carlo Wood + + PR binutils/351 + * dlltool.c (make_one_lib_file): For IDATA6 take the name from + exp->internal_name if it is present. + +2004-09-02 Alexandre Oliva + + * MAINTAINERS: Add self as co-maintainer of FR-V. + * readelf.c (get_machine_flags): Print FR-V cpu types. + +2004-08-28 Alan Modra + + * nm.c (show_synthetic): New var. + (long_options): Add "synthetic". + (usage): Here too. + (display_rel_file): Handle show_synthetic. + +2004-08-28 Alan Modra + + * objdump.c (dump_bfd): Pass both symbol tables to + bfd_get_synthetic_symtab. + +2004-08-17 Jakub Jelinek + + * objdump.c (dump_bfd): For relocatable objects, pass syms instead + of dynsyms to bfd_get_synthetic_symtab. + +2004-08-16 Alan Modra + + * readelf.c (debug_apply_rela_addends): New function, extracted from.. + (display_debug_info): ..here. + (display_debug_frames): Call debug_apply_rela_addends. Don't do + DW_EH_PE_pcrel adjustment for ET_REL. + +2004-08-06 Andreas Schwab + + * readelf.c (dump_relocations): Fix typo when calculating + sec_index. + +2004-08-02 Jakub Bogusz + + * dllwrap.c (deduce_name): Fix typos introduced when program_name + was renamed to prog_name. + +2004-07-29 Alexandre Oliva + + * readelf.c (get_machine_flags ): Handle EF_SH2A and + EF_SH2A_NOFPU. + +2004-07-28 Alexandre Oliva + + 2003-07-08 Alexandre Oliva + * readelf.c (get_machine_flags + * readelf.c (get_machine_flags ): Print SH ISA name. + +2004-07-21 H.J. Lu + + * objcopy.c (filter_symbols): Use bfd_coff_get_comdat_section + to access comdat. + * objdump.c (dump_section_header): Likewise. + +2004-07-15 Aravinda PR + + * nlmconv.c (main): Pass map_file argument to link_inputs. + (link_inputs): Use map_file argument if it is defined. + +2004-07-13 Nick Clifton + + * dllwrap.c: Replace 'program_name' with 'prog_name' to avoid + conflicts with exported global defined in bucomm.h. + (deduce_name): Rename parameter 'program_name' to 'name' to avoid + shadowing the global defined in bucomm.h. + +2004-07-12 Aaron W. LaFramboise + + * dlltool.c (ext_prefix_alias): New global variable. + (make_one_lib_file): Add aliases with prefixes for external + and import definitions. + (usage): Document -p option. + (long_options): Add --ext-prefix-alias option. + (main): Handle -p. + * doc/binutils.texi: Document new switch. + * NEWS: Mention new switch. + +2004-07-09 Aaron W. LaFramboise + + * binutils/dlltool.c (asm_prefix): Add parameter: name. + No underscore for symbols beginning with ?. + (ASM_PREFIX): Add parameter: NAME. + (gen_exp_file): Use new parameter. + (make_label): Likewise. + (make_imp_label): Likewise. + (make_one_lib_file): Likewise. + +2004-07-07 Tomer Levi + + * MAINTAINERS: Added myself to the list. + * readelf.c: Include "elf/crx.h". + (guess_is_rela): Handle EM_CRX. + (get_machine_name): Likewise. + (dump_relocations): Likewise. + +2004-07-03 Aaron W. LaFramboise + + * doc/binutils.texi (nm): Clarify weak symbol description. + +2004-06-24 Ben Elliston + + * readelf.c (get_segment_type): Display "GNU_STACK", not just + "STACK", when a PT_GNU_STACK segment is encountered. + +2004-06-24 Alan Modra + + * objcopy.c (copy_section): Don't set _cooked_size. + +2004-06-22 Alan Modra + + * readelf.c (Elf32_Word): Delete. + (get_32bit_dynamic_section): Handle SGI ELF dynamic segment. + (get_64bit_dynamic_section): Likewise. + + * readelf.c (get_32bit_dynamic_section): Stop at first DT_NULL entry. + (get_64bit_dynamic_section): Likewise. + + * readelf.c (dynamic_nent): New variable. + (get_32bit_dynamic_section): Set it. + (get_64bit_dynamic_section): Here too. + (process_dynamic_section): Use it instead of dynamic_size. + (process_syminfo): Likewise. + + * readelf.c (get_32bit_dynamic_section): Correct number of entries + translated from external to internal form. + (get_64bit_dynamic_section): Likewise. + +2004-06-18 Jie Zhang + + * readelf.c (process_program_headers): When locating the dynamic + section use the section table if it is present. + (dynamic_segment): Renamed to dynamic_section. + Replace references to dynamic segment with references to dynamic + section, except where appropriate. + (dynamic_segment_mips_val): Rename to dynamic_section_mips_val. + (dynamic_segment_parisc_val): Rename to dynamic_section_parisc_val. + (dynamic_segment_ia64_val): Rename to dynamic_section_ia64_val. + (get_32bit_dynamic_segment): Rename to get_32bit_dynamic_section. + Remove tag counting code as it is no longer needed. + (get_64bit_dynamic_segment): Rename to get_64bit_dynamic_section. + Remove tag counting code as it is no longer needed. + (process_dynamic_segment): Rename to process_dynamic_section. + +2004-06-15 Alan Modra + + * objcopy.c (copy_section): Use bfd_get_section_size instead of + _raw_size or bfd_get_section_size_before_reloc. Don't set reloc_done. + (compare_section_lma): Likewise. + * addr2line.c (find_address_in_section): Likewise. + * coffgrok.c (do_sections_p1): Likewise. + * dlltool.c (scan_drectve_symbols): Likewise. + * nlmconv.c (main): Likewise. + (copy_sections): Likewise. + (powerpc_mangle_relocs): Likewise. + * objdump.c (disassemble_section): Likewise. + * prdbg.c (find_address_in_section): Likewise. + * size.c (berkeley_sum): Likewise. + * srconv.c (wr_ob): Likewise. + * strings.c (strings_a_section): Likewise. + +2004-05-28 Ian Lance Taylor + + * readelf.c (decode_ARM_machine_flags): Add EF_ARM_VFP_FLOAT. + +2004-05-17 David Heine + + * objcopy.c (setup_bfd_headers): New function. + (copy_object): Call setup_bfd_headers. + +2004-05-13 Paul Brook + + * readelf.c (display_debug_frames): Handle dwarf3 format CIE + entries. + +2004-05-13 Nick Clifton + + * po/fr.po: Updated French translation. + +2004-05-11 Jakub Jelinek + + * readelf.c (get_segment_type): Handle PT_GNU_RELRO. + +2004-05-07 H.J. Lu + + * readelf.c (section_groups): New. + (group_count): New. + (section_headers_groups): New. + (process_section_groups): Populate group_count, section_groups + and section_headers_groups. + (process_unwind): Support section group. + (process_object): Always call process_section_groups. Free + section_groups and section_headers_groups. + +2004-04-30 H.J. Lu + + * readelf.c (process_section_headers): Use %3lu on sh_info. + +2004-04-30 Michael Deutschmann + + * ranlib.sh: Quote $1 argument in case it contains spaces. + +2004-04-27 John Paul Wallington + + * objcopy.c (copy_usage, strip_usage): Fix spelling. + +2004-04-26 H.J. Lu + + * readelf.c (do_section_groups): New. + (options): Add --section-groups/-g. + (usage): Mention --section-groups/-g. + (parse_args): Support --section-groups/-g. + (get_group_flags): New. + (process_section_groups): New. + (process_object): Call process_section_groups. + +2004-04-24 Alan Modra + + * objdump.c (disassemble_section): Don't disassemble sections + without SEC_HAS_CONTENTS. + +2004-04-22 Jakub Jelinek + + * objdump.c (synthsyms, synthcount): New variables. + (disassemble_data): Use dynsyms for stripped binaries or libraries. + Add synthetized symbols. + (dump_bfd): For disassemble, initialize dynsyms always and + also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count + before returning. + +2004-04-14 Alan Modra + + * strings.c (print_strings): Cast file_off to unsigned long in + printf arg list. + +2004-04-07 Benjamin Monate + + PR 86 + * arsup.c (ar_save): Use smart_rename. + +2004-04-01 Dean Luick + + * readelf.c (display_debug_pubnames): Align offset and data + columns. + (read_and_display_attr_value): Add missing break; + (debug_displays): Enable the display of the .debug_pubtypes + section. + +2004-03-30 Stan Shebs + + * mpw-config.in, mpw-make.sed, mac-binutils.r: Remove MPW + support files, no longer used. + +2004-03-23 Paul Brook + + * readelf.c (decode_ARM_machine_flags): Add EABI v3. + +2004-03-21 Richard Henderson + + * readelf.c (display_debug_frames): Don't crash for mismatched + DW_CFA_restore_state. + +2004-03-19 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + * aclocal.m4: Regenerate. + * config.in: Regenerate. + * configure: Regenerate. + * po/binutils.pot: Regenerate. + +2004-03-15 Nathan Sidwell + + * objdump.c (struct SFILE): Replace current pointer with pos + offset, rename size to alloc. + (objdump_sprintf): Avoid unnecessary copies in the common case + (disassemble_bytes): Keep sfile live throughout the + function. Adjust usage appropriately. + +2004-03-10 Ben Elliston + + * MAINTAINERS: Update my mail address. + +2004-03-08 Danny Smith + + * deflex.l: Handle "PRIVATE" string. + * defparse.y (%token): Add PRIVATE. + (%type): Add opt_PRIVATE. + (expline): Pass opt_PRIVATE to def_exports. + (opt_PRIVATE): Handle PRIVATE token. + * dlltool.h (def_exports): Add 7th param for private flag to + declaration. + * dlltool.c: Add PRIVATE to comment on EXPORTS syntax. + (struct export): Add 'private' field. + (def_exports): Set 'private' field of struct exports. + (scan_drectve_symbols): Adjust calls to def_exports. + (scan_filtered_symbols): Likewise. + (dump_def_info): Print 'private' field. + (gen_def_file): Likewise. + (gen_lib_file): Skip generation of lib object if private. + Delete tmp object files in same order as they were generated. + Don't delete non-existent private object files. + +2004-02-27 Andreas Schwab + + * ar.c (main): Support POSIX-compatible argument parsing. + +2004-02-23 Daniel Lucq + + * readelf.c (process_mips_specific): Print conflictsno as an + unsigned long. + +2004-02-21 Dmitry Timoshkov + + * dlltool.c (gen_exp_file): Always output names for forwarded symbols. + +2004-02-19 Jakub Jelinek + + * objcopy.c (copy_section): Avoid warnings. + +2004-02-14 Andrew Cagney + + * ar.c (remove_output): Use bfd_cache_close. + * arsup.c (ar_end): Ditto. + +2004-01-21 Roland McGrath + + * readelf.c (get_note_type): Match NT_AUXV. + +2004-01-20 Nick Clifton + + * version.c (print_version): Update copyright year to 2004. + +2004-01-14 Maciej W. Rozycki + + * acinclude.m4: Quote names of macros to be defined by AC_DEFUN + throughout. + * aclocal.m4: Regenerate. + * configure: Regenerate. + +2004-01-12 Jakub Jelinek + + * objcopy.c: Include elf-bfd.h. + (is_strip_section): Don't strip debugging sections if + STRIP_NONDEBUG. + (setup_section): If STRIP_NONDEBUG make SEC_ALLOC sections + ~(SEC_LOAD | SEC_HAS_CONTENTS) and on ELF targets also SHT_NOBITS. + + * objcopy.c (copy_section): Free relpp if relcount == 0. + +2004-01-12 Ian Lance Taylor + + * stabs.c (parse_stab_argtypes): Handle g++ ABI version 3 names. + (stab_demangle_argtypes): Likewise. + (stab_demangle_v3_argtypes): New static function. + (stab_demangle_v3_arg): New static function. + +2004-01-12 Nick Clifton + + * objcopy.c (copy_object): Make the function boolean, returning + FALSE upon failure. + (copy_archive): Handle the return value from copy_object. + (copy_file): Likewise. + +2004-01-07 Nick Clifton + + * readelf.c (find_section): New function. Locates a named + section. + (get_debug_line_pointer_sizes): New function: Initialises the + debug_line_pointer_sizes array. + (display_debug_lines): Call get_debug_line_pointer_sizes. + (display_debug_loc): Likewise. + (load_debug_loc): Use find_section. + (load_debug_str): Likewise. + (display_debug_info): Likewise. + (prescan_debug_info): Delete. + (debug_displays): Remove prescan field. + (process_section_contents): Do not perform prescans. + +2004-01-03 Alan Modra + + * objcopy.c (filter_bytes): Delete. Move code to.. + (copy_section): ..here. Simplify size adjustment. Divide + section lma by interleave. + +2004-01-02 Nick Clifton + + * po/ru.po: New file: Russian translation. + * configure.in (ALL_LINGUAS): Add ru + * configure: Regenerate. + +For older changes see ChangeLog-0203 + +Copyright (C) 2004 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2005 b/support/sdbinutils/binutils/ChangeLog-2005 new file mode 100644 index 0000000..416013e --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2005 @@ -0,0 +1,1356 @@ +2005-12-30 Jie Zhang + + * readelf.c (get_machine_name): Add case for Blackfin. + +2005-12-27 Alan Modra + + * Makefile.am: Run "make dep-am". + (Makefile): Remove dependency. + * Makefile.in: Regenerate. + +2005-12-26 Jan-Benedict Glaw + + * MAINTAINERS: Add myself as VAX maintainer. + +2005-12-22 Randolph Chung + + * rddbg.c (read_section_stabs_debugging_info): Add $GDB_SYMBOLS$ + entry to names[] array for SOM binaries. + +2005-12-21 H.J. Lu + + * MAINTAINERS: Add myself as x86_64 maintainer. + +2005-12-16 Nathan Sidwell + + Second part of ms1 to mt renaming. + * readelf.c (guess_is_rela): Use EM_MT. + (dump_relocations, get_machine_name): Adjust. + +2005-12-12 Nathan Sidwell + + * Makefile.am: Replace ms1 files with mt files. + * Makefile.in: Rebuilt. + * readelf.c (elf/mt.h): Adjust #include. + +2005-11-30 Nick Clifton + + * configure.in (ALL_LINGUAS): Add fi. + * configure: Regenerate. + * po/fi.po: New file: Finnish translation. + +2005-11-21 Arnold Metselaar + + * MAINTAINERS: add myself as Z80 maintainer + +2005-11-17 Andrew Haley + + * cxxfilt.c (main): Flush output at newline. + +2005-11-16 Mark Mitchell + + * doc/binutils.texi: Include config.texi and @file documentation + for manual pages. + +2005-11-15 Jan Beulich + + * objcopy.c (keep_file_symbols): New. + (enum command_line_switch): Add OPTION_KEEP_FILE_SYMBOLS. + (strip_options): Add --keep-file-symbols. + (copy_options): Likewise. + (copy_usage): Likewise. + (strip_usage): Likewise. + (filter_symbols): Act upon keep_file_symbols. + (strip_main): Handle OPTION_KEEP_FILE_SYMBOLS. + (copy_main): Likewise. + * doc/binutils.texi: Document --keep-file-symbols for objcopy + and strip. + +2005-11-14 Daniel Jacobowitz + + * readelf.c (struct dump_list_entry, request_dump_byname) + (initialise_dumps_byname): New. + (parse_args): Call request_dump_byname. + (process_section_contents): Call initialise_dumps_byname. + * doc/binutils.texi (readelf): Mention -x NAME. + * NEWS: Likewise. + +2005-11-11 Nick Clifton + + PR 1150 + * readelf.c (get_mips_symbol_other): New function. + (get_symbol_other): New function. + (process_symbol_table): Call get_symbol_other() to get a + description of the st_other field if it contains more information + than just the visibility. + +2005-11-07 Steve Ellcey + + * configure: Regenerate after modifying bfd/warning.m4. + +2005-10-30 H.J. Lu + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerated. + + * dep-in.sed: Replace " ./" with " ". + +2005-10-25 Alan Modra + + * po/POTFILES.in: Regenerate. + * po/binutils.pot: Regenerate. + +2005-10-24 Bernd Schmidt + + * MAINTAINERS: Add self as BFIN maintainer. + +2005-10-18 Jie Zhang + + * MAINTAINERS: Add self as BFIN maintainer. + +2005-10-11 Danny Smith + + * rclex.l (handle quotes): Stop parsing hex notation escaped + chars after the first two digits, + +2005-10-11 Nick Clifton + + PR binutils/1437 + * cxxfilt.c (flags): Remove DMGL_TYPES; + (long_options): Rename --no-types to --types. + (usage): Likewise. + (demangle_it): Add a comment describing why _ and $ prefixes are + skipped. Use printf rather than puts to emit the demangled output + in order to avoid emitting a new line character. + (main): Have the -t flag enable type demangling. + Emit a newline after every demangled command line argument. + Copy whitespace from stdin to stdout. + * doc/binutils.texi (c++filt): Document the change to the -t + switch. + Document why demangling names on the command line is slightly + different to demangling names read from the standard input. + +2005-10-10 Mark Mitchell + + * doc/Makefile.am (config.texi): Set top_srcdir. + * doc/Makefile.in: Regenerated. + * doc/binutils.texi: Use at-file.texi from libiberty. + +2005-10-10 H.J. Lu + + PR binutils/1436 + * readelf.c (ABSADDR): New. + (dump_ia64_unwind): Use ABSADDR to get the unwind info address. + +2005-10-10 Thomas Weidenmueller + + * resbin.c (res_to_bin_accelerator): Place the terminating NUL at + the correct location in the bindata structure. + +2005-10-10 Bryce Schober + + * doc/binutils.texi (objdump): Fix typo: -reg-name-std should be + -reg-names-std. + +2005-10-04 Nick Clifton + + * cxxfilt.c: Treat mangled names specified on the command line in + the same way as mangled names read from stdin. + Add -i switch to disable the display of implementation details. + Add -t switch to disable the demangling of types. + * NEWS: Mention the new switches. + * doc/binutils.texi (cxxfilt): Document the -i and -t switches. + +2005-10-03 Mark Mitchell + + * addr2line.c (usage): Document @file. + * ar.c (usage): Likewise. + * coffdump (usage): Likewise. + * cxxfilt.c (usage): Likewise. + * dlltool.c (usage): Likewise. + * dllwrap.c (usage): Likewise. + * nlmconv.c (usage): Likewise. + * nm.c (usage): Likewise. + * objcopy.c (usage): Likewise. + * objdump.c (usage): Likewise. + * readelf.c (usage): Likewise. + * size.c (usage): Likeise. + * srconv.c (usage): Likewise. + * strings.c (usage): Likewise. + * windres.c (usage): Likewise. + * doc/binutils.texi: Add section on common options. + +2005-10-03 H.J. Lu + + * NEWS: Mention -W/--dwarf. + + * doc/binutils.texi: Document -W/--dwarf for objdump. + +2005-10-01 Paul Brook + + * readelf.c (arm_attr_tag_CPU_arch, arm_attr_tag_ARM_ISA_use, + arm_attr_tag_THUMB_ISA_use, arm_attr_tag_VFP_arch, + arm_attr_tag_WMMX_arch, arm_attr_tag_NEON_arch, + arm_attr_tag_ABI_PCS_config, arm_attr_tag_ABI_PCS_R9_use, + arm_attr_tag_ABI_PCS_RW_data, arm_attr_tag_ABI_PCS_RO_DATA, + arm_attr_tag_ABI_PCS_GOT_use, arm_attr_tag_ABI_PCS_wchar_t, + arm_attr_tag_ABI_FP_rounding, arm_attr_tag_ABI_FP_denormal, + arm_attr_tag_ABI_FP_exceptions, arm_attr_tag_ABI_FP_user_exceptions, + arm_attr_tag_ABI_FP_number_model, arm_attr_tag_ABI_align8_needed, + arm_attr_tag_ABI_align8_preserved, arm_attr_tag_ABI_enum_size, + arm_attr_tag_ABI_HardFP_use, arm_attr_tag_ABI_VFP_args, + arm_attr_tag_ABI_WMMX_args, arm_attr_tag_ABI_optimization_goals, + arm_attr_tag_ABI_FP_optimization_goals, arm_attr_public_tags): New. + (display_arm_attribute, process_arm_specific): New functions. + (process_arch_specific): Add EM_ARM. + +2005-09-30 Mark Mitchell + + * dlltool.c (main): Fix typo. + * windres.c (main): Likewise. + +2005-09-30 H.J. Lu + + * Makefile.in: Regenerated. + +2005-09-30 H.J. Lu + + * sysinfo.y (main): Undo last change. + +2005-08-30 Mark Mitchell + + * addr2line.c (main): Use expandargv. + * ar.c (main): Likewise. + * coffdump.c (main): Likewise. + * cxxfilt.c (main): Likewise. + * dlltool.c (main): Likewise. + * dllwrap.c (main): Likewise. + * nlmconv.c (main): Likewise. + * nm.c (main): Likewise. + * objcopy.c (main): Likewise. + * objdump.c (main): Likewise. + * readelf.c (main): Likewise. + * size.c (main): Likeiwse. + * srcconv.c (main): Likewise. + * strings.c (main): Likewise. + * sysdump.c (main): Likewise. + * sysinfo.y (main): Likewise. + * windres.c (main): Likewise. + +2005-09-30 H.J. Lu + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerated. + * aclocal.m4: Likewise. + +2005-09-30 Catherine Moore + + * Makefile.am: Bfin support. + * Makefile.in: Regenerated. + * aclocal.m4: Regenerated. + * readelf.c (elf/bfin.h): Include. + (guess_is_rela): EM_BLACKFIN support. + (dump_relocations): Likewise. + +2005-09-30 H.J. Lu + + * dwarf.c (fetch_indirect_string): Adjust for section address. + (process_debug_info): Likewise. + (display_debug_loc): Likewise. + (display_debug_ranges): Likewise. + + * objdump.c (mach_o_dwarf_sections): New. + (generic_dwarf_sections): Likewise. + (check_mach_o_dwarf): Likewise. + (dump_dwarf): Call check_mach_o_dwarf. + +2005-09-30 H.J. Lu + + * Makefile.am (objdump_SOURCES): Add dwarf.c. + * Makefile.in: Regenerated. + + * objdump.c: Include "dwarf.h". + (usage): Add -W/--dwarf. + (long_options): Likewise. + (dump_dwarf_section_info): New. + (load_debug_section): Likewise. + (free_debug_section): Likewise. + (dump_dwarf_section): Likewise. + (dump_dwarf): Likewise. + (dump_bfd): Load symbol table and call dump_dwarf if + dump_dwarf_section_info isn't zero. + (main): Handle -W/--dwarf. + +2005-09-30 H.J. Lu + + * readelf.c: Reordered. + (is_relocatable): New. + (dwarf_section): New structure for DWARF section. + (load_debug_section): New. + (free_debug_section): Likewise. + (debug_str_section): Likewise. + (debug_abbrev_section): Likewise. + (debug_str_contents): Removed. + (debug_str_size): Likewise. + (debug_loc_contents): Likewise. + (debug_loc_size): Likewise. + (debug_range_contents): Likewise. + (debug_range_size): Likewise. + (load_debug_str): Likewise. + (free_debug_str): Likewise. + (load_debug_loc): Likewise. + (free_debug_loc): Likewise. + (load_debug_arange): Likewise. + (free_debug_arange): Likewise. + (load_debug_abbrev): Likewise. + (free_debug_abbrev): Likewise. + (fetch_indirect_string): Updated. + (debug_apply_rela_addends): Likewise. + (process_debug_info): Likewise. + (get_debug_info): Likewise. + (display_debug_lines): Likewise. + (display_debug_pubnames): Likewise. + (display_debug_macinfo): Likewise. + (display_debug_abbrev): Likewise. + (display_debug_loc): Likewise. + (display_debug_str): Likewise. + (display_debug_info): Likewise. + (display_debug_aranges): Likewise. + (display_debug_ranges): Likewise. + (display_debug_frames): Likewise. + (display_debug_not_supported): Likewise. + (debug_displays): Likewise. + (display_debug_section): Likewise. + (get_file_header): Set is_relocatable. + +2005-09-30 H.J. Lu + + * readelf.c (debug_apply_rela_addends): Relocate the whole + section. + (process_debug_info): Don't call debug_apply_rela_addends. + (display_debug_frames): Likewise. + (get_debug_info): Call debug_apply_rela_addends. + (debug_displays): Add the "relocate" field. + (display_debug_section): Call debug_apply_rela_addends if + needed. + +2005-09-30 Matthias Kurz + + * bucomm.h: Prevent the inclusion of from the Solaris + version of when ENABLE_NLS is not defined. + +2005-09-26 Mark Mitchell + + * BRANCHES: Mention binutils-csl-gxxpro-3_4-branch. + +2005-09-20 Richard Henderson + + * readelf.c (display_debug_lines): Use unsigned long for address + increments. Use 0x prefix for all hex numbers. + +2005-09-09 Richard Earnshaw + + * readelf.c (get_arm_section_type_name): Add SHT_ARM_PREEMPTMAP and + SHT_ARM_ATTRIBUTES. + +2005-09-07 H.J. Lu + + * readelf.c (get_elf_section_flags): Handle 64bit sh_flags. + +2005-09-02 H.J. Lu + + * readelf.c (debug_abbrev_contents): New. + (debug_abbrev_size): Likewise. + (load_debug_abbrev): Likewise. + (free_debug_abbrev): Likewise. + (process_debug_info): Use them. + +2005-08-17 H.J. Lu + + PR binutils/1179 + * objdump.c (disassemble_bytes): Don't adjust + adjust_section_vma. + (adjust_addresses): Don't adjust vma for debugging section. + Adjust lma only for relocatable files. + (dump_bfd): Tell adjust_addresses if it is a relocatable file. + +2005-08-16 H.J. Lu + + * bucomm.h (stpcpy): Declare if HAVE_DECL_STPCPY isn't defined. + + * configure.in (AC_GNU_SOURCE): Added. + (AC_CHECK_DECLS): Add stpcpy. + * configure: Regenerated. + * config.in: Likewise. + +2005-08-16 Jakub Jelinek + + * unwind-ia64.c (UNW_DEC_SPILL_SPREL, UNW_DEC_SPILL_PSPREL, + UNW_DEC_RESTORE, UNW_DEC_SPILL_REG): Increase {,ab,t}regname + buffer sizes. + +2005-08-15 Daniel Jacobowitz + + * doc/binutils.texi (objdump): Document -M e300. + +2005-08-14 John David Anglin + + * readelf.c (slurp_hppa_unwind_table): Fix entry size on hppa64-hpux. + Don't access table entries past the end of the table. + +2005-08-13 John David Anglin + + * readelf.c (get_parisc_segment_type): Handle PT_PARISC_WEAKORDER. + (get_parisc_section_type_name): Handle SHT_PARISC_DLKM. + +2005-08-11 H.J. Lu + + * NEWS: Mention "-t/--section-details" and + "-N/--full-section-name". + + * doc/binutils.texi: Document "-t/--section-details". Remove + "-N/--full-section-name". + + * readelf.c (do_full_section_name): Renamed to ... + (do_section_details): This. + (option): Rename "-N/--full-section-name" to + "-t/--section-details". + (usage): Likewise. + (parse_args): Likewise. + (get_elf_section_flags): Support do_section_details. + (process_section_headers): Updated for do_section_details. + +2005-08-04 John David Anglin + + * readelf.c (get_parisc_dynamic_type): Add new dynamic types. + (get_dynamic_type): Use old values for DT_LOOS and DT_HIOS when + e_machine is EM_PARISC. + (get_parisc_segment_type): Add new segment types. + (get_parisc_section_type_name): Add new section names. + (dynamic_section_parisc_val): Add new table entries. + +2005-08-01 Filip Navara + + * dlltool.c (alphafunc): Remove and replace usage with nfunc. + (nfunc): Fix sorting of fastcall symbols when --kill-at is used. + +2005-07-25 H.J. Lu + + * readelf.c (dump_relocations): Handle SHN_X86_64_LCOMMON. + (get_symbol_index_type): Likewise. + (get_elf_section_flags): Handle SHF_X86_64_LARGE. + +2005-07-21 Eric Christopher + + * MAINTAINERS: Change affiliation. + +2005-07-19 Ben Elliston + + * readelf.c (read_and_display_attr_value): Remove comment adjacent + to DW_ATE_decimal_float about it being a GNU extension. + +2005-07-18 Nick Clifton + + * binemul.c: Fix name of Red Hat. + * binemul.h: Likewise. + * emul_aix.c: Likewise. + * emul_vanilla: Likewise. + +2005-07-18 Ben Elliston + + * readelf.c (read_and_display_attr_value): Handle a DW_AT_encoding + value of DW_ATE_decimal_float instead of DW_ATE_GNU_decimal_float. + +2005-07-16 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + +2005-07-15 Eric Christopher + + * MAINTAINERS: Change affiliation. + +2005-07-14 Jim Blandy + + * readelf.c: #include "elf/m32c.h" + (guess_is_rela, dump_relocations, get_machine_name): Add cases for + EM_M32C. + * Makefile.am (readelf.o): Update dependencies. + * Makefile.in: Regenerated. + +2005-07-08 Ben Elliston + + * bucomm.h: Include unconditionally, not only when + ANSI_PROTOTYPES is defined. Remove #ifdef logic. + * dlltool.c: Likewise. + * dllwrap.c: Likewise. + +2005-07-07 Kaveh R. Ghazi + + * bucomm.h (report): Add format attribute. + * dlltool.c (inform): Likewise. + * dllwrap.c (display, inform, warn): Likewise. + * objdump.c (objdump_sprintf): Likewise. + * readelf.c (error, warn): Likewise. Fix format bugs. + +2005-07-05 Dmitry V. Levin + Nick Clifton + + * strings.c (filename_and_size_t): New typedef. + (strings_a_section): Skip sections with size greater or equal to + the file size. Cache the file size to avoid repeated stat()s. + (strings_object_file): Pass filename_and_size_t argument to + strings_a_section() via bfd_map_over_sections(). + +2005-07-04 Alan Modra + + PR 1004 + * objcopy.c (copy_object): Use bfd_make_section_with_flags. + (write_debugging_info): Likewise. + (setup_section): Use bfd_make_section_anyway_with_flags. + +2005-07-01 Steve Ellcey + + * configure.in (AM_BINUTILS_WARNINGS): Add. + (BFD_NEED_DECLARATION): Replace with AC_CHECK_DECLS. + * configure: Regenerate. + * config.in: Regenerate. + * objdump.c (NEED_DECLARATION_*): Replace with !HAVE_DECL_*. + * bucomm.h: (NEED_DECLARATION_*): Ditto. + +2005-06-30 Ben Elliston + + * Makefile.am (check-DEJAGNU): Don't search for expect. + * Makefile.in: Regenerate. + +2005-06-30 Ben Elliston + + * Makefile.am (EXPECT): Set to expect. + (RUNTEST): Likewise, set to runtest. + * Makefile.in: Regenerate. + +2005-06-17 Jakub Jelinek + + * readelf.c (CHECK_ENTSIZE_VALUES, CHECK_ENTSIZE): Define. + (process_section_headers): Use it. + (process_relocs): Don't crash if symsec is not SHT_SYMTAB + or SHT_DYNSYM. + (process_version_sections): Use sizeof (Elf_External_Versym) + instead of sh_entsize. + +2005-06-16 Nick Clifton + + * rename.c (simple_copy): Only define if it is going to be used. + (smart_rename): Mark the preserve_dates parameter as possibly + being unused. + + * resres.c (write_res_data): Prevent a potential compile time + warning by casting the return value from fwrite. + +2005-06-14 H.J. Lu + + PR 995 + * ar.c (BUFSIZE): Moved to ... + * bucomm.h (BUFSIZE): Here. + + * bucomm.c: Include . + (bfd_get_archive_filename): New. + * bucomm.h (bfd_get_archive_filename): New. + + * objcopy.c (copy_unknown_object): New. + (copy_object): Use bfd_get_archive_filename when reporting input + error. Don't call fatal on unknown arch. + (copy_archive): Call copy_unknown_object on unknown format or + arch. + +2005-06-14 Jakub Jelinek + + * readelf.c (cmalloc, xcmalloc, xcrealloc): New functions. + (get_data): Add nmemb argument. Return NULL if nmemb * size + overflows. If var == NULL, allocate one extra byte and + clear it. + (slurp_rela_relocs, slurp_rel_relocs, get_32bit_program_headers, + get_64bit_program_headers, get_program_headers, + get_32bit_section_headers, get_64bit_section_headers, + get_32bit_elf_symbols, get_64bit_elf_symbols, process_section_headers, + process_section_groups, process_relocs, slurp_ia64_unwind_table, + ia64_process_unwind, slurp_hppa_unwind_table, hppa_process_unwind, + get_32bit_dynamic_section, get_64bit_dynamic_section, + process_dynamic_section, process_version_sections, get_dynamic_data, + process_symbol_table, dump_section, load_debug_str, load_debug_loc, + load_debug_range, read_and_display_attr_value, process_debug_info, + get_debug_info, frame_need_space, display_debug_frames, + display_debug_section, process_mips_specific, process_gnu_liblist, + process_corefile_note_segment): Adjust get_data callers. Use + cmalloc, xcmalloc and xcrealloc instead of {m,xm,xre}alloc where + passed size is a product of 2 numbers. + + * readelf.c (print_mode): Fix comment typo. + (slurp_rela_relocs, slurp_rel_relocs): Fix memory leaks. + (dump_relocations): Fix a thinko in check for invalid st_name. + (process_program_headers): Don't crash if string_table is NULL. + (process_section_headers): Don't crash if e_shstrndx is invalid. + Ensure string_table_length is 0 if string_table == NULL. + Don't return just because string_table is NULL. + (process_section_groups): Don't crash if symtab's sh_link or + symbol's st_name is invalid. Fix a memory leak. Fix check for + invalid section number entry. + (process_relocs): Don't crash if relocation or symbol section's + sh_link is invalid. + (slurp_ia64_unwind_table, slurp_hppa_unwind_table): Don't crash if + relocation section's sh_info is invalid. + (ia64_process_unwind, hppa_process_unwind): Don't crash if symbol + table's sh_link is invalid. + (process_version_sections): Don't crash on version or symbol + section's sh_link is invalid. Don't crash if symbol's st_shndx + is invalid. + (process_symbol_table): Don't crash if string table is corrupt + or symbol's st_name, st_shndx, vna_name or vda_name is invalid. + (debug_apply_rela_addends): Don't crash if relocation section's + sh_info or sh_link is invalid. + (display_debug_loc): Warn for unterminated .debug_loc section + or start offsets not within .debug_loc section boundaries. + (process_gnu_liblist): Don't crash if liblist section's sh_link + or entry's l_name is invalid. + +2005-06-09 Jakub Jelinek + + * objdump.c (disassemble_bytes): Don't crash if q->howto == NULL. + If q->howto->name == NULL, print q->howto->type as number instead. + (dump_reloc_set): Likewise. + +2005-06-07 Eric Christopher + + * readelf.c (guess_is_rela): Support ms1. + (dump_relocations): Ditto. + (get_machine_name): Ditto. + +2005-06-07 Aldy Hernandez + Michael Snyder + Stan Cox + + * Makefile.am (readelf.o): Depend on ms1.h. + + * Makefile.in: Regenerate. + + * readelf.c: Include ms1.h. + +2005-06-06 H.J. Lu + + PR 990 + * nm.c (print_symbol): Call bfd_find_line before + bfd_find_nearest_line. + +2005-06-06 Alan Modra + + * NEWS: Mention new powerpc ld support. + +2005-06-03 Steve Ellcey + + * configure.in: Check for getc_unlocked prototype. + * configure: Regenerate. + * config.in: Regenerate. + * strings.c (get_char): Only call getc_unlocked if we have seen a + prototype. + +2005-06-03 Nick Clifton + + * configure.in (ALL_LINGUAS): Add zh_TW + * configure: Regenerate. + * po/zh_TW.po: New Chinese (traditional) translation. + +2005-05-31 Richard Henderson + + * readelf.c (dump_relocations): Special case R_ALPHA_LITUSE. + +2005-05-29 Richard Henderson + + * readelf.c (get_alpha_dynamic_type): New. + (get_dynamic_type): Call it. + +2005-05-24 H.J. Lu + + * readelf.c (process_section_groups): Report group section + index. Check if the section member index is valid. + +2005-05-23 Fred Fish + + * addr2line.c (unwind_inlines): New flag for 'i' option. + (usage): Document '-i' option. + (long_options): Recognize '--inlines'. + (translate_addresses): Loop, calling bfd_find_inliner_info as + necessary and printing multiple output lines. + (main): Handle 'i' option. + * doc/binutils.texi (addr2line): Document '-i' option. + * NEWS: Mention new addr2line '-i' option. + +2005-05-23 Nick Clifton + + * readelf.c (fetch_indirect_string): Display a warning message + when a corrupt DW_FORM_strp value is encountered. + + (process_debug_info): Mention that the compilation unit offset is + being displayed in hexadecimal. + + (display_debug_lines): Fix typo in name of .debug_line section. + +2005-05-19 Zack Weinberg + + * Makefile.am: Have 'all' depend on 'info'. + * Makefile.in: Regenerate. + +2005-05-19 Ben Elliston + + * readelf.c (read_and_display_attr_value): Handle a DW_AT_encoding + value of DW_ATE_GNU_decimal_float. + +2005-05-17 Daniel Jacobowitz + + * doc/Makefile.am (config.texi): Don't use $<. + * doc/Makefile.in: Regenerated. + +2005-05-15 Yitzchak Scott-Thoennes + + * deflex.l: Ignore CRs + +2005-05-15 Daniel Jacobowitz + + * acinclude.m4: Remove obsolete code. + * configure.in: Update AC_PREREQ. + * doc/Makefile.am (binutils_TEXINFOS): Define. + (config.texi): Depend on distributed files instead of built + files. + (binutils.dvi, binutils.info): Remove unnecessary rules. + (DISTCLEANFILES): Remove. + (install-data-local): Renamed from install. + (info-local): Renamed from info. + * Makefile.in, aclocal.m4, config.in, configure, + doc/Makefile.in: Regenerated. + +2005-05-14 Alan Modra + + * readelf.c (get_ppc_dynamic_type): Display DT_PPC_GOT, not + DT_PPC_GLINK. + +2005-05-13 Fred Fish + + * readelf.c: Fix a couple of obvious comment typos, + 'debug_str' -> 'debug_ranges' and proecess' -> 'process'. + +2005-05-13 H.J. Lu + + * readelf.c (dump_ia64_unwind): Get stamp with proper size. + +2005-05-12 Nick Clifton + + * readelf.c (display_debug_lines): If pointer_size has not been + found then assume that it is 4 in order to prevent a seg fault + when process_extend_line_op attempts to read the line data. + +2005-05-11 Alan Modra + + * readelf.c (get_ppc_dynamic_type): New function for DT_PPC_GLINK. + (get_dynamic_type): Call the above. + +2005-05-07 Nick Clifton + + * Update the address and phone number of the FSF organization in + the GPL notices in the following files: + aclocal.m4, addr2line.c, ar.c, arlex.l, arparse.y, arsup.c, + arsup.h, binemul.c, binemul.h, bucomm.c, bucomm.h, budbg.h, + budemang.c, budemang.h, coffdump.c, coffgrok.c, coffgrok.h, + cxxfilt.c, debug.c, debug.h, deflex.l, defparse.y, dlltool.c, + dlltool.h, dllwrap.c, emul_aix.c, emul_vanilla.c, filemode.c, + ieee.c, nlmconv.c, nlmconv.h, nlmheader.y, nm.c, objcopy.c, + objdump.c, prdbg.c, rclex.l, rcparse.y, rdcoff.c, rddbg.c, + readelf.c, rename.c, resbin.c, rescoff.c, resrc.c, resres.c, + size.c, srconv.c, stabs.c, strings.c, sysdump.c, sysinfo.y, + syslex.l, unwind-ia64.c, unwind-ia64.h, version.c, windres.c, + windres.h, winduni.c, winduni.h wrstabs.c, doc/fdl.texi + +2005-05-06 Jan Beulich + + * objcopy.c (copy_file): Don't delete output upon error here. + (copy_main): Delete output upon error. + +2005-05-02 Ben Elliston + + * dlltool.c (dtab): Remove empty function. + (process_duplicates): Remove calls to dtab(). + +2005-05-01 Maciej W. Rozycki + + * doc/binutils.texi (strip, objcopy): Clarify the description of + the "--strip-debug" option. Fix a typo. + +2005-04-29 H.J. Lu + + * bucomm.c: Undo the last change. + * bucomm.h: Likewise. + +2005-04-29 Ben Elliston + + * syslex.l (word, number, unit): Remove unused variables. + * nlmheader.y (keyword_tokens): Make static. + * coffdump.c (dump_coff_symbol, coff_dump): Make static. + * coffgrok.c (lofile, last_function_symbol, last_function_type, + last_struct, last_enum, cur_sfile): Make variables static. + * sysdump.c (getCHARS, fillup, getBARRAY, getINT, getBITS, + sysroff_swap_tr_in, sysroff_print_tr_out): Make static. + * sysinfo.y (writecode, it, code, repeat, oldrepeat, name, rdepth, + names, pnames): Likewise. + +2005-04-29 Ben Elliston + + * ar.c (mri_mode): Make static. + * arsup.c (obfd, real_name, outfile): Likewise. + * binemul.c (ar_emul_create): Remove unused function. + (ar_emul_default_create): Likewise. + * binemul.h (ar_emul_create): Remove declaration. + (ar_emul_default_create): Likewise. + (struct bin_emulation_xfer_struct): Remove ar_create member. + * bucomm.c (report): Make static. + * bucomm.h (report): Remove declaration. + * cxxfilt.c (mbuffer): Make static. + (main): Use unsigned ints for some loop control variables. + * readelf.c: Make many global variables static. + * size.c (berkeley_format): Make static. + (long_options): Likewise. + * emul_aix.c (bin_aix_emulation): Remove ar_emul_default_create + structure initialiser. + (bin_aix5_emulation): Likewise. + * emul_vanilla.c (bin_vanilla_emulation): Likewise. + +2005-04-27 Ben Elliston + + * syslex.l: Adjust top-of-file comment: this file is part of GNU + binutils, not GNU ld. + +2005-04-25 Nick Clifton + + PR872 + * objcopy.c (copy_archive): Initialise 'obfd' field of new + name_list structure. + + * objcopy.c (copy_usage): Fix description of -K switch. + + * doc/binutils.texi (strip, objcopy): Fix description of -K + switch. + +2005-04-20 Daniel Jacobowitz + + * readelf.c (display_debug_frames): Use data factor for + DW_CFA_def_cfa_sf and DW_CFA_def_cfa_offset_sf. + +2005-04-19 H.J. Lu + + * objdump.c (dump_section_header): Skip linker created section. + +2005-04-17 H.J. Lu + + * objdump.c (dump_section_header): Support SEC_GROUP. + +2005-04-16 Nick Clifton + + * readelf.c (debug_apply_rela_addends): Remove redundant %s from + printf string. + +2005-04-15 Nick Clifton + + * objcopy.c (copy_file): Issue an error message when attmepting to + copy an empty input file. + +2005-04-14 Alan Modra + + * Makefile.am (NO_WERROR): Define. Use instead of -Wno-error. + * configure.in: Include ../bfd/warning.m4 contents. + * Makefile.in: Regenerate. + * configure: Regenerate. + * doc/Makefile.in: Regenerate. + +2005-04-12 Alan Modra + + * Makefile.am: Run "make dep-am". + (syslex.o, sysinfo.o, arparse.o, arlex.o): Add -Wno-error to command. + (sysroff.o, defparse.o, deflex.o): Likewise. + (nlmheader.o, rcparse.o, rclex.o): Likewise. + * Makefile.in: Regenerate. + * aclocal.m4: Regenerate. + * config.in: Regenerate. + * configure: Regenerate. + +2005-04-11 Jan Beulich + + * MAINTAINERS: Add myself as ix86 Intel mode maintainer. + +2005-04-06 Nick Clifton + H.J. Lu + + * po/rw.po: New translation: Kinyarwanda. + * configure.in (ALL_LINGUAS): Add rw. + * configure: Regenerate. + +2005-04-04 Maciej W. Rozycki + + * readelf.c (debug_apply_rela_addends): Reorder r_info as + necessary for 64-bit MIPS. + +2005-04-04 Maciej W. Rozycki + + * doc/binutils.texi (readelf): Remove a duplicate paragraph. + +2005-04-04 Ramana Radhakrishnan + + PR binutils/813 + * objdump.c (dump_symbols): Add a check to see if the section for + the symbol is chosen using process_section_p. + +2005-04-01 H.J. Lu + + * NEWS: Mention new readelf options, "-N/--full-section-name" + and "-g/--section-groups". + + * doc/binutils.texi: Document new readelf options, + "-N/--full-section-name" and "-g/--section-groups". + +2005-03-31 H.J. Lu + + * readelf.c (do_full_section_name): New. + (options): Add "--full-section-name"/'N'. + (usage): Add -N/--full-section-name. + (parse_args): Handle 'N'. + (process_section_headers): Print out the full section name if + do_full_section_name isn't 0. + +2005-03-31 Nick Clifton + + * configure.in: Add a check for providing a prototype + for getopt() which is compatible with the one in + include/getopt.h. If so then define HAVE_DECL_GETOPT. + * configure: Regenerate. + * config.in (HAVE_DECL_GETOPT): Add. + * aclocal.m4: Regenerate. + * addr2line.c: Include "config.h" before "bfd.h" so that + HAVE_DECL_GETOPT is defined before getopt.h is included. + +2005-03-21 Jan-Benedict Glaw + + * doc/binutils.texi: Document new VAX disassembler-specific option + -M entry:0xfooba8. + * NEWS: Mention the new option. + +2005-03-29 Anil Paranjpe + + * MAINTAINERS: Add myself as H8300 maintainer. + +2005-03-28 Aaron W. LaFramboise + + * objdump.c (disassemble_bytes): Remove cast. + +2005-03-25 Daniel Jacobowitz + + * BRANCHES: Add binutils-csl-arm-2005q1-branch and + binutils-2_16-branch. + +2005-03-25 Mark Kettenis + + * MAINTAINERS: Add myself as M88k maintainer. + +2005-03-24 Danny Smith + + * winduni.c (unicode_from_ascii): Don't declare variables + 's' and 'w' if _WIN32. Use MultiByteToWideChar to set the unicode + string len. + +2005-03-24 Dmitry Diky + + * MAINTAINERS: Add myself as MSP430 maintainer. + +2005-03-23 Nick Clifton + + * po/fr.po: Updated translation. + +2005-03-22 Nick Clifton + + * MAINTAINERS: Add Daniel Jacobwitz to the blanket write + privileges list. + +2005-03-17 Paul Brook + Dan Jacobowitz + Mark Mitchell + + * binutils/readelf.c (get_arm_segment_type): New function. + (get_segment_type): Use it. + +2005-03-18 Paul Brook + + * objdump.c (objdump_print_addr): Avoid uninitialized warning. + +2005-03-17 Diego Novillo + + * MAINTAINERS: Remove self as maintainer of x86 intel + mode. + +2005-03-16 Nick Clifton + Ben Elliston + + * configure.in (werror): New switch: Add -Werror to the + compiler command line. Enabled by default. Disable via + --disable-werror. + * configure: Regenerate. + +2005-03-15 Daniel Marques + Nick Clifton + + * objcopy.c (globalize_specific_list): New linked list of symbols + to convert from local binding into global binding. + (command_line_switch): Add OPTION_GLOBALIZE_SYMBOL and + OPTION_GLOBALIZE_SYMBOLS. + (copy_options): Add "globalize-symbol" and "globalize-symbols". + (copy_usage): Document the new switches. + (filter_symbols): Convert defined local symbols mentioned on the + globalize_specific_list into global symbols. + (copy_object): Perform actions if the globalize_specific_list is + not empty. + (copy_main): Handle new switches. + * NEWS: Mention new feature. + * doc/binutils.texi: Document new switches. + +2005-03-15 Alan Modra + + * po/es.po: Commit new Spanish translation. + + * po/fr.po: Commit new French translation. + +2005-03-14 Alan Modra + + * po/tr.po: Commit new Turkish translation. + +2005-03-11 Nick Clifton + + * po/fr.po: Updated French translation. + +2005-03-10 Nick Clifton + + * configure.in (ALL_LINGUAS): Add Romanian lingua "ro". + * configure: Regenerate. + * po/ro.po: New file. + + * po/ru.po: Updated file. + +2005-03-05 Alan Modra + + * po/binutils.pot: Regenerate. + +2005-03-02 Jan Beulich + + * ar.c (remove_output): Use unlink_if_ordinary instead of unlink. + * objcopy.c (copy_file): Likewise. + (strip_main): Likewise. + +2005-03-01 Stig Petter Olsroed + Nick Clifton + + * objdump.c: Fix coding for DISASSEMBLER_NEEDS_RELOC: + (struct objdump_disasm_info): Add 'reloc' field. + (disassemble_bytes): Fix check for when an insn has a reloc + associated with it. Improve comment explaining why the use of + octets is wrong. Set the 'reloc' field in objdump_disasm_info + structure. + (objdump_print_addr): Use new 'reloc' field to lookup the correct + address for the symbol associated with the current instruction's + relocation. + (disassemble_info): Initialise 'reloc' field. + +2005-02-28 Jakub Jelinek + + * readelf.c (get_file_type, get_machine_name, get_osabi_name, + get_segment_type, get_section_type_name, get_elf_class, + get_data_encoding, get_group_flags, dynamic_section_mips_val, + get_symbol_binding, get_symbol_type, get_TAG_name, get_FORM_name, + get_AT_name, process_mips_specific, process_gnu_liblist, + get_note_type, get_netbsd_elfcore_note_type): Use snprintf instead of + sprintf where needed. + (get_dynamic_type): Likewise. Increase buff to 64 bytes. + (get_elf_section_flags): Increase buff to 33 bytes. Avoid + using strcat. + (get_dynamic_flags): Renamed to... + (print_dynamic_flags): ... this. Print the flags to stdout instead + of returning them as string. + (process_dynamic_section): Adjust caller. + +2005-02-25 H.J. Lu + + * readelf.c (display_debug_ranges): Print out offset for end of + list. + +2005-02-23 Alan Modra + + * dlltool.c: Warning fixes. + * objdump.c: Likewise. + +2005-02-22 Alan Modra + + * Makefile.am (syslex.o, sysinfo.o): Pass AM_CFLAGS to compiler. + (syslex.o, sysinfo.o, dlltool.o, rescoff.o): Remove duplicate + dependencies. Run "make dep-am". + * nlmconv.c: Warning fixes. + * readelf.c: Likewise. + * srconv.c: Likewise. + * sysdump.c: Likewise. + * sysinfo.y: Likewise. + * syslex.l: Likewise. Use yyleng instead of strlen, memcpy instead + of strcpy. + * Makefile.in: Regenerate. + +2005-02-21 H.J. Lu + + * objcopy.c (parse_flags): Replace SEC_SHARED with + SEC_COFF_SHARED. + + * objdump.c (dump_section_header): Dump SEC_TIC54X_BLOCK and + SEC_TIC54X_CLINK for TI c54x only. Remove SEC_ARCH_BIT_0. Dump + SEC_COFF_SHARED for COFF only. + +2005-02-21 Alan Modra + + * Makefile.am: Run "make dep-am" + * Makefile.in: Regenerate. + * doc/Makefile.in: Regenerate. + +2005-02-21 Alan Modra + + * readelf.c (BYTE_GET8): Delete. Replace uses with BYTE_GET. + (byte_get_little_endian): Don't handle size of -8. + (byte_get_signed, byte_get_big_endian): Likewise. + (print_dec_vma, print_hex_vma): New functions. + (print_vma): Use them. Return chars output. + (get_dynamic_data): Return a bfd_vma array. Add ent_size parm. + (process_symbol_table): Handle alpha and s390 .hash. + +2005-02-18 H.J. Lu + + * readelf.c (display_debug_loc): Print out offset for end of + list. + +2005-02-18 Joseph S. Myers + + * Makefile.am (TOOL_PROGS): Add objdump. + * Makefile.in: Regenerate. + +2005-02-17 Alan Modra + + * deflex.l (YY_NO_UNPUT): Define. + * rclex.l (YY_NO_UNPUT): Define. + * rcparse.y (null_unichar): New static var. + (res_null_text): Use it rather than attempting to init from wchar_t. + * windres.c: Include assert.h and time.h before getopt.h. + Include config.h and unistd.h too. + +2005-02-15 Nick Clifton + + * nlmconv.c: Provide a full prototype for the localtime() function + in order to avoid a compile time warning. + +2005-02-11 H.J. Lu + + * readelf.c (group_count): Don't initialize it. + (process_section_groups): Reurn 1 if we won't do unwind nor + section groups. Set group_count to 0 before counting group + sections and return 1 if there are no group sections. Reread + SHT_SYMTAB/SHT_STRTAB sections only when needed. Don't skip + section 0. + (process_object): Only set do_unwind to 0 if + process_section_groups return 0. + +2005-02-10 Ian Lance Taylor + + * MAINTAINERS: Update my e-mail address. + +2005-02-10 Mark Mitchell + + * MAINTAINERS: Add Paul Brook and Mark Mitchell as ARM (Symbian) + maintainers. + +2005-02-07 Inderpreet Singh + + * MAINTAINERS: Add self as maintainer of MAXQ. + +2005-01-31 Richard Sandiford + + * readelf.c (eh_addr_size): New variable. + (find_section): Move earlier in file. Return empty sections too. + (process_program_headers): Use find_section to find .dynamic. + (process_section_headers): Initialize eh_addr_size. + (dump_ia64_unwind, slurp_ia64_unwind_table, ia64_process_unwind) + (dump_hppa_unwind, slurp_hppa_unwind_table, hppa_process_unwind) + (display_debug_frames): Use it instead of local addr_size variable. + (size_of_encoded_value): Get pointer size from eh_addr_size rather + than is_32bit_elf. + +2005-01-31 Andrew Cagney + + * configure: Regenerate to track ../gettext.m4. + +2005-01-31 Nick Clifton + + * version.c (print_version): Bump the copyright date to 2005. + +2005-01-25 Alan Modra + + * nm.c (display_rel_file): Read dynamic syms before calling + bfd_get_synthetic_symtab. + +2005-01-21 Ben Elliston + + * dlltool.c (dump_iat): Remove unused function. + (gen_exp_file): Remove #if 0'd code. + (make_one_lib_file): Likewise. + * srconv.c: Remove #if 0'd code throughout. + * size.c (lprint_number): Remove. + (print_berkeley_format): Remove #if 0'd code. + * ar.c (do_quick_append): Remove declaration and definiton. + (main): Remove #if 0'd code. + * filemode.c (filemodestring): Remove #if 0'd function. + * sysdump.c (unit_info_list): Remove function. + (object_body_list): Likewise. + (program_structure): Likewise. + (debug_list): Likewise. + (module): Remove #if 0'd code. + +2005-01-20 Mark Mitchell + + * BRANCHES: Add binutils-2_15-branch. + + * MAINTAINERS: Document branch policy. + * BRANCHES: New file. + +2005-01-19 Fred Fish + + * NEWS: Make note of the new MIPS disassembly option "no-aliases". + * doc/binutils.texi (objdump): Document the "no-aliases" + disassembly option. + +2005-01-17 Eugene Kotlyarov + + PR binutils/647 + * rcparse.y (RCDATA): Allow a filename to be supplied as the + parameter. Parse it with define_rcdata_file(). + * resrc.c (define_rcdata_file): New function. + * windres.h: Provide a prototype for the new function. + + * resrc.c (define_user_file): Fix typo by replacing "font file" + with "file". + +2005-01-16 Jason Thorpe + + * MAINTAINERS: Update my email address. + +2005-01-16 Danny Smith + + * dlltool.c (set_dll_name_from_def): New function. Strip name + to basename, with warning. + (def_name): Use it. + (def_library): Likwise. + (main): Strip arg of --dllname to basename, with warning. + Only use basename of exp_name when inferring dll_name. + +2005-01-11 Nick Clifton + + PR binutils/637 + * doc/binutils.texi (c++filt): Use uppercase CXXFILT in the + footnote in order to prevent the sed script in the Makefile from + converting it into c++filt. + +2005-01-10 H.J. Lu + + BZ 635 + readelf.c (saved_base_address): Removed. + (decode_64bit_range): Likewise. + (decode_range): Likewise. + (display_64bit_debug_ranges): Likewise. + (debug_info): Add range_lists, num_range_lists and + max_range_lists. + (read_and_display_attr_value): Handle do_debug_ranges. + (process_debug_info): Likewise. + (display_debug_ranges): Rewrite. + (process_object): Free range_lists. + +2005-01-10 Andreas Schwab + + * configure.in: Don't define SKIP_ZEROES. + * configure: Regenerate. + * objdump.c (disassemble_data): Set skip_zeroes and + skip_zeroes_at_end in disasm_info to defaults. + (DEFAULT_SKIP_ZEROES): Rename from SKIP_ZEROES and always define. + (DEFAULT_SKIP_ZEROES_AT_END): Rename from SKIP_ZEROES_AT_END and + always define. + (disassemble_bytes): Use skip_zeroes and skip_zeroes_at_end from + objdump_disasm_info. + +2005-01-05 H.J. Lu + + * readelf.c (display_debug_loc): Display base address + specifiers. Always output . + +2005-01-05 H.J. Lu + + * readelf.c (have_frame_base): New. + (need_base_address): Likewise. + (saved_base_address): Likewise. + (decode_location_expression): Return 1 if DW_AT_frame_base is + needed. + (debug_info): Add base_address and a have_frame_base pointer. + (read_and_display_attr_value): Replace saved_DW_AT_low_pc with + saved_base_address. Record base address. Set have_frame_base. + Record if a location list has DW_AT_frame_base. Display if a + location expression has no DW_AT_frame_base but needs one. Set + saved_base_address only if needed. + (process_debug_info): Clear have_frame_base, saved_base_address + and set need_base_address. + (display_debug_loc): Display if a location expression has no + DW_AT_frame_base but needs one. Display if start >= end. Don't + adjust for section address. Properly handle base address. + (process_object): Free the have_frame_base pointer in + debug_info. + +2005-01-04 H.J. Lu + + * readelf.c (display_debug_loc): Display offsets for hole and + overlap. + (display_debug_str): Add a newline at the end. + +2005-01-04 Armin Diehl + + PR binutils/630 + * nlmconv.c (main): Only store the basename of the output filename + in the module table. + +2005-01-04 H.J. Lu + + BZ 615 + * readelf.c (process_debug_info): New. + (debug_info): Add num_loc_offsets, loc_offsets and + last_loc_offset_p. + (get_debug_info): Use process_debug_info. + (display_debug_loc): Properly handle location list. Warn if bad + location lists are encoutnered. + (read_and_process_attr_value): New. + (read_and_display_attr_value): Use "%lx" for DW_FORM_data4. + (display_debug_info): Use process_debug_info. + (process_object): Also free loc_offsets in debug_information. + +For older changes see ChangeLog-2004 + +Copyright (C) 2005 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2006 b/support/sdbinutils/binutils/ChangeLog-2006 new file mode 100644 index 0000000..8286b4a --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2006 @@ -0,0 +1,605 @@ +2006-12-25 Kazu Hirata + + * readelf.c (get_machine_flags): Handle EF_M68K_CPU32_FIDO_A. + +2006-12-11 J"orn Rennecke + + MAINTAINERS (SH): Remove my entry. + +2006-12-11 Daniel Jacobowitz + + * configure.in: Define GENINSRC_NEVER. + * doc/Makefile.am (MAINTAINERCLEANFILES): Add info file. + (DISTCLEANFILES): Pretend to add info file. + * po/Make-in (.po.gmo): Put gmo files in objdir. + * configure, Makefile.in, doc/Makefile.in: Regenerated. + +2006-12-07 Kazu Hirata + + * readelf.c: Update uses of EF_M68K_*. + +2006-10-30 Paul Brook + + * objdump.c (disassemble_section): Set info->symtab_pos. + (disassemble_data): Set info->symtab and info->symtab_size. + +2006-10-29 H.J. Lu + + PR binutils/3384 + * configure.in (AC_CHECK_HEADERS): Add limits.h and sys/param.h. + * configure: Regenerated. + * config.in: Likewise. + + * readelf.c: Include and for PATH_MAX. + (program_interpreter): Allocate PATH_MAX bytes instead of 64. + (process_program_headers): Don't assume that program interpreter + is shorter than 64 characters. + +2006-10-25 Trevor Smigiel + Yukishige Shibata + Nobuhisa Fujinami + Takeaki Fukuoka + Alan Modra + + * readelf.c: Add SPU support. + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + +2006-10-13 Robert Connolly + + PR binutils/2876 + * configure.in: Check for the mkstemp and mkdtemp functions. + * configure: Regenerate. + * config.in (HAVE_MKDTEMP): New potential define. + (MAKE_MKSTEMP): Likewise. + * bucomm.c (make_tempname): Use mkstemp if it is available. + (make_tempdir): New function: Create a temporary directory using + mkdtemp, if it is available. + * bucomm.h (make_tempdir): New prototype. + * objcopy.c (copy_archive): Use make_tempdir if it is available. + (strip_main): Produce an warning message if a temporary file could + not be created. + (copy_main): Likewise. + * ar.c (write_archive): Likewise. + +2006-10-10 Andreas Schwab + + * dwarf.c (display_debug_loc): Don't dereference loc_offsets when + there are no location lists. + (display_debug_ranges): Similar for range_lists. + +2006-10-04 H.J. Lu + + * readelf.c (debug_apply_rela_addends): Don't ignore relocation + against symbols without type. + +2006-09-25 Pedro Alves + + * nlmconv.c (main) : Use LITMEMCPY. + * prdbg.c (tg_class_static_member) : Use LITSTRCPY. + +2006-09-26 H.J. Lu + + PR binutils/3257 + * strings.c (main): Handle "-T format". + +2006-09-26 Nick Clifton + + * MAINTAINERS: Add Mei Ligang as maintainer of the Score port. + +2006-09-26 Thiemo Seufer + + * configure.in: Remove broken changequote lines. + +2006-09-20 Kai Tietz + + * configure.in: Add new target x86_64-pc-mingw64. + * configure: Regenerate. + * dlltool.c: Adjust include for this target. + (DLLTOOL_MX86_64): Added macro to handle target specific code. + (mname): Added default target static as "i386:x86-64". + (MX86): Added macro for target ident. + (mtable): Added target specific definitions. + (rvaafter): Add handling of MX86. + (rvabefore): Add handling of MX86. + (asmprefix): Add handling of MX86. + +2006-09-17 Mei Ligang + + * readelf.c: Add support for Score binaries. + * Makefile.am: Update readelf's dependencies. + * Makefile.in: Regenerate. + +2006-09-16 Nick Clifton + Pedro Alves + + * ar.c: Make use of new STRING_COMMA_LEN and CONST_STRNEQ + macros defined in bfd.h. + * dlltool.c: Likewise. + * emul_aix.c: Likewise. + * nlmconv.c: Likewise. + * objdump.c: Likewise. + * prdbg.c: Likewise. + * stabs.c: Likewise. + * readelf.c (const_strneq): New macro. + (process_section_headers, slurp_ia64_unwind_table, + slurp_hppa_unwind_table, display_debug_section, process_notes, + process_archive): Use the new macro. + +2006-09-14 H.J. Lu + + PR binutils/3181 + * objcopy.c (group_signature): Return proper group signature. + +2006-09-14 Alan Modra + + PR 3181 + * objcopy.c (group_signature): New function, split out from.. + (setup_section): ..here. + (is_strip_section): Return true for SHT_GROUP sections that are + going to lose their group signature symbol. + +2006-09-14 Alan Modra + + PR 3181 + * objcopy.c (copy_object): Load symbols earlier. + (setup_section): Mark group signature symbols with BSF_KEEP. + +2006-09-09 Nick Clifton + + PR binutils/3110 + * objcopy.c (copy_archive): Add new parameter: + force_output_target. If not true, then perserve the file formats + of each copied archive element, otherwise force them to be one + specific file format. + (copy_file): Compute force_output_target parameter to pass to + copy_archive. + +2006-09-05 Nick Clifton + + PR binutils/3166 + * objcopy.c (is_strip_section): Do not treat group sections as + debugging sections. + * doc/binutils.texi (--only-keep-debug): Document that this switch + is only intended for use on fully linked files. + +2006-09-01 Nick Clifton + + PR binutils/3146 + * readelf.c (dump_relocations): Check for a NULL value in rtype + before using it. + +2006-08-21 Pedro Alves + + * configure.in: Split arm-pe and arm-wince-pe. Build dlltool + with -DDLLTOOL_ARM_WINCE for Windows CE case. + * configure: Regenerate. + * dlltool.c: Add support for arm-wince. + +2006-08-15 Nick Clifton + + PR binutils/3039 + * wrstabs.c (stab_tag_type): Initialize 'size'. + +2006-08-10 J"orn Rennecke + + PR binutils/3017 + * doc/Makefile.am: Use single quotes inside backquotes for + date command while generating config.texi. + * doc/Makefile.in: Regenerate. + +2006-08-08 Nick Clifton + + PR binutils/2768 + * dwarf.c (display_debug_aranges): When the address size is + greater than 4 display addresses and lengths as 16 hex digits, + otherwise use 8 hex digits. + +2006-08-06 Nick Clifton + + PR binutils/3001 + * addr2line.c (process_file): Change function from void to + returning an int. Return 0 upon success, 1 otherwise. + (main): Use return value from process_file as the exit value. + * ar.c (ranlib_only): Change function from void to returning an + int. Return 0 upon success, 1 otherwise. + (ranlib_touch): Likewise. + (main): Use return value from ranlib functions as exit value. + * objcopy.c (add_specific_symbol): Set status to 1 if get_file_size + fails. + (copy_file): Likewise. + (strip_main): Likewise. + (copy_main): Likewise. + * objdump.c (display_file): Set exit_status to 1 if get_file_size + fails. + * size.c (display_file): Set return_code to 1 if get_file_size + fails. + +2006-08-02 Thiemo Seufer + Nigel Stephens + + * readelf.c (dump_relocations): Handle MIPS-specific + SHN_MIPS_SCOMMON and SHN_MIPS_SUNDEFINED. + (get_symbol_index_type): Similarly. + +2006-07-24 Ralk Wildenhues + + * doc/binutils.texinfo: Fix spelling mistakes. + +2006-07-10 Jakub Jelinek + + * readelf.c (get_dynamic_type): Handle DT_GNU_HASH. + (get_section_type_name): Handle SHT_GNU_HASH. + (dynamic_info_DT_GNU_HASH): New variable. + (process_dynamic_section): Handle DT_GNU_HASH. + (process_symbol_table): Print also DT_GNU_HASH histogram. + +2006-07-06 Mohammed Adnène Trojette + + PR binutils/2879 + * doc/binutils.texi (Strings): Document -T shorthand for --target + switch. + * strings.c: Update comment to include -T option. + + PR binutils/2875 + * doc/binutils.texi (readelf): Fix spelling typo. + +2006-06-30 Nick Clifton + + * dwarf.c (display_debug_frames): Catch a corrupt length field + generating an end of block address that is beyond the end of the + section. + When encountering a corrupt CIE pointer do not reset the start + pointer as more data still has to be read. + Do not warn about user defined call frame instructions. + +2006-06-29 DJ Delorie + + * readelf.c (process_section_headers): Add H8/300 support. + +2006-06-23 Richard Sandiford + + * objcopy.c (localize_hidden): New variable. + (OPTION_LOCALIZE_HIDDEN): New command_line_switch value. + (copy_options): Add --localize-hidden. + (copy_usage): Mention --localize-hidden. + (is_hidden_symbol): New function. + (filter_symbols): Handle localize_hidden. + (copy_object): Call filter_symbols if localize_hidden. + (copy_main): Handle OPTION_LOCALIZE_HIDDEN. + * doc/binutils.texi (--localize-hidden): Document new option. + +2006-06-23 Daniel Jacobowitz + + * Makefile.am (ar_DEPENDENCIES, ranlib_DEPENDENCIES) + (dlltool_DEPENDENCIES, windres_DEPENDENCIES): Remove @LEXLIB@. + * Makefile.in: Regenerate. + +2006-06-23 Alan Modra + + * Makefile.am (*_DEPENDENCIES): Add missing dependencies. + * Makefile.in: Regenerate. + +2006-06-07 Joseph S. Myers + + * po/Make-in (pdf, ps): New dummy targets. + +2006-06-05 Daniel Jacobowitz + + * po/Make-in (top_builddir): Define. + +2006-06-05 Alan Modra + + * config.in: Regenerate. + +2006-06-02 Joseph S. Myers + + * doc/Makefile.am (TEXI2DVI): Define. + * doc/Makefile.in: Regenerate. + +2006-05-31 Daniel Jacobowitz + + * Makefile.am: Replace INTLLIBS with LIBINTL everywhere. Add + DEPENDENCIES variables for every program. + (INTLLIBS): Remove. + (INCLUDES): Use @INCINTL@. + * acinclude.m4: Include new gettext macros. + * configure.in: Use ZW_GNU_GETTEXT_SISTER_DIR and AM_PO_SUBDIRS. + Remove local code for po/Makefile. + * Makefile.in, configure, doc/Makefile.in: Regenerated. + +2006-05-30 Nick Clifton + + * po/es.po: Updated Spanish translation. + +2006-05-25 J"orn Rennecke + + * MAINTAINERS: Update my email address. + +2006-05-24 Nick Clifton + + * po/fr.po: Updated French translation. + +2006-05-23 Nick Clifton + + * po/vi.po: Updated Vietnamese translation. + +2006-05-22 Daniel Jacobowitz + + * po/ru.po: Updated translation. + +2006-05-19 Andreas Schwab + + * doc/Makefile.am (addr2line.1): Depend on $(binutils_TEXINFOS). + (ar.1): Likewise. + (dlltool.1): Likewise. + (nlmconv.1): Likewise. + (nm.1): Likewise. + (objcopy.1): Likewise. + (objdump.1): Likewise. + (ranlib.1): Likewise. + (readelf.1): Likewise. + (size.1): Likewise. + (strings.1): Likewise. + (strip.1): Likewise. + (windres.1): Likewise. + (cxxfilt.man): Likewise. + * doc/Makefile.in: Regenerated. + +2006-05-17 Carlos O'Donell + + * doc/binutils.texi: Use "Binutils Index" for index name. + +2006-05-15 H.J. Lu + + * dwarf.c (display_debug_frames): Don't return on ZERO + terminator. + +2006-05-02 Daniel Jacobowitz + + * doc/Makefile.am (AM_MAKEINFOFLAGS): New. + (TEXI2POD): Use AM_MAKEINFOFLAGS. + (config.texi): Don't set top_srcdir. + * doc/binutils.texi: Don't use top_srcdir. + * aclocal.m4, Makefile.in, doc/Makefile.in: Regenerated. + +2006-04-26 Julian Brown + + * readelf.c (arm_attr_tag_VFP_arch): Add VFPv3. + +2006-04-19 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + +2006-04-19 Alan Modra + + * configure: Regenerate. + +2006-04-18 Nick Clifton + + PR 2257 + * readelf.c (SECTION_NAME): Cope with a missing string table. + (process_file_header): Cope with a corrupt e_shstrndx field. + (process_section_headers): Correctly handle an e_shstrndx value of + SHF_UNDEF. + +2006-04-12 Nick Clifton + + * objdump.c (objdump_symbol_at_address): Fix typo in comment. + +2006-04-10 Ben Elliston + + * MAINTAINERS (CGEN Maintainers): Remove myself. + +2006-04-06 Carlos O'Donell + + * po/Make-in: Add install-html target. + * Makefile.am: Add install-html and install-html-recursive targets. + * Makefile.in: Regenerate. + * configure.in: AC_SUBST datarootdir, docdir and htmldir. + * configure: Regenerate. + * doc/Makefile.am: Add install-html and install-html-am targets. + * doc/Makefile.in: Regenerate. + +2006-04-05 Eric Botcazou + + * addr2line.c (long_options): Add new option 'section'. + (usage): Document new -j/--section option. + (find_offset_in_section): New function. + (translate_addresses): Add 'section' parameter. + If it is non-null, call find_offset_in_section on it. + (process_file): Add 'section_name' parameter. + If it is non-null, look for the section in the BFD object. + Pass the section to translate_addresses. + (main): Handle new -j option. + Pass the section name to process_file. + * doc/binutils.texi (addr2line): Document new -j/--section option. + +2006-03-29 Ben Elliston + + * resbin.c: Avoid duplicating constants in calls to reswr_alloc. + +2006-03-20 Nathan Sidwell + + * BRANCHES: Remove binutils-csl-arm-2006q1-branch. Document + binutils-csl-2_17-branch instead. + +2006-03-20 Paul Brook + + * BRANCHES: Mention binutils-csl-arm-2006q1-branch. + +2006-03-16 Alan Modra + + PR 2434 + * ieee.c (write_ieee_debugging_info): Adjust bfd_hash_table_init calls. + * wrstabs.c (write_stabs_in_sections_debugging_info): Likewise. + +2006-03-13 Ben Elliston + + * bucomm.c (display_target_list): Make local variable `a' to be of + type enum bfd_architecture. Thus no need to cast enums to int. + (display_info_table): Likewise. + +2006-03-10 Paul Brook + + * readelf.c (decode_ARM_machine_flags): Handle EABIv5. + +2006-03-10 Alan Modra + + * dwarf.c (process_extended_line_op): Remove pointer_size param. + Use length instead to determine address size. + (get_pointer_size_and_offset_of_comp_unit): Delete. + (display_debug_lines): Adjust for above. + (display_debug_aranges): Don't stop on finding two zeros. + (display_debug_frames): For warning, print offset not pointer. + +2006-03-09 Danny Smith + + * dlltool.c: Update copyright year. + * doc/binutils.texi: Likewise. + +2006-03-09 Danny Smith + + * dlltool.c (add_stdcall_underscore): New flag. + (xlate): Also add underscore to stdcall symbol if + add_stdcall_underscore set. + (usage): Document --add-stdcall-underscore option. + (OPTION_ADD_STDCALL_UNDERSCORE): New define. + (long_options): Use it for --add-stdcall-underscore option. + (main): Handle it. + * doc/binutils.texi: Document --add-stdcall-underscore option + and differentiate from --add-underscore. + +2006-03-06 Nathan Sidwell + + * readelf.c (get_machine_flags): Adjust. + +2006-03-03 Jakub Jelinek + + * dwarf.c (frame_display_row, display_debug_frames): Handle + DW_CFA_val_offset, DW_CFA_val_offset_sf and DW_CFA_val_expression. + +2006-02-28 Nick Clifton + + * objcopy.c (use_alt_mach_code): Change type to unsigned long. + (copy_object): If bfd_alt_mach_code fails emit a more helpful + message and if the target architecture is ELF use the alternative + as replacement value for the e_machine number. + (copy_main): Use strtoul to parse the number provided with the + --alt-mach-code switch. + * doc/binutils.texi (--alt-mach-code): Document that this switch + can now set the absolute e_machine value. + +2006-02-27 Carlos O'Donell + + * po/Make-in: Add html target. + +2006-02-17 Nick Hudson + + * readelf.c (get_machine_flags): Add logic for missing EF_SH flags. + +2006-02-14 Jakub Jelinek + + * config.in: Rebuilt. + +2006-02-10 H.J. Lu + + PR binutils/2258 + * readelf.c (process_program_headers): Use + ELF_IS_SECTION_IN_SEGMENT_MEMORY. + +2006-02-09 Eric Botcazou + + * configure.in (CHECK_DECLS): Add snprintf and vsnprintf. + * configure: Regenerate. + * objdump.c (fprintf): Remove declaration. + * bucomm.h (fprintf): Declare if not already declared. + (snprintf): Likewise. + (vsnprintf): Likewise. + +2006-02-08 H.J. Lu + + * readelf.c (process_program_headers): Match PT_TLS segment + only with SHT_TLS sections. + +2006-02-07 Nathan Sidwell + + * readelf.c (get_machine_flags): Add logic for EF_M68K flags. + +2006-02-02 H.J. Lu + + * readelf.c (process_program_headers): Undo the last change. + +2006-02-02 H.J. Lu + + * readelf.c (process_program_headers): Undo the change made on + 2004-09-22. Match PT_DYNAMIC segment only with SHT_DYNAMIC + sections. + +2006-01-30 Nick Clifton + + * objcopy.c (copy_object): Catch the case where an attempt is made + to add a section that already exists and produce a more helpful + warning message. + +2006-01-26 Nick Clifton + + * po/vi.po: New Vietnamese translation. + * configure.in (ALL_LINGUAS): Add vi. + * configure: Regenerate. + +2006-01-18 Alexandre Oliva + + Introduce TLS descriptors for i386 and x86_64. + * readelf.c (get_dynamic_type): Handle DT_TLSDESC_GOT and + DT_TLSDESC_PLT. + +2006-01-18 Nick Clifton + + PR binutils/1391 + * objcopy.c (copy_object): For PE format targets set the VMA of a + newly created gnu_debuglink section to a non-zero, aligned, + contiguous value. + * Makefile.am (objcopy.c): Add a dependency upon libbfd.h. + * Makefile.in: Regenerate. + +2006-01-17 Andreas Schwab + + PR binutils/1486 + * configure.in: Don't define DISASSEMBLER_NEEDS_RELOCS. + * configure: Regenerate. + * objdump.c (struct objdump_disasm_info): Don't check for + DISASSEMBLER_NEEDS_RELOCS. + (objdump_print_addr): Likewise. + (disassemble_bytes): Check disassembler_needs_relocs from + disassemble_info at run-time instead of DISASSEMBLER_NEEDS_RELOCS + at compile-time. + (disassemble_section): Likewise. + (disassemble_data): Initialize it. + +2006-01-11 Alan Modra + + * objcopy.c (copy_object): Fix thinko. + + * objcopy.c (copy_object): Set isympp and osympp to NULL after free. + +2006-01-09 Mike Frysinger : + + * readelf.c (guess_is_rela): Add case for Nios/Nios II. + (get_machine_name): Likewise. + +For older changes see ChangeLog-2005 + +Copyright (C) 2006 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2007 b/support/sdbinutils/binutils/ChangeLog-2007 new file mode 100644 index 0000000..3e77793 --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2007 @@ -0,0 +1,1171 @@ +2007-12-24 Nick Clifton + + * po/ru.po: Updated Russian translation. + +2007-12-22 H.J. Lu + + * doc/binutils.texi: Document the new intel-mnemonic and + intel-mnemonic options for i386 disassembler. + +2007-12-07 Bob Wilson + + * readelf.c (is_32bit_pcrel_reloc): Add Xtensa. + +2007-12-04 Alan Modra + + * readelf.c (is_32bit_abs_reloc, is_32bit_pcrel_reloc): Add SPU. + +2007-11-29 Mark Shinwell + + * readelf.c (get_machine_flags): Handle Loongson-2E and -2F + flags. + +2007-11-26 Alan Modra + + * cxxfilt.c (demangle_it): Don't call printf without format string. + +2007-11-21 Hans-Peter Nilsson + + * dwarf.c (display_debug_loc): Cast section_end - start to long + for output format. + +2007-11-20 Nick Clifton + + * dwarf.c (display_debug_loc): Issue a warning if there are bytes + at the end of the .debug_loc section which are not referenced by + any attribute in the .debug_info section. + +2007-11-19 Nick Clifton + + * readelf.c (is_32bit_abs_reloc): Add support for NIOS relocs. + (is_64bit_abs_reloc): Add support for HPPA relocs. + (is_16bit_abs_reloc): Add support for NIOS relocs. + +2007-11-17 Thiemo Seufer + + * readelf.c (display_mips_gnu_attribute): Recognize -mips32r2 -mfp64 + objects. + +2007-11-16 Nick Clifton + + * dwarf.c (process_extended_line_op): Add cases for HP extensions + to the line ops. Mention if an unknown op code is in the user + defined range. + (decode_location_expression): Add cases for HP extensions, the + DW_OP_GNU_uninit extension and the DW_OP_call_frame_cfa and + DW_OP_bit_piece DWARF3 operators. + (read_and_display_attr): Correct list of attributes which can + reference a location list. + (read_and_display_attr_value): Add cases for DWARF3 values and HP + extensions. + Correct list of attributes which can reference a location list. + (get_AT_name): Add cases for DWARF3 values and HP and PGI + extensions. + +2007-11-07 Karl Berry + + * doc/binutils.texi: Update to FDL 1.2. + (Top): consistent punctuation in menu entries. + (Index): Rename from Binutils Index. + * doc/fdl.texi: Update from http://www.gnu.org/licenses/fdl.texi. + +2007-10-31 Nick Clifton + + * dwarf.c (is_relocatable): Remove definition. + (display_debug_frames): Remove check in is_relocatable. + * dwarf.h (is_relocatable): Remove declaration. + * objdump.c (is_relocatable): New static definition. + * readelf.c (dump_relocations): Make the function void. + (is_32bit_abs_reloc): Add support for x86, Arc, Arm, D10V, Dlx, + OR32 and Score. + (is_32bit_pcrel_reloc): Add support for x86 and Arm. + (is_16bit_abs_reloc): Add support for D10V. + (debug_apply_rela_addends): Rename to debug_apply_relocations. + Add code to support rel relocations. + (load_debug_section): Fix call to debug_apply_relocations. + (get_file_header): Remove setting of is_relocatable. + +2007-10-31 Alan Modra + + * readelf.c (debug_apply_rela_addends): Clarify FIXME. + +2007-10-29 Nick Clifton + + * readelf.c (is_32bit_abs_reloc): Add knowledge of reloc used by + IA64. + (is_64bit_abs_reloc): Likewise. + +2007-10-28 Nick Clifton + + * dwarf.c (process_debug_info): Check for corrupt lengths. + * readelf.c (get_reloc_type): New function. Returns the reloc + number extracted from the info field of a reloc. + (get_reloc_symindex): New function. Returns the symbol index + extracted from the info field of a reloc. + (dump_relocations): Use the new functions. + (slurp_ia64_unwind_table): Use the new functions. + (slurp_hppa_unwind_table): Use the new functions. + (dump_section_as_bytes): Use the new functions. + (get_reloc_size): Delete function. + (is_32bit_abs_reloc): New function. Determines if a given reloc + type is a 32-bit absolute relocation. + (is_32bit_pcrel_reloc): New function. Like is_32bit_abs_reloc but + for pc-relative relocations. + (is_64bit_abs_reloc): New function. Like is_32bit_abs_reloc but + for 64-bit absolute relocations. + (is_16bit_abs_reloc): New function. Like is_32bit_abs_reloc but + for 32-bit absolute relocations. + (debug_apply_rela_addends): Use the new functions. Skip and warn + about any unrecognised relocations. + +2007-10-26 Karl Berry + + * doc/binutils.texi: Move top stuff to the top. + Use @direntry/@dircategory, format entries to play nicely with + others. + Avoid duplicate copying strings. + Don't misspell "Texinfo". + +2007-10-25 Daniel Jacobowitz + + * readelf.c (display_power_gnu_attribute): Add support for + Tag_GNU_Power_ABI_Vector. + +2007-10-25 Carlos Eduardo Seo + + * readelf.c (get_note_type): Handle NT_PPC_VMX. + +2007-10-24 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + * po/POTFILES.in: Regenerate. + +2007-10-24 Alan Modra + + * strings.c (print_strings): Don't use %L, use %ll in printf + format strings. + +2007-10-24 Tristan Gingold + Alan Modra + + * readelf.c (process_program_headers): Use dynamic segment unless + dynamic section is found. + +2007-10-16 Bob Wilson + + * doc/binutils.texi (objcopy, strip): Replace hyphens with em-dashes. + (objdump, strip, c++filt): Correct punctuation for "e.g." and "i.e." + and change to spell out "for example" in two places. + +2007-10-16 Nick Clifton + + * configure.in: Build windows tools for --enable-targets=all. + * configure: Regenerate. + +2007-10-15 Alan Modra + + * objdump.c (print_line): Check fwrite return value. + * srconv.c (checksum, wr_tr, wr_cs): Likewise. + * sysdump.c (fillup): Return zero on getc or fread EOF. Return count + read. + +2007-10-10 Jim Blandy + + * dwarf.c (process_debug_info): Line up section offsets of + attribute values with those of dies. + (read_and_display_attr): Reduce spacing here. + + * dwarf.c (display_debug_lines): Print the offset of each line + number program header. + +2007-10-09 H.J. Lu + + PR binutils/4476 + * readelf.c (print_dynamic_symbol): New. + (process_symbol_table): Handle DT_GNU_HASH for dynamic symbols. + +2007-10-08 Carlos O'Donell + + * resrc.c (read_rc_file): Rename e to edit, and c to dir. + Pass dir to windres_add_include_dir. Add comments. + (close_input_stream): Check pclose error, and call fatal if + the preprocessor failed. + * windres.c (windres_add_include_dir): Assert that p is non-NULL, + and not an empty string. + +2007-10-04 Nick Clifton + + PR binutils/5098 + * dlltool.c: Fix spelling typos. + +2007-10-03 Masaki Muranaka + + * readelf.c (dump_section_as_strings): Use %6tx instead of %6zx. + +2007-09-25 Thien-Thi Nguyen + + * MAINTAINERS: Fix typo. + +2007-09-17 Shen Feng + + * readelf.c (do_archive_index): New. + (options): Add -c and --archive-index option. + (usage): Add -c option. + (parse_args): Add c option parsing. + (process_archive): Dump archive index. + * NEWS: Mention the new feature. + * doc/binutils.texi: Document the new feature. + +2007-09-17 Nick Clifton + + * po/es.po: Updated Spanish translation. + +2007-09-17 Nick Clifton + + * doc/binutils.texi (objdump): Describe the output of the --syms + option in more detail. + +2007-09-17 Alon Bar-Lev + + PR binutils/4987 + * resrc.c: (read_rc_file): Move 'filename' default initialization + to start of function. + +2007-08-31 Michael Meissner + Dwarakanath Rajagopal + + * NEWS: Add note about SSE5 being added on i386. + +2007-09-13 Alan Modra + Zhou Drangon + + * nm.c (value_format_64bit, set_print_radix, print_value): Handle + BFD_HOST_64BIT_LONG_LONG. + * readelf.c (print_dec_vma): Don't define if BFD_HOST_64BIT_LONG_LONG. + (print_vma): Handle BFD_HOST_64BIT_LONG_LONG. + (dump_relocations): Likewise. Expand _bfd_int64_low in a + number of places. + +2007-09-11 Kai Tietz + + * rcparse.y: (string_data): Removed ill token removal. + +2007-09-10 Alan Modra + + PR 5011 + * readelf.c (process_version_sections): Don't read past end of + various section buffers. + +2007-08-31 H.J. Lu + + * Makefile.am (INCLUDES): Remove -D_GNU_SOURCE. + * Makefile.in: Regenerated. + + * sysdep.h: Include "config.h" first. + +2007-08-31 Nick Clifton + + * po/sk.po: New Slovakian translation. + * configure.in (LINGUAS): Add sk. + * configure: Regenerate. + +2007-08-30 Nick Clifton + + * readelf.c (dump_type): New type used to classify the kinds of + dump requested by the user. + (dump_sects, cmdline_dump_sects): Use the new type. + (options): Add --string-dump option. + (request_dump): Rename to request_dump_bynumber. Use dump_type. + (request_dump_byname): Use dump_type. + (parse_args): Parse --string-dump option. + (process_section_headers): Fix calls to request_dump. + (initialise_dumps_byname): Likewise. + (dump_section): Rename to dump_section_as_bytes. + (dump_section_as_strings): New function. Display the contents of + a section as printable strings. + (process_section_contents): String dump the section if requested. + (process_object): Use dump_type. + (main): Likewise. + * Makefile.am: Add dependency for readelf.c on safe-ctype.h. + * Makefile.in: Regenerate. + * NEWS: Mention the new feature. + * doc/binutils.texi: Document the new feature. + +2007-08-30 Nathan Sidwell + + * bucomm.c (bfd_nonfatal_message): New. + * bucomm.h (bfd_nonfatal_message): Declare. + * objcopy.c (RETURN_NONFATAL): Take BFD not NAME, use + bfd_nonfatal_message. + (copy_unknown_object): Adjust bfd_nonfatal and RETURN_NONFATAL + calls, or replace with bfd_nonfatal_message calls as appropriate. + (copy_object, copy_archive, copy_file, setup_section, + copy_section, write_debugging_info): Likewise. + +2007-08-28 Nick Clifton + + * NEWS: Mention Coverity's contribution. + +2007-08-25 Ulrich Weigand + + * readelf.c (process_note): Recognize SPU core file notes. + +2007-08-24 Daniel Jacobowitz + + * configure.in: Install embedspu on powerpc*-*-eabi* also. + * configure: Regenerated. + +2007-08-24 Daniel Jacobowitz + + * po/uk.po: Updated Ukrainian translation. + +2007-08-22 Ben Elliston + + * doc/binutils.texi (objdump): Document -Mppcps. + +2007-08-17 Alan Modra + + * po/Make-in: Add --msgid-bugs-address to xgettext invocation. + +2007-08-16 H.J. Lu + + * readelf.c: Revert last change. + +2007-08-16 H.J. Lu + + * readelf.c (get_segment_type): Change PT_GNU_STACK to + PT_GNU_ATTR. + +2007-08-12 Daniel Jacobowitz + + * NEWS: Add a marker for the 2.18 features. + +2007-08-12 Matthias Klose + + * doc/Makefile.am (AM_MAKEINFOFLAGS, TEXI2DVI): Include + $(top_srcdir)/../../bfd/doc. + * doc/Makefile.in: Regenerate. + +2007-08-10 M R Swami Reddy + + * MAINTAINERS: Add myself as CR16 support maintainer and + update myself as CRX support maintainer. + +2007-08-10 Nick Clifton + + * po/fi.po: Updated Finnish translation. + * po/vi.po: Updated Vietnamese translation. + +2007-08-10 Kai Tietz + + * doc/binutils.texi: (windmc): Correct incorrect desciption. + +2007-08-04 Alan Modra + + PR 4888 + * objcopy.c (setup_section): Do modify section flags for ELF + STRIP_NONDEBUG (reverting part of 2007-05-30 change). Prevent + header rewrite by twiddling input section flags instead. + Simplify code setting SHT_NOBITS. + +2007-07-28 Christopher Faylor + + * MAINTAINERS: Update my email address. + +2007-07-26 Adam Nemet + + * readelf.c (process_archive): Also skip Irix6-style archive symbol + tables. + +2007-07-24 Nick Clifton + + * readelf.c (NUM_ELEM): Remove redundant macro; replace references + to it with references to ARRAY_SIZE. + Add support for CR16. + Fix formatting. + +2007-07-19 Nick Clifton + + PR binutils/4802 + * srconv.c (strip_suffix): Add const qualifier to argument. + +2007-07-16 Nick Clifton + + * po/uk.po: New Ukrainian translation. + * configure.in (ALL_LINGUAS): Add 'uk'. + * configure: Regenerate. + +2007-07-10 Alan Modra + + * objdump.c (dump_dwarf): Correct setting of is_relocatable. + +2007-07-09 Roland McGrath + + * readelf.c (get_gnu_elf_note_type): New function. + (process_note): Use it for "GNU" name. + +2007-07-08 Andreas Schwab + + * Makefile.am (HFILES): Add dwarf.h, sysdep.h and unwind-ia64.h. + (CFILES): Add unwind-ia64.c. + Regenerate dependencies. + * Makefile.in: Regenerate. + +2007-07-05 Nick Clifton + + * addr2line.c: Update copyright notice to refer to GPLv3. + * ar.c, arlex.l, arparse.y, arsup.c, arsup.h, bin2c.c, binemul.c, + binemul.h, bucomm.c, bucomm.h, budbg.h, coffdump.c, coffgrok.c, + coffgrok.h, cxxfilt.c, debug.c, debug.h, deflex.l, defparse.y, + dlltool.c, dlltool.h, dllwrap.c, dwarf.c, dwarf.h, embedspu.sh, + emul_aix.c, emul_vanilla.c, filemode.c, ieee.c, mclex.c, + mcparse.y, nlmconv.c, nlmconv.h, nlmheader.y, nm.c, objcopy.c, + objdump.c, prdbg.c, rclex.c, rcparse.y, rdcoff.c, rddbg.c, + readelf.c, rename.c, resbin.c, rescoff.c, resrc.c, resres.c, + size.c, srconv.c, stabs.c, strings.c, sysdep.h, sysdump.c, + sysinfo.y, syslex.l, unwind-ia64.c, unwind-ia64.h, version.c, + windint.h, windmc.c, windmc.h, windres.c, windres.h, winduni.c, + winduni.h, wrstabs.c: Likewise. + * is-ranlib.c, is-strip.c, maybe-ranlib.c, maybe-strip.c, + not-ranlib.c, not-strip.c, ranlib.sh, sanity.sh: Add a copyright + notice. + * NEWS: Mention that the sources are now released under GPLv3. + Add a marker for the changes that went into v2.17. + * version.c (print_version): Specify that the program is released + under version 3 of the GPL. + +2007-07-05 Kai Tietz + + * resrc.c: (read_rc_file): Add include path of user passed rc + input file. + * windres.c: (windres_add_include_dir): New. + (main): Use of windres_add_include_dir. + * windres.h: (windres_add_include_dir): Add prototype. + +2007-07-05 Alan Modra + + * doc/binutils.texi (size): Document --common. + * size.c: Make a number of vars static. Delete unnecessary + function declarations. + (show_common, common_size): New vars. + (usage): Describe --common. + (OPTION_FORMAT, OPTION_RADIX, OPTION_TARGET): Define and use. + (long_options): Add common. + (calculate_common_size): New function. + (print_berkeley_format): Add common_size to bsssize. + (sysv_one_line): New function split out from.. + (sysv_internal_printer): ..here. + (print_sysv_format): Handle display of *COM*. + (print_sizes): Call calculate_common_size. + +2007-07-05 Alan Modra + + * emul_aix.c (ar_emul_aix_internal): Rename "next" to "archive_next". + +2007-07-02 Alan Modra + + PR 4716 + * objcopy.c (filter_symbols): Correct relocatable file test. + +2007-07-02 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + * aclocal.m4: Regenerate. + * config.in: Regenerate. + * doc/Makefile.in: Regenerate. + * po/POTFILES.in: Regenerate. + * po/binutils.pot: Regenerate. + +2007-06-30 H.J. Lu + + * aclocal.m4: Regenerated. + * doc/Makefile.in: Likewise. + * Makefile.in: Likewise. + +2007-06-29 Joseph Myers + + * readelf.c (display_power_gnu_attribute, process_power_specific): + New. + (process_arch_specific): Call process_power_specific. + +2007-06-29 Joseph Myers + + * readelf.c (display_mips_gnu_attribute): New. + (process_mips_specific): Call process_attributes. + +2007-06-29 Joseph Myers + + * readelf.c (display_gnu_attribute): New. + (process_arm_specific): Rearrange as process_attributes. + (process_arm_specific): Replace by wrapper of process_attributes. + +2007-06-28 Roland McGrath + + * objcopy.c (setup_section): Don't reset ELF section type to + SHT_NOBITS when it is SHT_NOTE. + * doc/binutils.texi (objcopy, strip): Mention under --only-keep-debug. + +2007-06-27 Alan Modra + + * ar.c: Rename uses of bfd.next to bfd.archive_next throughout. + * arsup.c: Likewise. + * binemul.c: Likewise. + * objcopy.c: Likewise. + * dlltool.c: Likewise. + +2007-06-26 Shantonu Sen + + PR binutils/4693 + * Makefile.am (windres_DEPENDENCIES, windmc_DEPENDENCIES): Move + dependency on $(LIBICONV) to ... + (windres_LDADD, windmc_LDADD) ... here. + * Makefile.in: Regenerate. + +2007-06-21 Alan Modra + + * embedspu.sh (relas): Correct sh_info parsing. + +2007-06-19 Danny Smith + + * objdump.c: Include sys/stat.h. + +2007-06-19 Kai Tietz + + * Makefile.am: Add windmc tool. + * Makefile.in: Regenerate. + * configure.in: Add windmc tool. + * configure: Regenerate. + * mclex.c: New. + * mcparse.y: New. + * windmc.c: New. + * windmc.h: New. + * doc/Makefile.am: Add windmc tool. + * doc/Makefile.in: Regenerate. + * doc/binutils.texi: Add windmc documentation. + * NEWS: Mention new tool. + +2007-06-18 Andi Kleen + + * objdump.c: Include sys/mman.h + (print_file_list): Remove f, add map, mapsize, linemap, maxline, + last_line, first fields. + (slurp_file): Add. + (index_file): Add. + (print_file_open): Call slurp_file and index_file. Initialize new + fields. + (skip_to_line): Rename to print_line and write only single line. + (dump_line): Add. + (show_line): Change to new algorithm. + +2007-06-18 Thomas Weidenmueller + + * resres.c (probe_binary): Fix test for badly formatted headers. + +2007-06-18 Kai Tietz + + * rclex.c: (cpp_line): Add code_page pragma support. + * windres.c: (usage, long_options, main): Add new option + --codepage or -c. + * winduni.c: (wind_default_codepage, wind_current_codepage): New. + (unicode_from_ascii, ascii_from_unicode): Use + wind_current_codepage as codepage parameter. + (unicode_print): Print 4 characters for hexadecimal values in + unicode strings. + * winduni.h: (wind_default_codepage, wind_current_codepage): + Export. + * doc/binutils.texi: Document new option. + * NEWS: Mention new features of windres. + +2007-06-18 Brian D. Watt + + * embedspu.sh: Parse _SPUEAR_ symbol values as hex. + +2007-06-14 H.J. Lu + + * Makefile.am (ACLOCAL_AMFLAGS): Add -I ../config -I ../bfd. + + * acinclude.m4: Removed. + + * Makefile.in: Regenerated. + * aclocal.m4: Likewise. + * configure: Likewise. + +2007-06-11 Nathan Sidwell + + * dwarf.c (decode_location_expression): Add DW_OP_form_tls_address. + +2007-06-06 Kai Tietz + + PR binutils/4356 binutils/591 + * resrc.c (filename_need_quotes): New function. + (look_for_default): If filename_need_quotes is true then quote the + filename in the command line being created. + (read_rc_file): Likewise. + +2007-06-06 Ben Elliston + + * doc/binutils.texi (objdump): Fix capitalisation of "PowerPC". + +2007-06-05 Kai Tietz + + * Makefile.am: Add LIBICONV to windres. + * acinclude.m4: Added missing "lib-*.m4" and "lt*.m4" files. + * configure.in: Add AC_CHECK_HEADER for iconv.h and use AM_ICONV. + * config.in: Add ICONV defines. + * aclocal.m4: Regenerate. + * confugure: Regenerate. + * winduni.c: (local_iconv_map codepages, wind_language_t, + languages, unicode_is_valid_codepage, wind_find_language_by_id, + wind_find_language_by_codepage, wind_find_codepage_info, + unicode_from_codepage, codepage_from_unicode, iconv_onechar, + wind_iconv_cp, wind_MultiByteToWideChar wind_WideCharToMultiByte): + New. + (ascii_from_unicode): Use codepage_from_unicode. + (ascii_from_unicode): Use unicode_from_codepage. + Use for cygwin windows API for unicode transformation. + * winduni.h: (CP_ACP, CP_UTF7, CP_UTF8, CP_OEM, CP_UTF16): New + macros. + (wind_language_t, local_iconv_map): New types. + (wind_find_language_by_id, wind_find_language_by_codepage, + unicode_is_valid_codepage, wind_find_codepage_info, + unicode_from_codepage, codepage_from_unicode): New + prototypes. + +2007-06-05 Alan Modra + + * embedspu.sh: Handle R_SPU_PPU* relocs with no symbol. + +2007-05-30 Alan Modra + + * objcopy.c (copy_object): Revert 2007-05-11 change. Don't + avoid calling bfd_copy_private_bfd_data for ELF STRIP_NONDEBUG. + (setup_section): Don't modify flags, and don't avoid calling + bfd_copy_private_section_data for ELF STRIP_NONDEBUG. + * readelf.c (process_program_headers): Ignore .dynamic of type + SHT_NOBITS. + +2007-05-29 Alan Modra + + * embedspu.sh: Emit SPU ELF image to .data.rel.ro.speelf if + pic or pie and image needs relocs. + +2007-05-24 Steve Ellcey + + * Makefile.in: Regenerate. + * configure: Regenerate. + * aclocal.m4: Regenerate. + * doc/Makefile.in: Regenerate. + +2007-05-24 Kai Tietz + + * rcparse.y: Join strings for elements having no side-effects in + "rc"-grammar. + +2007-05-23 Kai Tietz + + * rclex.c: New file replacing rclex.l. + * rclex.l: Removed. + * windint.h: New file holding common structure and type + definitions. + * Makefile.am: Added new header windint.h and exchanged rclex.l by + rclex.c. + * Makefile.in: Regenerate. + * rcparse.y: Renamed some structures. + Use in internal representation always bfd_vma instead of long or + int. + Removed from %union unused stringtable. + Added to %union suni structure for unicode strings. + Added new tokens for ANICURSOR, ANIICON, DLGINCLUDE, + DLGINIT, FONTDIR, HTML, MANIFEST, PLUGPLAY, VXD, + TOOLBAR, BUTTON, QUOTEDUNISTRING, and SIZEDUNISTRING. + Added support for these new rc file tokens. + * resbin.c: Rewrote using bfd and binary structures, and support + new resource types. + * rescoff.c: Likewise. + * resres.c: Likewise. + * resrc.c: Likewise. Dumps as RC are now recompilable. + * windres.c: As above. Using bfd for res and provide target + specific endianess support. + * windres.h: Use windint.h as include. Additionally removed K&R + syntax. + * winduni.c: New printing and unichar support routines. + * winduni.h: Prototypes for new unichar helpers. + * windint.h: New file. + +2007-05-22 Paul Brook + + * objdump.c (find_symbol_for_address): Merge section and target + specific filtering code. + +2007-05-22 Nick Clifton + + * doc/binutils.texi: Use @copying around the copyright notice. + +2007-05-21 Richard Sandiford + + * objdump.c (disassemble_bytes): Ignore disassembler_needs_relocs + for executables and shared libraries. + +2007-05-18 Nathan Sidwell + + * objcopy.c (strip_main): Detect identical input and output file + names. + (copy_main): Refactor tempname detection and use. + +2007-05-17 Nick Clifton + + * objdump.c (load_debug_section): Select bias for DWARF debug + addresses based on the flavour of the bfd. + +2007-05-11 Alan Modra + + PR 4479 + * objcopy.c (copy_object): Don't copy ELF program headers for + --only-keep-debug. + +2007-05-11 Alan Modra + + * embedspu.sh (find_prog): Prefer prog in same dir as embedspu + over one found on the users path. + (main): Generate .reloc for each R_SPU_PPU* reloc. + +2007-04-28 Alan Modra + + * prdbg.c (tg_variable): Adjust for changed demangler. + (tg_start_function): Likewise. + +2007-04-27 Alan Modra + + * bucumm.h: Split off host dependencies to.. + * sysdep.h: ..here. + Many files: Include sysdep.h. Remove duplicate headers and reorder. + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + +2007-04-24 Nick Clifton + + * srconv.c (walk_tree_type_1): Initialise dpt.dunno. + +2007-04-24 Nathan Froyd + Phil Edwards + + * objcopy.c (filter_symbols): Explicitly stripping a symbol + used in relocations is an error. + Retype 'keep' to bfd_boolean. + +2007-04-24 Alan Modra + + * Makefile.in: Regenerate. + * doc/Makefile.in: Regenerate. + +2007-04-20 Nathan Froyd + Phil Edwards + Thomas de Lellis + + * objcopy.c (reverse_bytes): New variable. + (command_line_switch, copy_main): Add OPTION_REVERSE_ENDIAN. + (copy_options, copy_usage): Add "reverse-bytes" entry. + (copy_section): Reverse bytes within output sections. + * doc/binutils.texi: Document new objcopy option. + +2007-04-20 Nick Clifton + + * rclex.l: Allow underscores at the start of identifiers. + +2007-04-19 Alan Modra + + * budemang.c: Delete. + * budemang.h: Delete. + * addr2line.c (translate_addresses): Call bfd_demangle rather than + demangle. + * nm.c (print_symname): Likewise. + * objdump.c (objdump_print_symname, dump_symbols): Likewise. + (dump_bfd): Likewise. + * prdbg.c (struct pr_handle ): Add int param. + (tg_variable, tg_start_function): Adjust demangler calls. + * Makefile.am: Remove mention of budemang.[ch]. Run "make dep-am". + * Makefile.in: Regenerate. + * po/POTFILES.in: Regenerate. + +2007-04-14 Steve Ellcey + + * Makefile.am: Add ACLOCAL_AMFLAGS. + * configure.in: Change macro call order. + * Makefile.in: Regenerate. + * configure: Regenerate. + +2007-04-13 Nathan Sidwell + + * Makefile.am (TOOL_PROGS): Add objcopy. + * Makefile.in: Rebuilt. + +2007-04-12 H.J. Lu + + PR binutils/4348 + * objcopy.c (copy_object): Don't stop when there are no + sections to be copied. + +2007-04-10 Vladimir Prus + + * NEWS: Mention disjoint histograms support in + gprof. + +2007-04-09 Daniel Jacobowitz + + * dwarf.c (process_debug_info): Do not require DW_AT_frame_base for + DW_TAG_inlined_subroutine. + +2007-04-06 Matt Thomas + + * MAINTAINERS: Add myself as VAX and NetBSD support maintainer. + +2007-04-05 Alan Modra + + PR binutils/4292 + * nm.c (print_value): Cast bfd_vma to unsigned long to suit + value_format_32bit. + +2007-04-02 Nick Clifton + + PR binutils/4292 + * nm.c (value_format): Replace with value_format_32bit and + value_format_64bit. + (set_radix): Update setting of value_format. + (set_print_width): New function. Compute the address size of a + given bfd and set the print_width global appropriately. + (display_archive): Use set_print_width. + (display_file): Likewise, + (print_object_filename_sysv): Update use of print_width. + (print_archive_member_sysv): Likewise. + (print_symbol_filename_posix): Likewise. + (print_sumbol_info_bfd, print_symbol_info_sysv): Likewise. + +2007-03-28 Richard Sandiford + Phil Edwards + + * doc/binutils.texi: Put the contents after the title page rather + than at the end of the document. + +2007-03-28 Nick Clifton + + * readelf.c (slurp_rela_relocs): Add newline to end of error + messages. + (slurp_rel_relocs, request_dump, request_dump_byname, + process_program_headers, process_dynamic_section, + process_symbol_table, process_mips_specific, main): Likewise. + +2007-03-28 Alan Modra + + * MAINTAINERS: Update mailing list addresses. Add myself + as PPC maintainer. + +2007-03-27 Alan Modra + + * embedspu.sh: Correct toe_addr quoting. + +2007-03-27 Alan Modra + + * embedspu.sh: Combine "_EAR_" and "_EAR_*" patterns. Tighten + .toe section and .toe address checks. Use .reloc for _EAR* + symbols defined in non-BSS sections. Build table for _SPUEAR_ + symbols. + +2007-03-23 Kaz Kojima + + PR gas/3811 + * readelf.c (debug_apply_rela_addends): Do nothing for SH. + +2007-03-22 Joseph Myers + + * doc/binutils.texi: Include VERSION_PACKAGE when reporting + version. + +2007-03-16 Kai Tietz + + * dlltool.c (make_one_lib_file): Use pc-relative relocation + instead of an absolute relocation for x86_64-pc-mingw32 target. + +2007-03-15 H.J. Lu + + * Makefile.am (REPORT_BUGS_TO): Removed. + (INCLUDES): Remove -DREPORT_BUGS_TO. + * Makefile.in: Regenerated. + + * bucomm.c: Don't include bfdver.h. + * objdump.c: Likewise. + * version.c: Likewise. + + * bucomm.h: Include bfdver.h. + + * configure.in (--with-bugurl): Removed. + * configure: Regenerated. + + * doc/Makefile.am (binutils_TEXINFOS): Removed. + (AM_MAKEINFOFLAGS): Add -I ../../bfd/doc. + (TEXI2DVI): Likewise. + (config.texi): Removed. + (MOSTLYCLEANFILES): Remove config.texi. + * doc/Makefile.in: Regenerated. + + * doc/binutils.texi: Include bfdver.texi instead of + config.texi. + +2007-03-13 Nick Clifton + + * readelf.c (dump_section): Also test for SHT_REL sections when + producing the warning about unapplied relocs. + +2007-03-07 Joseph Myers + + * configure.in (REPORT_BUGS_TEXI): Define to Texinfo version of + bug-reporting URL. + * doc/Makefile.am (config.texi): Define BUGURL. + * doc/binutils.texi: Use BUGURL. Remove text about large files + and uuencoding. + * Makefile.in, configure, doc/Makefile.in: Regenerate. + +2007-03-01 Phil Edwards + Richard Sandiford + + * NEWS: Mention addition of --extract-symbol. + * doc/binutils.texi: Document it. + * objcopy.c (extract_symbol): New variable. + (OPTION_EXTRACT_SYMBOLS): New command_line_switch. + (copy_options): Add an entry for --extract-symbol. + (copy_usage): Mention --extract-symbol. + (copy_object): Set the start address to zero for --extract-symbol. + Do not copy private BFD data in that case. + (setup_section): Set the size, LMA and VMA to zero for + --extract-symbol. Do not copy private BFD data in that case. + (copy_section): Do not copy section contents if --extract-symbol + is passed. + (copy_main): Set extract_symbol to TRUE if --extract-symbol + is passed. + +2007-03-01 Paul Brook + + * MAINTAINERS: Update my entry. + +2007-03-01 Joseph Myers + + * version.c: Update copyright date. + +2007-03-01 Daniel Jacobowitz + + * Makefile.am (install-exec-local): Depend on $(noinst_PROGRAMS). + Adjust $(EXEEXT) handling for $(RENAMED_PROGS). + * Makefile.in, doc/Makefile.in: Regenerate. + +2007-03-01 Alan Modra + + * embedspu.sh: Set type and size of global program handle symbol. + +2007-02-28 Alan Modra + + * Makefile.am (PROGS): Delete. + (RENAMED_PROGS): Define. Extracted from.. + (noinst_PROGRAMS): ..here. Add BUILD_MISC. + (install-exec-local): Adjust. + * Makefile.in: Regenerate. + +2007-02-28 Alan Modra + + * Makefile.am (PROGS): Add BUILD_INSTALL_MISC. + (bin_PROGRAMS): Replace BUILD_MISC with BUILD_INSTALL_MISC. + (EXTRA_PROGRAMS): Remove bin2c. + (bin2c$(EXEEXT_FOR_BUILD)): New rule. + (bin2c_SOURCES): Delete. + (DISTCLEANFILES): Remove sysinfo. + (MOSTLYCLEANFILES): Add sysinfo$(EXEEXT_FOR_BUILD) and + bin2c$(EXEEXT_FOR_BUILD). + * configure.in (BUILD_MISC): Add $(EXEEXT_FOR_BUILD) to bin2c. + Move embedspu to.. + (BUILD_INSTALL_MISC): ..here. + * Makefile.in: Regenerate. + * configure: Regenerate. + +2007-02-27 Alan Modra + + * bin2c.c: New file. + * Makefile.am (EXTRA_PROGRAMS): Add bin2c. + (CFILES): Add bin2c.c. + (bin2c_SOURCES): Define. + (bin2c.o): Dependencies from "make dep-am". + * configure.in (BUILD_MISC): Add bin2c. + * version.c: Update year. + * po/POTFILES.in: Regenerate. + * Makefile.in: Regenerate. + * configure: Regenerate. + +2007-02-17 Mark Mitchell + Nathan Sidwell + Vladimir Prus + + * configure.in (--with-bugurl): New option. + * configure: Regenerate. + * Makefile.am (REPORT_BUGS_TO): Define. + (INCLUDES): Define REPORT_BUGS_TO. + Regenerate dependencies. + * Makefile.in: Regenerate. + * doc/Makefile.in: Regenerate. + * bucomm.h: Remove include of bin-bugs.h. + * addr2line.c (usage): Don't print empty REPORT_BUGS_TO. + * ar.c (usage): Pass s to list_supported_targets. Don't print + empty REPORT_BUGS_TO. + * coffdump.c (show_usage): Don't print empty REPORT_BUGS_TO. + * cxxfilt.c (usage): Print bug url when giving help. + * dlltool.c (usage): Likewise. + * dllwrap.c (usage): Likewise. + * nlmconv.c (show_usage): Don't print empty REPORT_BUGS_TO. + * nm.c (usage): Likewise. + * objcopy.c (copy_usage, strip_usage): Likewise. + * objdump.c (usage): Likewise. + * readelf.c ((usage): Likewise. Add STREAM argument. Adjust + callers. + * size.c (usage): Don't print empty REPORT_BUGS_TO. + * srconv.c (show_usage): Likewise. + * strings.c (usage): Likewise. + * sysdymp.c (show_usage): Likewise. + * windres.c (usage): Likewise. + +2007-02-13 Alan Modra + + * embedspu.sh: Add -W to readelf invocation. + +2007-02-06 Dave Brolley + + * MAINTAINERS: Add myself as the maintainer of the MeP port. + +2007-02-06 Nick Clifton + + PR gas/3800 + * readelf.c: Include elf/h8.h twice. The first time in order to + get the reloc numbers, the second time in order to get the reloc + decoder function. + (dump_section): Tell the user if the section being displayed has + unprocessed relocs associated with it. + (get_reloc_size): New function - returns the size of a reloc. + (debug_apply_rela_addends): Use get_reloc_size(). + * dwarf.c (read_and_display_attr_value): Extend number of + languages known for the DW_AT_language attribute. + (process_debug_info): Display the attribute offset before decoding + the attribute, in case there are problems. + +2007-02-05 Dave Brolley + + * readelf.c (dump_relocations): Don't check for + (rtype == NULL && type == R_RELC). + +2007-02-05 Dave Brolley + + * Makefile.am (readelf.o): Depends on $(INCDIR)/elf/mep.h. + * Makefile.in: Regenerated. + * Contribute the following changes: + 2003-10-29 Dave Brolley + + * configure.in: Define SKIP_ZEROES and SKIP_ZEROES_AT_END for mep. + * configure: Regenerated. + + 2001-04-03 Ben Elliston + + * readelf.c: Include "elf/mep.h". + (guess_is_rela): Handle EM_CYGNUS_MEP. + (get_machine_name): Ditto. + (dump_relocations): Ditto. + +2007-02-02 H.J. Lu + + * MAINTAINERS: Add a space between H.J. and Lu. + +2007-02-02 H.J. Lu + + * doc/binutils.texi (objdump): Document the new addr64 option + for i386 disassembler. + +2007-02-02 H.J. Lu + + PR binutils/3945 + * configure.in (DLLTOOL_DEFAULT): New. Defined for the first PE + target. + (DLLTOOL_DEFS): Add $DLLTOOL_DEFAULT. + * configure: Regenerated. + + * dlltool.c (mname): Defined with DLLTOOL_DEFAULT_XXX. + +2007-02-02 Nick Clifton + + * doc/binutils.texi (objdump): Document support for disassembling + the 440 PowerPC architecture. + +2007-01-31 Nathan Sidwell + + * dwarf.c (process_debug_info): Protect against bogus length and + abbrev offsets. + +2007-01-25 Kazu Hirata + + * ar.c (print_contents, extract_file): Cast the return value + of fwrite to size_t. + +2007-01-12 Alan Modra + + * ar.c (open_inarch): Check fwrite return. Use size_t. + (extract_file): Likewise. Remove test for "negative" file size. + * readelf.c (process_program_headers): Check fscanf return. + +2007-01-11 H.J. Lu + + * bucomm.c (template_in_dir): Fix typo. + +2007-01-11 Alan Modra + + * embedspu.sh: New file. + * Makefile.am (embedspu): Add rule. + * configure.in (BUILD_MISC): Add embedspu for powerpc-linux. + * Makefile.in: Regenerate. + * configure: Regenerate. + +2007-01-11 Alan Modra + + * bucomm.h (make_tempdir): Declare independently of HAVE_MKDTEMP. + * bucomm.c (template_in_dir): New function, split out from.. + (make_tempname): ..here. Open the file with O_EXCL if !HAVE_MKSTEMP. + (make_tempdir): Use template_in_dir. Handle directory creation + when !HAVE_MKDTEMP. + * objcopy.c (MKDIR): Don't define. + (copy_archive): Use make_tempdir when !HAVE_MKDTEMP too. Fix + error message. + +2007-01-08 Kazu Hirata + + * readelf.c (get_machine_flags): Treat Fido as an architecture + by itself. + +2007-01-08 Kai Tietz + + * configure.in: Renamed target x86_64-*-mingw64 to + x86_64-*-mingw*. + * configure: Regenerated. + +2007-01-05 Alan Modra + + * readelf.c (dump_section): Don't print 32-bit values, which + were done incorrectly for little-endian. Instead print bytes. + +For older changes see ChangeLog-2006 + +Copyright (C) 2007 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2008 b/support/sdbinutils/binutils/ChangeLog-2008 new file mode 100644 index 0000000..f04688c --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2008 @@ -0,0 +1,880 @@ +2008-12-23 Jon Beniston + + * MAINTAINERS: Added Jon Beniston as maintainer for LM32 port. + * readelf.c: Add support for LM32 machine number. + +2008-12-23 Kai Tietz + + * rcparse.y (rcdata_data): Allow empty comma elements. + +2008-12-23 Nick Clifton + + * objdump.c (dump_reloc_set): Remove STT_IFUNC support. + * readelf.c (dump_relocations): Likewise. + (get_symbol_type): Likewise. + * doc/binutils.texi: Likewise. + +2008-12-18 Ralf Wildenhues + + * configure: Regenerate. + +2008-12-09 Tom Tromey + + * srconv.c (wr_hd): Add parens to placate gcc 4.4. + +2008-12-09 Andrew Stubbs + + * readelf.c (arm_attr_tag_CPU_arch): Add "v6-M" and "v6S-M". + (arm_attr_tag_WMMX_arch): Add "WMMXv2". + (arm_attr_tag_NEON_arch): Rename to ... + (arm_attr_tag_Advanced_SIMD_arch): ... official name. + (arm_attr_tag_ABI_PCS_config): Rename to ... + (arm_attr_tag_PCS_config): ... official name. + (arm_attr_tag_ABI_PCS_RO_DATA): Rename to ... + (arm_attr_tag_ABI_PCS_RO_data): ... official name. + (arm_attr_tag_ABI_FP_denormal): Add "Sign only". + (arm_attr_tag_CPU_unaligned_access): New array. + (arm_attr_tag_T2EE_use): New array. + (arm_attr_tag_Virtualization_use): New array. + (arm_attr_tag_MPextension_use): New array. + (arm_attr_publ): NEON_arch -> Advanced_SIMD_arch. + ABI_PCS_config -> PCS_config. + ABI_PCS_RO_DATA -> ABI_PCS_RO_data. + Add CPU_unaligned_access, nodefaults, also_compatible_with, + T2EE_use, conformance, Virtualization_use and MPextension_use. + (display_arm_attribute): Handle Tag_nodefaults and + Tag_also_compatible_with. + +2008-12-04 Ben Elliston + + * doc/binutils.texi (objdump): Update booke documentation. + * NEWS: Document user-visible changes to command line options. + +2008-12-04 Nick Clifton + + * objdump.c (dump_reloc_set): Append "()" to symbol names which + have the BSF_INDIRECT_FUNCTION type. + * readelf.c (print_symbol): Fix handling of negative widths. + (dump_relocations): Append "()" to symbol names which have the + STT_IFUNC type. Display negative offsets as a positive number with + a "-" prefix. + (get_symbol_type): Return "IFUNC" for STT_IFUNC symbols. + * doc/binutils.texi: Document 'i' symbol type. + +2008-11-26 Jan Kratochvil + + * strings.c (main): New variable `s'. Have string_min parsing + call fatal for invalid input strings. + +2008-11-25 Nick Clifton + + PR7044 + * dlltool.c (run): Use formatting string to avoid compile time + warning. + (gen_exp_file): Check return value from fread. + * windmc.c (main): Check return value from fread. + +2008-11-21 Sterling Augustine + + * MAINTAINERS: Take over from Bob Wilson as Xtensa maintainer. + +2008-11-19 Nick Clifton + + * doc/fdl.texi: Update to v1.3 + * doc/binutils.texinfo: Change license to v1.3. + +2008-11-18 Catherine Moore + + * readelf.c (arm_attr_tag_ABI_FP_16bit_format): New. + (arm_attr_tag_VFP_HP_extension): New. + (arm_attr_public_tag arm_attr_public_tags): Support + new attributes. + +2008-11-17 Nick Clifton + + * version.c (print_version): Update copyright year. + +2008-11-16 Danny Smith + + * dlltool.c (identify_search_section): Cast argument, not return + value, of xstrdup to 'char*'. + +2008-11-15 Charles Wilson + + Added --identify option to dlltool. + * binutils/dlltool.c: Add new global variables + identify_imp_name and identify_dll_name. + (identify_dll_for_implib, identify_search_archive, + identify_search_member, identify_process_section_p, + identify_search_section): New functions. + (usage): Added --identify. + (long_options): Added --identify. + (main): Handle --identify option. + * binutils/doc/binutils.texi: Document --identify. + +2008-11-14 Tristan Gingold + + Remove outdated mach-o specific tests. + * objdump.c (load_debug_section): Remove mach-o specific test. + (mach_o_uncompressed_dwarf_sections): Removed. + (mach_o_compressed_dwarf_sections): Removed. + (generic_uncompressed_dwarf_sections): Removed. + (generic_compressed_dwarf_sections): Removed. + (check_mach_o_dwarf): Removed. + (dump_dwarf): Remove call to check_mach_o_dwarf. + +2008-11-14 Tristan Gingold + + * configure.com: Get version from configure.in of bfd. + * makefile.vms-in (DEBUG_OBJS): Add dwarf.obj. + (CFLAGS): Update flags. + +2008-11-13 Hans-Peter Nilsson + Alan Modra + + * nm.c (filter_symbols): Only call memcpy when from != to. + +2008-11-10 Tristan Gingold + Alan Modra + + * objdump.c (disassemble_bytes): Don't skip leading zeros when + end of section calculation overflows. + +2008-11-07 Prafulla Thakare + + * MAINTAINERS: Take over from Anil Paranjpe as H8300 maintainer. + +2008-10-31 Alan Modra + + * po/id.po: New file. + * configure.in (ALL_LINGUAS): Add id. + * configure: Regenerate. + +2008-10-21 Alan Modra + + * windmc.c (res_alloc): Remove unnecessary cast. + * windres.c (res_alloc, reswr_alloc): Likewise. + +2008-10-20 Nick Clifton + + * readelf.c: Tidy up code formatting. + +2008-10-10 Nathan Froyd + + * readelf.c (display_power_gnu_attribute): Decode + Tag_GNU_Power_ABI_Struct_Return. + +2008-10-10 Alan Modra + + * embedspu.sh: Pass -Wa,-noexecstack to $CC. + +2008-10-09 Kai Tietz + + * dlltool.c (PAGE_SIZE): Make sure it has bfd_vma type. + (PAGE_MASK): Likewise. + (sfunc): Change to address size of bfd_vma for base-file. + (flush_page): Likewise. + (gen_exp_file): Likewise. + +2008-10-07 Jan Kratochvil + + * readelf.c (process_section_headers): Do not cut the section names and + types if running with --wide. + +2008-10-06 Tom Tromey + + * dwarf.c (display_debug_frames): Change text for uniformity. + (process_debug_info): Likewise. + (display_debug_aranges): Likewise. Indent address output. + (display_debug_pubnames): Print offset in hex. + +2008-10-02 Andrew Paprocki + + PR 6934 + * stabs.c (parse_stab_string): Parse and ignore =Y strings + generated by the SUNPro C++ compiler. + +2008-09-30 Andrew Paprocki + + PR 6922 + * stabs.c (parse_stab_sun_builtin_type): Parse, but ignore SUN's + 'b' and 'v' extensions. + +2008-09-29 Peter O'Gorman + Steve Ellcey + + * configure: Regenerate for new libtool. + * aclocal.m4: Ditto. + * Makefile.in: Ditto. + * doc/Makefile.in: Ditto. + +2008-09-28 Alan Modra + + * objcopy.c (setup_section): Set elf_group_id. + +2008-09-24 Richard Henderson + + * dwarf.c (size_of_encoded_value, get_encoded_value): Move up. + (decode_location_expression): Add section parameter. Handle + DW_OP_GNU_encoded_addr. + (read_and_display_attr_value): Update decode_location_expression call. + (display_debug_loc, display_debug_frames): Likewise. + +2008-09-25 Alan Modra + + PR 6913 + * dwarf.c (print_dwarf_vma): Don't call printf without format string. + +2008-09-17 Jan Kratochvil + + Suppress warnings on NONE relocations to discarded sections. + * readelf.c (is_none_reloc): New function. + (debug_apply_relocations): Ignore is_none_reloc() relocations. + +2008-09-11 Jan Kratochvil + + Fix loading large elf64 binaries on 32bit hosts. + * configure.in: Call AC_SYS_LARGEFILE. + * config.in: Regenerate. + * configure: Regenerate. + +2008-09-11 Alan Modra + + * po/sv.po: Update. + +2008-09-08 Tristan Gingold + + * BRANCHES: Add 2.18 and 2.19 release branches. + +2008-09-08 Tristan Gingold + + * NEWS: Add a marker for the 2.19 features. + +2008-09-05 Daniel Jacobowitz + + * readelf.c (load_specific_debug_section): New function, from + load_debug_section. + (load_debug_section): Use load_specific_debug_section. + (display_debug_section): Use load_specific_debug_section. Check for + multiple sections with the same name. + +2008-08-28 Tristan Gingold + + * objdump.c (dump_stabs): Add sections for Darwin. + +2008-08-25 Alan Modra + + * sysdep.h: Include "binary-io.h". + (O_BINARY): Don't define here. + * bin2c.c (O_BINARY, O_TEXT, SET_BINARY): Don't define here. + * strings.c: Likewise. + (main): Remove #ifdef SET_BINARY. + * Makefile.am: Run "make dep-am" + * Makefile.in: Regenerate. + +2008-08-24 Alan Modra + + * configure.in: Update a number of obsolete autoconf macros. + * configure: Regenerate. + * aclocal.m4: Regenerate. + +2008-08-21 Richard Henderson + + * readelf.c (is_32bit_pcrel_reloc): Fix hppa entry. + (is_64bit_pcrel_reloc): New. + (debug_apply_relocations): Use it. Handle hppa pcrel bias. + +2008-08-15 Alan Modra + + PR 6526 + * configure.in: Invoke AC_USE_SYSTEM_EXTENSIONS. + * Makefile.in: Regenerate. + * aclocal.m4: Regenerate. + * config.in: Regenerate. + * configure: Regenerate. + * doc/Makefile.in: Regenerate. + +2008-08-09 Alan Modra + + PR 6615 + * rename.c (smart_rename): Punctuate error messages. + +2008-08-08 Richard Sandiford + Daniel Jacobowitz + Catherine Moore + Mark Shinwell + + * readelf.c (get_mips_symbol_other): Handle STO_MIPS_PLT and + STO_MIPS_PIC. + (slurp_rela_relocs, slurp_rel_relocs): Handle MIPS ELF64 here. + (dump_relocations, debug_apply_relocations): Don't handle it here. + (get_mips_dynamic_type): Handle DT_MIPS_PLTGOT and DT_MIPS_RWPLT. + (print_mips_pltgot_entry): New function. + (process_mips_specific): Dump the PLT GOT. + +2008-08-08 Alan Modra + + * readelf.c (is_64bit_abs_reloc): Return true for R_MIPS_64. + +2008-08-06 Alan Modra + + PR 6774 + * objcopy.c (copy_object): Don't setup_bfd_headers when extract_symbol. + (setup_section): Don't zero vma and lma when extract_symbol. + (copy_section): Discard relocations when extract_symbol. + * doc/binutils.texi: Update --extract-symbol description. + +2008-08-04 Alan Modra + + * Makefile.am (POTFILES.in): Set LC_ALL=C. + * Makefile.in: Regenerate. + +2008-08-04 Markus Weiss + + * readelf.c (get_osabi_name ): Change name. + +2008-08-01 H.J. Lu + + * dwarf.c (dwarf_regnames_i386): Remove AVX registers. + (dwarf_regnames_x86_64): Likewise. + +2008-07-30 Alan Modra + + * dlltool.c, dwarf.c, objdump.c, readelf.c, resrc.c, resres.c, + windmc.c: Silence gcc warnings. + +2008-07-28 Alan Modra + + * readelf.c (print_vma): Typo fix. + +2008-07-28 Alan Modra + + PR 6769 + * readelf.c (print_dec_vma, print_hex_vma): Delete. + (print_vma): Use BFD_VMA_FMT. + * size.c (size_number, rprint_number): Likewise. + +2008-07-26 Michael Eager + + * readelf.c (display_power_gnu_attribute): Display + single-precision hard float. + +2008-07-21 Luis Machado + + * readelf.c (get_note_type): Handle VSX notes. + +2008-07-15 H.J. Lu + + * objdump.c (load_debug_section): Initialize section_is_compressed + for gcc 3.4/ia64. + * readelf.c (load_debug_section): Likewise. + +2008-07-12 Jie Zhang + + Revert + 2008-07-12 Jie Zhang + * readelf.c (get_machine_flags): Deal with Blackfin specific + flags. + +2008-07-12 Jie Zhang + + * readelf.c (get_machine_flags): Deal with Blackfin specific + flags. + +2008-07-09 Craig Silverstein + + * config.in: Add HAVE_ZLIB_H + * configure.in: Add test for libz and zlib.h + * configure: Regenerate. + * dwarf.c (debug_displays): Add .zdebug_* strings. + * dwarf.h (struct dwarf_section): Add fields uncompressed_namd + and compressed_name. + * objdump.c (load_debug_section): Call + bfd_uncompress_section_contents when loading a compressed + section. + (dump_dwarf_section): Recognize compressed section name. + (mach_o_dwarf_sections): Rename as + mach_o_uncompressed_dwarf_sections. + (mach_o_compressed_dwarf_sections): New variable. + (generic_dwarf_section): Rename as + generic_uncompressed_dwarf_sections. + (generic_compressed_dwarf_sections): New variable. + (check_mach_o_dwarf): Save and restore + mach_o_compressed_dwarf_sections. + * readelf.c: Add #include for config.h and zlib.h + (process_section_headers): Recognize compressed section name. + (uncompress_section_contents): New function. + (load_debug_section): Call uncompress_section_contents when + loading a compressed section. + (display_debug_section): Recognize compressed section name. + +2008-07-07 Alan Modra + + * objdump.c (find_symbol_for_address): Prefer symbols in current + section. + +2008-07-07 Alan Modra + + * ieee.c (write_ieee_debugging_info): Use bfd_make_section_with_flags. + * nlmconv.c (main, powerpc_build_stubs): Likewise. + * rescoff.c (write_coff_file): Likewise. + * resres.c (write_res_file): Likewise. + * windmc.c (windmc_write_bin): Likewise. + +2008-06-18 M R Swami Reddy + + * readelf.c (guess_is_rela): Add EM_CR16_OLD. + (dump_relocations): Likewise. + (get_machine_name): Likewise. + (is_32bit_abs_reloc): Likewise. + +2008-06-17 Ralf Wildenhues + + * configure: Regenerate. + +2008-06-12 DJ Delorie + + * readelf.c (guess_is_rela): Add EM_M32C_OLD. + (dump_relocations): Likewise. + (process_section_headers): Likewise. + (is_32bit_abs_reloc): Likewise. + (is_16bit_abs_reloc): Likewise. + +2008-06-12 Nick Clifton + + PR binutils/6483 + * objdump.c (dump_bfd): If the -g option found no STABS or IEEE + debug information to display, try dumping DWARF information + instead. + * rddbg.c (read_debugging_info): Add a parameter to suppress the + display of a warning message when no debug information is found. + * budbg.h (read_debugging_info): Update prototype. + * objcopy.c (copy_object): Continue to allow read_debugging_info + to produce warning messages. + * doc/binutils.texi (--debugging): Document new behaviour of the + -g/--debugging option. + +2008-06-10 Ben Elliston + + * MAINTAINERS: Remove myself as m68k maintainer. + +2008-05-14 Alan Modra + + * Makefile.in: Regenerate. + * doc/Makefile.in: Regenerate. + +2008-05-12 Alan Modra + + * embedspu.sh: Test for presence of ._ea by looking at section + table rather than looking at relocs. Correct toe_addr substitution. + +2008-05-08 Alan Modra + + * embedspu.sh: Take note of R_SPU_PPU32/64 relocs without a symbol, + and if present, put image in ".data.speelf". Put program handle + in ".data.spehandle". + +2008-05-01 Nick Clifton + + * readelf.c (print_symbol): Add code to display non-printing + characters. + +2008-04-30 John Heidemann + + * doc/binutils.texi (strings): Add "unicode" to the documentation + of strings in order to make explicit that it supports this + feature. + +2008-04-30 Alan Modra + + * readelf.c (process_program_headers): Correct section in segment + display. + +2008-04-28 M Thomas + Nick Clifton + + PR binutils/6449 + * objdump.c (slurp_file): Open the file in binary mode. + * ar.c: Remove conditional definition of O_BINARY. + * bin2.c: Likewise. + * rename.c: Likewise. + * strings.c: Likewise. + * sysdep.h: Add conditional definition of O_BINARY. + +2008-04-23 Paolo Bonzini + + * aclocal.m4: Regenerate. + * configure: Regenerate. + +2008-04-16 Jean-Yves Lefort + + PR binutils/6034 + * objcopy.c (stuct symlist): Rename to + is_specified_symbol_predicate_data. + (strip_specific_list): Rename to strip_specific_htab. + (strip_unneeded_list): Rename to strip_unneeded_htab. + (keep_specific_list): Rename to keep_specific_htab. + (localize_specific_list): Rename to localize_specific_htab. + (globalize_specific_list): Rename to globalize_specific_htab. + (keepglobal_specific_list): Rename to keepglobal_specific_htab. + (weaken_specific_list): Rename to weaken_specific_htab. + (eq_string): New function. + (create_symbol_htab): New function. + (create_symbol_htabs): New function. + (add_specific_symbol): Change to use hash tables. + (is_specified_symbol_predicate): New function. + (is_specified_symbol): Use hash table lookup. + (is_strip_section): Update to use new functions and hash tables. + (filter_symbols): Likewise. + (copy_object): Likewise. + (copy_section): Likewise. + (strip_main): Likewise. + (copy_main): Likewise. + (main): Likewise. + +2008-04-14 David S. Miller + + * readelf.c (get_gnu_elf_note_type): Recognize NT_GNU_GOLD_VERSION. + +2008-04-11 Torleif Sandnes + + * dwarf.c (display_debug_lines): Rename to + display_debug_lines_raw. + (display_debug_lines_decoded): New function. Displays the + interpreted contents of a .debug_line section. + (display_debug_lines): New function: Selects either a raw dump or + a decoded dump (or both) as requested by the user. + * dwarf.h (do_debug_lines_decoded): New extern. + * readelf.c: Add support for -wL or --debug-dump=decodedline + option to display the decoded contents of a .debug_line section. + * doc/binutils.texi: Document the new option. + * NEWS: Mention the new feature. + +2008-04-08 Alan Modra + + * dwarf.c: Remove trailing whitespace throughout file. + +2008-04-04 Nick Clifton + + * po/sk.po: Updated Slovak translation. + +2008-04-03 H.J. Lu + + * dwarf.c (dwarf_regnames_i386): Add AVX registers. + (dwarf_regnames_x86_64): Likewise. + +2008-03-27 Cary Coutant + + Add support for thin archives. + * ar.c (make_thin_archive): New global flag. + (map_over_members): Deal with full pathnames in thin archives. + (usage, main): Add 'T' option for building thin archives. + (replace_members): Pass thin archive flag to ar_emul_append. + * arsup.c (ar_open): Initialize new flag. + * binemul.c (ar_emul_append): Add new parameter for + flattening nested archives. + (do_ar_emul_default_append): New function. + (ar_emul_default_append): Factored out recursive code. + * binutils/binemul.h (ar_emul_default_append): Add new parameter. + (struct bin_emulation_xfer_struct): New parameter for ar_append. + * dlltool.c (gen_lib_file): Initialize thin archive flag. + * emul_aix.c (ar_emul_aix_internal): Add new flatten + parameter, currently unimplemented. + All callers changed. + * objcopy.c (copy_archive): Preserve thin archive flag. + * doc/binutils.texi: Update ar documentation. + * NEWS: Mention the new feature. + +2008-03-20 H.J. Lu + + * readelf.c (process_mips_specific): Declare addr_size as int. + +2008-03-20 Richard Sandiford + + * readelf.c (print_mips_got_entry): New function. + (process_mips_specific): Print GOT information. + +2008-03-17 Ralf Wildenhues + + * aclocal.m4: Regenerate. + * configure: Likewise. + * Makefile.in: Likewise. + * doc/Makefile.in: Likewise. + +2008-03-16 Brian Dessent + + * rcparse.y (resid): Allow control text to span multiple lines. + +2008-03-13 Alan Modra + + * readelf.c: Use %u throughout when printing sh_link or sh_info, + %lu when printing sh_addralign. + (process_version_sections): Use identical formats when printing + all offset and sh_link fields. + +2008-03-13 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + * doc/Makefile.in: Regenerate. + * configure: Regenerate. + +2008-03-12 Alan Modra + + PR 5900 + * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. + Remove use throughout file. + (SECTION_HEADER): Likewise. + (dump_relocations): Don't adjust st_shndx for reserved range. + (process_file_header): Mask SHN_XINDEX to values seen in external + elf structs. Simplify valid section index tests. + (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. + Map reserved st_shndx to internal form. + (process_section_groups): Test that group symbol st_shndx is in + range, not just non-zero. Delete reserved range check. + (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, + OS or RSV. + +2008-03-09 Paul Brook + + * readelf.c (arm_attr_tag_VFP_arch): Add "VFPv3-D16". + +2008-03-03 James E. Wilson + + * MAINTAINERS: Update my email address. + +2008-03-03 Nick Clifton + + * dwarf.c (decode_location_expression): Handle + DW_OP_PGI_omp_thread_num. + +2008-03-01 Alan Modra + + * objdump.c (objdump_print_addr): Initialise "sym". + +2008-02-27 Justin Pryzby + Nick Clifton + + * ar.c (usage): Mention -t command line switch. + * doc/binutils.texi (ranlib): Document -t command line switch. + +2008-02-26 Nick Clifton + + * objdump.c (objdump_print_addr): If displaying file offsets, show + the offset even if there are no symbols available. + (dump_section): Display nothing if none of the section is going to + be dumped. Display the file offset, if requested, of the location + from where the dump starts. + * doc/binutils.texi (objdump): Mention that dumping via the -s + switch is also affected by the -F option. + +2008-02-26 Nick Clifton + + Re-apply this patch which was accidentally deleted: + 2006-05-16 Carlos O'Donell + + * doc/binutils.texi: Use "Binutils Index" for index name. + +2008-02-22 Nick Clifton + + * objdump.c (display_file_offsets): New variable. + (long_options): Add -F/--file-offsets. + (objdump_print_addr_with_sym): If displaying file offsets, print + the offset of the given address. + (disassemble_bytes): If displaying file offsets, tell the user how + many zeroes are skipped and the file offset of the point where + dumping resumes. + (disassemble_section): Only display the name of the section if + data is going to be dumped from it. + (main): Handle new option. Produce error messages if the start or + stop addresses do not make sense. + * doc/binutils.texi: Document the new feature. + * NEWS: Mention the new feature. + +2008-02-15 Chu Li + Nick Clifton + + PR binutils/5713 + * strings.c (integer_arg): Delete function. + (string_min): Initialise to 4. + (main): Use strtoul to parse integer arguments. + Move check for an invalid string length to after all the arguments + have been parsed. + (usage): Use indentation to indicate that - is a another form + of the --bytes= command line option. + +2008-02-12 Nick Clifton + + * dlltool.c (mcore_elf_cache_filename): Add a const qualifier to + the argument. + (scan_obj_filename): Do not drop the const qualifier when calling + mcore_elf_cache_filename. + (struct fname_cache): Add const qualifier to filename field. + +2008-02-08 H.J. Lu + + PR binutils/5713 + * strings.c (main): Set string_min to 4 if it is <= 0. + +2008-02-07 Alan Modra + + * objdump.c (main): Don't pass unadorned NULL to concat. + +2008-02-04 H.J. Lu + + PR 5715 + * configure: Regenerated. + +2008-02-03 Adam Nemet + + * readelf.c (get_machine_flags): Handle Octeon. + +2008-01-30 Tristan Gingold + + * readelf.c (dump_relocations): Decode OpenVMS-specific sections. + (get_ia64_dynamic_type): Decode OpenVMS-specific tags. + (get_dynamic_type): Handle IA64-specific tags. + (get_ia64_section_type_name): Handle OpenVMS-specific sections. + (get_section_type_name): Handle OS-specific sections (and + particularly IA64 OpenVMS one). + (get_elf_section_flags): Makes flags static. Add entries for IA64 and + decode them. + +2008-01-29 Nick Clifton + + * dwarf.c (print_dwarf_vma): New function. Display the value of a + dwarf_vma type at a specified precision. Use mingw field type + specifier if necessary. + (display_debug_loc): Use dwarf_vma type for begin and end values. + Use print_dwarf_vma to display their values. Use byte_get_signed + in order to correctly detect the -1 escape value. + (display_debug_aranges): Likewise. + (display_debug_ranges): Likewise. + +2008-01-29 Alan Modra + + * dwarf.c (display_debug_loc): Correct test for base address + entry when 64-bit host dumping 32-bit object. + +2008-01-29 Alan Modra + + * MAINTAINERS: Remove myself as ix86 maintainer. Add for SPU. + +2008-01-28 Nick Clifton + + PR binutils/5529 + * rclex.c (yylex): Also allow the hypen character. + +2008-01-28 H.J. Lu + + * dwarf.c: Include "elf/common.h". + (eh_addr_size): Changed to int. + (dwarf_regnames_i386): New. + (dwarf_regnames_x86_64): Likewise. + (dwarf_regnames): Likewise. + (dwarf_regnames_count): Likewise. + (init_dwarf_regnames): Likewise. + (regname): Likewise. + (frame_display_row): Properly support different address size. + Call regname to get register name. + (display_debug_frames): Call regname to get register name. + Display DW_CFA_def_cfa_register as DW_CFA_def_cfa_register + instead of DW_CFA_def_cfa_reg. + + * dwarf.h (init_dwarf_regnames): New. + + * objdump.c: Include "elf-bfd.h". + (dump_dwarf): Call init_dwarf_regnames on ELF input. + + * readelf.c (guess_is_rela): Change argument to int. + (parse_args): Remove the undocumented upper case options for + -wX. + (process_file_header): Call init_dwarf_regnames. + +2008-01-25 DJ Delorie + + * readelf.c (process_section_headers): Add m16c handler. + (is_16bit_abs_reloc): Recognize R_M32C_16. + +2008-01-25 Kai Tietz + + * prdbg.c: Correct formatter style use. + * readelf.c: Likewise. + * strings.c: Likewise. + +2008-01-25 Nick Clifton + + * po/ru.po: Updated Russian translation. + +2008-01-17 H.J. Lu + + * MAINTAINERS: Update my email address. + +2008-01-14 Nick Clifton + + * dwarf.c (process_debug_info): Include the CU offset and corrupt + version value when reporting unrecognised DWARF version numbers. + (load_debug_info): Remember a failed attempt to load and parse the + .debug_info section and do not repeat such attempts. + (display_debug_lines): Check the return value from load_debug_info + and return whilst displaying a warning message if the load failed. + (display_debug_loc): Likewise. + (display_debug_ranges): Likewise. + (DEBUG_INFO_UNAVAILABLE): Value stored in num_debug_info_entries + when the .debug_info section could not be loaded/parsed. + (process_debug_info): Display the length of the compilation unit + in hex, so that it corresponds with the offsets that will follow. + Tell the user if the length was 32-bit or 64-bit. + If a DIE abbreviation could not be found, tell the user the offset + of the DIE. + (free_debug_memory): Do not attempt to free any entries in the + debug_information array if num_debug_info_entries is set to + DEBUG_INFO_UNAVAILABLE. + +2008-01-10 Andreas Schwab + + * readelf.c (is_64bit_abs_reloc): Handle R_S390_64. + +2008-01-09 Jakub Zawadzki + + PR binutils/55326 + * bucomm.c (list_supported_architectures): Free architecture list + after use. + * windres.c (set_endianess): Likewise. + * windmc.c (set_endianess): Likewise. + +2008-01-08 Kai Tietz + + PR binutils/5529 + * binutils/rclex.c: (yylex): Add ':', '_', '\\', and '/' to post + characters for name tokens. + +2008-01-04 Greg McGary + + * prdbg.c (print_vma): Print as long long, if host supports it. + +2008-01-03 Nick Clifton + + * dwarf.c (read_and_display_attr_value): Prefix values that are + displayed in hexadecimal with 0x. + For the DW_AT_import attribute display the abbreviation number and + tag of the imported DIE. + (process_debug_info): Warn about lengths that reserved by the + DWARF3 specification. + Provide more information when corrupted DIEs are detected. + Warn if DIE corruption makes the sibling level negative. + +For older changes see ChangeLog-2007 + +Copyright (C) 2008 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2009 b/support/sdbinutils/binutils/ChangeLog-2009 new file mode 100644 index 0000000..d5f9357 --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2009 @@ -0,0 +1,1361 @@ +2009-12-31 Eirik Byrkjeflot Anonsen + Nick Clifton + + * objcopy.c (add_redefine_syms_file): Avoid symbol buffer + overrun. + +2009-12-21 Alan Modra + + * MAINTAINERS: Update my email address. + +2009-12-18 Ulrich Weigand + + * readelf.c (get_note_type): Handle NT_S390_HIGH_GPRS notes. + +2009-12-11 Nick Clifton + + * Makefile.in: Regenerate. + * doc/Makefile.in: Regenerate. + * ar.c: Fix shadowed variable warnings. + * bucomm.c: Likewise. + * coffgrok.c: Likewise. + * configure: Likewise. + * dlltool.c: Likewise. + * dllwrap.c: Likewise. + * dwarf.c: Likewise. + * ieee.c: Likewise. + * nlmconv.c: Likewise. + * nm.c: Likewise. + * objcopy.c: Likewise. + * objdump.c: Likewise. + * prdbg.c: Likewise. + * readelf.c: Likewise. + * resbin.c: Likewise. + * resrc.c: Likewise. + * resres.c: Likewise. + * srconv.c: Likewise. + * stabs.c: Likewise. + * sysdump.c: Likewise. + * sysinfo.y: Likewise. + * wrstabs.c: Likewise. + +2009-12-10 Tristan Gingold + + * addr2line.c (pretty_print): New variable. + (long_options): Add an entry for -p/--pretty-print. + (usage): Document -p/--pretty-print. + (translate_addresses): Handle pretty_print. Reindent. + (main): Handle option -p. + * doc/binutils.texi (addr2line): Document -p/--pretty-print. + * NEWS: Mention new feature. + +2009-12-09 Tristan Gingold + + * addr2line.c (translate_addresses): Display addresses + if option -a is used. + (with_addresses): New variable. + (long_options): Add option '-a'. + (usage): Add usage for option '-a'. + (main): Handle option '-a'. + * doc/binutils.texi (addr2line): Document option '-a'. + * NEWS: Mention new feature. + +2009-12-08 Cary Coutant + + * dwarf.c (dwarf_select_sections_by_names): Handle pubtypes correctly. + (debug_displays): Remove duplicate entry for debug_pubtypes. + +2009-12-03 David Daney + Adam Nemet + + * readelf.c (get_machine_flags): Handle E_MIPS_MACH_OCTEON2 case. + +2009-12-03 Nick Clifton + + PR binutils/11045 + * dwarf.c (do_debug_pubtypes): New variable. + (dwarf_select_sections_by_names): Handle .debug_pubtypes. + (dwarf_select_sections_by_letters): Add 't' for .debug_pubtype. + (dwarf_select_sections_all): Set do_debug_pubtypes. + (debug_displays): Add support for .debug_pubtypes. + * dwarf.h (do_debug_pubtypes): Export. + * objdump.c (usage): Add -wt or --dwarf=pubtypes. + * readelf.c (usage): Likewise. + (process_section_headers): Enable debug display if + do_debug_pubtypes is set. + * doc/binutils.texi: Document -wt/--dwarf=pubtypes option. + +2009-12-02 Jerker Bäck + + PR binutils/11017 + * dlltool.c (PAGE_SIZE): Delete. + (PAGE_MASK): Provide default definition based on COFF_PAGE_SIZE. + Check for DLLTOOL_DEFAULT_MX86_64 and DLLTOOL_DEFAULT_I386. + +2009-12-01 Joseph Myers + + * readelf.c (get_machine_name, get_osabi_name): Handle more + allocated values. + +2009-11-30 Joseph Myers + + * configure: Regenerate. + +2009-11-20 Nick Clifton + + * readelf.c: Include xc16x.h. + (dump_relocations): Handle relocations for the xc16x target. + (get_machine_name): Accept EM_C166 for xc16x targets. + (is_32bit_abs_reloc): Add support for xc16c 32-bit absolute reloc. + (is_16bit_abs_reloc): Add support for xc16c 16-bit absolute reloc. + (is_none_reloc): Add support for xc16c null reloc. + +2009-11-20 Ben Elliston + + * Makefile.am (syslex.o): Use $(NO_WERROR) not -Wno-error. + (sysinfo.o): Likewise. + * Makefile.in: Regenerate. + +2009-11-19 Ben Elliston + + * arlex.l: Enable noinput, nounput flex options. + * syslex.l: Likewise. + +2009-11-17 Paul Brook + Daniel Jacobowitz + + * readelf.c (arm_attr_tag_CPU_arch): Add v7E-M. + +2009-11-16 Kai Tietz + + * windmc.c (set_endianess): Use bfd_get_target_info. + * windres.c (set_endianess): Likewise. + (find_arch_match): Removed. + +2009-11-11 Nick Clifton + + * po/id.po: Updated Indonesian translation. + +2009-11-11 Jan Kratochvil + + * configure.in: Stop checking for fopen64 and stat64. + * strings.c (file_off, file_open, statbuf, file_stat): Remove. + (strings_file): Change file_off to file_ptr, file_open to fopen, + statbuf to struct stat and file_stat to stat. + (get_char): Change parameter type file_off * to file_ptr *. + (print_strings): Change parameter and variable `start' type file_off to + file_ptr. + * configure: Regenerate. + * config.in: Regenerate. + +2009-11-11 Jan Kratochvil + + * configure.in: Call ACX_LARGEFILE. Stop calling AC_PLUGINS, + AC_SYS_LARGEFILE and checking the Solaris largefile exception. + * aclocal.m4: Regenerate. + * configure: Regenerate. + +2009-11-09 Jan Kratochvil + + * bucomm.c (get_file_size): Update comment for the error return value. + +2009-11-08 John David Anglin + + * readelf.c (slurp_hppa_unwind_table): Don't relocate address twice. + +2009-11-05 Kai Tietz + + * dllwrap.c (is_leading_underscore): New variable. + (cpu_type): New enum type. + (which_cpu): New variable. + (usage): Add new options --no-leading-underscore + and --leading-underscore. + (long_options): Likewise. + (OPTION_NO_LEADING_UNDERSCORE): New define. + (OPTION_LEADING_UNDERSCORE): Likewise. + (main): Initialize which_host, pass new options + to dlltool, do underscoring dependent on + is_leading_underscore, and do '@12' decoration + only for x86. + +2009-11-02 Paul Brook + + * readelf.c (arm_attr_tag_VFP_arch): Add VFPv4 and VFPv4-D16. + +2009-10-28 Kai Tietz + + * dlltool.c (leading_underscore): New local variable. + (asm_prefix): Interpret leading_underscore. + (xlate): Likewise. + (add_excludes): Use leading_underscore for making + symbol name. + (gen_exp_file): Use leading_underscore for internal + _imp_ symbols. + (usage): Add display of --no-leading-underscore and + --leading-underscore option. + (OPTION_NO_LEADING_UNDERSCORE): New. + (OPTION_LEADING_UNDERSCORE): New. + (long_options): Add --no-leading-underscore and + --leading-underscore option. + (main): Handle new options. + * doc/binutils.text: Add documentation of the options + --no-leading-underscore and --leading-underscore. + +2009-10-23 Kai Tietz + + * deflex.l: Allow '<' and '>' in ID names. + + * defparse.y (EQUAL): New token constant. + (opt_import_name): New rule for emptry or '==' ID. + (expline): Add opt_import_name as last line element. + (impline): Likewise. + * dlltool.c (ifunct): New member its_name. + (export): Likewise. + (append_import): Add its_name argument. + (defexports): Likewise. + (defimport): Likewise. + (scan_drectve_symbols): Adjust calls to def_exports. + (dump_def_info): Print new optinal import/export table + symbol name. + (generate_idata_ofile): Use its_name member. + (make_one_lib_file): Likewise. + (nfunc): Take its_name in account on sort. + * dlltool.h (def_exports): Add its_name as argument. + (def_import): Likewise. + * doc/binutils.texi: Add new def file syntax extension. + * deflex.l (EQUAL): Add rule for '=='. + * NEWS: Mention new feature. + +2009-10-23 Thomas Cougnard + + * readelf.c (dynamic_info): Correct size of array. + +2009-10-21 Ben Elliston + + * MAINTAINERS (BUILD SYSTEM, TESTSUITES): Remove myself. + +2009-10-19 Jerker Bäck + + PR binutils/10793 + * prdbg.c (tg_end_struct_type): Warning fix. + + PR binutils/10792 + * dlltool.c (dll_name_list_append): Declare variable at start + of block. + (dll_name_list_count, dll_name-list_print): Likewise. + +2009-10-16 Doug Evans + + * MAINTAINERS: Add myself as m32r maintainer. + +2009-10-16 Jerker Bäck + + PR 10764 + * Makefile.am (sysinfo.o, syslex.o): Place source file after all + command line switches. + * Makefile.in: Regenerate. + +2009-10-16 Yann Droneaud + + PR 10768 + * dlltool.c (bfd_get_errmsg): New macro. + (scan_obj_file): Use it. + (make_one_lib_file): Use it. + (make_head): Use it. + (make_delay_head): Use it. + (make_tail): Use it. + (gen_lib_file): Use it. + (identify_dll_for_implib): Use it. + (identify_search_archive): Use it. + +2009-10-16 Nick Clifton + + * readelf.c (usage): Add mention of --debug-dump=frames-interp. + Wrap output to 80 columns. + * objdump.c (usage): Likewise. + * doc/binutils.texi (readelf): Add note about =frames-interp. + +2009-10-01 Alan Modra + + * addr2line.c (slurp_symtab): Don't use bfd_read_minisymbols. + +2009-09-29 Nick Clifton + + * doc/binutils.texi (c++filt): Remove spurious description of + nonexistent --java command line switch for cxxfilt. + +2009-09-29 DJ Delorie + + * readelf.c: Add support for RX target. + * MAINTAINERS: Add DJ and NickC as maintainers for RX. + +2009-09-28 Alan Modra + + * configure.in: Don't invoke configure.tgt on $enable_targets. + * configure: Regenerate. + +2009-09-28 Nick Clifton + + PR 10478 + * readelf.c (get_elf_section_flags): Allow SHN_BEFORE and + SHN_AFTER section link values in x86 binaries. + (process_section_headers): Likewise. + +2009-09-25 Dmitry Gorbachev + + PR 10656 + * readelf.c: Remove duplicate declaration of variable do_wide. + * dwarf.h: Add export of do_wide. + +2009-09-24 Cary Coutant + + * dwarf.c (get_TAG_name): Add missing DWARF-3 and new DWARF-4 tags. + (get_FORM_name): Add new DWARF-4 forms. + (read_and_display_attr_value): Add DW_FORM_ref_sig8, DW_LANG_Python. + (get_AT_name): Add new DWARF-4 and GNU-specific attributes. + (process_debug_info): Add do_types parameter; change all callers. + Add support for .debug_types sections. + (display_debug_types): New function. + (debug_displays): Add .debug_types section. + * readelf.c (process_section_headers): Add .debug_types section. + (display_debug_section): Simplify call to streq. + +2009-09-25 Alan Modra + + * readelf.c (print_dynamic_symbol): Format entries as for + normal symbol table. + (process_symbol_table): Use -7s format string for visibility. + +2009-09-22 Richard Sandiford + + * objdump.c (disassemble_section): Use bfd_get_arch_size + instead of assuming that the address size is 32 bits. + +2009-09-21 Alan Modra + + * readelf.c (get_ppc_dynamic_type): Add TLSOPT. + (get_ppc64_dynamic_type): Likewise. + +2009-09-18 Nick Clifton + + * po/es.po: Updated Spanish translation. + * po/vi.po: Updated Vietnamese translation. + +2009-09-11 Paul Pluzhnikov + + * readelf.c (process_version_sections, process_symbol_table): + Use symbolic constants. + +2009-09-11 Nick Clifton + + * po/binutils.pot: Updated by the Translation project. + +2009-09-11 Philippe De Muyter + + * obcopy.c (copy_object): New parameter `input_arch', architecture + of input file, if not specified in input file itself; all callers + updated; `binary_architecture' hack removed. + (copy_archive, copy_file): New parameter `input_arch', for + `copy_object' usage. + (copy_main): Accept `-B' (`--binary-architecture') option also + for any arch-less input ifile format, not only `binary'; remove + bfd_external_binary_architecture hack; instead, add `input_arch' + to calls to `copy_file'. + * windres.c, windmc.c : Obsolete and useless external references + to `bfd_external_binary_architecture' or `bfd_external_machine' + removed. + * doc/binutils.texi: Mention that -B parameter can be used for any + input file type which does not have its own architecture. + +2009-09-10 Martin Thuresson + + Update sources to compile cleanly with -Wc++-compat: + * addr2line.c (slurp_symtab): Fix casts. Introduce variable + minisyms to avoid aliasing varning. + * ar.c: Add casts. + (normalize): Use name del instead of delete. + (display_target_list,display_info_table): Change loop counter + variable a to int. + * bucomm.c: Add casts. + * debug.c: Update function to use new names. + (struct debug_baseclass): Rename member from virtual to + is_virtual. + (struct debug_type_s, struct debug_field_s, struct + debug_baseclass_s, struct debug_method_s, struct + debug_method_variant_s, struct debug_type_s): Rename struct from + avoid name collision. + * debug.h: Use new struct names. + * dwarf.c: Add casts. + (free_debug_memory): Change loop counter variable a to int. + * ieee.c: Add casts. + (enum ieee_var_kind): Move to top level. + (ieee_class_baseclass): Rename parameter virtual to is_virtual. + (ieee_class_method_var): Rename variable virtual to is_virtual. + * nm.c: Add casts. + * objcopy.c: Add casts. + (copy_archive): Rename variable delete to del. + * objdump.c: Add casts. + (dump_dwarf_section): Change loop counter variable i to int. + * prdbg.c: Add casts. + (pr_class_baseclass,tg_class_baseclass): Rename parameters virtual + to is_virtual. + * readelf.c: Add casts. + (struct ia64_unw_table_entry,struct hppa_unw_table_entry): Move to + top level. + * size.c: Add casts. + * stabs.c (parse_stab_type, parse_stab_range_type, + (parse_stab_cpp_abbrev): Rename parameter from typename to + type_name. + (parse_stab_baseclasses): Rename variable virtual to is_virtual. + * strings.c: Add casts. + * wrstabs.c (stab_class_baseclass): Rename parameter virtual to + is_virtual. + +2009-09-09 Nick Clifton + + PR 10478: + readelf.c (get_elf_section_flags): Add support for SHF_EXCLUDE and + SHF_ORDERED. + (process_section_headers): Warn about out of range sh_link + values. When displaying detailed section header information + annote the SHN_BEFORE and SHN_AFTER values. + +2009-09-08 Alan Modra + + * dwarf.c (byte_get_little_endian): Handle size of 3. + (byte_get_big_endian): Likewise. + * readelf.c (byte_put_little_endian): Likewise. + (byte_put_big_endian): Likewise. + (is_24bit_abs_reloc): New function. + (is_none_reloc): Formatting. + (apply_relocations): Use is_24bit_abs_reloc. Handle pj and xtensa + reloc peculiarity. + +2009-09-07 Jan Kratochvil + + * readelf.c (is_none_reloc , is_none_reloc ): + New. + +2009-09-07 Jan Kratochvil + + * dwarf.c (process_debug_info): Support section padding abbrev codes. + +2009-09-07 Tristan Gingold + + * po/binutils.pot: Regenerate. + +2009-09-05 Jan Kratochvil + + * Makefile.am (sysdump.o): Depend on sysroff.c. + * Makefile.in: Regenerate. + +2009-09-05 Martin Thuresson + + * ieee.c (ieee_read_cxx_misc, ieee_read_cxx_class, + ieee_read_reference): Rename variables named class to cxxclass. + +2009-09-04 Tristan Gingold + + * BRANCHES: Add binutils-2_20-branch. + +2009-09-04 Tristan Gingold + + * NEWS: Add marker for 2.20. + +2009-09-04 Timo Kreuzer + + * dlltool.c (delayimp_name): Add new global variable + (usage, long_options, main): Add new option "-y" / "--output-delaylib" + (struct mac): Add fields how_dljtab_size, how_dljtab_roff1, + how_dljtab_roff2, how_dljtab, trampoline. + (i386_dljtab): Add binary stub for x86 delay import. + (i386_trampoline): Add text assembly stub for x86 delay import. + (mtable): Add delay import data for M386 and MX86 only. + (make_delay_head): New function. + (make_one_lib_file): New arg delay creates delay-load import stub. + (gen_lib_file): New arg delay likewise. + (HOW_JTAB, HOW_JTAB_SIZE, HOW_JTAB_ROFF): New arg delay likewise. + (HOW_JTAB_ROFF2, HOW_JTAB_ROFF3): New macros for delay import. + (make_tail): Convert hard TABS embedded in strings to "\t" escapes. + * NEWS: Mention new feature. Also fix whitespace. + * doc/binutils.texi: Updated dlltool documentation. + +2009-09-02 Tristan Gingold + + * configure.com: Do not copy makefile.vms-in to makefile.vms + * makefile.vms-in: Renamed to... + * makefile.vms: ... this usual name as it is not processed anymore. + Remove WRITE_DEBUG_OBJS (unused) and reorder object files for + objdump.exe. + +2009-09-01 Ralf Wildenhues + + * Makefile.am (arparse.o, arlex.o, sysroff.o, defparse.o) + (deflex.o, nlmheaders.o, rcparse.o, mcparse.o): Supply correct + source file name for generated files which may be in $(srcdir). + * Makefile.in: Regenerate. + +2009-09-01 H.J. Lu + + * version.c (print_version): Change to "Copyright 2009". + +2009-09-01 Tristan Gingold + + * makefile.vms-in: Remove unused VERSION variable. Remove unused + dependencies. + * configure.com: Ported to Itanium VMS. Create build.com DCL script. + +2009-08-29 Martin Thuresson + + * nlmconv.c (main): Rename variable new to new_name. + +2009-08-28 H.J. Lu + + * Makefile.am (sysinfo$(EXEEXT_FOR_BUILD)): Replace + CFLAGS/LDFLAGS with CFLAGS_FOR_BUILD/LDFLAGS_FOR_BUILD. + (syslex.o): Likewise. + (sysinfo.o): Likewise. + (bin2c$(EXEEXT_FOR_BUILD)): Likewise. + * Makefile.in: Regenerated. + +2009-08-27 Dave Korn + + * doc/binutils.texi (--only-keep-debug): Relocate stray para here ... + (--subsystem): ... from here. + +2009-08-24 Cary Coutant + + * objdump.c (find_symbol_for_address): Avoid costly call to + bfd_octets_per_byte. + +2009-08-24 Ralf Wildenhues + + * Makefile.am (am__skiplex, am__skipyacc): New. + * Makefile.in: Regenerate. + +2009-08-23 Ralf Wildenhues + + * Makefile.am (syslex.o): Depend on sysinfo.h config.h. + * Makefile.in: Regenerate. + +2009-08-22 Ralf Wildenhues + + * Makefile.am (AM_CPPFLAGS): Renamed from ... + (INCLUDES): ... this. + (bin2c$(EXEEXT_FOR_BUILD): Adjust rule. + (installcheck-local): Renamed from ... + (installcheck): ... this. + * Makefile.in: Regenerate. + + * Makefile.am (AUTOMAKE_OPTIONS): Remove cygnus, add no-dist and + foreign. + (MKDEP, CLEANFILES): Remove now-unneeded variables. + (DEP, DEP1, dep.sed, dep, dep-in, dep-am): Remove. + (mkdep section): Remove. + (BUILT_SOURCES): New variable, list $(GENERATED_HFILES). + (EXTRA_ar_SOURCES): New, list $(CFILES). + (syslex.o): Depend on syslex.c. + (sysinfo.o): Depend on sysinfo.c. + (arparse.h, defparse.h, nlmheaders.h rcparse.h mcparse.h): + Remove dependencies, now tracked by automake. + (srconv.o): Depend on sysroff.c. + (objdump.o, arparse.o, arlex.o, sysroff.o, defparse.o, deflex.o) + (nlmheader.o, rcparse.o, mcparse.o, rclex.o, mclex.o, dlltool.o) + (rescoff.o, nlmconv.o): Rewrite using automake-style dependency + tracking rules; only list the dependency upon the primary source + file, but no included headers. + * Makefile.in: Regenerate. + + * Makefile.am (install-pdf, install-pdf-recursive, install-html) + (install-html-recursive): Remove. + * Makefile.in: Regenerate. + * doc/Makefile.am (pdf__strip_dir, install-pdf, install-pdf-am) + (html__strip_dir, install-html, install-html-am): Remove. + * doc/Makefile.in: Regenerate. + + * Makefile.in: Regenerate. + * aclocal.m4: Likewise. + * config.in: Likewise. + * configure: Likewise. + * doc/Makefile.in: Likewise. + +2009-08-17 Nick Clifton + + * readelf.c (is_32bit_abs_reloc): Treat R_PARISC_SECREL32 as a + 32-bit absolute reloc for the purposes of processing debug + sections. + +2009-08-10 Daniel Gutson + + * readelf.c (get_arm_section_type_name): Added support for + new sections headers. + +2009-08-03 H.J. Lu + + PR binutils/10364 + * objcopy.c (strip_main): Check return from smart_rename. + (copy_main): Likewise. + +2009-07-27 Nick Clifton + + PR 10413 + * objdump.c (dump_section_header): Skip sections that we are + ignoring. + +2009-07-25 H.J. Lu + + * readelf.c (guess_is_rela): Handle EM_L1OM. + (dump_relocations): Likewise. + (get_machine_name): Likewise. + (get_section_type_name): Likewise. + (get_elf_section_flags): Likewise. + (get_symbol_index_type): Likewise. + (is_32bit_abs_reloc): Likewise. + (is_32bit_pcrel_reloc): Likewise. + (is_64bit_abs_reloc): Likewise. + (is_64bit_pcrel_reloc): Likewise. + (is_none_reloc): Likewise. + +2009-07-23 Ulrich Drepper + + * readelf.c (get_symbol_binding): For Linux targeted files return + UNIQUE for symbols with the STB_GNU_UNIQUE binding. + * doc/binutils.texi: Document the meaning of the 'u' symbol + binding in the output of nm and objdump --syms. + +2009-07-20 H.J. Lu + + * NEWS: Mention --insn-width. + + * objdump.c (insn_width): New. + (usage): Display --insn-width. + (option_values): Add OPTION_INSN_WIDTH. + (long_options): Add --insn-width. + (disassemble_bytes): Handle insn_width. + (main): Handle OPTION_INSN_WIDTH. + + * doc/binutils.texi: Document --insn-width. + +2009-07-17 Nick Clifton + + * dwarf.c (display_debug_lines): If do_debug_lines has not been + set then default to displaying raw .debug_line section contents. + +2009-07-14 Jan Kratochvil + + Support unordered .debug_info references to .debug_ranges. + * dwarf.c (struct range_entry, range_entry_compar): New. + (display_debug_ranges): Remove variables last_offset, first, j, + seen_first_offset, use_debug_info and next. New variables + range_entries and range_entry_fill. Create the sorted copy + range_entries. Remove the FIXME error on detected unordered references. + * dwarf.h (debug_info ): New comment. + +2009-07-14 Nick Clifton + + PR 10380 + * README: Document use of LDFLAGS="--static". + +2009-07-10 H.J. Lu + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerated. + +2009-07-10 Tom Tromey + + * Makefile.am (dwarf.o): Refer to dwarf2.h, not elf/dwarf2.h. + * Makefile.in: Rebuild. + * dwarf.c: Include dwarf2.h, not elf/dwarf2.h. + +2009-07-06 Tristan Gingold + + * objdump.c (dump_dwarf_section): Handle .eh_frame like other dwarf + sections. + * dwarf.h (struct dwarf_section_display): Remove eh_frame field. + * dwarf.c (debug_displays): Adjust for removed field. + +2009-07-03 Jakub Jelinek + + * dwarf.c (decode_location_expression): Handle DW_OP_stack_value + and DW_OP_implicit_value. + +2009-07-01 Nick Clifton + + PR 6714 + * rclex.c (handle_quotes): Do not complain about whitespace + separating quoted strings. + (rclex_string): Ignore whitespace when looking for a new opening + quote following a closing quote. + +2009-06-27 H.J. Lu + + PR binutils/10321 + * bucomm.c (get_file_size): Return -1 on error. + + * objcopy.c (copy_file): Report empty file. + +2009-06-23 Nick Clifton + + * dwarf.c (display_debug_lines_raw): Include the name of the + section in warning message. + (struct debug_display): Enable reloc processing for .debug_line + and .debug_ranges sections. + + * readelf.c: Add --relocated-dump command line option to dump the + relocated contents of a specified section. + (request_dump): New function. + (parse_args): Use it. + (dump_section_as_bytes): Add parameter to indicate whether the + contents should be relocated. + (target_specific_reloc_handling): Add code for a R_MN10300_16 + reloc found after a R_MN10300_SYM_DIFF reloc. + (debug_apply_relocations): Rename to apply_relocations. + (get_section_contents): New function. Replaces common code found + in dump_section_as_strings and dump_section_as_bytes. + * doc/binutils.texi: Document new command line option. + * NEWS: Mention the new feature. + +2009-06-22 Nick Clifton + + * readelf.c (target_specific_reloc_handling): New function: + Processes relocs in a target specific manner. + (debug_apply_relocations): Use the new function. + * dwarf.c (display_debug_loc): End the dump with a blank line. + (struct debug_display): Enable reloc processing for .debug_aranges + and .debug_loc sections. + +2009-06-19 Nick Clifton + + * ar.c (usage): Do not use #ifdef inside _("...). + * nm.c (usage): Likewise. + +2009-06-18 Nick Clifton + + PR 10288 + * objdump.c (disassemble_bytes): Set the + USER_SPECIFIED_MACHINE_TYPE flag in the disassemble_info structure + if the user has invoked the -m switch. + * doc/binutils.texi: Document the additional behaviour of + objdump's -m switch for ARM targets. + +2009-06-18 Dave Korn + + * configure.in: Merge cegcc and mingw32ce target name changes from + CeGCC project. + +2007-12-25 Pedro Alves + + * configure.in: Add arm*-*-cegcc* and arm*-*-mingw32ce* targets. + * configure: Regenerate. + +2009-06-15 Nick Clifton + + PR 10263 + * objdump.c (disassemble_bytes): Set the DISASSEMBLE_DATA bit in + the flags field of the disassemble_info structure if the -D switch + is in operation. + +2009-06-12 Homer Xing + + * NEWS: Mention new feature added to gprof. + +2009-06-12 John Reiser + + * readelf.c (process_symbol_table): Set gnubuckets to NULL after + freeing it and before returning. + +2009-06-12 Jakub Jelinek + + * readelf.c (process_symbol_table): Don't return early if + .hash/.gnu.hash is empty/unusable and not -D. + +2009-06-09 Tom Bramer + + PR 10165 + * winduni.c (wind_MultiByteToWideChar): Do not pass MB_PRECOMPOSED + to MultiByteToWideChar when using the CP_UTF8 or CO_UTF7 types. + +2009-06-04 Alan Modra + + * strings.c (main): Delay parsing of decimal digits. + +2009-06-04 Alan Modra + + * dep-in.sed: Don't use \n in replacement part of s command. + * Makefile.am (DEP1): LC_ALL for uniq. + Run "make dep-am". + * Makefile.in: Regenerate. + +2009-06-03 Tristan Gingold + + * MAINTAINERS: Add myself as Mach-O maintainer. + +2009-06-01 Alan Modra + + PR 10199 + * doc/binutils.texi (nm): Correct -S description. + +2009-05-28 Nick Clifton + + * po/da.po: Updated Danish translation. + +2009-05-28 Nick Clifton + + * readelf.c (display_debug_section): Do not display debug sections + with the NOBITS section type. + +2009-05-27 Rafael Avila de Espindola + + * aclocal.m4: Include ../config/plugins.m4. + * configure.in: Use AC_PLUGINS. + * configure: Regenerate. + * Makefile.in: Regenerate. + * doc/Makefile.in: Regenerate. + +2009-05-27 Rafael Avila de Espindola + + * ar.c (main): Call bfd_plugin_set_program_name. + * nm.c (main): Call bfd_plugin_set_program_name. + +2009-05-27 Nathan Sidwell + + * sysdump.c (tab): Use puts rather than two printfs. + +2009-05-26 Nick Clifton + + * po/id.po: Updated Indonesian translation. + * po/binutils.pot: Updated template file. + +2009-05-26 Rafael Avila de Espindola + + * ar.c: Include plugin.h. + (main): Handle the --plugin option. + * nm.c: Include plugin.h. + (OPTION_PLUGIN): New. + (long_options): Add plugin. + (main): Handle OPTION_PLUGIN. + * NEWS: Mention the new feature. + * doc/binutils: Documement the new command line options. + * configure.in: Check for --enable-plugins. + * configure: Regenerate. + +2009-05-26 Alan Modra + + * dep-in.sed: Output one filename per line with all lines having + continuation backslash. Prefix first line with "A", following + lines with "B". + * Makefile.am (DEP): Don't use dep.sed here. + (DEP1): Run $MKDEP on single files, use dep.sed here on dependencies, + sort and uniq. + * Makefile.in: Regenerate. + +2009-05-25 Tristan Gingold + + * makefile.vms-in: Fix CFLAGS, add addr2line.exe target. + + * configure.com: Fix it: handle alloca and define TARGET in config.h. + +2009-05-22 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + +2009-05-12 Alan Modra + + * objcopy.c (set_long_section_mode): Check input_bfd is coff + before accessing coff specific fields of bfd. + +2009-05-09 Dave Korn + + * MAINTAINERS: Add myself as PE/COFF co-maintainer. + +2009-05-08 Kai Tietz + + * winduni.c (iconv_onechar): Only define when HAVE_ICONV + is defined, but not when __CYGWIN__ or _WIN32 are defined. + See wind_iconv_cp for call logic of this local funtion. + +2009-05-05 Guillaume Duhamel + + PR 10109 + * winduni.c: Replace test of HAVE_ICONV_H with a test of + HAVE_ICONV. + (iconv_onechar): Use ICONV_CONST instead of "const". + (wind_MultiByteToWideChar): Initialise local strings. + +2009-04-30 Nick Clifton + + * readelf.c (dump_relocations): Display a relocation against an + ifunc symbol as if it were a function invocation. + (get_symbol_type): Handle STT_GNU_IFUNC. + +2009-04-29 Anthony Green + + * NEWS: Tweak verilog support description. + +2009-04-29 Alan Modra + Denis Scherbakov + + * readelf.c (slurp_ia64_unwind_table): Correct 64-bit unwind table + read, and merge with 32-bit case. + +2009-04-27 Anthony Green + + * NEWS: Mention verilog support added to bfd. + +2009-04-27 H.J. Lu + + * objcopy.c (copy_object): Copy pe_opthdr before changing PE + parameters. + +2009-04-24 Cary Coutant + + * dwarf.c (process_extended_line_op): Add DW_LNE_set_discriminator. + Add missing newlines to HP extensions. + +2009-04-17 H.J. Lu + + * objcopy.c (set_pe_subsystem): Replace efi-rom with sal-rtd. + * doc/binutils.texi: Likewise. + +2009-04-17 H.J. Lu + + PR binutils/10074 + * objcopy.c: Include coff/i386.h and coff/pe.h. + (pe_file_alignment): New. + (pe_heap_commit): Likewise. + (pe_heap_reserve): Likewise. + (pe_image_base): Likewise. + (pe_section_alignment): Likewise. + (pe_stack_commit): Likewise. + (pe_stack_reserve): Likewise. + (pe_subsystem): Likewise. + (pe_major_subsystem_version): Likewise. + (pe_minor_subsystem_version): Likewise. + (set_pe_subsystem): Likewise. + (convert_efi_target): Likewise. + (command_line_switch): Add OPTION_FILE_ALIGNMENT, + OPTION_HEAP, OPTION_IMAGE_BASE, OPTION_SECTION_ALIGNMENT, + OPTION_STACK and OPTION_SUBSYSTEM. + (copy_options): Likewise. + (copy_usage): Add --file-alignment, --heap, --image-base, + --section-alignment, --stack and --subsystem. + (copy_object): Set up PE parameters. + (copy_main): Process Add OPTION_FILE_ALIGNMENT, + OPTION_HEAP, OPTION_IMAGE_BASE, OPTION_SECTION_ALIGNMENT, + OPTION_STACK and OPTION_SUBSYSTEM. Convert EFI target to + PEI target. + + * NEWS: Mention --file-alignment, --heap, --image-base, + --section-alignment, --stack and --subsystem command line + options for objcopy. + + * doc/binutils.texi: Document --file-alignment, --heap, + --image-base, --section-alignment, --stack and --subsystem + command line options for objcopy. + +2009-04-15 Anthony Green + + * MAINTAINERS: Add myself as Moxie port maintainer. + +2009-04-14 Dave Korn + + * objcopy.c (enum long_section_name_handling): New enum type. + (enum command_line_switch): Add OPTION_LONG_SECTION_NAMES. + (copy_options[]): Add entry for --long-section-names option. + (copy_usage): Document it. + (set_long_section_mode): New subroutine. + (copy_file): Call it. + (copy_main): Accept OPTION_LONG_SECTION_NAMES and parse arg. + * doc/binutils.texi: Update objcopy documentation with details + of new option. + +2009-04-01 Dave Korn + + * dlltool.c (set_dll_name_from_def): Accept new second arg that + indicates if we are building DLL or EXE, and use it to add a + default suffix to the output filename when none is already present. + (def_name): Indicate we are building an EXE when calling it. + (def_library): Indicate we are building a DLL when calling it. + +2009-04-01 Jari Aalto + + PR 9972 + * doc/binutils.texi (strings): Document the -V alias for the + --version option. + * strings.c (usage): Likewise. + +2009-03-31 Nick Clifton + + PR 9992 + * configure.in: Import Solaris specific largefile test from + bfd/configure.in. + * configure: Regenerate. + +2009-03-30 Richard Sandiford + + * MAINTAINERS: Add self. + +2009-03-27 Nick Clifton + + * dwarf.c (display_debug_ranges): Add the base address to the + displayed values for 'Begin' and 'End'. + +2009-03-25 Ryan Mansfield + + * readelf.c (process_file_header): Don't report a corrupt string + table index if it is zero. + +2009-03-19 H.J. Lu + + * dwarf.c (dwarf_regnames): Moved before frame_need_space. + (dwarf_regnames_count): Likewise. + (frame_need_space): Return int. + (display_debug_frames): Check invalid registers. + +2009-03-19 H.J. Lu + + * readelf.c (debug_apply_relocations): Check relocations + against STT_SECTION symbol. + +2009-03-18 H.J. Lu + + * readelf.c (debug_apply_relocations): Allow relocations + against function symbols. + +2009-03-18 Alan Modra + + * sysdep.h: Include alloca-conf.h instead of config.h and remove + existing #if's handling alloca. + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + +2009-03-14 Richard Sandiford + + * configure.tgt: Extend AIX 5 behavior to AIX 6 and above. + * configure.in: Likewise. + * configure: Regenerate. + +2009-03-13 H.J. Lu + + PR binutils/9945 + * objcopy.c (copy_object): Clear HAS_RELOC when stripping all. + +2009-03-11 Chris Demetriou + + * ar.c (deterministic): New global variable. + (main): Recognize new 'D' option, which enables 'deterministic mode'. + (usage): Document new 'D' option. + (write_archive): Set BFD_DETERMINISTIC_OUTPUT in output archive's + flags if deterministic mode was requested. + * doc/binutils.texi (ar): Document deterministic mode ('D' option). + +2009-03-09 H.J. Lu + + PR binutils/9933 + * objcopy.c (filter_symbols): Properly handle common symbols + in relocatable file. + +2009-03-06 Nick Clifton + + * po/es.po: Updated Spanish translation. + +2009-03-05 Nick Clifton + + * objdump.c (disassemble_section): If the computed next offset is + not beyond the current offset then just continue to the end. + +2009-03-04 Tristan Gingold + + * MAINTAINERS: Add myself as VMS maintainer. + +2009-03-03 Nick Clifton + + * readelf.c: Update formatting. + +2009-03-03 Alan Modra + + * Makefile.am: Run "make dep-am". + * Makefile.in: Regenerate. + +2009-03-03 Alan Modra + + * objdump.c (disassemble_section): Mask address before sign extending. + +2009-03-02 Sebastian Biallas + + * ieee.c (parse_ieee_ty): Add support for undocumented 'v' type. + (parse_ieee_bb): Set the filename if it has not already been + discovered. + +2009-03-02 Cary Coutant + + * readelf.c (adjust_relative_path): New function. + (struct archive_info): New type. + (setup_archive): New function. + (release_archive): New function. + (setup_nested_archive): New function. + (get_archive_member_name): New function. + (get_archive_member_name_at): New function. + (make_qualified_name): New function. + (process_archive): Factor out code for reading archive index and + long filename table to setup_archive. Add support for thin archives. + +2009-03-02 Nick Clifton + + * po/sk.po: Updated Slovak translation. + +2009-03-01 Ralf Wildenhues + + * configure: Regenerate. + +2009-02-23 Cary Coutant + + * objdump.c (load_specific_debug_section): New function, from + load_debug_section. + (load_debug_section): Use load_specific_debug_section. + (dump_dwarf_section): Likewise. + +2009-02-23 Cary Coutant + + * readelf.c (parse_args): Select all sections explicitly for -w. + +2009-02-09 Kai Tietz + + * windres.c (set_endianess): Copy name without leading '-'. + +2009-02-09 Tristan Gingold + + * NEWS: Mention feature match between objdump and readelf for dumping + dwarf info. + + * doc/binutils.texi (objdump): Document -W/--dwarf improvments to + objdump. + + * objdump.c (usage): Update documentation for -W/--dwarf. + (enum option_values): Add OPTION_DWARF. + (long_options): --dwarf can accept arguments. + (dump_dwarf_section): Also check enabled field. + (main): Option -W can accept arguments, code moved to + dwarf.c and call dwarf_select_sections_all instead. + * readelf.c (process_section_headers): Remove do_debug_lines_decoded. + (parse_args): Move code to... + * dwarf.c (dwarf_select_sections_by_letters, + dwarf_select_sections_by_names): : ...here (new functions). + (do_debug_lines_decoded): Remove and replaced by ... + (FLAG_DEBUG_LINES_RAW, FLAG_DEBUG_LINES_DECODED): ... new macros. + (display_debug_lines): Adjust for previous change. + (dwarf_select_sections_all): New function. + (debug_displays): Add initializer for enabled field. + * dwarf.h (do_debug_lines_decoded): Remove. + Add prototypes for the new functions. + (struct dwarf_section_display): Add enabled field. + +2009-02-06 Nick Clifton + + * po/vi.po: Updated Vietnamese translation. + +2009-02-03 Sandip Matte + + * readelf.c (get_machine_flags): Handle E_MIPS_MACH_XLR. + +2009-02-03 H.J. Lu + + * NEWS: Move --as-needed change to ... + * ../ld/NEWS: Here. + +2009-02-03 Carlos O'Donell + + * configure.in: AC_SUBST pdfdir. + * Makefile.am: Add install-pdf, install-pdf-am, + and install-pdf-recursive targets. + * doc/Makefile.am: Define pdf__strip_dir. Add + install-pdf and install-pdf-am targets. + * po/Make-in: Add install-pdf target. + * configure: Regenerate. + * Makefile.in: Regenerate. + * doc/Makefile.in: Regenerate. + +2009-02-03 H.J. Lu + + PR binutils/9784 + * NEWS: Mention --prefix=PREFIX and --prefix-strip=LEVEL. + + * doc/binutils.texi: Document --prefix=PREFIX and + --prefix-strip=LEVEL. + + * objdump.c: Include "filenames.h". + (prefix): New. + (prefix_strip): Likewise. + (prefix_length): Likewise. + (usage): Add --prefix=PREFIX and --prefix-strip=LEVEL. + (option_values): Add OPTION_PREFIX and OPTION_PREFIX_STRIP. + (long_options): Likewise. + (show_line): Handle prefix and prefix_strip. + (main): Handle OPTION_PREFIX and OPTION_PREFIX_STRIP. + + * readelf.c (PATH_MAX): Moved to ... + * sysdep.h: Here. + +2009-01-31 Alan Modra + + * NEWS: Mention --as-needed change. + +2009-01-29 Alan Modra + + PR 9798 + * bucomm.c (bfd_nonfatal_message): Use bfd_get_archive_filename. + (bfd_get_archive_filename): Constify param. + * bucomm.h (bfd_get_archive_filename): Update prototype. + * objcopy.c (RETURN_NONFATAL): Delete. + (copy_unknown_object): Don't call bfd_get_archive_filename for + bfd_nonfatal_message filename, instead just pass bfd. + (copy_object): Likewise. + (copy_archive, copy_file): Likewise. Expand RETURN_NONFATAL. On + bfd_close errors, do not pass the bfd to bfd_nonfatal_message. + (setup_bfd_headers): Fix error message. + +2009-01-27 Nick Clifton + + PR 9774 + * objdump.c (disassemble_section): When the target uses signed + addresses make sure that we compute signed values. + +2009-01-27 Nick Clifton + + * MAINTAINERS: Remove Thiemo Seufer's name from the list of MIPS + maintainers. + +2009-01-26 Nick Clifton + + PR 9766 + * dlltool.c (xlate): When strip text after the @ sign, look for + the last one not the first one. + +2009-01-16 Alan Modra + + * configure.in (commonbfdlib): Delete. + * configure: Regenerate. + +2008-01-14 Charles Wilson + + Cleanup code related to --identify option. + + * dlltool.c (file scope): Removed globals identify_ms, + identify_member_contains_symname_result, + identify_dll_name_list_head, and identify_dll_name_list_tail. + Renamed existing typedef dll_name_list_type to + dll_name_list_node_type. + Added new typedefs dll_name_list_type, symname_search_data_type, + and identify_data_type. + (identify_append_dll_name_to_list): Renamed to... + (dll_name_list_append): ...here. Changed signature to accept list + argument rather than use global. + (identify_count_dll_name_list): Renamed to... + (dll_name_list_count): ...here. Changed signature to accept list + argument rather than use global. + (identify_print_dll_name_list): Renamed to... + (dll_name_list_print): ...here. Changed signature to accept list + argument rather than use global. + (identify_free_dll_name_list): Renamed to... + (dll_name_list_free_contents): ...here. + (dll_name_list_free): New function. + (dll_name_list_create): New function. + (identify_process_section_p): Changed signature to accept + ms_style_implib argument rather than use global. + (identify_member_contains_symname): Expect incoming void * data to + be symname_search_data_type. + (identify_dll_for_implib): Use new functions dll_name_list_create + and dll_name_list_free. Use new types symname_search_data_type + and identify_data_type to communicate with search routines. + (identify_search_section): Expect incoming void * data to be + identify_data_type. Use its contents rather than global + variables. + +2009-01-13 Charles Wilson + + Add --identify-strict option. Handle ms-style implibs: + + * dlltool.c (file scope): Added new globals identify_ms and + identify_strict. New typedef dll_name_list_type, and globals + identify_dll_name_list_head and identify_dll_name_list_tail. Added + new global identify_member_contains_symname_result. + (identify_append_dll_name_to_list): New function. + (identify_count_dll_name_list): New function. + (identify_print_dll_name_list): New function. + (identify_free_dll_name_list): New function. + (identify_search_archive): Changed signature to take function + pointer to operation to apply to each member, and data to pass on + to that function. + (identify_search_member): Changed signature to accept user data + from caller. + (identify_member_contains_symname): New function. + (identify_dll_for_implib): Rewrite. Now determines whether implib + is ms- or binutils- style, before searching sections for + dllname. Allows multiple dllnames. + (identify_process_section_p): Search alternate section for dllname + when implib is ms-style. + (identify_search_section): Add additional conditions to excludes + candidate sections from consideration. + (usage): Added --identify-strict. + (long_options): Added --identify-strict. + (main): Handle --identify-strict option. + * doc/binutils.texi: Document --identify-strict option. + * NEWS: Document --identify and --identify-strict options. + +2009-01-13 Alan Modra + + PR 7034 + * doc/binutils.texi (objdump -R): Note effect of -d or -D. + +2009-01-13 Alan Modra + + * objdump.c (disassemble_section): Don't assume non-instruction + data if object symbol at given address is in different section. + +2009-01-12 Kai Tietz + + * dlltool.c (create_for_pep): New. + (flush_page): Use create_for_pep instead of using + macro DLLTOOL_MX86_64 clause. + (generate_idata_ofile): Likewise. + (make_one_lib_file): Likewise. + (make_head): Likewise. + (make_tail): Likewise. + (main): Initialize create_for_pep. + +2009-01-08 Kai Tietz + + * dlltool.c (use_nul_prefixed_import_tables): New. + (make_head): Make prefix leading zero prefix element for + idata$4 and idata$5 dependent to new flag. + (usage): Add new option --use-nul-prefixed-import-tables. + (OPTION_USE_NUL_PREFIXED_IMPORT_TABLES): New. + (long_options): Add --use-nul-prefixed-import-tables. + (main): Likewise. + * doc/binutils.texi: Add new option documentation for + --use-nul-prefixed-import-tables. + * NEWS: Add new option. + +2009-01-06 Kai Tietz + + * windres.c (set_endianess): Get architecture name + for internal target names like "pe-arm-wince-little". + (find_arch_match): New helper. + * ChangeLog: Reset it. + * ChangeLog-2008: Moved old ChangeLog. + +For older changes see ChangeLog-2008 + +Copyright (C) 2009 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2010 b/support/sdbinutils/binutils/ChangeLog-2010 new file mode 100644 index 0000000..ba56871 --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2010 @@ -0,0 +1,1083 @@ +2010-12-15 Kai Tietz + + * dwarf.c (display_gdb_index): Fix printf types for + used formatters. + +2010-12-12 Peter Breitenlohner + + PR binutils/12306 + * doc/binutils.texi: Fix typos in elfedit documentation. + +2010-12-10 Alan Modra + + * binemul.h (do_ar_emul_append): Declare. + * binemul.c (any_ok): New function. + (do_ar_emul_append): Rename from do_ar_emul_default_append. Make + global, add check arg. Adjust callers. + (ar_emul_default_replace): Tidy. + * configure.tgt (powerpc-*-aix[5-9]*,rs6000-*-aix[5-9]*): Use + bin_aix_emulation. + * emul_aix.c (bin_aix5_emulation, ar_emul_aix_internal): Delete. + (ar_emul_aix5_append, ar_emul_aix5_replace): Delete. + (check_aix): New function. + (ar_emul_aix_append, ar_emul_aix_replace): Rewrite. + +2010-12-09 Mike Frysinger + + * .gitignore: New file. + +2010-12-08 Alan Modra + + * ar.c: Formatting. + (usage): Correct help strings. + (decode_options): Correct getopt_long short options. Remove + duplicate non-handled option message. + (main): Don't handle -M specially. + +2010-12-08 Arnaud Lacombe + + * ar.c (long_options): Add target. + (decode_options): Handle the --target option. + (open_inarch): Check for plugin's target, default to --target + (replace_members): Use generic `target'. + + * ar.c (operation): New global variable. + (show_version): Likewise. + (show_help): Likewise. + (long_options): Likewise. + (usage): Fix help string argument order. + (decode_options): New. + (ranlib_main): Use getopt_long. + (main): Use decode_options. + + * ar.c (main): Split ranlib path. + (ranlib_usage): New + (ranlib_main): New + +2010-12-03 Doug Evans + + * dwarf.c: #include "bfd_stdint.h". + (do_gdb_index): New global. + (display_gdb_index): New function. + (dwarf_select_sections_by_names) Add "gdb_index". + (dwarf_select_sections_all): Set do_gdb_index. + (debug_displays): Add .gdb_index. + * dwarf.h (do_gdb_index): Declare. + * objdump.c (usage): Add gdb_index. + * readelf.c (usage): Add gdb_index. + (process_section_headers): Process ".gdb_index". + * doc/binutils.texi (readelf): Document gdb_index dump. + (objdump): Ditto. + +2010-12-01 Kai Tietz + + PR binutils/11065 + * dlltool.c (dll_name_set_by_exp_name): New variable. + (def_name): Allow setting of dll_name by .def file. + (def_library): Likewise. + (main): Set dll_name_set_by_exp_name, if dll_name is + set indirect by exp_name. + +2010-11-26 Alan Modra + + * dwarf.c (decode_location_expression, display_debug_frames): Move + code handling DW_EH_PE_pcrel into.. + (get_encoded_value): ..here. + +2010-11-26 Alan Modra + + * po/ja.po: Update. + +2010-11-25 Alan Modra + + * po/bg.po: Update. + * po/es.po: Update. + * po/fi.po: Update. + * po/ja.po: Update. + * po/ru.po: Update. + * po/zh_CN.po: Update. + +2010-11-21 H.J. Lu + + PR binutils/12235 + * elfcomm.c: New. + * elfcomm.h: Likewise. + + * Makefile.am (HFILES): Add elfcomm.h. + (CFILES): Add elfcomm.c. + (ELFLIBS): New. + (readelf_SOURCES): Add $(ELFLIBS). + (elfedit_SOURCES): Likewise. + (objdump_SOURCES): Likewise. + * Makefile.in: Regenerated. + + * dwarf.c: Include "elfcomm.h". + (byte_get): Removed. + (byte_get_little_endian): Likewise. + (byte_get_big_endian): Likewise. + (byte_get_signed): Likewise. + (error): Likewise. + (warn): Likewise. + + * dwarf.h (dwarf_vma): Defined with HOST_WIDEST_INT. + (dwarf_size_type): Likewise. + (byte_get): Removed. + (byte_get_signed): Likewise. + (byte_get_little_endian): Likewise. + (byte_get_big_endian): Likewise. + (error): Likewise. + (warn): Likewise. + + * elfedit.c: Include "elfcomm.h". Don't include "aout/ar.h". + Call error () instead of non_fatal (). + (streq): Removed. + (strneq): Likewise. + (const_strneq): Likewise. + (non_fatal): Likewise. + (BYTE_GET): Likewise. + (BYTE_PUT): Likewise. + (byte_get): Likewise. + (byte_put): Likewise. + (byte_get_little_endian): Likewise. + (byte_get_big_endian): Likewise. + (byte_put_little_endian): Likewise. + (byte_put_big_endian): Likewise. + (adjust_relative_path): Likewise. + (archive_info): Likewise. + (setup_archive): Likewise. + (release_archive): Likewise. + (setup_nested_archive): Likewise. + (get_archive_member_name): Likewise. + (get_archive_member_name_at): Likewise. + (make_qualified_name): Likewise. + + * objdump.c: Include "elfcomm.h". + + * readelf.c: Include "elfcomm.h". Don't include "aout/ar.h". + (BYTE_GET): Removed. + (BYTE_GET_SIGNED): Removed. + (streq): Likewise. + (strneq): Likewise. + (const_strneq): Likewise. + (byte_put): Likewise. + (byte_put_little_endian): Likewise. + (byte_put_big_endian): Likewise. + (adjust_relative_path): Likewise. + (archive_info): Likewise. + (setup_archive): Likewise. + (release_archive): Likewise. + (setup_nested_archive): Likewise. + (get_archive_member_name): Likewise. + (get_archive_member_name_at): Likewise. + (make_qualified_name): Likewise. + +2010-11-18 Alan Modra + + PR binutils/11742 + * readelf.c (get_archive_member_name): Formatting. Properly + handle full size ar_name. + +2010-11-17 Alan Modra + + * ar.c (print_contents): Don't internationalize strings without words. + * dwarf.c (process_extended_line_op): Likewise. + (process_debug_info): Likwise. + (display_debug_lines_raw): Likewise. + (display_debug_lines_decoded): Likewise. + (display_debug_abbrev): Likewise. + * readelf.c (process_file_header): Likewise. + (GET_OP): Likewise. + (decode_arm_unwind): Likewise. + (process_mips_specific): Likewise. + * resrc.c (run_cmd): Likewise. + (rcparse_warning): Likewise. + * objdump.c (dump_headers): Don't print "Pg". + +2010-11-16 Jorma Karvonen + + * windmc.c: ,%s' -> `%s' in a number of strings. + +2010-11-16 Jie Zhang + + * readelf.c (get_machine_flags): Deal with Blackfin specific flags. + +2010-11-11 Mingming Sun + + * readelf.c (get_machine_flags): Add loongson-3a. + +2010-11-10 Nick Clifton + + * po/ja.po: Updated Japanese translation. + * po/fr.po: Updated French translation. + +2010-11-08 Nick Clifton + + * po/ja.po: Updated Japanese translation. + +2010-11-08 Alan Modra + + * objcopy.c (copy_main): No need to rename sections when compressing + or decompressing. + +2010-11-05 Alan Modra + + * bin2c.c: Remove internationalization and version report. + * Makefile.am: Update bin2c rule. + * Makefile.in: Regenerate. + +2010-11-05 Tristan Gingold + + * po/binutils.pot: Regenerate + +2010-11-05 Tristan Gingold + + * NEWS: Add marker for 2.21. + +2010-11-02 H.J. Lu + + * objdump.c (dump_bfd_header): Don't display + BFD_FLAGS_FOR_BFD_USE_MASK bits in abfd->flags. + +2010-11-02 Joseph Myers + + * readelf.c (display_tic6x_attribute): Handle more attributes. + +2010-10-30 Kai Tietz + + * dlltool.c (scan_drectve_symbols): Allow quoted strings for -export + directives. + +2010-10-29 Joseph Myers + + * readelf.c (display_tic6x_attribute): Use Tag_ABI_compatibility + not hardcoded 32. Display name of this attribute. + +2010-10-29 H.J. Lu + + * addr2line.c (process_file): Set BFD_DECOMPRESS. + + * objcopy.c (do_debug_sections): New. + (OPTION_COMPRESS_DEBUG_SECTIONS): New. + (OPTION_DECOMPRESS_DEBUG_SECTIONS): Likewise. + (copy_options): Add OPTION_COMPRESS_DEBUG_SECTIONS and + OPTION_DECOMPRESS_DEBUG_SECTIONS. + (copy_usage): Add --compress-debug-sections and + --decompress-debug-sections. + (copy_file): Set BFD_COMPRESS or BFD_DECOMPRESS. + (copy_section): Replace bfd_get_section_contents with + bfd_get_full_section_contents. + (copy_main): Handle OPTION_COMPRESS_DEBUG_SECTIONS and + OPTION_DECOMPRESS_DEBUG_SECTIONS. Check do_debug_sections to + rename DWARF debug sections. + + * objdump.c (load_specific_debug_section): Replace + bfd_get_section_contents with bfd_get_full_section_contents. + Remove bfd_uncompress_section_contents. + (dump_section): Replace bfd_get_section_contents with + bfd_get_full_section_contents. + (display_file): Set BFD_DECOMPRESS if needed. + + * readelf.c (uncompress_section_contents): Set buffer to NULL + to indiate decompression failure. + (load_specific_debug_section): Always call + uncompress_section_contents. + + * doc/binutils.texi: Document --compress-debug-sections and + --decompress-debug-sections. + +2010-10-29 Nick Clifton + + PR binutils/12058 + * ar.c (usage): Revert previous change. Describe how 's' can be + used as a command letter. + * doc/binutils.texi (ar cmdline): Describe how 's' can be used as + a command letter. + +2010-10-29 Bernd Schmidt + Joseph Myers + + * readelf.c (display_tic6x_attribute): Handle Tag_ABI_DSBT. + +2010-10-28 Nick Clifton + + PR binutils/12058 + * ar.c (usage): Remove spurious 's' from list of accepted command + letters. + +2010-10-28 Alan Modra + + * readelf.c (is_32bit_abs_reloc): Support i960 and microblaze. + (is_32bit_pcrel_reloc): Support microblaze. + +2010-10-26 Nick Clifton + + * po/ja.po: Updated Japanese transaltion. + +2010-10-21 Joseph Myers + + * readelf.c (display_tic6x_attribute): Update for attribute + renaming. + +2010-10-08 H.J. Lu + + * dwarf.c (byte_get_signed): Make it extern. + + * dwarf.h (byte_get_signed): New. + + * readelf.c (BYTE_GET_SIGNED): New. + (slurp_rela_relocs): Use BYTE_GET_SIGNED on r_addend. + (dump_relocations): Properly dump r_addend. + +2010-10-08 Joseph Myers + + * nm.c (value_format_64bit): Define appropriately for __MSVCRT__. + (set_print_radix): Update for __MSVCRT__ definition of + value_format_64bit. + +2010-10-08 Pierre Muller + + Fix build with -DDEBUG=7 + * nlmheader.y (DEBUG token): Rename to DEBUG_K. + +2010-10-06 Alan Modra + + * bucomm.c (bfd_nonfatal, bfd_nonfatal_message): Don't clobber errno. + +2010-10-05 Alan Modra + + * bucomm.c (bfd_nonfatal): Flush stdout before output to stderr. + (bfd_nonfatal_message, report, list_matching_formats): Likewise. + (list_supported_targets): Tidy. + * objdump.c (free_only_list): Formatting. + (slurp_dynamic_symtab): Non-zero exit status for "not a dynamic + object". + (update_source_path): Delete redundant check for NULL filename. + (disassemble_bytes): Error if disassemble_fn returns a value + that won't increment address. + (disassemble_data): Don't capitalize error message. + (read_section_stabs): Likewise. + (main): Return non-zero exit status on bad options. + +2010-10-03 H.J. Lu + + PR binutils/12088 + * nm.c (plugin_target): New. + (main): Set plugin_target to "plugin" for --plugin. + (display_file): Pass plugin_target to bfd_openr if target + isn't set. + +2010-09-27 Ralf Wildenhues + + * configure: Regenerate. + +2010-09-22 Mike Frysinger + + * MAINTAINERS: Add self as ADI Blackfin maintainer. + +2010-09-17 H.J. Lu + + * emul_aix.c (ar_emul_aix_append): Add a target argument + and ignore it if it is set. + (ar_emul_aix5_append): Likewise. + (ar_emul_aix_replace): Likewise. + (ar_emul_aix5_replace): Likewise. + +2010-09-15 H.J. Lu + + * ar.c (plugin_target): New. + (main): Set plugin_target to "plugin" for --plugin. + (open_inarch): Initialize target to plugin_target. + (replace_members): Pass plugin_target to ar_emul_replace + and ar_emul_append. + + * binemul.h (ar_emul_append): Add a target argument. + (ar_emul_default_append): Likewise. + (ar_emul_replace): Likewise. + (ar_emul_default_replace): Likewise. + (bin_emulation_xfer_struct): Add a target argument to + ar_append and ar_replace. + + * binemul.c (ar_emul_append): Updated. Pass target to bfd_openr. + (do_ar_emul_default_append): Likewise. + (ar_emul_default_append): Likewise. + (ar_emul_replace): Likewise. + (ar_emul_default_replace): Likewise. + +2010-09-10 Ben Gardiner + + * objcopy.c: Add --interleave-width option to allow interleaving + of more than one byte at a time. + (copy_width): New variable. + (copy_options): Add --interleave-width. + (copy_section): When interleaving copy in units of copy_width + bytes. + (copy_main): Parse the new option. + * doc/binutils: Document the new option. + * NEWS: Mention the new feature. + +2010-09-09 Jakub Jelinek + + * dwarf.c (decode_location_expression): Fix data adjustment + for DW_OP_GNU_implicit_pointer in v3+. + +2010-09-09 Tristan Gingold + + * NEWS: Add entry to NEWS for hppa/som. + +2010-09-09 Jakub Jelinek + + * dwarf.h (debug_info): Add offset_info and dwarf_version fields. + * dwarf.c (decode_location_expression): Add offset_size and + dwarf_version arguments. Prefix DIE offset with 0x for + DW_OP_call{2,4,_ref}. Fix up DW_OP_call_ref operand size, + complain if in frame info section. Handle + DW_OP_GNU_implicit_pointer. + (read_and_display_attr_value, display_debug_loc, + display_debug_frames): Adjust decode_location_expression callers. + (process_debug_info): Save offset_size and dwarf_version values + into debug_information array. + +2010-09-07 Nick Clifton + + * readelf.c (process_section_headers): Mention meaning of 'l' + section flag for x86-64 targets. + +2010-09-03 Jan Kratochvil + Jakub Jelinek + + * dwarf.c (regname): New declaration. + (decode_location_expression): Print for registers also regname output. + +2010-09-02 Richard Henderson + + * dwarf.c (init_dwarf_regnames_i386, init_dwarf_regnames_x86_64): New. + (init_dwarf_regnames): Use them. + * dwarf.h: Declare them. + * objdump.c (dump_dwarf): Use bfd_get_arch + bfd_get_mach to set up + the regnames, rather than using elf_machine_code. + +2010-09-02 Richard Henderson + + * objdump.c (dump_dwarf): Use bfd_arch_bits_per_address. + +2010-08-23 H.J. Lu + + * elfedit.c (input_elf_osabi): New. + (output_elf_osbi): Likewise. + (osabis): Likewise. + (elf_osabi): Likewise. + (update_elf_header): Support updating ELF OSABI. + (make_qualified_name): Break long line. + (command_line_switch): Add OPTION_INPUT_OSABI and + OPTION_OUTPUT_OSABI. + (options): Likewise. + (usage): Add --input-osabi and --output-osabi. + (main): Handle OPTION_INPUT_OSABI and OPTION_OUTPUT_OSABI. + + * doc/binutils.texi: Document --input-osabi and --output-osabi + for elfedit. + +2010-08-23 Maciej W. Rozycki + + * readelf.c (display_mips_gnu_attribute): Replace GCC options + with a textual description of a MIPS32r2 64-bit FPU. + +2010-08-13 Dan Rosenberg + + PR binutils/11889 + * readelf.c (get_32bit_elf_symbols): Check for a corrupt + sh_entsize. + (get_64bit_elf_symbols): Likewise. + (process_symbol_table): Likewise. + (process_section_groups): Check for corrupt headers. + (process_version_sections): Check for corrupt indicies. + (process_corefile_note_segment): Likewise. + +2010-08-13 Nathan Sidwell + + * readelf.c (get_machine_flags): Detect CF ISA C and EMAC_B + variants. + +2010-08-13 Tom Tromey + + * dwarf.c (process_debug_info): Don't subtract section address + when calculating location of cu abbrev within section. + +2010-08-12 Michael Haubenwallner + + PR binutils/11742 + * readelf.c (get_archive_member_name): Do not read beyond the end + of the ar_name field. + +2010-08-03 Tristan Gingold + + * dwarf.c (display_debug_lines): Mark file argument unused. + Do not try to load .debug_info section. + +2010-08-02 Alan Modra + + * readelf.c (apply_relocations): D30V is really REL. + +2010-07-23 Naveen.H.S + Ina Pandit + + * binutils/readelf.c: Add support for V850E2 and V850E2V3. + +2010-07-22 Alan Modra + + * readelf.c: Add Moxie support. + +2010-07-20 Alan Modra + + * readelf.c (process_program_headers): Don't ignore all zero size + sections. + +2010-07-19 Andreas Schwab + + * readelf.c (process_section_headers): Update key to flags. + +2010-07-17 Dave Korn + + * objcopy.c (copy_usage): Tweak previous typofix. + +2010-07-17 H.J. Lu + + * objcopy.c (copy_usage): Fix a typo. + +2010-07-15 Kai Tietz + + * dllwrap.c (main): Make sure is_leading_underscore + gets initialized with correct default. + +2010-07-05 Alan Modra + + * readelf.c (uncompress_section_contents): Avoid gcc-4.6 warning. + +2010-07-03 Cary Coutant + + * objdump.c (load_specific_debug_section): Decompress section contents + before applying relocations. + * readelf.c (load_specific_debug_section): Update section size after + decompression. + +2010-06-29 Alan Modra + + PR binutils/3166 + * objcopy.c (is_strip_section): Revert 2006-09-05. + (setup_section): Make SHT_GROUP section nobits. + +2010-06-29 Alan Modra + + * configure: Regenerate. + * po/POTFILES.in: Regenerate. + +2010-06-27 Alan Modra + + * resbin.c (res_to_bin_accelerator): Delete set but unused variables. + +2010-06-17 Nick Clifton + + PR binutils/11711 + * windres.c (enum option_values): New enum. + (long_options): Use separate option number for --include-dir + option. + (main): Separate backwards compatibility check from code to + implement --include-dir. Check to see if directory exists and do + not complain if it does. + +2010-06-15 Joseph Myers + + * readelf.c (display_tic6x_attribute, process_tic6x_specific): + New. + (process_arch_specific): Call process_tic6x_specific for + EM_TI_C6000. + +2010-06-11 H.J. Lu + + * readelf.c (dump_ia64_vms_dynamic_fixups): Cast to unsigned long + for 0x%lx. + +2010-06-11 Tristan Gingold + Doug Rupp + + * readelf.c (is_ia64_vms): New function. + (dump_relocations): Use it. + (get_machine_flags): Display IA-64 OpenVMS flags. + (process_program_headers): No error on OpenVMS if no .dynamic section. + (struct ia64_vms_dynfixup, struct ia64_vms_dynimgrela): New + declarations. + (dump_ia64_vms_dynamic_fixups): New function. + (dump_ia64_vms_dynamic_relocs): Ditto. + (process_ia64_vms_dynamic_relocs): Ditto. + (process_relocs): Handle IA-64 OpenVMS relocs. + (VMS_EPOCH_OFFSET, VMS_GRANULARITY_FACTOR): New macros. + (print_vms_time): New function. + (dynamic_section_ia64_val): Handle DT_IA_64_VMS_LINKTIME and + DT_IA_64_VMS_LNKFLAGS. + (get_ia64_symbol_other): New function. + (get_symbol_other): Handle EM_IA_64. + +2010-06-11 Tristan Gingold + + * unwind-ia64.c (unw_print_abreg): Add const to special_reg. + (UNW_DEC_ABI): Ditto for abiname. + (unw_decode_table): Make it const. + +2010-06-10 Tristan Gingold + + * readelf.c (slurp_ia64_unwind_table): IA64 rela relocations are + not inplace. + +2010-05-25 Daniel Jacobowitz + Joseph Myers + Andrew Stubbs + + * readelf.c (get_machine_flags): Handle EF_SH_PIC and EF_SH_FDPIC. + +2010-05-25 Jay Krell + + PR ld/11621 + * Makefile.am: Replace all occurences of .o with .@OBJEXT@ + * Makefile.in: Regenerate. + +2010-05-24 Tristan Gingold + + * readelf.c (usage): Add new trace sections for --debug-dump. + (process_section_headers): Handle dump of trace sections. + * objdump.c (usage): Add new trace sections for --dwarf. + * dwarf.h (do_trace_info, do_trace_abbrevs): New variables. + (do_trace_aranges): Ditto. + (enum dwarf_section_display_enum): Add trace_info, trace_abbrev + and trace_aranges literals. + * dwarf.c (do_trace_info, do_trace_abbrevs): New variables. + (do_trace_aranges): Ditto. + (process_debug_info): Add abbrev_sec argument and replace + abbrev with abbrev_sec. + (load_debug_info): Adjust call of process_debug_info. + (display_debug_info): Ditto. + (display_trace_info): New function. + (dwarf_select_sections_by_names): Add trace_info, trace_abbrevs + and trace_aranges sections name. + (dwarf_select_sections_all): Also select trace sections. + (debug_displays): Reindent. Add entries for the trace sections. + * doc/binutils.texi (readelf): Document new --dwarf parameters. + (objdump): Ditto. + +2010-05-18 H.J. Lu + + PR gas/11600 + * readelf.c (get_elf_section_flags): Treat SHF_EXCLUDE as a + generic flag. + +2010-05-07 Tristan Gingold + + * Makefile.in: Regenerate with automake 1.11.1. + * aclocal.m4: Ditto. + * doc/Makefile.in: Ditto. + +2010-05-06 H.J. Lu + + * dwarf.c (init_dwarf_regnames): Handle EM_L1OM. + * readelf.c (get_elf_section_flags): Likewise. + (process_section_headers): Likewise. + +2010-05-05 Nick Clifton + + * po/es.po: Updated Spanish translation. + +2010-04-27 Kai Tietz + + * dlltool.c (main): Query for bfd's underscoring default for + default target case. + +2010-04-27 Nick Clifton + + * po/ru.po: Updated Russian translation. + +2010-04-23 Alan Modra + + * readelf.c (process_program_headers): Replace use of + ELF_IS_SECTION_IN_SEGMENT_MEMORY with ELF_SECTION_IN_SEGMENT. + +2010-04-22 Nick Clifton + + * po/binutils.pot: Updated by the Translation project. + * po/fi.po: Updated Finnish translation. + * po/vi.po: Updated Vietnamese translation. + * po/bg.po: New Bulgarian translation. + * configure.in (ALL_LINGUAS): Add bg. + * configure: Regenerate. + +2010-04-20 Nick Clifton + + * po/fr.po: Updated french translation. + +2010-04-20 Nick Clifton + + * readelf.c: Add _() macros to constant strings that are + translatable. + + * readelf.c (display_mips_gnu_attribute): Replace GCC options + with a textual description of single and double precision float. + +2010-04-15 Matthew Gretton-Dann + + * readelf.c (arm_attr_tag_FP_arch): Rename from arm_attr_tag_VFP_arch. + (arm_attr_tag_ABI_align8_needed): Remove. + (arm_attr_tag_ABI_align8_preserved): Remove. + (arm_attr_tag_ABI_HardFP_use): Update text strings. + (arm_attr_public_tags): Add strings for ABI v2.08 attribute tags. + (display_arm_attribute): Add decoding of ABI v2.08 attributes. + +2010-04-13 Nick Clifton + + PR binutils/11419 + * dwarf.c (process_debug_info): Initialise the signature array. + +2010-04-09 Nick Clifton + + * dwarf.c (process_debug_info): Remove unused variable + cu_abbrev_offset_ptr. + (display_debug_lines_decoded): Remove unused variable prev_line. + * elfedit.c (process_archive): Remove unused variable + file_name_size. + * ieee.c (ieee_start_compilation_unit): Remove unused variable + nindx. + (ieee_set_type): Remove unused variables info, targetindx and + baseindx. + * objdump.c (disassmble_byte): Remove unused variable done_dot. + * rddbg.c (read_section_stabs_debugging_info): Remove unused + variable other. + * readelf.c (dump_section_as_strings): Remove unused variable + addr. + (process_archive): Remove unused variable file_name_size. + * stabs.c (parse_stab_string): Mark desc parameter as unused. + Remove unused variable lineno. + (parse_stab_struct_type): Remove unused variable orig. + (stab_demangle_type): Remove unused variables constp, volatilep + and hold. + +2010-04-07 Alan Modra + + * configure: Regenerate. + +2010-04-06 Nick Clifton + + * po/vi.po: Updated Vietnamese translation. + +2010-04-05 Jakub Jelinek + + * dwarf.c (struct Frame_Chunk): Add ptr_size and segment_size + fields. + (display_debug_frames): Handle CIE version 4. + + * dwarf.c (struct State_Machine_Registers): Add op_index field, + change end_sequence type to unsigned char. + (reset_state_machine): Clear op_index. + (process_extended_line_op): For DW_LNE_set_address clear op_index. + (display_debug_lines_raw): Initialize li_max_ops_per_insn. + Track op_index state machine register and print it if + li_max_ops_per_insn is != 1. + (display_debug_lines_decoded): Likewise. + +2010-04-01 Jakub Jelinek + + * dwarf.c (read_and_display_attr_value): Don't reject + dwarf_version == 4. Handle DW_FORM_sec_offset, DW_FORM_flag_present + and DW_FORM_exprloc. + (process_debug_info): Handle cu_version == 4. + (display_debug_lines_raw, display_debug_lines_decoded): Handle + li_version == 4. + +2010-03-30 Andreas Schwab + + * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Define. + * Makefile.in: Regenerate. + +2010-03-25 Joseph Myers + + * MAINTAINERS: Add self as TI C6X maintainer. + * NEWS: Add news entry for TI C6X support. + * readelf.c: Include elf/tic6x.h. + (guess_is_rela): Handle EM_TI_C6000. + (dump_relocations): Likewise. + (get_tic6x_dynamic_type): New. + (get_dynamic_type): Call it. + (get_machine_flags): Handle EF_C6000_REL. + (get_osabi_name): Handle machine-specific values only for relevant + machines. Handle C6X values. + (get_tic6x_segment_type): New. + (get_segment_type): Call it. + (get_tic6x_section_type_name): New. + (get_section_type_name): Call it. + (is_32bit_abs_reloc, is_16bit_abs_reloc, is_none_reloc): Handle + EM_TI_C6000. + +2010-03-25 Thomas Schwinge + + * doc/binutils.texi (readelf) : Mention support for + ARM unwind tables. + +2010-03-18 H.J. Lu + + * readelf.c (decode_arm_unwind): Increase buf size to 9 byte. + +2010-03-17 Alan Modra + + * readelf.c (dump_arm_unwind): Warning fix. + +2010-03-16 Daniel Jacobowitz + + * MAINTAINERS: Update my email address. List Tristan Gingold + as the release branch maintainer. + +2010-03-05 Rainer Orth + + * readelf.c (get_ver_flags): Handle VER_FLG_INFO. + +2010-03-02 Daniel Jacobowitz + + * NEWS: Document .ARM.exidx / .ARM.extab support. + + * dwarf.c (read_leb128): Make non-static. + * dwarf.h (read_leb128): Declare. + * readelf.c (REMOVE_ARCH_BITS): Define. + (find_section_by_address): New. + (read_uleb128): Move higher. Use read_leb128 from dwarf.c. + (find_symbol_for_address): Handle the Thumb bit for ARM, by + using REMOVE_ARCH_BITS. + (struct arm_section, struct arm_unw_aux_info, arm_print_vma_and_name) + (arm_free_section, arm_section_get_word, decode_arm_unwind) + (dump_arm_unwind, arm_process_unwind): New. + (process_unwind): Handle ARM. + +2010-02-26 Jie Zhang + + * MAINTAINERS: Update my email address. + +2010-02-23 Peter Breitenlohner + + PR binutils/11298 + * doc/binutils.texi (windmc): Fix synopsis and description of + ASCII options. + +2010-02-19 Alan Modra + + * readelf.c (get_group_flags): Return empty string when flags zero. + Add space in other returned values. + (process_section_groups): Adjust format string. + +2010-02-18 Matthew Gretton-Dann + + * readelf.c (arm_attr_tag_Advanced_SIMD_arch): Add description of + newly permitted attribute values. + (arm_attr_tag_Virtualization_use): Likewise. + (arm_attr_tag_DIV_use): Add description of new attribute. + (arm_attr_tag_MPextension_use_legacy): Likewise. + +2010-02-15 Nick Clifton + + * po/vi.po: Updated Vietnamese translation. + +2010-02-09 Michael Holzheu + + * readelf.c (get_note_type): Handle NT_S390_TIMER, NT_S390_TODCMP, + NT_S390_TODPREG, NT_S390_CTRS and NT_S390_PREFIX. + +2010-02-08 Jim Blandy + + * dwarf.c (display_debug_frames): Skip the 'S' character in CFI + 'z' augmentation strings. + +2010-02-08 Christophe Lyon + + * objdump.c (disassemble_bytes): Clear aux->reloc before printing + a new address, so as not to reuse a previous, non-related reloc. + +2010-02-02 H.J. Lu + + * readelf.c (get_note_type): Handle NT_X86_XSTATE. + +2010-02-01 Nathan Sidwell + + * objcopy.c (copy_object): Set SEC_LINKER_CREATED when adding + sections. + +2010-01-28 Nick Clifton + + PR 11225 + * objdump.c (only): Replace with linked list. + (only_size, only_used): Replace with only_list. + (process_section_p): Set seen field on matches sections. + (add_only): New function. + (free_only_list): New function. + (disassemble_section): Check only_list. + (main): Use add_only and free_only_list. + +2010-01-26 Tristan Gingold + + * Makefile.am (bin2c): Add libintl dependance and library. + * Makefile.in: Regenerate. + +2010-01-21 Andreas Krebbel + + * readelf.c (get_machine_flags): Handle EF_S390_HIGH_GPRS. + +2010-01-19 Ian Lance Taylor + + * objcopy.c (copy_main): Rewrite OPTION_ADD_SECTION code to work + with non-ordinary files like /dev/null. + +2010-01-19 Daisuke Hatayama + Alan Modra + + * readelf.c (process_file_header): Handle e_phnum extension. + +2010-01-14 Tristan Gingold + + * dwarf.c (get_AT_name): Handle DW_AT_use_GNAT_descriptive_type + and DW_AT_GNAT_descriptive_type. + +2010-01-13 Tristan Gingold + + * ar.c (main): Use lbasename. + (normalize): Ditto. + * objdump.c (update_source_path): Ditto. + +2010-01-12 Tristan Gingold + + * makefile.vms (CFLAGS): Turns warnings into informational messages. + +2010-01-11 H.J. Lu + + PR ld/11146 + * NEWS: Mention --dyn-syms for readelf. + + * readelf.c (do_dyn_syms): New. + (OPTION_DYN_SYMS): Likewise. + (options): Add "dyn-syms". + (usage): Add --dyn-syms. + (parse_args): Handle OPTION_DYN_SYMS. + (process_symbol_table): Handle do_dyn_syms. + (process_object): Likewise. + (process_archive): Likewise. + + * doc/binutils.texi: Document --dyn-syms for readelf. Mention + symbol hash tables for -D. + +2010-01-11 Nick Clifton + + * NEWS: Mention addition of elfedit. + + * po/fi.po: Updated Finnish translation. + +2010-01-09 Ralf Wildenhues + + * Makefile.in: Regenerate. + * configure: Regenerate. + * doc/Makefile.in: Regenerate. + +2010-01-08 H.J. Lu + + * version.c (print_version): Change to "Copyright 2010". + +2010-01-08 H.J. Lu + + * elfedit.c (input_elf_type): New. + (output_elf_type): Likewise. + (elf_type): Likewise. + (update_elf_header): Support updating ELF file type. + (command_line_switch): Add OPTION_INPUT_TYPE and + OPTION_OUTPUT_TYPE. + (options): Likewise. + (usage): Add --input-type and --output-type. + (main): Handle OPTION_INPUT_TYPE and OPTION_OUTPUT_TYPE. Check + one of --output-mach and --output-type must be specified. + + * doc/binutils.texi: Document --input-type and --output-type + for elfedit. + +2010-01-08 H.J. Lu + + * doc/binutils.texi: Fix a typo. + +2010-01-08 H.J. Lu + + * elfedit.c (update_elf_header): Don't change input_elf_class + nor input_elf_machine if they are -1. + +2010-01-08 Tristan Gingold + + * ar.c: Remove bfd_special_undocumented_glue prototype. + +2010-01-07 H.J. Lu + + * elfedit.c (update_elf_header): Reformat. + +2010-01-07 H.J. Lu + + * readelf.c (usage): Fix indent for --symbols. + +2010-01-07 H.J. Lu + + * doc/binutils.texi: Replace -histogram with --histogram. + +2010-01-06 H.J. Lu + + PR binutils/11131 + * Makefile.am (ELFEDIT_PROG): New. + (bin_PROGRAMS): Add $(ELFEDIT_PROG). + (CFILES): Add elfedit.c. + (elfedit_DEPENDENCIES): New. + (elfedit_SOURCES): Likewise. + (elfedit_LDADD): Likewise. + * Makefile.in: Regenerated. + + * elfedit.c: New. + + * doc/binutils.texi: Document elfedit. + + * doc/Makefile.am (man_MANS): Add elfedit.1. + (elfedit.1): New. + * doc/Makefile.in: Regenerated. + +2010-01-06 Tristan Gingold + + * nm.c (usage): Remove extra blanks. + +2010-01-04 H.J. Lu + + * objcopy.c: Update copyright. + * readelf.c: Likewise. + +2010-01-04 H.J. Lu + + PR binutils/11130 + * objcopy.c (copy_object): Remove "Warning: " from error + message. + +2010-01-04 Nick Clifton + + PR 11128 + * readelf.c (dump_section_as_strings): Use two separate + invocations of printf() in order to work around bugs in + the Solaris 8 implementation. + +2010-01-04 Nick Clifton + + * po/ru.po: Updated Russian translation. + +For older changes see ChangeLog-2009 + +Copyright (C) 2010 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2011 b/support/sdbinutils/binutils/ChangeLog-2011 new file mode 100644 index 0000000..c92d0d3 --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2011 @@ -0,0 +1,936 @@ +2011-12-28 Ian Lance Taylor + + * dwarf.c (read_and_display_attr_value): Handle DW_LANG_Go. + +2011-12-20 Roland McGrath + + * configure.in (--enable-deterministic-archives): Grok new + argument. Set DEFAULT_AR_DETERMINISTIC to 1 or 0 accordingly. + * configure: Regenerated. + * config.in: Regenerated. + * ar.c (deterministic): Initialize to -1. + (decode_options, ranlib_main): Grok U option. + (usage, ranlib_usage): Mention U; say for D and U which is the default. + (default_deterministic): New function. + (ranlib_main): Call it. + (main): Likewise. Make newer_only && deterministic error + non-fatal if it was just DEFAULT_AR_DETERMINISTIC and not the D option. + * doc/binutils.texi (ar cmdline, ranlib): Document U modifier and + --enable-deterministic-archives behavior. + +2011-12-16 Tristan Gingold + + * od-macho.c: Include mach-o/codesign.h + (OPT_CODESIGN): Define. + (options): Add an entry for codesign. + (mach_o_help): Likewise. + (dump_header): Fix indentation. + (dump_thread): Do not test result of xmalloc. + (bfd_mach_o_cs_magic, bfd_mach_o_cs_hash_type): New. + (dump_code_signature_superblob): New function. + (swap_code_codedirectory_v1_in): Likewise. + (hexdump): Likewise. + (dump_code_signature_codedirectory): Likewise. + (dump_code_signature_blob, dump_code_signature): Likewise. + (dump_load_command): Dump code signature. + (mach_o_dump): Likewise. + +2011-12-15 Andreas Tobler + + * readelf.c (get_symbol_type): Add ELFOSABI_FREEBSD to the + supported abi's. + +2011-12-13 Tristan Gingold + + * od-macho.c: New file. + * objdump.h (objdump_private_desc_mach_o): Add. + * configure.in: Add Mach-O od_vectors. + * Makefile.am (CFILES): Add od-macho.c + * configure: Regenerate. + * Makefile.in: Regenerate. + +2011-12-06 David Daney + + * readelf.c (dynamic_section_mips_val): Factor out trailing '\n' + from printed strings and move it to the end of the function. + Use BFD_VMA_FMT for printf format specifier for dynamic tag value. + Use print_vma() to print dynamic tag values. + +2011-12-02 Nick Clifton + + * readelf.c (ia64_process_unwind): Turn into a void funtion. + (hppa_process_unwind): Likewise. + (arm_process_unwind): Likewise. + (process_unwind): Likewise. + (arm_get_section_word): Rename to get_unwind_section_word. + Add sym_name parameter to return the offset into the string table + of the symbol associated with the reloc applied to the word. + (decode_tic6x_unwind_regmask): Add NULL argument to invocation of + get_unwind_section_word. + (dump_arm_unwind): Likewise. + (decode_arm_unwind_bytecode): Prepend a comma when *not* the first + register in a list. + (decode_arm_unwind): If the returned function address is 0 and a + valid symname offset is provided use that to compute the name + associated with the entry. + Add extra checks of the compact model index entry. + +2011-11-29 Roland McGrath + + * ar.c (ranlib_usage): Describe -D. + (ranlib_main): Parse -D. + (ranlib_touch): Set BFD_DETERMINISTIC_OUTPUT under -D. + * doc/binutils.texi (ranlib): Describe -D, and also --help/-h/-H. + +2011-11-28 Nick Clifton + + PR binutils/13421 + * readelf.c (arm_section_get_word): Add descriptive comments. + Initliase the rel_type field of the arm_sec structure. + (expand_prel31): Rename to arm_expand_prel31. + (dump_arm_unwind): Use new name. + Print the function name based on the function address entry. + +2011-11-11 Andreas Schwab + + * readelf.c (process_program_headers): Fix typo printing p_memsz + field. + +2011-11-01 DJ Delorie + + * readelf.c: Include elf/rl78.h + (guess_is_rela): Handle EM_RL78. + (dump_relocations): Likewise. + (get_machine_name): Likewise. + (is_32bit_abs_reloc): Likewise. + * NEWS: Mention addition of RL78 support. + * MAINTAINERS: Add myself as RL78 port maintainer. + +2011-10-28 Ian Lance Taylor + + * dwarf.c (display_debug_frames): If do_debug_frames_interp, + DW_CFA_restore goes to DW_CFA_undefined, not DW_CFA_unreferenced. + +2011-10-28 Walter Lee + + * NEWS: Mention addition of TILEPro and TILE-Gx support. + * MAINTAINERS: Add myself as TILEPro and TILE-Gx port maintainer. + +2011-10-27 Joern Rennecke + + * MAINTAINERS: Add myself as EPIPHANY port maintainer. + +2011-10-25 Mike Frysinger + + * Makefile.am (syslex.@OBJEXT@): Add -I$(srcdir). + * Makefile.in: Regen. + +2011-10-25 Joern Rennecke + + * readelf.c: Include "elf/epiphany.h". + (guess_is_rela, dump_relocation): Handle EM_ADAPTEVA_EPIPHANY. + (get_machine_name, is_32bit_abs_reloc, is_32bit_pcrel_reloc): Likewise. + (is_16bit_abs_reloc, is_none_reloc): Likewise. + * po/binutils.pot: Regenerate. + +2011-10-25 Kai Tietz + + * winduni.h (unicode_from_ascii_len): New prototype. + * winduni.c (unicode_from_ascii_len): New function. + * windres.h (define_stringtable): Add additional length argument. + * windres.c (define_stringtable): Add length argument for string. + * rcparse.y (res_unicode_sizedstring): New rule. + (res_unicode_sizedstring_concat): Likewise. + (string_data): Adjust rule. + +2011-10-24 Jan Kratochvil + + * dwarf.c (read_and_display_attr_value) : Add CU_OFFSET + also for DW_FORM_ref_udata. + +2011-10-24 Nick Clifton + + * po/ja.po: Updated Japanese translation. + +2011-10-16 H.J. Lu + + PR binutils/13278 + * ar.c (open_inarch): Set the target from the first object + on the list only if it isn't set. + +2011-10-13 Nick Clifton + + Fixes to aid translation: + * addr2line.c (translate_address): Add comments describing context + of a couple of printf statements. + * ar.c (write_archive): Allow translation of error message. + * bucomm.c (endian_string): Allow translation of strings. + (display_target_list): Allow translation. + * coffdump.c (dump_coff_type): Allow translation of output. + (dump_coff_where): Likewise. + (dump_coff_symbol): Likewise. + (dump_coff_scope): Likewise. + (dump_coff_sfile): Likewise. + (dump_coff_section): Likewise. + (coff_dump): Likewise. + * dlltool (def_version): Allow translation of output. + (run): Likewise. + * dllwrap.c (run): Allow translation of output. + * dwarf.c (print_dwarf_vma): Allow translation of output. + (process_extended_line_op): Remove spurious translation. + Add translation for strings that can be translated. + (decode_location_exression): Allow translation of output. + (read_and_display_attr_value): Allow translation of output. + * readelf.c (slurp_rela_relocs): Add translation for error + messages when failing to get data. + (slurp_rel_relocs): Likewise. + (get_32bit_elf_symbols): Likewise. + (get_64bit_elf_symbols): Likewise. + (dump_ia64_vms_dynamic_relocs): Replace abbreviation with full + word. + (process_relocs): Remove spurious translation. + (decode_tic6x_unwind_bytecode): Likewise. + (process_version_section): Improve error messages. + (process_mips_specific): Likewise. + (print_gnu_note): Remove spurious translation. + (print_stapsdt_note): Likewise. + (get_ia64_vms_note_type): Likewise. + * sysdump.c (getCHARS): Allow translation. + (fillup): Allow translation of output. + (getone): Likewise. + (must): Likewise. + (derived_type): Likewise. + * doc/binutils.doc (addr2line): Extend description of command line + options. + * po/binutils.pot: Regenerate. + +2011-10-13 Nick Clifton + + PR binutils/13219 + * readelf.c (GET_ELF_SYMBOLS): Add sym_count parameter. + (get_32bit_elf_symbols): Add num_syms_return argument. + Return the number of symbols loaded into the symbol table. + (get_64bit_elf_symbols): Likewise. + (process_section_headers): Use GET_ELF_SYMBOLS to initialise + symbol count. + (proces_relocs): Likewise. + (ia64_process_unwind): Likewise. + (hppa_process_unwind): Likewise. + (arm_process_unwind): Likewise. + (process_dynamic_section): Likewise. + (process_version_sections): Likewise. + (process_symbol_table): Likewise. + (process_section_groups): Likewise. + Add check before indexing into the symbol table. + (apply_relocations): Likewise. + +2011-10-11 Chris + + PR binutils/13051 + Fix a syntax error bug when compiling rc files with the VERSIONINFO resource + containing more than one language block inside a single StringFileInfo block. + + * windint.h (rc_ver_stringtable): New structure definition. + (rc_ver_info): Use it. + * rcparse.y (verstringtable): New variable. + (verstringtables): New type. + (verstringtables:): New rule declaration. + (verblocks:): Use it. + * resrc.c (append_ver_stringtable): New function. + (append_ver_stringfileinfo): Update to use stringtables. + * windres.h (append_ver_stringfileinfo): Update declaration. + (append_ver_stringtable): New declaration. + * resrc.c (write_rc_versioninfo): Update to support multiple blocks. + * resbin.c (bin_to_res_version): Likewise. + (res_to_bin_versioninfo): Likewise. + +2011-10-10 Nick Clifton + + * po/bg.po: Updated Bulgarian translation. + * po/es.po: Updated Spansih translation. + * po/fi.po: Updated Finnish translation. + * po/fr.po: Updated French translation. + +2011-10-05 DJ Delorie + Nick Clifton + + * readelf.c (get_machine_dlags): Add support for RX's PID mode. + +2011-10-04 Paul Woegerer + Carlos O'Donell + + * dwarf.c (display_debug_lines_decoded): Index directory_table with + directory_index from file_table entry. + +2011-09-30 Cary Coutant + + * binutils/dwarf.h (dwarf_section_display_enum): Add missing enum + constant. + +2011-09-28 Tristan Gingold + + * od-xcoff.c (dump_xcoff32_aout_header): Fix typo. + +2011-09-27 Tristan Gingold + + * od-xcoff.c (dump_xcoff32_aout_header): Remove some gettext macros. + (dump_xcoff32_sections_header): Likewise. + (dump_xcoff32_symbols, dump_xcoff32_relocs): Likewise. + (dump_xcoff32_lineno, dump_xcoff32_loader): Likewise. + (dump_xcoff32_except): Likewise. + (dump_xcoff32_typchk, dump_xcoff32_tbtags): Likewise. + +2011-09-27 Tristan Gingold + + * readelf.c (print_ia64_vms_note): Fix xgettext warnings. + +2011-09-22 Tristan Gingold + + * NEWS: Add marker for 2.22. + +2011-09-21 David S. Miller + + * MAINTAINER: Take over from Jakub Jalinek as SPARC maintainer. + + * readelf.c (display_sparc_hwcaps): New. + (display_sparc_gnu_attribute): New. + (process_sparc_specific): New. + (process_arch_specific): When EM_SPARC, EM_SPARC32PLUS, + or EM_SPARCV9 invoke process_sparc_specific. + +2011-09-18 H.J. Lu + + PR binutils/13196 + * dwarf.c (display_debug_aranges): Check zero address size. + +2011-09-15 H.J. Lu + + PR binutils/13180 + * objcopy.c (is_strip_section_1): New. + (is_strip_section): Use it. Remove the group section if all + members are removed. + +2011-09-08 Nick Clifton + + * po/ja.po: Updated Japanese translation. + +2011-08-26 Nick Clifton + + * po/es.po: Updated Spanish translation. + +2011-08-08 Marcus Comstedt + + PR binutils/12964 + * Makefile.am (embedspu): Use awk rather than sed. + * Makefile.in: Regenerate. + +2011-07-27 Jan Kratochvil + + * dwarf.c (read_and_display_attr_value): Recognize DW_FORM_data4 and + DW_FORM_data8 as location list pointers only for DWARF < 4. + +2011-07-26 Jakub Jelinek + + * NEWS: Mention .debug_macro support. + * dwarf.c (read_and_display_attr_value): Don't print a tab + if attribute is 0. + (get_AT_name): Handle DW_AT_GNU_macros. + (get_line_filename_and_dirname, display_debug_macro): New + functions. + (debug_displays): Add an entry for .debug_macro and .zdebug_macro. + * readelf.c (process_section_headers): With do_debug_macinfo + handle also .debug_macro sections. + * dwarf.h (dwarf_section_display_enum): Add macro. + +2011-07-24 Chao-ying Fu + Maciej W. Rozycki + + * readelf.c (get_machine_flags): Handle microMIPS ASE. + (get_mips_symbol_other): Likewise. + +2011-07-22 H.J. Lu + + * dwarf.c (init_dwarf_regnames): Handle EM_K1OM. + + * elfedit.c (elf_machine): Support EM_K1OM. + (elf_class): Likewise. + + * readelf.c (guess_is_rela): Handle EM_K1OM. + (dump_relocations): Likewise. + (get_machine_name): Likewise. + (get_section_type_name): Likewise. + (get_elf_section_flags): Likewise. + (process_section_headers): Likewise. + (get_symbol_index_type): Likewise. + (is_32bit_abs_reloc): Likewise. + (is_32bit_pcrel_reloc): Likewise. + (is_64bit_abs_reloc): Likewise. + (is_64bit_pcrel_reloc): Likewise. + (is_none_reloc): Likewise. + + * doc/binutils.texi: Mention K1OM for elfedit. + +2011-07-11 Cary Coutant + + PR 12983 + * binutils/nm.c (display_file): Decompress debug sections when + printing line numbers. + +2011-07-03 Samuel Thibault + Thomas Schwinge + + PR binutils/12913 + * elfedit.c (osabis): Use ELFOSABI_GNU name instead of ELFOSABI_LINUX + alias and ELFOSABI_HURD. Add GNU alias. + * readelf.c (get_osabi_name, get_symbol_binding, get_symbol_type): + Likewise. + * doc/binutils.texi : Update accordingly. + +2011-07-01 Nick Clifton + + PR binutils/12325 + * doc/binutils.texi (ar cmdline): Document --target, --version and + --help command line options. + +2011-06-30 Nick Clifton + + PR binutils/12558 + * ar.c (main): When asked to move members in an archive that is + being created, ignore the move request. + +2011-06-29 Nick Clifton + + * readelf.c (get_section_type_name): When displaying an unknown + section type display the hex value first on the assumption that + the full message will probably be truncated into a 15 character + field. + +2011-06-22 Jakub Jelinek + + * dwarf.c (decode_location_expression): For DW_OP_GNU_convert and + DW_OP_GNU_reinterpret, if uvalue is 0, don't add cu_offset. + Handle DW_OP_GNU_parameter_ref. + +2011-06-16 Tom Tromey + + * dwarf-mode.el (dwarf-do-insert-substructure): Call + expand-file-name. + (dwarf-do-refresh): Likewise. + +2011-06-15 Ulrich Weigand + + * readelf.c (get_note_type): Handle NT_ARM_VFP. + +2011-06-13 Walter Lee + + * readelf.c: Include tilepro.h and tilegx.h. + (guess_is_rela): Handle EM_TILEGX and EM_TILEPRO. + (dump_relocations): Likewise. + (get_machine_name): Likewise. + (is_32bit_abs_reloc): Likewise. + (is_32bit_pcerel_reloc): Likewise. + (is_64bit_abs_reloc): Likewise. + (is_64bit_pcrel_reloc): Likewise. + +2011-06-09 Tristan Gingold + + * od-xcoff.c (xcoff32_read_symbols): Allow missing string table + length. + +2011-06-08 Nick Clifton + + PR binutils/12855 + * readelf.c (process_version_sections): Handle binaries containing + corrupt version information. + (process_symbol_table): Stop processing a symbol's version + information if it could not be read in. + + (get_data): Add comment describing the function. + (process_section_headers): Set dynamic_strings_length to 0 if the + dynamic strings could not be read in. + (process_dynamic_section): Likewise. + (process_section_groups): Stop processing the group information if + the data could not be read in. + (hppa_processs_unwind): Assert that there is only one string table + in the file. + (arm_process_unwind): Likewise. + (ia64_process_unwind): Likewise. + Set the size of the unwind auxillary information to 0 if the data + could not be read. + (load_specific_debug_section): Handle a failure to read in the + section. + (process_mips_specific): Stop display of the PLT GOT section if it + could not be read in. + +2011-06-08 Tristan Gingold + + * makefile.vms (DEFS): Define OBJDUMP_PRIVATE_VECTORS. + +2011-06-07 Cary Coutant + + * dwarf.c: Fix conversion to TU number. + +2011-06-02 Nick Clifton + + * resres.c: Fix spelling typo. + * windint.h: Likewise. + * windmc.c: Likewise. + * windres.c: Likewise. + * po/POTFILES.in: Regenerate. + * po/binutils.pot: Regenerate. + +2011-06-01 Daniel Jacobowitz + + * MAINTAINERS: Update my email address. + +2011-05-31 Matthias Klose + + * configure.in (BUILD_INSTALL_MISC): Only add embedspu once. + * configure: Regenerate. + +2011-05-30 Alan Modra + + PR binutils/12820 + * Makefile.am (bin_PROGRAMS): Move BUILD_INSTALL_MISC to.. + (bin_SCRIPTS): ..here. + (EXTRA_SCRIPTS): Define. + (EXTRA_DIST): Add embedspu.sh. + (DISTCLEANFILES): Add embedspu. + (embedspu): Depend on Makefile. Replace sed "s" command with "c". + * Makefile.in: Regenerate. + +2011-05-25 Jakub Jelinek + + * dwarf.c (loc_offsets): New variable. + (loc_offsets_compar): New routine. + (display_debug_loc): Handle loc_offsets not being in ascending order + and also a single .debug_loc entry being used multiple times. + +2011-05-18 Nick Clifton + + PR binutils/12753 + * nm.c (filter_symbols): Treat unique symbols as global symbols. + * doc/binutils.texi (nm): Mention that some lowercase letters + actually indicate global symbols. + +2011-05-15 Tristan Gingold + + * od-xcoff.c: New file. + * objdump.h: New file. + * objdump.c: Include objdump.h + (dump_private_options, objdump_private_vectors): New variables. + (usage): Mention -P/--private. Display handled options. + (long_options): Add -P/--private. + (dump_target_specific): New function. + (dump_bfd): Handle dump_private_options. + (main): Handle -P. + * doc/binutils.texi (objdump): Document -P/--private. + * configure.in (OBJDUMP_PRIVATE_VECTORS, OBJDUMP_PRIVATE_OFILES): + New variables, compute them. + (od_vectors): Add vectors for private dumpers. Make them uniq. + (OBJDUMP_DEFS): Add OBJDUMP_PRIVATE_VECTORS. + * Makefile.am (HFILES): Add objdump.h + (CFILES): Add od-xcoff.c + (OBJDUMP_PRIVATE_OFILES): New variable. + (objdump_DEPENDENCIES): Append OBJDUMP_PRIVATE_OFILES. + (objdump_LDADD): Ditto. + (EXTRA_objdump_SOURCES): Define. + * Makefile.in: Regenerate. + * configure: Regenerate. + +2011-05-10 Tristan Gingold + + * dwarf.c (process_extended_line_op): Dump unknown records. + +2011-05-07 Alan Modra + + PR binutils/12632 + * objcopy.c (copy_archive): Check bfd_openw result in unknown object + case. Rewrite without goto. + +2011-05-03 Jakub Jelinek + + * dwarf.c (decode_location_expression): Handle DW_OP_GNU_const_type, + DW_OP_GNU_regval_type, DW_OP_GNU_deref_type, DW_OP_GNU_convert + and DW_OP_GNU_reinterpret. + + * MAINTAINERS: Add myself as DWARF2 maintainer. + +2011-05-02 Alan Modra + + PR binutils/12720 + Revert the following change + Michael Snyder + * ar.c (move_members): Plug memory leak. + (delete_members): Plug memory leak. + +2011-04-28 Tom Tromey + + * NEWS: Add note about --dwarf-depth, --dwarf-start, and + dwarf-mode.el. + * objdump.c (suppress_bfd_header): New global. + (usage): Update. + (OPTION_DWARF_DEPTH, OPTION_DWARF_START): New constants. + (options): Add dwarf-depth and dwarf-start entries. + (dump_bfd): Use suppress_bfd_header. + (main): Handle OPTION_DWARF_START, OPTION_DWARF_DEPTH. + * doc/binutils.texi (objcopy): Document --dwarf-depth and + --dwarf-start. + (readelf): Likewise. + * dwarf-mode.el: New file. + * dwarf.c (dwarf_cutoff_level, dwarf_start_die): New globals. + (read_and_display_attr_value): Also check debug_info_p. + (process_debug_info): Handle dwarf_start_die and + dwarf_cutoff_level. + * dwarf.h (dwarf_cutoff_level, dwarf_start_die): Declare. + * readelf.c (usage): Update. + (OPTION_DWARF_DEPTH): New macro. + (OPTION_DWARF_START): Likewise. + (options): Add dwarf-depth and dwarf-start entries. + (parse_args): Handle OPTION_DWARF_START and OPTION_DWARF_DEPTH. + +2011-04-28 Jan Kratochvil + + * dwarf.c (display_gdb_index): Support version 5, warn on version 4. + +2011-04-27 Tristan Gingold + + * dwarf.c (process_extended_line_op): Handle + DW_LNE_HP_source_file_correlation. + +2011-04-27 Nick Clifton + + * po/da.po: Updated Danish translation. + +2011-04-21 Tom Tromey + + * readelf.c (print_stapsdt_note): New function. + (process_note): Use it. + +2011-04-21 Tom Tromey + + * readelf.c (get_stapsdt_note_type): New function. + (process_note): Recognize "stapsdt" notes. + +2011-04-21 Tom Tromey + + * readelf.c (process_corefile_note_segment): Change header field + widths. + (process_note): Change field widths. + +2011-04-21 Tom Tromey + + * readelf.c (print_gnu_note): New function. + (process_note): Use it. + +2011-04-21 Jie Zhang + + * MAINTAINERS: Update my email address. + +2011-04-11 Kai Tietz + + * windres.c (usage): Add new --preprocessor-arg option. + (option_values): Add new OPTION_PREPROCESSOR_ARG enumerator. + (option long_options): Add preprocessor-arg option. + (main): Handle it. + * doc/binutils.texi: Add documentation for --preprocessor-arg + option. + * NEWS: Add line about new --preprocessor-arg option for windres. + +2011-04-08 John Marino + + * arlex.l: Prevent redefinition of YY_NO_UNPUT. + * syslex.l: Likewise. + +2011-04-07 Paul Brook + + * readelf.c (arm_section_get_word): Handle C6000 relocations. + (decode_tic6x_unwind_regmask, decode_arm_unwind_bytecode, + decode_tic6x_unwind_bytecode, expand_prel31): New functions. + (decode_arm_unwind): Split out common code from ARM specific bits. + (dump_arm_unwind): Use expand_prel31. + (arm_process_unwind): Handle SHT_C6000_UNWIND sections. + (process_unwind): Add SHT_C6000_UNWIND. + +2011-04-06 Joseph Myers + + * configure.in (thumb-*-pe*): Remove. + * configure: Regenerate. + +2011-04-05 Sterling Augustine + + * MAINTAINERS: Update my email address. + +2011-04-03 H.J. Lu + + PR binutils/12632 + * objcopy.c (copy_unknown_object): Make the archive element + readable. + +2011-04-03 David S. Miller + + * objdump.c (dump_reloc_set): Output R_SPARC_OLO10 relocations + accurately, rather than how they are represented internally. + +2011-03-31 Tristan Gingold + + * makefile.vms (readelf.exe): New target. + +2011-03-31 Tristan Gingold + + * makefile.vms (DEBUG_OBJS): Add elfcomm.obj. + +2011-03-31 Bernd Schmidt + + * readelf.c (get_symbol_index_type): Handle SCOM for TIC6X. + (dump_relocations): Likewise. + +2011-03-31 Tristan Gingold + + * readelf.c (get_ia64_vms_note_type): New function. + (print_ia64_vms_note): Ditto. + (process_note): Recognize VMS/ia64 specific notes. + Display them. + (process_corefile_note_segment): Decode VMS notes. + +2011-03-30 Catherine Moore + + * addr2line.c (translate_addresses): Sign extend the pc + if sign_extend_vma is enabled. + +2011-03-30 Michael Snyder + + * readelf.c (process_gnu_liblist): Stop memory leak. + +2011-03-29 Alan Modra + + * coffdump.c: Include bfd_stdint.h + +2011-03-28 Pierre Muller + + * coffdump.c (coff_dump): Correct spelling error. + (show_usage): Replace SYSROFF by COFF. + +2011-03-25 Pierre Muller + + * coffdump.c (dump_coff_scope): Use double typecast for pointer P + to allow compilation for all targets. + +2011-03-25 Pierre Muller + + * dwarf.c (process_debug_info): Use offset_size to determine + the bit-size of the computation unit's offset. + (decode_location_expression): Use dwarf_vmatoa function to display + DW_OP_addr OP. + (process_debug_info): Use dwarf_vma type for local variables + length and type_offset. + +2011-03-25 Michael Snyder + + * strings.c (print_strings): Plug memory leak. + * ar.c (move_members): Plug memory leak. + (delete_members): Plug memory leak. + (write_archive): Plug memory leak. + * ieee.c (ieee_add_bb11): Plug memory leak. + (ieee_function_type): Likewise. + (ieee_class_baseclass): Likewise. + * prdbg.c (pr_function_type): Close memory leaks. + (pr_method_type): Likewise. + (tg_class_static_member): Likewise. + (tg_class_method_variant): Likewise. + (tg_class_static_method_variant): Likewise. + * stabs.c (parse_stab_enum_type): Fix memory leaks. + (parse_stab_struct_type): Likewise. + (parse_stab_struct_fields): Likewise. + (parse_stab_one_struct_field): Likewise. + (parse_stab_members): Likewise. + (stab_demangle_qualified): Likewise. + * objdump.c (dump_reloc_set): Free malloced memory. + * bucomm.c (make_tempname): Stop memory leak. + +2011-03-25 Pierre Muller + + Replace bfd_vma type and analog types by dwarf_vma and analogs. + Use dwarf specific print functions to display these type values. + * dwarf.h (dwarf_signed_vma): New type; + (DWARF2_External_LineInfo): Replace bfd_vma by dwarf_vma. + (DWARF2_External_PubNames): Likewise. + (DWARF2_External_CompUnit): Likewise. + (DWARF2_External_ARange): Likewise. + (read_leb128): Change return type to dwarf_vma. + * dwarf.c (print_dwarf_vma): Use __MINGW32__ conditional and + check byte_size values. + (dwarf_vmatoa): Change parameter type to dwarf_vma. + (dwarf_svmatoa): New static function. + (read_leb128): Change return type to dwarf_vma. + (read_sleb128): New static function. + (struct State_Machine_Registers): Change address field type to + dwarf_vma. + (process_extended_line_op): Adapt to type changes. + (fetch_indirect_string): Likewise. + (idisplay_block): Likewise. + (decode_location_expression): Likewise. + (read_and_display_attr_value): Likewise. + (process_debug_info): Likewise. + (display_debug_lines_raw): Likewise. + (display_debug_lines_decoded): Likewise. + (SLEB macro): Use new read_sleb128 function. + +2011-03-17 Alan Modra + + PR 12590 + * ar.c (ranlib_main): Init arg_index properly. + (usage): Describe --target. + +2011-03-16 Jakub Jelinek + + * dwarf.c (dw_TAG_name): Handle DW_TAG_GNU_call_site_parameter. + (read_and_display_attr_value): Handle DW_AT_GNU_call_site_data_value, + DW_AT_GNU_call_site_target and DW_AT_GNU_call_site_target_clobbered. + (get_AT_name): Handle DW_AT_GNU_call_site_value, + DW_AT_GNU_call_site_data_value, DW_AT_GNU_call_site_target, + DW_AT_GNU_call_site_target_clobbered, DW_AT_GNU_tail_call, + DW_AT_GNU_all_tail_call_sites, DW_AT_GNU_all_call_sites and + DW_AT_GNU_all_source_call_sites. + (decode_location_expression) : Adjust + handling. + +2011-03-16 Jan Kratochvil + + * dwarf.c (get_TAG_name): Handle DW_TAG_GNU_call_site. + (decode_location_expression): Handle DW_OP_GNU_entry_value. + (read_and_display_attr_value): Handle DW_AT_GNU_call_site_value. + (get_AT_name): Likewise. + +2011-03-14 Michael Snyder + + * objcopy.c (set_pe_subsystem): Free subsystem. + + * wrstabs.c (stab_start_struct_type): Close memory leak. + + * readelf.c (process_version_sections): Free symbols. + + * nm.c (display_rel_file): Free symsizes. + +2011-03-10 Nick Clifton + + * readelf.c (get_machine_name): Update EM_V850 entry. + +2011-03-03 Mike Frysinger + + * objdump.c (usage): Fix single typo. + * po/bg.po, po/binutils.pot, po/da.po, po/es.po, po/fi.po, + po/fr.po, po/id.po, po/ja.po, po/ru.po, po/vi.po: Likewise. + +2011-03-01 Akos Pasztory + + PR binutils/12523 + * readelf.c (process_object): Clear dynamic_info_DT_GNU_HASH. + +2011-02-28 Kai Tietz + + * debug.c (debug_start_source): Use filename_(n)cmp. + * ieee.c (ieee_finish_compilation_unit): Likewise. + (ieee_lineno): Likewise. + * nlmconv.c (main): Likewise. + * objcopy.c (strip_main): Likewise. + (copy_main): Likewise. + * objdump.c (show_line): Likewise. + (dump_reloc_set): Likewise. + * srconv.c (main): Likewise. + * wrstabs.c (stab_lineno): Likewise. + +2011-02-24 Zachary T Welch + + * readelf.c (decode_arm_unwind): Implement decoding of remaining + ARM unwind instructions (i.e. VFP/NEON and Intel Wireless MMX). + +2011-02-23 Kai Tietz + + * dwarf.c (read_leb128): Use bfd_vma instead of + long type. + (dwarf_vmatoa): New helper routine. + (process_extended_line_op): Use for adr bfd_vma + type and print those typed values via BFD_VMA_FMT + or via dwarf_vmatoa for localized prints. + (fetch_indirect_string): Adjust offset's type. + (decode_location_expression): Adjust argument types + and uvalue type. + (read_and_display_attr_value): Likewise. + (read_and_display_attr): Likewise. + (decode_location_expression): Adjust printf format. + (process_debug_info): Likewise. + (display_debug_lines_raw): Likewise. + (display_debug_lines_decoded): Likewise. + (display_debug_pubnames): Likewise. + (display_debug_loc): Likewise. + (display_debug_aranges): Likewise. + * dwarf.h (DWARF2_External_LineInfo, + DWARF2_Internal_LineInfo, DWARF2_External_PubNames, + DWARF2_Internal_PubNames, DWARF2_External_CompUnit, + DWARF2_Internal_CompUnit, DWARF2_External_ARange, + DWARF2_Internal_ARange): Added.. + (read_leb128): Adjust return type. + +2011-02-13 Ralf Wildenhues + + * configure: Regenerate. + +2011-02-08 Nick Clifton + + PR binutils/12467 + * readelf.c (process_program_headers): Issue a warning if there + are no program headers but the file header has a non-zero program + header offset. + (process_section_headers): Issue a warning if there are no section + headers but the file header has a non-zero section header offset. + (process_section_groups): Reword the no section message so that it + can be distinguished from the one issued by process_section_headers. + +2011-01-26 Jan Kratochvil + Doug Evans + + * dwarf.c (display_gdb_index): Support version 4, warn on version 3. + +2011-01-19 Maciej W. Rozycki + + * readelf.c (process_object): Free dynamic_section after use. + +2011-01-18 H.J. Lu + + PR binutils/12408 + * readelf.c (process_archive): Free and reset dump_sects + after processing each archive member. + +2011-01-11 Andreas Schwab + + * readelf.c (print_symbol): Handle symbol characters as unsigned. + Whitespace fixes. + +2011-01-10 Nick Clifton + + * po/da.po: Updated Danish translation. + +2011-01-06 Vladimir Siminov + + * bucomm.c (get_file_size): Check for negative sizes and issue a + warning message if encountered. + +2011-01-01 H.J. Lu + + * version.c (print_version): Update copyright to 2011. + +For older changes see ChangeLog-2010 + +Copyright (C) 2011 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2012 b/support/sdbinutils/binutils/ChangeLog-2012 new file mode 100644 index 0000000..da7d9e4 --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2012 @@ -0,0 +1,756 @@ +2012-12-17 Nick Clifton + + * BRANCHES: Add copyright notice. + * MAINTAINERS: Likewise. + * Makefile.am: Likewise. + * NEWS: Likewise. + * README: Likewise. + * configure.com: Likewise. + * configure.in: Likewise. + * configure.tgt: Likewise. + * dwarf-mode.el: Likewise. + * makefile.vms: Likewise. + * syslex_wrap.c: Likewise. + * doc/Makefile.am: Likewise. + * Makefile.in: Regenerate. + * doc/Makefile.in: Regenerate. + +2012-11-27 Kai Tietz + + * resbin.c (bin_to_res_version): Correct offset + and length calculation of resource. + (get_version_header): Apply alignement of 4 to len. + +2012-11-16 H.J. Lu + + * readelf.c (process_dynamic_section): Correct DF_1_CONFALT. + Also dump DF_1_ENDFILTEE, DF_1_DISPRELDNE, DF_1_NODIRECT, + DF_1_IGNMULDEF, DF_1_NOKSYMS, DF_1_NOHDR, DF_1_EDITED, + DF_1_NORELOC, DF_1_SYMINTPOSE, DF_1_GLOBAUDIT and DF_1_SINGLETON. + +2012-11-14 Tristan Gingold + + * od-macho.c (bfd_mach_o_load_command_name): Add new definitions. + (dump_load_command): Handle BFD_MACH_O_LC_SOURCE_VERSION + and BFD_MACH_O_LC_MAIN. + +2012-11-13 Maciej W. Rozycki + + * readelf.c (get_machine_flags) : Move + code to handle EF_SH_PIC and EF_SH_FDPIC... + : ... here. + +2012-11-09 Nick Clifton + + * readelf.c (get_machine_flags): Add support for E_FLAG_RX_ABI. + (guess_is_rela): Add EM_V800. + (dump_relocations): Likewise. + (get_machine_name): Update EM_V800. + (get_machine_flags): Add support for RH850 ABI flags. + (is_32bit_abs_reloc): Add support for RH850 ABI reloc. + +2012-11-09 H.J. Lu + + * coffgrok.c (coff_grok): Remove trailing redundant `;'. + * resrc.c (open_input_stream): Likewise. + +2012-11-08 Alan Modra + + * po/POTFILES.in: Regenerate. + +2012-11-07 H.J. Lu + + * objcopy.c (copy_section): Don't read beyond section end. + +2012-11-06 H.J. Lu + + PR binutils/14567 + * Makefile.am (BFDTEST2_PROG): New. + (bfdtest2_DEPENDENCIES): Likewise. + (TEST_PROGS): Add $(BFDTEST2_PROG). + * Makefile.in: Regenerated. + * bfdtest2.c: New file. + +2012-11-05 Stephane Carrez + + * MAINTAINERS: Update my email address. + +2012-11-05 Alan Modra + + * configure.in: Apply 2012-09-10 change to config.in here. Add + __CONFIG_H__ check. + * config.in: Regenerate. + +2012-11-01 Tom Tromey + + * readelf.c (get_note_type): Handle NT_386_TLS, NT_386_IOPERM. + +2012-10-30 Nick Clifton + + PR binutils/14779 + * configure.in: Add checks for wchar.h and mbstate_t. + * config.in: Regenerate. + * configure: Regenerate. + * readelf.c: Conditionally include wchar.h. + (print_symbol): Conditionally use mbstate_t. + +2012-10-30 Steve McIntyre + + * readelf.c (decode_ARM_machine_flags): Recognise and display the + new ARM hard-float/soft-float ABI flags for EABI_VER5. Split out + the code for EABI_VER4 and EABI_VER5 to allow this. + +2012-10-29 Alan Modra + + * dlltool.c (INIT_SEC_DATA): Move. + (secdata ): Use here too. + +2012-10-26 Nick Clifton + + * po/hr.po: New Croation translation. + * configure.in (ALL_LINGUAS): Add hr. + * configure: Regenerate. + +2012-10-23 Cary Coutant + + * dwarf.c (do_debug_addr, do_debug_cu_index): New global flags. + (load_debug_info): Fix typo. + (cu_tu_indexes_read, shndx_pool, shndx_pool_size, shndx_pool_used): + New global variables. + (prealloc_cu_tu_list, add_shndx_to_cu_tu_entry, end_cu_tu_entry) + (process_cu_tu_index, load_cu_tu_indexes, find_cu_tu_set) + (display_cu_index): New functions. + (dwarf_select_sections_by_names): Add "debug_addr", "cu_index". + Sort entries alphabetically. + (dwarf_select_sections_all): Set do_debug_addr, do_debug_cu_index. + (debug_displays): Add .debug_cu_index, .debug_tu_index. + Clean up formatting. + * dwarf.h (dwarf_section_display_enum): Add dwp_cu_index, + dwp_tu_index. + (do_debug_addr, do_debug_cu_index): New global flags. + (find_cu_tu_set): New function declaration. + * objdump.c (usage): Add --dwarf=addr, --dwarf=cu_index. + * readelf.c (find_section_in_set): New function. + (usage): Add --debug-dump=addr, --debug_dump=cu_index. + (process_section_headers): Check do_debug_addr and do_debug_cu_index. + (section_subset): New global variable. + (load_debug_section): Restrict search to section subset. + (display_debug_section): Add section index as paramter. Select subset + of sections when dumping a .dwp file. Update caller. + +2012-10-23 Tom Tromey + + * readelf.c (get_note_type): Handle NT_SIGINFO, NT_FILE. + (print_core_note): New function. + (process_note): Call it. + +2012-10-21 H.J. Lu + + * objdump.c (dump_dwarf): Handle bfd_mach_x64_32 and + bfd_mach_x64_32_intel_syntax. + +2012-10-21 Alan Modra + + * objdump.c (load_specific_debug_section): Use + bfd_cache_section_contents. + +2012-10-18 Kai Tietz + + * objdump.c (dump_bfd): Call dump headers after + call of slurp_symtab. + + * objcopy.c (is_strip_section_1): Don't strip + .reloc section by default. + +2012-10-11 Doug Evans + + * dwarf.c (display_gdb_index): Include static/global information + of each symbol. + +2012-09-14 David Edelsohn + + * configure: Regenerate. + +2012-09-10 Matthias Klose + + * config.in: Disable sanity check for kfreebsd. + +2012-09-10 H.J. Lu + + * configure: Regenerated. + +2012-09-06 Cary Coutant + + * dwarf.c (decode_location_expression): Add + DW_OP_GNU_const_index. + +2012-09-06 Nick Clifton + + * doc/binutils.texi (nm): Alpha-sort the option descriptions. + Add description of the --synthetic option. + +2012-09-04 H.J. Lu + + PR binutils/14493 + * readelf.c (get_symbol_index_type): Check bad section index. + +2012-08-24 Matthew Gretton-Dann + + * readelf.c (arm_attr_tag_CPU_arch): Update for ARMv8. + (arm_attr_tag_FP_arch): Likewise. + (arm_attr_tag_Advanced_SIMD_arch): Likewise. + +2012-08-17 Yuri Chornoivan + + * doc/binutils.texi, * objdump.c, * od-xcoff.c: Typo fixes. + +2012-08-16 H.J. Lu + + PR binutils/14481 + * Makefile.am (BFDTEST1_PROG): New. + (TEST_PROGS): Likewise. + (bfdtest1_DEPENDENCIES): Likewise. + (noinst_PROGRAMS): Add $(TEST_PROGS). + * Makefile.in: Regenerated. + + * bfdtest1.c: New file. + +2012-08-13 Ian Bolton + Laurent Desnogues + Jim MacArthur + Marcus Shawcroft + Nigel Stephens + Ramana Radhakrishnan + Richard Earnshaw + Sofiane Naci + Tejas Belagod + Yufeng Zhang + + * readelf.c (guess_is_rela): Handle EM_AARCH64. + (get_machine_name): Likewise. + (get_aarch64_segment_type): New function. + (get_segment_type): Handle EM_AARCH64 by calling the new function. + (get_aarch64_section_type_name): New function. + (get_section_type_name): Handle EM_AARCH64 by calling the new function. + (is_32bit_abs_reloc): Handle EM_AARCH64. + (is_32bit_pcrel_reloc): Likewise. + (is_64bit_abs_reloc): Likewise. + (is_64bit_pcrel_reloc): Likewise. + (is_none_reloc): Likewise. + +2012-08-09 Nick Clifton + + * po/vi.po: Updated Vietnamese translation. + +2012-08-03 Tom Tromey + + * dlltool.c (scan_obj_file): Close arfile after calling + bfd_openr_next_archived_file. + +2012-08-02 H.J. Lu + + PR binutils/14420 + * dwarf.c (process_abbrev_section): Add attribute terminator. + Warn missing section terminator. + (get_FORM_name): Special check for 0 value. + (get_AT_name): Likewise. + (process_debug_info): Display zero abbrev number. Check + attribute terminator. + +2012-07-30 Nick Clifton + + * po/binutils.pot: Updated template. + * po/bg.po: Updated Bulgarian translation. + * po/es.po: Updated Spanish translation. + * po/fi.po: Updated Finnish translation. + * po/fr.po: Updated French translation. + * po/uk.po: Updated Ukranian translation. + +2012-07-28 Kai Tietz + + * rcparse.y (FILEVERSION): Use optcnumexpr instead of cnumexpr. + (PRODUCTVERSION): Likewise. + +2012-07-27 Mike Frysinger + + * configure.in (BFD_VERSION): Run bfd/configure --version and + parse the output of that. + * configure: Regenerate. + +2012-07-27 Tristan Gingold + + * NEWS: Add marker for 2.23. + +2012-07-24 Teresa Johnson + + * addr2line.c (find_address_in_section): Invoke + bfd_find_nearest_line_discriminator to get the discriminator. + (find_offset_in_section): Likewise. + (translate_addresses): Print discriminator if it is non-zero. + * objdump.c (show_line): Invoke + bfd_find_nearest_line_discriminator to get the discriminator, + and keep track of prev_discriminator. Print discriminator + if it is non-zero. + (disassemble_data): Initialize prev_discriminator. + (dump_reloc_set): Invoke bfd_find_nearest_line_discriminator + to get the discriminator, and keep track of last_discriminator. + Print discriminator if it is non-zero. + +2012-07-17 Nick Clifton + + * elfcomm.c (setup_archive): Extract index table and symbol table + scanning code into... + (process_archive_index_and_symbols): ... this function and add + support for 64-bit index tables. + * elfcomm.h (struct archive_info): Change type of index_num and + index_array to elf_vma. + Add 'uses_64bit_indicies' field. + * readelf.c (process_archive): Fix support for 64-bit indicies. + +2012-07-03 Nick Clifton + + * readelf.c (process_archive): Display member indicies when + dumping index. + +2012-07-02 Tom Tromey + + * dwarf.c: Include gdb-index.h. + (display_gdb_index): Handle version 7. + +2012-06-29 H.J. Lu + + * nm.c (filter_symbols): Simplify global symbol handling. + +2012-06-29 Francois Gouget + + PR binutils/14302 + * bucomm.c (print_arelt_descr): Correctly report the archive size + field (for 'ar tv'). + * ar.c (print_contents): Use correct types for archive element + sizes (for 'ar p'). + (extract_file): Likewise (for 'ar x'). + +2012-06-29 Alan Modra + + * readelf.c (is_16bit_abs_reloc): Handle mn10200 reloc. + +2012-06-12 Tom Tromey + + * dwarf-mode.el: Add final comment. Bump version. + (dwarf-insert-substructure-button): Use string-to-number. + (dwarf-browse): Fix autoload cookie. + +2012-06-08 Jakub Jelinek + + * dwarf.c (read_and_display_attr_value): Handle + DW_FORM_GNU_ref_alt and DW_FORM_GNU_strp_alt. + (display_debug_macro): Handle DW_MACRO_GNU_define_indirect_alt, + DW_MACRO_GNU_undef_indirect_alt and + DW_MACRO_GNU_transparent_include_alt. + +2012-06-01 Alan Modra + + * addr2line.c (translate_addresses): Truncate input addresses to + arch_size bits. Avoid undefined shift. Print '?' for zero line. + +2012-05-30 Nick Clifton + + * readelf.c (process_section_headers): Correct bug in previous + delta - display full section type in wide mode. + +2012-05-28 Nick Clifton + + * readelf.c (print_symbol): Display multibyte characters in symbol + names. + (process_section_headers): Use print_symbol. + +2012-05-18 Andreas Schwab + + * aclocal.m4: Regenerate. + * configure: Regenerate. + * config.in: Regenerate. + * Makefile.in: Regenerate. + +2012-05-17 Daniel Richard G. + Nick Clifton + + PR 14072 + * configure.in: Add check that sysdep.h has been included before + any system header files. + * configure: Regenerate. + * config.in: Regenerate. + * unwind-ia64.h: Include config.h. + +2012-05-17 Alan Modra + + * dwarf.c (process_debug_info): Display abbrev offset in hex. + (display_debug_abbrev): Show offset of abbrev. + +2012-05-17 Alan Modra + + * dwarf.c (display_debug_ranges): Don't report more than one use + of the same range set as an overlap. + +2012-05-16 Daniel Richard G. + + PR binutils/13558 + * Makefile.am (CFILES): Add syslex_wrap.c. + (sysinfo): Depend upon syslex_wrap.o. + (syslex_wrap.o): New rule. + (syslex.o): Delete rule. + * syslex_wrap.c: New file. + * Makefile.in: Regenerate. + +2012-05-15 James Murray + + * readelf.c (get_machine_name): Update m68hc12 entry. + +2012-05-13 H.J. Lu + + * objdump.c (disassemble_bytes): Print addend as signed. + (dump_reloc_set): Likewise. + +2012-05-04 Sterling Augustine + Cary Coutant + + * doc/binutils.texi: Add --dwarf-check option. + * dwarf.c (dwarf_check): New global flag. + (fetch_indexed_string): New function. + (fetch_indexed_value): New function. + (get_FORM_name): Add DW_FORM_GNU_str_index and DW_FORM_GNU_addr_index. + (decode_location_expression): Add DW_OP_GNU_addr_index. + (read_and_display_attr_value): Add DW_FORM_GNU_str_index, + DW_FORM_GNU_addr_index, DW_AT_GNU_addr_base, and DW_AT_GNU_ranges_base. + (get_AT_name): Add new attributes for Fission. + (process_debug_info): Load new debug sections for Fission. + (load_debug_info): Check for .debug_info.dwo section. + (display_loc_list, display_loc_list_dwo): New functions. + (display_debug_loc): Move logic to above two functions. + (display_debug_info): Choose abbrev section based on info section. + (display_debug_types): Likewise. + (display_trace_info): Likewise. + (comp_addr_base): New function. + (display_debug_addr): New function. + (display_debug_str_offsets): New function. + (display_debug_ranges): Allow missing range lists. Suppress + diagnostics if dwarf_check not set. + (debug_displays): Add column to select abbrev section. + * dwarf.h (enum dwarf_section_display_enum): Add new debug sections + for Fission. + (struct dwarf_section): Add abbrev_sec field. + (struct dwarf_section_display): New type. + (debug_info): Add addr_base, ranges_base fields. + (dwarf_check): New global variable. + * objdump.c (usage): Add --dwarf-check option. + (enum option_values): Add OPTION_DWARF_CHECK. + (long_options): Add --dwarf-check. + (main): Likewise. + * readelf.c (OPTION_DWARF_CHECK): New macro. + (options): Add --dwarf-check. + (parse_args): Likewise. + (process_section_headers): Use const_strneq instead of + streq. + +2012-05-11 H.J. Lu + + PR binutils/14088 + * readelf.c (dump_relocations): Always display addend as + signed hex number. + +2012-05-11 Daniel Richard G. + + PR binutils/14028 + * configure.in: Invoke ACX_HEADER_STRING. + * configure: Regenerate. + * config.in: Regenerate. + * sysdep.h: If STRINGS_WITH_STRING is defined then include both + string.h and strings.h. + +2012-05-10 Jakub Jelinek + + * dwarf.c (read_and_display_attr_value): Don't look up tag from + abbrev for DW_FORM_ref_addr. + +2012-05-08 Sean Keys + + * binutils/MAINTAINERS: Added my entry to the maintainers secion. + +2012-05-08 Cary Coutant + + * doc/binutils.texi (objcopy): Add --strip-dwo, --extract-dwo options. + (strip): Add --strip-dwo option. + * objcopy.c (enum strip_action): Add STRIP_DWO, STRIP_NONDWO. + (enum command_line_switch): Add OPTION_EXTRACT_DWO, OPTION_STRIP_DWO. + (strip_options): Add --strip-dwo option. + (copy_options): Add --extract-dwo, --strip-dwo options. + (copy_usage): Likewise. + (strip_usage): Add --strip-dwo option. + (is_dwo_section): New function. + (is_strip_section_1): Check for DWO sections. + (copy_object): Check for --strip-dwo, --extract-dwo options. + (copy_relocations_in_section): Discard relocations for DWO sections. + Discard entire relocation section when no relocations. + (strip_main): Add --strip-dwo option. + (copy_main): Add --strip-dwo, --extract-dwo options. + +2012-05-08 Alan Modra + + * Makefile.am (check_DEJAGNU): Export LC_ALL=C in place of other + LC and LANG environment vars. + * Makefile.in: Regenerate. + +2012-05-07 Tom Tromey + + * dwarf.c (get_TAG_name): Use get_DW_TAG_name. + (get_FORM_name): Use get_DW_FORM_name. + (get_AT_name): Use get_DW_AT_name. + +2012-05-07 Alan Modra + + * Makefile.am (check-DEJAGNU): Clear LC_COLLATE, LC_ALL and LANG. + * Makefile.in: Regenerate. + +2012-05-05 Alan Modra + + * dlltool.c (make_one_lib_file): Use bfd_und_section_ptr. + +2012-05-03 Sean Keys + + * readelf.c: Add support for XGATE. + +2012-05-02 Nick Clifton + + * po/vi.po: Updated Vietnamese translation. + * po/it.po: New Italian translation. + * configure.in (ALL_LINGUAS): Add it. + * configure: Regenerate. + +2012-05-01 Nick Clifton + + PR binutils/13121 + * rescoff.c: Rename 'finfo' to 'flaginfo' to avoid conflicts with + AIX system headers. + +2012-04-25 Cary Coutant + + * doc/binutils.texi: Add -D/--enable-deterministic-archives option + to strip and objcopy. + * objcopy.c (deterministic): New global variable. + (strip_options): Add --enable-deterministic-archives. + (copy_options): Likewise. + (copy_usage): Likewise. + (strip_usage): Likewise. + (copy_archive): When stripping all, don't add archive map; set + deterministic output when requested. + (strip_main): Add -D/--enable-deterministic-archives option. + (copy_main): Likewise. + +2012-04-12 H.J. Lu + + PR binutils/13947 + * objcopy.c (copy_object): Call copy_relocations_in_section + before copy_section. + (skip_section): New. + (copy_relocations_in_section): Likewise. + (copy_section): Use skip_section. Don't copy relocations here. + +2012-04-11 Ryan Mansfield + + * objdump.c (dump_bfd): If defaulting to dwarf call + dwarf_select_sections_all to enable displays. + +2012-04-06 Roland McGrath + + * configure.in (AC_CHECK_HEADERS): Add locale.h. + * config.in: Regenerate. + * configure: Regenerate. + +2012-04-05 Nick Clifton + + * configure.in (AC_CHECK_FUNCS): Add setlocale. + (AM_LC_MESSAGES): Add. + * aclocal.m4: Regenerate. + * config.in: Regenerate. + * configure: Regenerate. + +2012-03-30 Nick Clifton + + PR binutils/13925 + * stabs.c (stab_demangle_v3_arglist): Cope with the demangler + returning an empty context for a function with no arguments. + +2012-03-28 Tom Tromey + + * dwarf.c (display_gdb_index): Handle index version 6. + +2012-03-07 Nick Clifton + + * readelf.c (is_16bit_abs_reloc): Add detection of R_MN10300_16. + +2012-02-29 Jeff Law + + * doc/binutils.texi (c++filt): Fix typos. + +2012-02-24 Kai Tietz + + PR binutils/13710 + * defparse.y (keyword_as_name): Disable LIBRARY + keyword. + * doc/binutils.texi: Document LIBRARY exception. + +2012-02-21 Kai Tietz + + PR binutils/13682 + * NEWS: Mention new feature. + * dlltool.c (i386_x64_dljtab): New stub-code for x64 + delayed-load feature. + (i386_x64_trampoline): New trampoline-code for x64 + delayed-load feature. + (make_one_lib_file): Add support for x64 delayed-load + feature. + (make_delay_head): Likewis + +2012-02-20 Namhyung Kim + + * objdump.c (slurp_file): Close file if fstat fails. + +2012-02-14 Cary Coutant + + * dwarf.c (dwarf_vmatoa64): New function. + (read_and_display_attr_value): Print 8-byte forms as single hex + numbers. + (process_debug_info): Print type signatures as single hex numbers. + * elfcomm.c (byte_get_64): New function. + * elfcomm.h (byte_get_64): New function. + +2012-02-11 Kai Tietz + + PR binutils/13657 + * defparse.y (%union): New type id_const. + (opt_name2): New rule. + (keyword_as_name): New rule. + (opt_name): Adjust rule. + (opt_import_name): Likewise. + (opt_equal_name): Likewise. + +2012-02-11 Kai Tietz + + PR binutils/13297 + * resrc.c (write_rc_dialog_control): Omit text dump for + EDITTEXT, COMBOBOX, LISTBOX, and SCROLLBAR. + +2012-02-09 Alan Modra + + * sysdep.h: Include sys/stat.h here. + * ar.c: Don't include headers already included by sysdep.h. + * bucomm.c: Likewise. + * budbg.h: Likewise. + * dlltool.h: Likewise. + * elfedit.c: Likewise. + * nlmconv.c: Likewise. + * objcopy.c: Likewise. + * objdump.c: Likewise. + * objdump.h: Likewise. + * readelf.c: Likewise. + * rename.c: Likewise. + * resrc.c: Likewise. + * strings.c: Likewise. + * windres.c: Likewise. + * od-macho.c: Ensure #include sysdep.h is first. + * od-xcoff.c: Likewise. + * dllwrap.c: Remove alloca pragma handled by sysdep.h, and + remove duplicate headers. + * dlltool.c: Likewise and ensure #include sysdep.h is first. + +2012-02-01 Nick Clifton + + PR binutils/13493 + * ar.c (ranlib_main): Process --plugin option. + * doc/binutils.texi: Document --plugin support for ranlib. + +2012-02-01 Nick Clifton + + PR binutils/13482 + * readelf.c (process_corefile_note_segment): Fix off-by-one errors + verifying the contents of a note. + +2012-01-26 Nick Clifton + + PR binutils/13622 + * readelf.c (process_section_groups): If there are no section + headers do not scan for section groups. + (process_note_sections): Likewise for note sections. + +2012-01-20 Tristan Gingold + + * od-macho.c (OPT_SEG_SPLIT_INFO): New macro. + (options): Add an entry for seg_split_info. + (mach_o_help): Document it. + (dump_segment_split_info): New function. + (dump_load_command): Handle seg_split_info. + +2012-01-19 Tristan Gingold + + * dwarf.c (process_extended_line_op): Add a cast to silent a + warning. + +2012-01-19 Tristan Gingold + + * dwarf.c (process_extended_line_op): Reindent define_file output. + Detect define_file opcode length mismatch. + (display_debug_lines_decoded): Add an entry in file_table for each + define_file opcode. + Ignore DW_LNE_set_discriminator and DW_LNE_HP_set_sequence. + Display extended opcode for unhandle opcode. + +2012-01-17 Alan Modra + + * version.c (print_version): Update copyright message year. + +2012-01-16 Alan Modra + + PR binutils/13593 + * nm.c (OPTION_SIZE_SORT): Define. + (long_options): Don't set no_sort, sort_numerically or + sort_by_size directly. + (main): Instead set the flags here, making them mutually exclusive. + +2012-01-10 Tristan Gingold + + * objdump.c (display_object_bfd): Renamed from ... + (display_bfd): ... this. + (display_any_bfd): New function. + (display_file): Split. Handle nested archives. + +2012-01-09 Roland McGrath + + * configure.in: Use AM_ZLIB. + * configure: Regenerated. + +2012-01-06 Nick Clifton + + * po/ru.po: Updated Russian translation. + +2012-01-04 Tristan Gingold + + * od-macho.c (dump_load_command): Handle fvmlib. + +2012-01-04 Tristan Gingold + + * od-macho.c: Update copyright year. + (dump_load_command): Handle BFD_MACH_O_LC_ENCRYPTION_INFO. + +For older changes see ChangeLog-2011 + +Copyright (C) 2012 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2013 b/support/sdbinutils/binutils/ChangeLog-2013 new file mode 100644 index 0000000..541de44 --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2013 @@ -0,0 +1,681 @@ +2013-12-31 Nick Clifton + + * objcopy.c (dump_sections): New list. + (command_line_switch): Add OPTION_DUMP_SECTION. + (copy_options): Add dump-section. + (copy_usage): Document new option. + (copy_object): Dump requested sections. + (copy_main): Handle --dump-section. + * doc/binutils.texi: Document --dump-section option. + * NEWS: Mention new feature. + +2013-12-20 Nick Clifton + + PR binutils/16218 + * dwarf.c (read_and_display_attr_value): Only print a tab + character if it preceeds further text. + +2013-12-19 Tom Tromey + + * dwarf.c (fetch_indirect_string): Don't bias by section address. + (fetch_indexed_string): Likewise. + (process_debug_info): Likewise. + (display_debug_loc): Likewise. + (display_debug_ranges): Likewise. + +2013-12-13 Kuan-Lin Chen + Wei-Cheng Wang + + * readelf.c: Include elf/nds32.h + (guess_is_rela): Add case for EM_NDS32. + (dump_relocations): Add case for EM_NDS32. + (decode_NDS32_machine_flags): New. + (get_machine_flags): Add case for EM_NDS32. + (is_32bit_abs_reloc): Likewise. + (is_16bit_abs_reloc): Likewise. + (process_nds32_specific): New. + (process_arch_specific): Add case for EM_NDS32. + * NEWS: Announce Andes nds32 support. + * MAINTAINERS: Add nds32 maintainers. + +2013-12-10 Roland McGrath + + * Makefile.am (install-exec-local): Prefix libtool invocation with + $(INSTALL_PROGRAM_ENV). + * Makefile.in: Regenerate. + +2013-11-22 Cory Fields + + * windres.c (define_resource): Use zero for timestamp, making + output deterministic. time.h include is no longer needed. + * resres.c (res_append_resource): Likewise. + +2013-11-13 Martin Mitas + + * rescoff.c (write_coff_file): Use 64-bit alignment for resource + data. + (coff_res_to_bin): Likewise. + +2013-11-07 Doug Evans + + Add pretty-printing of .debug_gnu_pubnames, .debug_gnu_pubtypes. + * dwarf.c (get_gdb_index_symbol_kind_name): New function. + (display_debug_pubnames_worker): Renamed from display_debug_pubnames. + Add support for .debug_gnu_pubnames, .debug_gnu_pubtypes. + (display_debug_pubnames, display_debug_pubnames_gnu): New functions. + (display_gdb_index): Redo printing of symbol kind. + (debug_displays): Add .debug_gnu_pubnames, .debug_gnu_pubtypes. + * dwarf.h (dwarf_section_display_enum): Add gnu_pubnames, gnu_pubtypes. + * readelf.c (process_section_headers): Add gnu_pubnames, gnu_pubtypes. + +2013-11-07 Roland McGrath + + * objdump.c (dump_dwarf): Grok bfd_mach_x86_64_nacl and + bfd_mach_x64_32_nacl as equivalent to bfd_mach_x86_64. + +2013-10-30 Alan Modra + + * readelf.c (get_ppc_dynamic_type): Replace PPC_TLSOPT with PPC_OPT. + (get_ppc64_dynamic_type): Replace PPC64_TLSOPT with PPC64_OPT. + +2013-10-30 Ulrich Weigand + + * readelf.c (get_ppc64_symbol_other): New function. + (get_symbol_other): Use it for EM_PPC64. + +2013-10-30 Alan Modra + + * readelf.c (get_machine_flags): Display ABI version for EM_PPC64. + +2013-10-24 Nick Clifton + + * nm.c (display_rel_file): Treat bfd_error_no_symbols as + non-fatal. + +2013-10-14 Chao-ying Fu + + * readelf.c (display_mips_gnu_attribute): Support Tag_GNU_MIPS_ABI_MSA. + * doc/binutils.texi: Document -Mmsa disassembler option. + +2013-10-14 Jan-Benedict Glaw + + * readelf.c (decode_arm_unwind): Don't initialize `addr'. + +2013-10-14 Nick Clifton + + * readelf.c (decode_arm_unwind): Initialise addr structure. + (process_symbol_table): Free lengths. + * srcconv.c (wr_sc): Free info. + +2013-10-11 Roland McGrath + + * winduni.c (languages): Use \345 (octal syntax) rather than + literal non-ASCII/non-UTF8 character in string literal. + + * readelf.c (print_dynamic_symbol): Use array subscript syntax + rather than addition syntax with string literal. + +2013-10-09 Nick Clifton + + PR binutils/16023 + * debug.c (debug_type_samep): Add missing break statement. + + PR binutils/16024 + * objdump.c (usage): Mark as a no-return function. + (main): Add comment explaining why a break statement is not + needed. + + * dwarf.c (add64): New function. + (read_and_display_attr_value): Add CU offset in to the value + displayed for a DW_AT_ref8 attribute. + +2013-10-01 Cory Fields + + * arsup.c (ar_save): Respect the deterministic setting when + reading from an mri script. + * ar.c (main): Set the default deterministic mode when reading + from an mri script. + +2013-10-01 Jan-Benedict Glaw + + * dwarf.c (SAFE_BYTE_GET): Fix argument check. + +2013-09-27 H.J. Lu + + * dwarf.c (display_debug_frames): Pass offset_size to + print_dwarf_vma for cie_id. + +2013-09-20 Alan Modra + + * configure: Regenerate. + +2013-09-18 Tristan Gingold + + * NEWS: Add marker for 2.24. + +2013-09-18 Tristan Gingold + + * Makefile.am (LEXLIB): Define. Replase references to @LEXLIB@ + by $(LEXLIB). + * Makefile.in: Regenerate. + +2013-09-17 Doug Gilmore + + * readelf.c (get_machine_flags): Handle EF_MIPS_FP64. + +2013-09-12 Nick Clifton + + * dwarf.c (dwarf_vmatoa): Rename to dwarf_vmatoa_1 and add a + precision parameter. + (dwarf_vmatoa): New wrapper for dwarf_vmatoa_1. + (print_dwarf_vma): Use dwarf_vmatoa_1. + (SAFE_BYTE_GET): Add check that VAL is big enough to contain + AMOUNT bytes. + (process_debug_info): Use an unsigned int for the offset size. + (process_debug_pubnames): Likewise. + (display_debug_aranges): Likewise. + (struct Frame_Chunk): Use dwarf_vma type for pc_begin and pc_range + fields. + (frame_display_row): Use print_dwarf_vma to display dwarf_vma + values. + (display_debug_frames): Likewise. + +2013-09-10 Nick Clifton + + * dwarf.c (display_debug_frames): Check for DW64_CIE_ID when + parsing 64-bit frames. + +2013-08-27 Nick Clifton + + PR binutils/15796 + * ar.c (map_over_members): Correctly handle multiple same-name + entries on the command line and in the archive. + +2013-08-23 H.J. Lu + + * doc/binutils.texi: Remove the extra space. + +2013-08-23 Mikael Pettersson + + PR binutils/15779 + * doc/binutils.texi (ranlib -D): Correct description. + PR binutils/15777 + (nm --special-syms): Fix typo. + +2013-08-23 Nick Clifton + + PR binutils/15798 + * doc/binutils.texi (ar cmdline): Update description of 'q' + command. + + PR binutils/14136 + (nm): Add description of 'I' symbol type. + +2013-08-23 Yuri Chornoivan + + PR binutils/15834 + * od-xcoff.c: Fix typos. + +2013-08-19 Tristan Gingold + + * nm.c (print_size_symbols): Directly get symbol size. + +2013-08-12 Andreas Schwab + + PR binutils/15818 + * objdump.c (disassemble_section): Return early if nothing from + this section needs to be disassembled. + +2013-08-09 Nick Clifton + + * readelf.c (get_machine_flags): Handle RL78 G10 flag. + +2013-07-26 Sergey Guriev + Alexander Ivchenko + Maxim Kuznetsov + Sergey Lega + Anna Tikhonova + Ilya Tocar + Andrey Turetskiy + Ilya Verbin + Kirill Yukhin + Michael Zolotukhin + + * dwarf.c (dwarf_regnames_i386): Add k0-k7 registers and + numeration in comments. + (dwarf_regnames_x86_64): Add xmm16-31 and k0-k7 registers to + dwarf table. + +2013-07-19 Nick Clifton + + PR binutils/15745 + * readelf.c (get_unwind_section_word): Whilst searching for a + reloc section associated with an unwind section, check the type as + well as the section number. + +2013-07-18 Jim Thomas + + * ar.c (usage): Fix C conformance issue. + +2013-07-18 Nick Clifton + + * doc/binutils.texi (nm, objdump): Remove bogus links to STABS + documentation. + + * readelf.c (process_unwind): Do not return the result of a void + function. + +2013-07-15 Maciej W. Rozycki + + * readelf.c (display_mips_gnu_attribute): Replace hardcoded magic + numbers with enum values. + +2013-07-12 Maciej W. Rozycki + + * readelf.c (get_machine_flags): Handle EF_MIPS_NAN2008. + +2013-07-10 Tristan Gingold + + * od-xcoff.c (OPT_LDINFO): Define. + (options): Add ldinfo. + (xcoff_help): Mention ldinfo. + (xcoff_dump): Rename to ... + (xcoff_dump_obj): ... this. Add a break. + (dump_dumpx_core): New function. + (xcoff_dump_core): Likewise. + (xcoff_dump): Likewise. + * doc/binutils.texi (objdump): Mention ldinfo. + +2013-07-09 Tristan Gingold + + * configure.com: Add new defines to match changes in configure. + +2013-05-28 Cary Coutant + + * dwarf.c (display_debug_lines_raw): Print section offsets. + +2013-05-15 Cary Coutant + + * dwarf.c (SAFE_BYTE_GET64): Correct end-of-buffer check; + don't increment PTR. + (decode_location_expression): DW_OP_const2u should read 2 bytes. + (display_debug_lines_decoded): Adjust formatting. + * elfcomm.c (byte_get_little_endian): Add cases for 5-, 6-, and + 7-byte reads. + (byte_get_big_endian): Likewise. + (byte_get_signed): Likewise. + +2013-05-09 Andrew Pinski + + * doc/binutils.texi: Document -Mvirt disassembler option. + +2013-05-02 Nick Clifton + + * readelf.c: Add support for MSP430X architecture. + +2013-05-02 Nick Clifton + + * dwarf.c (display_debug_lines_raw): Do not treat .debug_line.dwo + sections as if they were fragmentary .debug_line sections. + (display_debug_lines_decoded): Likewise. + +2013-04-29 Nick Clifton + + * dwarf.c (read_debug_line_header): New function. Reads in a + header in a .debug_line section. + (display_debug_lines_raw): Use new function. Handle fragmentary + .debug_line sections. + (display_debug_lines_decoded): Likewise. + * readelf.c (process_section_headers): Handle fragmenatry + .debug_line sections. + (display_debug_section): Likewise. + +2013-04-26 Ian Lance Taylor + + * MAINTAINERS: Add myself and Cary as gold maintainers. + +2013-04-08 Tom Tromey + + * dwarf.c (process_debug_info): Check dwarf_cutoff_level. + +2013-04-08 Tom Tromey + + * dwarf-mode.el: Bump version number. + (dwarf-mode): Remove autoload. + (dwarf-die-reference): Relax regexp. + +2013-04-05 Alan Modra + + PR binutils/15324 + * configure.in: Add strnlen to AC_CHECK_DECLS, sort. + * dwarf.c (strnlen): Provide fallback decl. + * config.in: Regnerate. + * configure: Regenerate. + +2013-03-29 H.J. Lu + + * dwarf.c (process_debug_info): Increment hdrptr by 8 after + SAFE_BYTE_GET64. + +2013-03-27 Phil Krylov + + PR binutils/13409 + * winduni.c (codepages[]): Use UTF-16LE. + (wind_MultiByteToWideChar): Likewise. + (wind_WideCharToMultiByte): Likewise. + +2013-03-27 Alan Modra + + PR binutils/15206 + * dwarf.c (read_and_display_attr_value): Cast format '*' arg to int. + +2013-03-26 Nick Clifton + + PR binutils/15206 + * dwarf.c (SAFE_BYTE_GET): New macro - checks remaining buffer + space before calling byte_get. + (SAFE_BYTE_GET_AND_INC): New macro. + (SAFE_SIGNED_BYTE_GET): New macro. + (SAFE_SIGNED_BYTE_GET_AND_INC): New macro. + (SAFE_BYTE_GET64): New macro. + (process_extened_line_op): Use new macros. Use strnlen when + appropriate. + (fetch_indirect_string): Likewise. + (get_FORM_name): Likewise. + (decode_location_expression): Likewise. + (read_and_display_attr_value): Likewise. + (process_debug_info): Likewise. + (display_debug_lines_raw): Likewise. + (display_debug_lines_decoded): Likewise. + (display_debug_pubnames): Likewise. + (display_debug_macinfo): Likewise. + (get_line_filename_and_dirname): Likewise. + (display_debug_macro): Likewise. + (display_loc_list): Likewise. + (display_loc_list_dwo): Likewise. + (display_debug_aranges): Likewise. + (display_debug_ranges): Likewise. + (frame_display_row): Likewise. + (display_debug_frames): Likewise. + +2013-03-25 Nick Clifton + + PR binutils/15202 + * dwarf.c (read_leb128): Add END parameter. Do not read at or + beyond end. + (read_sleb128): Add END parameter. + (read_uleb128): New function. + (process_extended_line_op): Pass END to leb128 functions. + (process_abbrev_section): Likewise. + (decode_location_expression): Likewise. + (read_and_display_attr_value): Likewise. + (read_and_display_attr): Likewise. + (process_debug_info): Likewise. + (display_debug_lines_raw): Likewise. + (display_debug_lines_decoded): Likewise. + (display_debug_macinfo): Likewise. + (get_line_filename_and_dirname): Likewise. + (display_debug_macro): Likewise. + (display_loc_list_dwo): Likewise. + (display_debug_ranges): Likewise. + * dwarf.h (read_leb128): Update prototype. + * readelf.c (read_uleb128): Add END parameter. + (decode_arm_unwind_bytecode): Pass END to read_uleb128. + (decode_tic6x_unwind_bytecode): Likewise. + (display_tag_value): New function. + (display_arm_attribute): Add END parameter. Pass END to + read_uleb128. Use display_tag_value. + (display_gnu_attribute): Likewise. + (display_power_gnu_attribute): Likewise. + (display_sparc_gnu_attribute): Likewise. + (display_mips_gnu_attribute): Likewise. + (display_tic6x_attribute): Likewise. + (process_attributes): Likewise. + (display_raw_attribute): New function. + +2013-03-22 Nick Clifton + + PR binutils/15201 + * dwarf.c (display_debug_ranges): Add checks for reading beyond + the end of the section. + + PR binutils/15157 + * readelf.c (apply_relocations): Catch relocations with negative + offsets. + +2013-03-15 Nick Clifton + + * addr2line.c (slurp_symtab): If canonicalization reveals that + there were no ordinary symbols, try loading the dynamic symbols + instead. + +2013-03-14 Markos Chandras + + * MAINTAINERS: Add myself as Meta maintainer. + +2013-03-08 Andreas Arnez + + * readelf.c (get_note_type): Add NT_S390_TDB. + +2013-03-07 Alan Modra + + * strings.c (get_char): Dispense with buf[]. Instead shift + chars into big-endian value and byte-swap later if + little-endian. Don't EOF check value read from object. + +2013-03-05 Corinna Vinschen + + * configure.in: Build DLL tools on x86_64-*-cygwin* as well. + * configure: Regenerate. + +2013-03-04 Nick Clifton + + * elfcomm.c (error): Flush stdout before emitting the error + message. + (warn): Likewise. + +2013-03-01 Cary Coutant + + * dwarf.c (cu_tu_indexes_read, shndx_pool, shndx_pool_size) + (shndx_pool_used): Move to top of file. + (struct cu_tu_set): New type. + (cu_count, tu_count, cu_sets, tu_sets): New file scope variables. + (fetch_indexed_string): Add "this_set" parameter. Update all callers. + (find_cu_tu_set_v2): New function. + (read_and_display_attr_value): Add "this_set" parameter. + (read_and_display_attr): Likewise. + (process_debug_info): Track base offsets for DWARF package files. + (load_debug_info): Call load_cu_tu_indexes. + (get_DW_SECT_short_name): New function. + (process_cu_tu_index): Add support for version 2 DWARF package files. + +2013-02-27 Alan Modra + + PR binutils/15191 + * readelf.c (offsetof): Define. + (CHECK_ENTSIZE_VALUES): Remove extraneous indefinite article. + (process_corefile_note_segment): Allow notes without name or + desc. Combine out-of-range checks. Disallow "negative" + notesz or descsz. + +2013-02-26 Nick Clifton + + PR binutils/15191 + * readelf.c (process_corefile_note_segment): Prevent attempts to + read beyond the end of the note buffer. + +2013-02-15 Kai Tietz + + * objcopy.c (copy_main): Initialize context variable. + +2013-02-15 Nick Clifton + + PR binutils/15140 + * ar.c (open_inarch): Fail on attempts to convert a normal archive + to a thin archive or vice versa. + * elfcomm.c (make_qualified_name): Handle corrupted thin + archives. + * readelf.c (process_archive): Likewise. + * doc/binutils.texi: Clarify documentation describing thin + archives. + +2013-02-15 Nick Clifton + + PR binutils/15033 + * objcopy.c (enum change_action): Delete. + (struct section_list): Delete remove, copy, change_vma, change_lma + and set_flags fields. Add context field. + (find_section_list): Add a context parameter. Add support for + wildcard characters in section names. + (is_strip_section): Check for sections being both copied and + removed. + (copy_object): Pass context to find_section_list. + (setup_section): Likewise. + (copy_section): Likewise. + (copy_main): Likewise. + * doc/binutils: Document the new behaviour. + * NEWS: Mention the new feature + +2013-02-14 Nick Clifton + + PR binutils/15125 + * objcopy.c (copy_object): Provide a helpful warning message when + adding a gnu_debuglink section to an object which already contains + one. + +2013-02-07 Nick Clifton + + * elfcomm.c (get_archive_member_name): Prevent seg-fault if a + corrupt archive uses long names but has no long name table. + +2013-02-06 Sandra Loosemore + Andrew Jenner + + Based on patches from Altera Corporation. + + * readelf.c: Include elf/nios2.h. + (dump_relocations): Add case for EM_ALTERA_NIOS2. + (get_nios2_dynamic_type): New. + (get_dynamic_type): Add case for EM_ALTERA_NIOS2. + (is_32bit_abs_reloc): Fix EM_ALTERA_NIOS2 case. + (is_16bit_abs_reloc): Likewise. + (is_none_reloc): Add EM_ALTERA_NIOS2 and EM_NIOS32 cases. + * NEWS: Note Altera Nios II support. + * MAINTAINERS: Add Nios II maintainers. + +2013-01-29 Xi Wang + + * readelf.c (process_version_sections): Fix overflow checks to + avoid undefined behaviour. + +2013-01-28 Doug Evans + + * dwarf.c (display_gdb_index): Handle .gdb_index version 8. + +2013-01-28 Robert Schiele + + * objcopy.c (parse_flags): Add merge and strings section flags. + +2013-01-25 Cary Coutant + + * dwarf.c (display_loc_list): Update offset for each line + printed. + (print_addr_index): New function. + (display_loc_list_dwo): Update offset for each line printed. + Fix problems displaying loclists in .dwo files. Add support + for type 4 entries. + (display_debug_loc): Remove custom header for .dwo files. + (display_debug_addr): Adjust formatting. + +2013-01-25 Marco Atzeri + + * objcopy.c : Enable long section names for OPTION_ADD_GNU_DEBUGLINK. + +2013-01-24 Doug Evans + + * dwarf.c (display_debug_addr): Add missing parentheses to expression. + +2013-01-24 Nick Clifton + + * readelf.c (get_machine_flags): Decode E_V850E3V5_ARCH. + +2013-01-23 Andreas Krebbel + + * readelf.c: Add strings for NT_S390_LAST_BREAK and + NT_S390_SYSTEM_CALL. + +2013-01-18 Nick Clifton + + PR binutils/15026 + * addr2line.c (translate_addresses): When pretty printing, print + unknown function names on the same line as unknown symbol names. + +2013-01-17 Nickolai Zeldovich + + * objdump.c (dump_target_specific): Fix NULL pointer test. + +2013-01-16 Alan Modra + + PR binutils/15018 + * stabs.c (parse_stab_members): Always set physname here to avoid + gcc warning.. + (parse_stab_argtypes): ..and don't duplicate the init here. + +2013-01-10 Will Newton + + * binutils/readelf.c: (guess_is_rela): Add EM_METAG. + (dump_relocations): Add EM_METAG. + (get_machine_name): Correct case for Meta. + (is_32bit_abs_reloc): Add support for Meta ADDR32 reloc. + (is_none_reloc): Add support for Meta NONE reloc. + +2013-01-08 Yufeng Zhang + + * readelf.c (get_note_type): Handle NT_ARM_TLS, NT_ARM_HW_BREAK + and NT_ARM_HW_WATCH. + +2013-01-07 Roland McGrath + + * objcopy.c (deterministic): Make int rather than bfd_boolean, + initialize to -1. + (strip_options, copy_options): Add -U/--disable-deterministic-archives. + (default_deterministic): New function. + (strip_main, copy_main): Handle -U. Call default_deterministic. + (copy_usage, strip_usage): Describe -U. Cite whether -D or -U is + the default based on DEFAULT_AR_DETERMINISTIC. + * doc/binutils.texi (objcopy, strip): Describe -U and effect of + configure options on -D. + + * ar.c (default_deterministic): Comment fix. + +2013-01-07 Patrice Dumas + + * doc/binutils.texi: Fix ordering of top level nodes. + Replace erroneous uses of @itemx with @item. + +2013-01-04 Andreas Schwab + + * doc/binutils.texi (elfedit): Fix use of @itemx in @table. + +2013-01-03 Marcus Shawcroft + + * MAINTAINERS: Add myself as AArch64 co-maintainer. + +2013-01-02 H.J. Lu + + * version.c (print_version): Update copyright year to 2013. + +For older changes see ChangeLog-2012 + +Copyright (C) 2013 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2014 b/support/sdbinutils/binutils/ChangeLog-2014 new file mode 100644 index 0000000..cf2cc03 --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2014 @@ -0,0 +1,960 @@ +2014-12-25 Thomas Preud'homme + + * readelf.c (arm_attr_tag_ABI_VFP_args): Add "compatible". + +2014-12-24 Alexander Cherepanov + + PR binutils/17671 + * objcopy.c (copy_main, strip_main): Add D and U to the list of + accepted short versions of long options. + +2014-12-24 Nick Clifton + + * dwarf.c (read_cie): Revert check for unused augmentation data - + it was bogus. + +2014-12-23 Andrew Stubbs + + * objcopy.c (strip_usage): Reword --remove-section description. + * doc/binutils.texi (strip): Likewise. + +2014-12-23 Nick Clifton + + * doc/binutils.texi (objdump): Reformat to avoid overlong lines. + +2014-12-22 H.J. Lu + + * dwarf.c (read_cie): Cast size to long to warn. + +2014-12-22 Nick Clifton + + PR binutils/17531 + * dwarf.c (decode_location_expression): Check for an out of range + value for a DW_OP_GNU_entry_value expression. + (display_debug_lines_raw): Check for a partial + .debug_line. section being encountered without a prior, full + .debug.line section. + (display_debug_lines_decoded): Likewise. Also check for + li_line_range being zero. + (display_debug_pubnames_worker): Check for an invalid pn_length + field. + (read_cie): Add range checks. + * elfcomm.c (setup_archive): Check for a negative longnames_size. + +2014-12-18 Mark Wielaard + + * dwarf.c (read_and_display_attr_value): Change display name of + DW_LANG_C11 from (ANSI C11) to (C11). + +2014-12-11 Nick Clifton + + PR binutils/17512 + * dwarf.c (display_gdb_index): Add more range checks. + +2014-12-11 Alan Modra + + * configure.ac: Check for long long and sizes of long long and long. + * elfcomm.h (HOST_WIDEST_INT): Test HAVE_LONG_LONG in place of + __STDC_VERSION__ and __GNUC__. + * strings.c (print_strings): Likewise. + * dwarf.c (DWARF_VMA_FMT, DWARF_VMA_FMT_LONG): Likewise. + (read_debug_line_header): Use dwarf_vmatoa to print warning. + * configure: Regenerate. + * config.in: Regenerate. + +2014-12-10 Alan Modra + + * objdump.c: #include "coff-bfd.h". + +2014-12-09 Senthil Kumar Selvaraj + + * od-elf32_avr.c (elf32_avr_dump_mem_usage): Fix device initialization. + +2014-12-09 Nick Clifton + + PR binutils/17512 + * objdump.c (display_any_bfd): Avoid infinite loop closing and + opening the same archive again and again. + +2014-12-09 Chen Gang + + * windres.c (open_file_search): Free path buffer on failure. + +2014-12-08 Nick Clifton + + PR binutils/17531 + * dwarf.c (display_debug_frames): Check for a negative + augmentation data length. + (display_gdb_index): Check for invalid offsets. + * elfcomm.c (process_archive_index_and_symbols): Check for an + index number that overflows when multiplied by the ar index size. + * readelf.c (dump_ia64_unwind): Add range checks. + (slurp_ia64_unwind_table): Change to a boolean function. Add + range checks. + (process_version_sections): Add range checks. + (get_symbol_version_string): Add check for missing section + headers. + +2014-12-08 Senthil Kumar Selvaraj + + * configure.ac: Add od-elf32_avr to build. + * configure: Regenerate. + * od-elf32_avr.c: New file. + * objdump.h: Declare objdump_private_desc_elf32_avr. + +2014-12-06 Eric Botcazou + + * readelf.c: Include elf/visium.h. + (guess_is_rela): Deal with EM_VISIUM. + (dump_relocations): Likewise. + (get_machine_name): Likewise. + (get_machine_flags): Likewise. + (get_osabi_name): Likewise. + (is_32bit_abs_reloc): Likewise. + (is_32bit_pcrel_reloc): Likewise. + (is_16bit_abs_reloc): Likewise. + +2014-12-05 Andrew Burgess + + * readelf.c (decode_AVR_machine_flags): New function. + (get_machine_flags): Add EM_AVR case. + +2014-12-03 Nick Clifton + + PR binutils/17512 + * objdump.c (free_debug_section): Reset the compress_status as + well. + +2014-12-03 Nick Clifton + + PR binutils/17531 + * readelf.c (get_machine_flags): Replace call to abort with a + warning message and a return value. + (get_elf_section_flags): Likewise. + (get_symbol_visibility): Likewise. + (get_ia64_symbol_other): Likewise. + (get_ia64_symbol_other): Likewise. + (is_32bit_abs_reloc): Likewise. + (apply_relocations): Likewise. + (display_arm_attribute): Likewise. + +2014-12-02 Denis Chertykov + + * MAINTAINERS: Fix my email address. + +2014-12-01 H.J. Lu + + * dwarf.c (process_cu_tu_index): Properly check for an out of + range row index. + +2014-12-01 Nick Clifton + + PR binutils/17512 + * dwarf.h (struct dwarf_section): Add user_data field. + * dwarf.c (frame_need_space): Check for an over large register + number. + (display_debug_frames): Check the return value from + frame_need_space. Check for a CFA expression that is so long the + start address wraps around. + (debug_displays): Initialise the user_data field. + * objdump.c (load_specific_debug_section): Save the BFD section + pointer in the user_data field of the dwarf_section structure. + (free_debug_section): Update BFD section data when freeing section + contents. + * readelf.c (load_specific_debug_section): Initialise the + user_data field. + +2014-12-01 Nick Clifton + + PR binutils/17531 + * dwarf.c (process_cu_tu_index): Check for an out of range row + index. + * elfcomm.c (adjust_relative_path): Change name_len parameter to + an unsigned long. Check for path length overflow. + (process_archive_index_and_symbols): Check for invalid header + size. + (setup_archive): Add checks for invalid archives. + (get_archive_member_name): Add range checks. + * elfcomm.h (adjust_relative_path): Update prototyoe. + * readelf.c (process_archive): Add range checks. + +2014-11-28 Alan Modra + + * readelf.c (get_32bit_elf_symbols): Cast bfd_size_type values to + unsigned long for %lx. + (get_64bit_elf_symbols, process_section_groups): Likewise. + +2014-11-27 Espen Grindhaug + Nick Clifton + + PR binutils/17531 + * readelf.c (get_data): Move excessive length check to earlier on + in the function and allow for wraparound in the arithmetic. + (get_32bit_elf_symbols): Terminate early if the section size is + zero. Check for an invalid sh_entsize. Check for an index + section with an invalid size. + (get_64bit_elf_symbols): Likewise. + (process_section_groups): Check for an invalid sh_entsize. + +2014-11-24 Mark Wielaard + + * dwarf.c (read_and_display_attr_value): Handle DW_LANG_C11, + DW_LANG_C_plus_plus_11 and DW_LANG_C_plus_plus_14. + +2014-11-26 Nick Clifton + + PR binutils/17512 + * dwarf.c (display_block): Do nothing if the block starts after + the end of the buffer. + (read_and_display_attr_value): Add range checks. + (struct Frame_Chunk): Make the ncols and ra fields unsigned. + (frame_need_space): Test for an ncols of zero. + (read_cie): Fail if the augmentation data extends off the end of + the buffer. + (display_debug_frames): Add checks for read_cie failing. Add + range checks. + +2014-11-25 H.J. Lu + + * objdump.c (objdump_print_symname): Replace + bfd_elf_get_symbol_version_string with + bfd_get_symbol_version_string. + +2014-11-25 H.J. Lu + + PR binutils/16496 + * objdump.c (objdump_print_symname): Call + bfd_elf_get_symbol_version_string to get ELF symbol version + string. Append version string if needed. + + * readelf.c (versioned_symbol_info): New enum. + (get_symbol_version_string): New. Extracted from + process_symbol_table. + (dump_relocations): Add a new argument to indicate if dynamic + symbol table is used. Use get_symbol_version_string to get + symbol version string for dynamic symbol. Append version string + if needed. + (process_relocs): Updated dump_relocations call. + (process_symbol_table): Use get_symbol_version_string. + +2014-11-24 H.J. Lu + + * configure: Regenerated. + +2014-11-21 Nick Clifton + + PR binutils/17512 + * dwarf.c (get_encoded_value): Check for an encoded size of 0. + (display_debug_lines_raw): Check for an invalid line range value. + (display_debug_frames): Check for corrupt augmentation data. + +2014-11-21 Nick Clifton + + PR binutils/17531 + * readelf.c (process_version_sections): Prevent an infinite loop + processing corrupt version need data. + (process_corefile_note_segment): Handle corrupt notes. + +2014-11-21 Terry Guo + + * readelf.c (arm_attr_tag_FP_arch): Extended to support FPv5. + +2014-11-19 Jan-Benedict Glaw + + * dwarf.c (process_extended_line_op): Fix signedness warning. + +2014-11-18 Nick Clifton + + PR binutuls/17605 + * bucomm.c (print_arelt_descr): Check for ctime returning NULL. + +2014-11-18 Nick Clifton + + PR binutils/17512 + * dwarf.c (get_encoded_value): Warn and return if the encoded + value is more than 64-bits long. + (SAFE_BYTE_GET): Do not attempt to read more than 64-bits. + (process_extended_line_op): Add more range checks. + (decode_location_expression): Use the return value from + display_block. Add more range checks. + (read_debug_line_header): Add range check. + (display_debug_lines_raw): Add range checks. + (display_debug_frames): Silently skip multiple zero terminators. + Add range checks. + (process_cu_tu_index): Check for non-existant or empty sections. + Use SAFE_BYTE_GET instead of byte_get. + +2014-11-18 Nick Clifton + + PR binutils/17531 + * readelf.c (get_unwind_section_word): Skip reloc processing if + there are no relocs associated with the section. + (decode_tic6x_unwind_bytecode): Warn and return if the stack + pointer adjustment falls off the end of the buffer. + +2014-11-14 Nick Clifton + + PR binutils/17512 + * dwarf.c (get_encoded_value): Add an 'end' parameter. Change the + 'data' parameter to a double pointer and return the updated value. + (decode_location_expression): Update call to get_encoded_value. + (frame_need_space): Handle the case where one or both of the + mallocs fails. + (read_cie): Initialise the cie pointer, even if the read fails. + (display_debug_frames): Warn if the calculated block_end is before + the start of the block. Break the loop if the CIE could not be + read. Update call to get_encoded_value. Warn if the read CFA + expressions are too big. + +2014-11-13 Nick Clifton + + PR binutils/17531 + * readelf.c (process_version_sections): If the read of the version + def information fails, make sure that the external verdef data is + not used. + (get_dynamic_data): Do not attempt to allocate memory for more + dynamic data than there is in the file. If the read fails, free + the allocated buffer. + (process_symbol_table): Do not print dynamic information if we + were unable to read the dynamic symbol table. + (print_gnu_note): Do not print the note if the descsz is too + small. + +2014-11-12 Nick Clifton + + PR binutils/17512 + * dwarf.c (read_and_display_attr_value): Check that we do not read + past end. + (display_debug_pubnames_worker): Add range checks. + (process_debug_info): Check for invalid pointer sizes. + (display_loc_list): Likewise. + (display_loc_list_dwo): Likewise. + (display_debug_ranges): Likewise. + (display_debug_aranges): Check for invalid address size. + (read_cie): Add range checks. Replace call strchr with while loop. + * objdump.c (dump_dwarf): Replace abort with a warning message. + (print_section_stabs): Improve range checks. + * rdcoff.c (coff_get_slot): Use long for indx parameter type. + Add check for an excesively large index. + * rddbg.c (read_section_stabs_debugging_info): Zero terminate the + string table. Avoid walking off the end of the stabs data. + * stabs.c (parse_stab_string): Add check for a NULL name. + +2014-11-11 Nick Clifton + + PR binutils/17531 + * binutils/readelf.c (dynamic_nent): Change type to size_t. + (slurp_rela_relocs): Use size_t type for nrelas. + (slurp_rel_relocs): Likewise. + (get_program_headers): Improve out of memory error message. + (get_32bit_section_headers): Likewise. + (get_32bit_section_headers): Likewise. + (get_64bit_section_headers): Likewise. + (get_32bit_elf_symbols): Likewise. + (get_64bit_elf_symbols): Likewise. + (process_section_groups): Likewise. + (get_32bit_dynamic_section): Likewise. + (get_64bit_dynamic_section): Likewise. + (process_dynamic_section): Likewise. + (process_version_sections): Likewise. + (get_symbol_index_type): Likewise. + (process_mips_specific): Likewise. + (process_corefile_note_segment): Likewise. + (process_version_sections): Use size_t type for total. + (get_dynamic_data): Change type of number parameter to size_t. + Improve out of memory error messages. + (process_symbol_table): Change type of nbuckets and nchains to + size_t. Skip processing of sections headers if there are none. + Improve out of memory error messages. + +2014-11-11 Nick Clifton + + * po/fr.po: Updated French translation. + +2014-11-11 Nick Clifton + + PR binutils/17531 + * readelf.c (display_arm_attribute): Avoid reading off the end of + the buffer when processing a Tag_nodefaults. + +2014-11-10 Nick Clifton + + PR binutils/17531 + * (ia64_process_unwind): Replace assertion with an error message. + Add range checking for group section indicies. + (hppa_process_unwind): Replace assertion with an error message. + (process_syminfo): Likewise. + (decode_arm_unwind_bytecode): Add range checking. + (dump_section_as_strings): Add more string range checking. + (display_tag_value): Likewise. + (display_arm_attribute): Likewise. + (display_gnu_attribute): Likewise. + (display_tic6x_attribute): Likewise. + (display_msp430x_attribute): Likewise. + +2014-11-10 Nick Clifton + + PR binutils/17552 + * (copy_archive): Clean up temporary files even if an error + occurs. + +2014-11-07 H.J. Lu + + * readelf.c (process_dynamic_section): Cast time value to unsigned + long to print. + +2014-11-07 Nick Clifton + + PR binutils/17531 + * readelf.c (get_data): Avoid allocating memory when we know that + the read will fail. + (find_section_by_type): New function. + (get_unwind_section_word): Check for invalid symbol indicies. + Check for invalid reloc types. + (get_32bit_dynamic_section): Add range checks. + (get_64bit_dynamic_section): Add range checks. + (process_dynamic_section): Check for a corrupt time value. + (process_symbol_table): Add range checks. + (dump_section_as_strings): Add string length range checks. + (display_tag_value): Likewise. + (display_arm_attribute): Likewise. + (display_gnu_attribute): Likewise. + (display_tic6x_attribute): Likewise. + (display_msp430x_attribute): Likewise. + (process_mips_specific): Add range check. + +2014-11-06 Nick Clifton + + PR binutils/17552, binutils/17533 + * bucomm.c (is_valid_archive_path): New function. Returns false + for absolute pathnames and pathnames that include /../. + * bucomm.h (is_valid_archive_path): Add prototype. + * ar.c (extract_file): Use new function to check for valid + pathnames when extracting files from an archive. + * objcopy.c (copy_archive): Likewise. + * doc/binutils.texi: Update documentation to mention the + limitation on pathname of archive members. + +2014-11-05 Nick Clifton + + PR binutils/17531 + * readelf.c (printable_section_name): New function. + (printable_section_name_from_index): New function. + (dump_relocations): Use new function. + (process_program_headers, get_32bit_elf_symbols, + (get_64bit_elf_symbols, process_section_headers, + (process_section_groups, process_relocs, ia64_process_unwind, + (hppa_process_unwind, get_unwind_section_word, decode_arm_unwind, + (arm_process_unwind, process_version_sections, + (process_symbol_table, apply_relocations, get_section_contents, + (dump_section_as_strings, dump_section_as_bytes, + (display_debug_section, process_attributes, process_mips_specific, + (process_mips_specific process_gnu_liblist): Likewise. + (get_unwind_section_word): Check for a missing symbol table. + Replace aborts with error messages. + (arm_process_unwind): Check for a missing string table. + (process_attributes): Check for an attribute length that is too + small. + (process_mips_specific): Check for a corrupt GOT symbol offset. + +2014-11-05 Nick Clifton + + PR binutils/17533 + * bucomm.c (is_valid_archive_path): New function. + * bucomm.h (is_valid_archive_path): Prototype it. + * ar.c (extract_file): Call is_valid_archive_path to verify a + member filename before extracting it. + * objcopy.c (copy_archive): Likewise. + +2014-11-05 Jan-Benedict Glaw + + * readelf.c (process_mips_specific): Fix format string warning. + +2014-11-04 Matthew Fortune + + * readelf.c (process_mips_specific): Rename index to idx. + +2014-11-04 Nick Clifton + + PR binutils/17531 + * readelf.c (get_data): If the reason parameter is null, do not + print any error messages. + (get_32bit_section_headers): Verify section header entry size + before reading in the section headers. + (get_64bit_section_headers): Likewise. + (process_section_headers): Pass FALSE to get_section_headers. + (get_file_header): Pass TRUE to get_section_headers. + (process_dynamic_section): Change an assert to an error message. + (process_symbol_table): Handle corrupt histograms. + + (get_32bit_program_headers): Verify program header entry size + before reading in the program headers. + (get_64bit_program_headers): Likewise. + (get_unwind_section_word): Do nothing if no section was provided. + Fail if the offset is outside of the section. + (print_dynamic_symbol): Catch out of range symbol indicies. + (process_mips_specific): Likewise. + (process_attributes): Make sure that there is enough space left in + the section before attempting to read the length of the next + attribute. + +2014-11-03 Nick Clifton + + PR binutils/17512 + * objdump.c (slurp_symtab): Fail gracefully if the table could not + be read. + (dump_relocs_in_section): Likewise. + +2014-11-03 Nick Clifton + + * po/fi.po: Updated Finnish translation. + * po/sv.po: Updated Swedish translation. + +2014-11-01 Hans-Peter Nilsson + + * readelf.c (get_32bit_elf_symbols): Cast error + parameters of bfd_size_type with the %lx format to + unsigned long. + +2014-10-31 Andrew Pinski + Naveen H.S + + * readelf.c (print_mips_isa_ext): Print the value of Octeon3. + +2014-10-31 Iain Buclaw + + * cxxfilt.c (main): Add case for dlang_demangling style. + +2014-10-31 Nick Clifton + + PR binutils/17512 + * readelf.c (process_program_headers): Avoid memory exhaustion due + to corrupt values in a dynamis segment header. + (get_32bit_elf_symbols): Do not attempt to read an over-large + section. + (get_64bit_elf_symbols): Likewise. + +2014-10-31 Nick Clifton + + * strings.c: Add new command line option --data to only scan the + initialized, loadable data secions of binaries. Choose the + default behaviour of --all or --data based upon a configure + option. + * doc/binutils.texi (strings): Update documentation. Include + description of why the --data option might be unsafe. + * configure.ac: Add new option --disable-default-strings-all which + restores the old behaviour of strings using --data by default. If + the option is not used make strings use --all by default. + * NEWS: Mention the new behaviour of strings. + * configure: Regenerate. + * config.in: Regenerate. + +2014-10-30 Nick Clifton + + * readelf.c (CHECK_ENTSIZE_VALUES): Rewrite error message so that + there is a single string for translation. + (dynamic_section_mips_val): Likewise. + +2014-10-29 Nick Clifton + + * po/bg.po: Updated Bulgarian translation. + * po/sr.po: New Serbian translation. + * po/sv.po: Updated Swedish translation. + +2014-10-22 Matthew Fortune + + * readelf.c (print_mips_ases): Print unknown ASEs. + (print_mips_isa_ext): Print the value of an unknown extension. + +2014-10-15 Tristan Gingold + + * configure: Regenerate. + +2014-10-14 Tristan Gingold + + * NEWS: Add marker for 2.25. + +2014-10-14 Alan Modra + + PR 17453 + * dwarf.c (read_leb128): Avoid signed overflow. + (read_debug_line_header): Likewise. + +2014-10-14 Alan Modra + + PR 17453 + * readelf.c (process_program_headers): Correct fscanf format used + for interpreter. + +2014-10-09 Jose E. Marchesi + + * readelf.c (display_sparc_hwcaps2): New function. + (display_sparc_gnu_attribute): Call `display_sparc_hwcaps2' when + handling `Tag_GNU_Sparc_HWCAPS2' attributes. + +2014-09-22 Alan Modra + + PR 16563 + * dwarf.c (GET): Remove semicolon. + (read_cie): New function, extracted from.. + (display_debug_frames): ..here. Correctly handle signed offset + from FDE to CIE in .eh_frame. Decode forward referenced CIEs too. + +2014-09-16 Nick Clifton + + * readelf.c (display_arm_attribute): Use unsigned int type for + tag, val and type variables. + +2014-09-16 Kuan-Lin Chen + + * readelf.c (decode_NDS32_machine_flags): Display ABI2 FP+. + +2014-09-15 Andrew Bennett + Matthew Fortune + + * readelf.c (get_machine_flags): Add support for mips32r6 and + mips64r6. + +2014-09-01 Jon TURNEY + + * objcopy.c (is_nondebug_keep_contents_section): Change + '.build-id' to '.buildid'. + +2014-08-22 Richard Henderson + + * dwarf.h (init_dwarf_regnames_aarch64): Declare. + * dwarf.c (dwarf_regnames_aarch64): New. + (init_dwarf_regnames_aarch64): New. + (init_dwarf_regnames): Call it. + * objdump.c (dump_dwarf): Likewise. + +2014-08-19 Alan Modra + + * configure: Regenerate. + +2014-08-14 Alan Modra + + * configure.ac: Move ACX_LARGEFILE after LT_INIT. + * config.in: Regenerate. + * configure: Regenerate. + +2014-07-29 Matthew Fortune + + * readelf.c (get_mips_segment_type): Display name for PT_MIPS_ABIFLAGS. + (get_mips_section_type_name): Display name for SHT_MIPS_ABIFLAGS. + (display_mips_gnu_attribute): Abstracted fp abi printing to... + (print_mips_fp_abi_value): New static function. Handle new FP ABIs. + (print_mips_ases, print_mips_isa_ext): New static functions. + (get_mips_reg_size): Likewise. + (process_mips_specific): Display abiflags data. + +2014-07-28 Alan Modra + + PR 13227 + * nm.c (filter_symbols): Warn on __gnu_lto_slim. + +2014-07-07 Nick Clifton + + * readelf.c (get_symbol_type): Revert accidental change to + detection of thumb function symbols. + +2014-07-04 Alan Modra + + * configure.ac: Rename from configure.in. + * Makefile.in: Regenerate. + * config.in: Regenerate. + * doc/Makefile.in: Regenerate. + +2014-07-04 Alan Modra + + * configure.in: Include bfd/version.m4. + (AC_INIT, AM_INIT_AUTOMAKE): Use modern form. + (BFD_VERSION): Delete. + * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Remove bfd/configure.in. + * configure: Regenerate. + * Makefile.in: Regenerate. + * doc/Makefile.in: Regenerate. + +2014-07-03 Tristan Gingold + + * doc/binutils.texi: Clarify addr2line output. + +2014-07-01 Alan Modra + + * objdump.c (dump_bfd_header): Don't print HAS_LOAD_PAGE. + +2014-06-26 Erik Akermann + + * strings.c: Add -w/--include-all-whitespace option to include any + whitespace character in the displayed strings. + * NEWS: Mention the new feature. + * doc/binutils.texi (strings): Document the new command line + option. + +2014-06-26 Nick Clifton + + * readelf.c (process_note_sections): If there are no note sections + try processing note segments instead. + +2014-06-17 Anton Lavrentiwev + + PR binutils/16923 + * rcparse.y (fixedverinfo): Prevent large version numbers from + corrupting other values. + +2014-06-09 Romain Chastenet + + PR binutils/16252 + * dwarf.c (display_debug_frames): Remember the state of the + cfa_offset, cfa_reg, ra and cfa_exp field + +2014-06-05 Joel Brobecker + + * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on + bfd's development.sh. + * Makefile.in, configure: Regenerate. + +2014-05-16 Jon Turney + + * objcopy.c (is_nondebug_keep_contents_section): New function. + (setup_section): Use it. + +2014-05-16 Kaushik Phata + + * readelf.c (get_machine_flags): Handle RL78 64-bit doubles flag. + +2014-05-02 Alan Modra + + * emul_aix.c: Update bfd target vector naming. + * testsuite/binutils-all/objcopy.exp: Likewise. + +2014-04-24 Christian Svensson + + * MAINTAINERS: Add myself and Stefan as OR1K maintainers. + +2014-04-23 Andrew Bennett + + * doc/binutils.texi: Document the disassemble MIPS XPA instructions + command line option. + +2014-04-22 Christian Svensson + + * readelf.c: Remove openrisc and or32 support. Add support for or1k. + +2014-04-18 Tristan Gingold + + * od-macho.c (dump_section_map): Adjust as load commands + are now chained. + (dump_load_command, dump_section_content): Likewise. + +2014-04-16 Tristan Gingold + + * od-macho.c (OPT_DYLD_INFO): New macro. + (options): Add entry for dyld_info. + (mach_o_help): Likewise. + (load_and_dump, dump_dyld_info_rebase, dump_dyld_info_bind) + (dump_dyld_info_export_1, dump_dyld_info_export): New functions. + (bfd_mach_o_dyld_rebase_type_name): New array. + (export_info_data): New struct. + (dump_dyld_info): Add verbose argument. Dump rebase, bind and + exports data. + (dump_load_command): Adjust dump_dyld_info call. + (mach_o_dump): Handle dyld_info. + +2014-04-16 Tristan Gingold + + * od-macho.c (dump_header): Display sizeofcmds in decimal too. + (dump_segment): Reformat output. + (dump_dyld_info): Also display end offsets. + (dump_load_command): Add IDX argument, display commands size + and offset, reformat display. + (dump_load_commands): Adjust for added argument. + +2014-04-07 Alan Modra + + PR binutils/16811 + * objcopy.c (copy_object): Error if no sections. + +2014-04-03 Markus Trippelsdorf + + PR binutils/14698 + ar.c: Set plugin_target early if plugins are supported. + nm.c: Likewise. + +2014-04-03 Tristan Gingold + + * od-macho.c (printf_uint64): New function. + (dump_load_command, dump_obj_compact_unwind): Use it. + (dump_exe_compact_unwind): Display personality functions. + +2014-04-02 Tristan Gingold + + * od-macho.c (OPT_TWOLEVEL_HINTS): New macro. + (options): Add entry for twolevel_hints. + (dump_data_in_code): Fix error message. + (dump_twolevel_hints): New function. + (dump_load_command): Handle prebound dylib, prebind cksum + and twolevel hints. + (mach_o_dump): Handle twolevel hints. + +2014-04-01 Tristan Gingold + + * od-macho.c (OPT_DATA_IN_CODE): New macro. + (options): Add entry for data in code. + (mach_o_help): Ditto. + (data_in_code_kind_name): New array. + (dump_data_in_code): New function. + (dump_load_command): Handle data in code. + (mach_o_dump): Ditto. + (dump_header): Display a terminal newline. + +2014-03-27 Tristan Gingold + + * od-macho.c (dump_load_command): Display value for + BFD_MACH_O_LC_DYLD_ENVIRONMENT. Handle BFD_MACH_O_LC_DATA_IN_CODE + and BFD_MACH_O_LC_DYLIB_CODE_SIGN_DRS. + +2014-03-27 Tristan Gingold + + * od-macho.c (OPT_FUNCTION_STARTS): New macro. + (options): Add entry for function_starts. + (mach_o_help): Ditto. + (disp_segment_prot): New function. + (dump_section_map): Call disp_segment_prot. + (dump_function_starts): New function. + (dump_obj_compact_unwind): Fix ouput indentation. + (dump_exe_compact_unwind): Fix ouput indentation. + (mach_o_dump): Handle function_starts. + +2014-03-26 Tristan Gingold + + * od-macho.c (bfd_mach_o_cpu_name): Add BFD_MACH_O_CPU_TYPE_ARM64. + +2014-03-24 Tristan Gingold + + * objdump.c (load_specific_debug_section): Set address of section. + +2014-03-24 Tristan Gingold + + * od-macho.c (dump_unwind_encoding_x86): Set the factor. + (dump_exe_compact_unwind): Change the condition. Improve + indentation. + +2014-03-20 Nick Clifton + + * readelf.c (process_version_sections): Fix off-by-one error in + previous delta. + +2014-03-19 Nick Clifton + + PR binutils/16723 + * readelf.c (process_version_sections): Prevent an infinite loop + when the vn_next field is zero but there are still entries to be + processed. + +2014-03-17 Tristan Gingold + + * od-macho.c (dump_section_header): Renames of dump_section. + (dump_segment): Adjust after renaming. + (OPT_COMPACT_UNWIND): Define. + (options): Add compact unwind. + (mach_o_help): Document compact_unwind. + (unwind_x86_64_regs, unwind_x86_regs): New arrays. + (dump_unwind_encoding_x86, dump_unwind_encoding) + (dump_obj_compact_unwind, dump_exe_compact_unwind) + (dump_section_content): New functions. + (mach_o_dump): Handle compact unwind. + +2014-03-17 Tristan Gingold + + * od-macho.c (dump_load_command): Handle lazy load dylib. + +2014-03-14 Anthony Green + + * objcopy.c (copy_object): Check fwrite return code. + +2014-03-14 Meador Inge + + * dwarf.c (strnlen): Move prototype ... + * sysdep.h (strnlen): ... to here. + +2014-03-12 Nick Clifton + + PR binutils/16652 + * doc/binutils.texi (ar cmdline): Move --plugin command line + option to after the command option. + +2014-03-12 Dmitry Gorbachev + + PR binutils/16567 + * deflex.l: Add noinput and nounput options. + +2014-03-12 Alan Modra + + * Makefile.in: Regenerate. + * doc/Makefile.in: Regenerate. + +2014-03-06 Nick Clifton + + PR binutils/16664 + * readelf.c (process_attributes): Add checks for corrupt + attribute section names. + +2014-03-05 Alan Modra + + Update copyright years. + +2014-03-03 Alan Modra + + * README: Add "Copyright Notices" paragraph. + +2014-02-11 Cary Coutant + + * binutils/dwarf.c (read_and_display_attr_value): Don't warn + for zero-length attribute value. + +2014-02-10 Alan Modra + + * po/binutils.pot: Regenerate. + +2014-02-06 Andrew Pinski + + * readelf.c (get_machine_flags): Handle E_MIPS_MACH_OCTEON3 case. + +2014-02-06 Cary Coutant + + PR binutils/16444 + * readelf.c (print_gnu_note): Add support for NT_GNU_GOLD_VERSION. + +2014-01-08 H.J. Lu + + * version.c (print_version): Update copyright year to 2014. + +2014-01-07 Tom Tromey + + * bucomm.c (fatal, non_fatal): Replace obsolete VA_* macros with + stdarg macros. + * dlltool.c (inform): Replace obsolete VA_* macros with stdarg + macros. + * dllwrap.c (inform, warn): Replace obsolete VA_* macros with + stdarg macros. + +2014-01-07 Tom Tromey + + * coffgrok.h (coff_ofile): Don't use PARAMS. + * nlmheader.y (strerror): Don't use PARAMS. + +For older changes see ChangeLog-2013 + +Copyright (C) 2014 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2015 b/support/sdbinutils/binutils/ChangeLog-2015 new file mode 100644 index 0000000..3f8e8a7 --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2015 @@ -0,0 +1,1034 @@ +2015-12-24 Thomas Preud'homme + + * readelf.c (arm_attr_tag_CPU_arch): Add ARMv8-M Baseline Tag_CPU_arch + value. + +2015-12-24 Thomas Preud'homme + + * readelf.c (arm_attr_tag_CPU_arch): Add ARMv8-M Mainline Tag_CPU_arch + value. + (arm_attr_tag_THUMB_ISA_use): Add ARMv8-M Mainline Tag_THUMB_ISA_use + value. + +2015-12-22 Nick Clifton + + * readelf.c (get_elf_section_flags): Add support for ARM specific + section flags. + +2015-12-17 Maciej W. Rozycki + + * MAINTAINERS: Add myself as MIPS maintainer. + +2015-12-14 Yoshinori Sato + + * readelf.c (get_machine_flags): Add support for RX v2 flag. + +2015-12-14 Jan Beulich + + * nm.c: Include coff/external.h, coff/internal.h, and + libcoff.h. + (struct extended_symbol_info): New field "coffinfo". + (get_symbol_type): Rename to get_elf_symbol_type. + (get_coff_symbol_type): New. + (print_symbol): Also init info.coffinfo. + (print_symbol_info_sysv): Print type and section name also for + COFF symbols. + +2015-12-08 Nick Clifton + + PR binutils/19310 + * dwarf.c (display_debug_frames): Recode range test to avoid + undefined behaviour. + +2015-12-03 Tristan Gingold + + * od-macho.c (bfd_mach_o_header_flags_name): Add name + for flags until BFD_MACH_O_MH_APP_EXTENSION_SAFE. + +2015-12-01 Alan Modra + + * configure: Regenerate. + +2015-11-30 Andrew Burgess + + * dwarf.c (is_max_address): New function. + (display_loc_list): Remove out of date comment, use + is_max_address. + (display_debug_ranges): Likewise. + +2015-11-28 Cary Coutant + + * MAINTAINERS: Update my email address. + +2015-11-20 Ronald Hoogenboom + + * objcopy.c (parse_symflags): Use xstrndup in place of strndup. + (copy_main): Likewise. + +2015-11-20 Nick Clifton + + * po/ca.po: New Catalan translation. + * configure.ac (ALL_LINGUAS): Add ca. + * configure: Regenerate. + +2015-11-18 Tristan Gingold + + * od-macho.c (bfd_mach_o_load_command_name): Add new + entries. + (dump_unwind_encoding_arm64): New function. + (dump_unwind_encoding): Handle arm64. + +2015-11-13 Tristan Gingold + + * configure: Regenerate. + +2015-11-13 Tristan Gingold + + * NEWS: Add marker for 2.26. + +2015-11-09 Dominik Vogt + + * dwarf.c (read_leb128): Fix left shift of negative value. + +2015-11-03 Alan Modra + + * readelf (process_version_sections): Check DT_VERNEED and + DT_VERDEF for all symbols. Report "*both*" should a symbol + have both a verneed and verdef. + (get_symbol_version_string): Reduce indentation by early + exits. Don't use SHT_NOBITS heuristic to detect case where a + defined symbol has a verneed entry. + +2015-10-30 Nick Clifton + + * po/zh_CN.po: Updated (simplified) Chinese translation. + +2015-10-27 Stephen Fisher + + * binutils.c (process_netbsd_elf_note): New function. + (process_note): Call the new function for NetBSD core notes. + +2015-10-22 Hans-Peter Nilsson + + * objcopy.c (setup_section): Don't omit bfd_copy_private_bfd_data + call when extract_symbol. + +2015-10-21 Ronald Hoogenboom + + PR binutils/19104 + * objcopy.c (command_line_switch): Add OPTION_ADD_SYMBOL. + (copy_options): Add add-symbol. + (copy_usage): Likewise. + (parse_symflags): New function. + (need_sym_before): New function. + (create_new_symbol): New function. + (filter_symbols): Add code to insert new symbols. + (copy_main): Process OPTION_ADD_SYMBOL. + * doc/binutils.texi: Document new feature. + * NEWS: Add note about the new feature. + +2015-10-18 Paul Pluzhnikov + + PR binutils/19147 + * readelf.c (print_core_note): Fix off-by-one bug. + +2015-10-15 Alan Modra + + * objcopy.c (copy_object): Don't omit bfd_copy_private_bfd_data + call when extract_symbol. + +2015-10-12 Andrew Burgess + + * od-elf32_avr.c (elf32_avr_dump_avr_prop): Fix printing of align + specific data, fix formatting for align and org data. + +2015-09-01 Claudiu Zissulescu + Cupertino Miranda + + * readelf.c (get_machine_name): Remove A5 reference. Add ARCompact + and ARCv2. + (get_machine_flags): Handle EM_ARCV2 and EM_ARCOMPACT. + (guess_is_rela): Likewise. + (dump_relocations): Likewise. + (is_32bit_abs_reloc): Likewise. + (is_16bit_abs_reloc): Likewise. + (is_none_reloc): Likewise. + * NEWS: Mention the new feature. + +2015-09-29 Andrew Stubbs + H.J. Lu + + PR binutils/19020 + * objcopy.c (copy_object): Don't adjust the output section size + when copying from input sections. + (copy_section): Use input section size for the copy. Get the + updated section size from bfd_convert_section_contents. + +2015-09-29 H.J. Lu + + PR binutils/19005 + * objcopy.c (copy_object): Adjust the output section size to + skip gap fills between sections when copying from input sections + to output sections. + +2015-09-28 Nick Clifton + + * po/fr.po: Updated French translation. + +2015-09-25 James Bowman + + * ft32-dis.c (print_insn_ft32): Fix incorrect data field mask. + +2015-09-23 Nick Clifton + + PR binutils/15835 + * readelf.c (struct elf_section_list): New structure. + (symtab_shndx_hdr): Replace with symtab_shndx_list. + (get_32bit_elf_symbols): Scan for a symbol index table matching + the symbol table in use. + (get_64bit_elf_symbols): Likewise. + (process_section_headers): Handle multiple symbol index sections. + +2015-09-22 Rainer Orth + + * readelf.c (process_dynamic_section): Handle DF_1_STUB, DF_1_PIE. + +2015-09-10 Erik Ackermann + + * strings.c: Add -s/--output-separator option to specify custom + separator string. + * NEWS: Mention the new feature. + * doc/binutils.text (strings): Document the new command line + option. + +2015-09-09 Nick Clifton + + * doc/binutils.texi (ar): Remove bogus sentance concerning thin + archives and invalid paths. + +2015-09-03 Nick Clifton + + PR binutils/18879 + * readelf.c (get_unwind_section_word): Check for negative offsets + and very small sections. + (dump_arm_unwind): Warn if the table offset is too large. + +2015-08-28 H.J. Lu + + * Makefile.am (TOOL_PROGS): Add readelf. + * Makefile.in: Regenerated. + +2015-08-24 Yaakov Selkowitz + + * configure: Regenerate. + +2015-08-17 Alan Modra + + * configure: Regenerate. + +2015-08-07 Andrew Burgess + + * objcopy.c (is_specified_symbol_predicate): Don't stop at first + match. Non-match rules set found to FALSE. + +2015-08-06 Yaakov Selkowitz + + * configure: Regenerate. + +2015-08-05 Nick Clifton + + * doc/binutils.texi: Document that the --only-keep-debug option + to strip and objcopy preserves the section headers of stripped + sections. + +2015-08-04 Yuriy M. Kaminskiy" + Tyler Hicks + + PR binutils/18750 + * readelf.c (process_mips_specific): Fix incorrect escape + sequence handling. + +2015-08-04 Nick Clifton + + * ar.c (extract_file): Free cbuf if the path is invalid. + +2015-07-27 H.J. Lu + + * configure: Regenerated. + +2015-07-24 H.J. Lu + + * stabs.c (parse_stab_range_type): Use 0xffffffffffffffffLL. + +2015-07-22 Alan Modra + + * readelf.c (dump_relocations): Show MIN_INT addends as negative. + +2015-07-20 Alan Modra + + * doc/Makefile.in: Regenerate. + +2015-07-16 Alan Modra + + PR binutils/18672 + * readelf.c (get_32bit_dynamic_section): Correct buffer limit test. + (get_64bit_dynamic_section): Likewise. + +2015-07-14 H.J. Lu + + * objcopy.c (copy_file): Set BFD_COMPRESS_GABI if not + zlib-gnu. + * doc/binutils.texi: Change --compress-debug-sections and + --compress-debug-sections=zlib to zlib-gabi. + +2015-07-10 H.J. Lu + + PR binutils/18656 + * objcopy.c (setup_section): Call bfd_convert_section_size + to get the output section size. + (copy_section): Get the section size from the output section + and call bfd_get_full_section_contents to convert section + contents for output. + +2015-07-10 H.J. Lu + + * readelf.c (dump_section_as_strings): Warn unsupported compress + type and corrupted compressed section. + (dump_section_as_bytes): Likewise. + (load_specific_debug_section): Likewise. + +2015-07-09 Catherine Moore + + * readelf.c (print_mips_fp_abi_value): Handle + Val_GNU_MIPS_ABI_FP_NAN2008. + +2015-06-26 Matthew Fortune + + * readelf.c (get_mips_dynamic_type): Handle DT_MIPS_RLD_MAP_REL. + +2015-06-22 Nick Clifton + + * objdump.c (disassemble_bytes): Set the stop_vma field in the + disassemble_info structure when disassembling code sections with + -d. + * doc/binutils.texi (objdump): Document the discrepancy between -d + and -D. + +2015-06-05 Nick Clifton + + * dwarf.c (read_debug_line_header): Use reloc_at to detect + incomplete .debug_line headers + +2015-05-29 Roland McGrath + + * readelf.c (print_gnu_note: NT_GNU_ABI_TAG): Recognize + GNU_ABI_TAG_SYLLABLE and GNU_ABI_TAG_NACL. + +2015-05-29 Stephen Kitt + + * dlltool.c (make_one_lib_file): Clear .idata$6 before use. + (main): Fail if the output file specified by the -z option cannot + be opened. + +2015-05-18 Nick Clifton + + PR binutils/18420 + * ia64-unwind.c (unw_decode): Add end parameter. Pass parameter + on to decode functions. + (unw_devode_p2_p5): Pass end paraemter to UNW_DEC_SPILL_MASK. + (UNW_DEC_SPILL_MASK): Add end parameter. Check that unw_rlen does + not take us beyond the end of the buffer. + * ia64-unwind.h (unw_decode): Update prototype. + * readelf.c (dump_ia64_unwind): Pass end pointer to unw_decode. + +2015-05-15 H.J. Lu + + * readelf.c (dump_section_as_strings): Change pointers from + char * to unsigned char *. + +2015-05-15 H.J. Lu + + PR binutis/18386 + * doc/binutils.texi: Document -Mamd64 and -Mintel64. + +2015-05-15 Nick Clifton + + * readelf.c (options): Add "decompress". + (usage): Mention -z/--decompress. + (parse_args): Handle -z. + (uncompress_section_contents): Move to earlier in the file. + (dump_section_as_strings): If requested, decompress the section + before dumping. + (dump_section_as_bytes): Likewise. + * doc/binutils.texi: Document the new option. + +2015-05-14 Peter Bergner + + * MAINTAINERS: Add myself as PPC maintainer. + +2015-05-14 H.J. Lu + + * readelf.c (uncompress_section_contents): Add a parameter for + uncompressed size. Don't check the zlib header. + (load_specific_debug_section): Updated. + +2015-05-15 Nick Clifton + + PR binutils/18374 + * dwarf.h (struct dwarf_section): Add reloc_info and num_relocs + fields. + (struct dwarf_section_display): Change bitfield to boolean. + (reloc_at): Add prototype. + * dwarf.c (display_loc_list): Ignore list terminators if there are + relocs against them. + (display_debug_loc): Issue a warning if there are relocs against + the .debug_loc section. + (display_displays): Initialise reloc_info and num_relocs fields. + * objdump.c (load_specific_debug_section): Initialise reloc_info + and num_relocs fields. + (reloc_at): New function. + * readelf.c (is_32bit_abs_reloc): Add IA64's R_IA64_DIS32LSB + reloc. + (reloc_at): New function. + (apply_relocations): Add relocs_return and num_relocs_return + parameters. Fill them in with the loaded relocs if non-NULL. + (dump_section_as_bytes): Update call to apply_relocations. + (load_specific_debug_section): Initialise reloc_info and + num_relocs fields. + +2015-05-13 H.J. Lu + + * elfedit.c (elf_class): Return ELF_CLASS_BOTH by default. + +2015-05-13 Andreas Krebbel + + * MAINTAINERS: Add myself as s390 and s390x maintainer. + +2015-05-12 Stephen Kitt + + * dlltool.c (main): Accept -t as an abbreviation for + --temp-prefix. + +2015-05-11 H.J. Lu + + * dwarf.c (dwarf_regnames_iamcu): New. + (init_dwarf_regnames_iamcu): Likewise. + (init_dwarf_regnames): Call init_dwarf_regnames_iamcu for EM_IAMCU. + * dwarf.h (init_dwarf_regnames_iamcu): New. + * objdump.c (dump_dwarf): Call init_dwarf_regnames_iamcu for + bfd_arch_iamcu. + +2015-05-11 H.J. Lu + + * elfedit.c (enum elfclass): New. + (input_elf_class): Change type to enum elfclass. + (output_elf_class): New. + (elf_class): Change return type to enum elfclass. Support EM_386 + and EM_IAMCU. + (update_elf_header): Check if input and output ELF classes match. + (elf_machine): Support EM_386 and EM_IAMCU. + (main): Update input_elf_class. Set output_elf_class. + * doc/binutils.texi: Update elfedit. + +2015-05-11 H.J. Lu + + * dwarf.c (init_dwarf_regnames): Replace EM_486 with EM_IAMCU. + * readelf.c (guess_is_rela): Likewise. + (dump_relocations): Likewise. + (get_machine_name): Likewise. + (get_elf_section_flags): Likewise. + (process_section_headers): Likewise. + (is_32bit_abs_reloc): Likewise. + (is_32bit_pcrel_reloc): Likewise. + +2015-04-30 Nick Clifton + + * readelf.c (get_machine_flags): Add description of MeP flags. + +2015-04-27 Andreas Krebbel + + * readelf.c (display_s390_gnu_attribute): New function. + (process_s390_specific): New function. + (process_arch_specific): Call process_s390_specific. + +2015-04-24 Nick Clifton + + PR 18313 + * ieee.c (ieee_read_cxx_class): Initialise the varargs variable. + * readelf.c (uncompress_section_contents): Zero initialise the + zstream structure. + +2015-04-23 H.J. Lu + + PR binutils/18209 + * objcopy.c (setup_section): Copy compress status. + +2015-04-15 H.J. Lu + + * NEWS: Mention + --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]. + +2015-04-14 Nick Clifton + + * readelf.c (target_specific_reloc_handling): Add code to handle + RL78 complex relocs. + +2015-04-13 Doug Evans + + PR binutils/18218 + * readelf.c (printable_section_name): Constify sec argument. + (apply_relocations): Ditto. New arg "size". All callers updated. + (load_specific_debug_section): Constify sec argument. + Remove side-effect of modifying sec->sh_size. + +2015-04-09 H.J. Lu + + * objcopy.c (do_debug_sections): Use bit patterns. + (copy_object): Return FALSE for compress_zlib, compress_gnu_zlib + and compress_gabi_zlib on non-ELF input. + (copy_file): Don't check non-ELF input here. + +2015-04-09 Nick Clifton + + * readelf.c (get_machine_flags): Report the setting of the string + insn using bits. + +2015-04-08 H.J. Lu + + * objcopy.c (do_debug_sections): Add compress_zlib, + compress_gnu_zlib and compress_gabi_zlib. + (copy_options): Use optional_argument on compress-debug-sections. + (copy_usage): Update --compress-debug-sections. + (copy_file): Handle compress_zlib, compress_gnu_zlib and + compress_gabi_zlib. + (copy_main): Handle + --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. + * doc/binutils.texi: Document + --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. + +2015-04-08 H.J. Lu + + * objcopy.c (copy_usage): Replace "--interleave []" with + --interleave[=]. + +2015-04-05 H.J. Lu + + * readelf.c (get_elf_section_flags): Support SHF_COMPRESSED. + (get_compression_header): New. + (process_section_headers): Dump compression header if needed. + (uncompress_section_contents): Don't free compressed_buffer here. + (load_specific_debug_section): Free the compressed buffer, update + the section buffer and the section size if uncompress is + successful. + +2015-04-02 H.J. Lu + + * configure: Regenerated. + +2015-04-02 Mike Frysinger + + * MAINTAINERS: Update my e-mail address. + +2015-04-01 H.J. Lu + + * configure: Regenerated. + +2015-03-31 H.J. Lu + + * configure.ac: Revert the AM_ZLIB change. + * Makefile.in: Regenerated. + * aclocal.m4: Likewise. + * configure: Likewise. + +2015-03-31 H.J. Lu + + * Makefile.am (ZLIB): New. + (ZLIBINC): Likewise. + (AM_CFLAGS): Add $(ZLIBINC). + (readelf_LDADD): Add $(ZLIB). + * configure.ac (AM_ZLIB): Removed. + (zlibdir): New. AC_SUBST. + (zlibinc): Likewise. + Add --with-system-zlib. + * Makefile.in: Regenerated. + * config.in: Likewise. + * configure: Likewise. + +2015-03-19 Nick Clifton + + * readelf.c (get_machine_flags): Decode RL78's G13 and G14 flags. + +2015-03-18 Jon Turney + Nick Clifton + + PR binutils/18087 + * doc/binutils.texi: Note that when objcopy compresses debug + sections the compression is only performed if it makes the section + smaller. + +2015-03-10 H.J. Lu + + PR binutils/18101 + * readelf.c (parse_args): Move nothing to do warning to ... + (main): Here. + +2015-03-10 Nick Clifton + + PR binutils/18101 + * readelf.c (parse_args): Enhance check for nothing to do by + accounting for the --wide option. + + PR binutils/17636 + * objcopy.c (copy_object): Avoid calling fatal as that does not + allow the parent to clean up temporary files. + +2015-03-10 Yuri Gribov + + PR ld/16572 + * readelf.c: Remove support for ELF_ARM_HASENTRY. + +2015-03-05 Nick Clifton + + PR binutils/18064 + * doc/binutils.texi (objcopy): Extend description of + --add-gnu-debuglink option to explain that the separate debug info + file must exist. Add a description of what to do if the debug + info file is built in one place but then installed into a separate + location. + +2015-03-05 Nick Clifton + + PR binutils/17994 + * dlltool.c (temp_file_to_remove): New local array. + (unlink_temp_files): New functions - unlinks any file in the + temp_file_to_remove array, unless dotdeltemps is set. + (gen_exp_file): Add temp files to array. + (make_head): Likewise. + (make_delay_head): Likewise. + (make_tail): Likewise. + (gen_lib_file): Call unlink_temp_files. + +2015-02-28 Andrew Burgess + + * objcopy.c (update_sections): New list. + (command_line_switch): Add OPTION_UPDATE_SECTION. + (copy_options): Add update-section. + (copy_usage): Document new option. + (is_update_section): New function. + (is_strip_section_1): Add check for attempt to update and remove + the same section. + (copy_object): Update size and content of requested sections. + (skip_section): Don't copy for updated sections. + (copy_main): Handle --update-section. + * doc/binutils.texi (objcopy): Add description of --update-section + option. + * NEWS: Mention --update-section option. + +2015-02-26 Nick Clifton + + PR binutils/17512 + * coffgrok.c (do_type): Check for an out of range tag index. + Check for integer overflow computing array dimension. + (do_define): Likewise. + +2015-02-26 Andrew Burgess + + * objcopy.c (init_section_add): Rename optarg to arg in order to + avoid shadowing a global variable. + +2015-02-26 Nick Clifton + + PR binutils/17512 + * resrc.c (write_rc_messagetable): Tighten check for invalid + message lengths. + + * dwarf.c (display_debug_loc): Pacify the undefined behaviour + sanitizer by simplifying address difference calculation. + (struct Frame_Chunk): Change type of cfa_offset to dwarf_vma in + order to avoid arithmetic overflows. + (frame_display_row): Cast cfa_offset before printing it. + (display_debug_frames): Likewise. + Check for an unexpected segment size. + Chnage type of 'l' local to dwarf_vma and cast it back to an int + when printing. + (process_cu_tu_index): Tighten check for an invalid ncols value. + * readelf.c (process_corefile_note_segment): Check for + inote.descdata extending beyond the end of the section. + (process_v850_notes): Likewise. + +2015-02-26 Terry Guo + + * readelf.c (arm_attr_tag_ABI_HardFP_use): Update how we + display it. + +2015-02-25 Andrew Burgess + + * objcopy.c (init_section_add): New function. + (section_add_load_file): New function. + (copy_main): Make use of new functions. + +2015-02-25 Andrew Burgess + + * od-elf32_avr.c: Add elf32-avr.h include. + (OPT_AVRPROP): Define. + (options[]): Add 'avr-prop' entry. + (elf32_avr_help): Add avr-prop help text. + (elf32_avr_dump_avr_prop): New function. + (elf32_avr_dump): Add check for avr-prop. + +2015-02-24 Nick Clifton + + * readelf.c (get_machine_flags): Remove deprecated V850 machine + flags. + (get_v850_section_type_name): New function. Handles V850 special + sections. + (get_section_type_name): Add support for V850. + (get_v850_elf_note_type): New function. Returns the name of a + V850 note. + (print_v850_note): New function. Prints a V850 note. + (process_v850_notes): New function. Prints V850 notes. + (process_note_sections): Add support for V850. + +2015-02-24 Mike Frysinger + + PR binutils/17531 + * readelf.c (process_symbol_table): Declare chained. Increment it + in every loop. Abort when chained is larger than nchains. Move + error check outside of chain loop. + +2015-02-24 Dmitry Antipov + + * readelf.c (find_symbol_for_address): Use a binary search to + speed up symbol location. Skip check for function symbol type. + (*_unw_aux_info): Add funtab and nfuns fields contains a sorted + list of function symbols. + (dump_ia64_unwind): Initialise the funtab and nfuns fields and + pass them to find_symbol_for_address. + (dump_hppa_unwind): Likewise. + (arm_print_vma_and_name): Pass funtab to find_symbol_for_address. + (dump_arm_unwind): Initialise the funtab and nfuns fields. + +2015-02-24 Nick Clifton + + * objdump.c (dump_section): Extend the warning message displayed + when a section cannot be loaded. + +2015-02-21 Mike Frysinger + + * readelf.c (process_program_headers): Add newline to warning + message. + +2015-02-20 Andreas Arnez + + * readelf.c (get_note_type): Add NT_S390_VXRS_LOW and + NT_S390_VXRS_HIGH. + +2015-02-13 Nick Clifton + + PR binutils/17512 + * dwarf.c (read_leb128): Fix test for shift becoming too large. + + * coffgrok.c (do_define): Add check for type size overflow. + * srconv.c (walk_tree_sfile): Check that enough sections are + available before parsing. + (prescan): Likewise. + + PR binutils/17531 + * dwarf.c (display_debug_aranges): Add check for an excessive + ar_length value. + (process_cu_tu_index): Check for a row * columns sum being too + large. + +2015-02-13 Alan Modra + + * dwarf.c: Formatting, whitespace. + (process_debug_info): Style fix. + +2015-02-11 Nick Clifton + + * rl78-decode.opc: Add 'a' attribute to instructions that support + [HL+0] addressing. + * rl78-decode.c: Regenerate. + * rl78-dis.c (print_insn_rl78): Display the offset in [HL+0] + addresses. + +2015-02-11 Nick Clifton + + PR binutils/17531 + * dwarf.c (display_debug_pubnames_worker): Work around compiler + bug checking address ranges. + (display_debug_frames): Likewise. + (display_gdb_index): Likewise. + (process_cu_tu_index): Add range check on the ncols value. + +2015-02-10 Nick Clifton + + PR binutils/17512 + * dwarf.c (eh_addr_size): Use an unsigned type. + (size_of_encoded_value): Return an unsigned type. + (read_leb128): Break if the shift becomes too big. + (process_extended_line_op): Do not read the address if the length + is too long. + (read_cie): Warn and fail if the pointer size or segment size are + too big. + * dwarf.h (DWARF2_External_LineInfo): Delete unused and incorrect + structure definition. + (DWARF2_External_PubNames): Likewise. + (DWARF2_External_CompUnit): Likewise. + (DWARF2_External_ARange): Likewise. + (DWARF2_Internal_LineInfo): Use dwarf_vma type for + li_prologue_length. + (eh_addr_size): Update prototype. + + PR binutils/17531 + * dwarf.c (process_debug_info): Zero the debug information array + since correct initialisation cannot be relied upon. + (process_cu_tu_index): Improve range checks. + + PR binutils/17531 + * dwarf.c (display_debug_pubnames_worker): Use dwarf_vma type for + offset. + * readelf.c (dump_relocations): Handle printing offsets which are + MIN_INT. + (process_corefile_note_segment): Add range check of the namesz + field. + +2015-02-09 Mark Wielaard + + * dwarf.c (read_and_display_attr_value): Handle DW_LANG_Fortran03 + and DW_LANG_Fortran08. + +2015-02-06 Nick Clifton + + PR binutils/17512 + * dwarf.c (display_debug_frames): Fix range checks to work on + 32-bit binaries complied on a 64-bit host. + + PR binutils/17531 + * dwarf.c (xcmalloc): Fail if the arguments are too big. + (xcrealloc): Likewise. + (xcalloc2): Likewise. + * readelf.c (process_mips_specific): Fail if an option has an + invalid size. + +2015-02-05 Alan Modra + + PR binutils/17926 + * dwarf.c (dwarf_select_sections_by_letters): Don't refer to optarg. + +2015-02-04 Nick Clifton + + PR binutils/17531 + * dwarf.c (read_and_display_attr_value): Test for a block length + being so long that it wraps around to before the start of the block. + (process_debug_info): Test for section_begin wrapping around to + before the start of the section. + (display_gdb_index): Test for num_cus being so large that the end + address wraps around to before the start of the section. + (process_cu_tu_index): Test for j being so large that the section + index pool wraps around to before the start of the section. + +2015-02-03 Nick Clifton + + PR binutils/17531 + * dwarf.c (process_debug_info): Add range check. + (display_debug_pubnames_worker): Likewise. + (display_gdb_index): Fix range check. + (process_cu_tu_index): Add range check. + * readelf.c (get_data): Change parameter types from size_t to + bfd_size_type. Add checks for loss of accuracy when casting from + bfd_size_type to size_t. + (get_dynamic_data): Likewise. + (process_section_groups): Limit number of error messages. + +2015-02-03 Nick Clifton + + PR binutils/17512 + * objdump.c (display_any_bfd): Fail if archives nest too deeply. + +2015-01-28 James Bowman + + * readelf.c: Add FT32 support. + +2015-01-27 Nick Clifton + + PR binutils/17512 + * dlltool.c (identify_search_archive): If the last archive was the + same as the current archive, terminate the loop. + + * addr2line.c (slurp_symtab): If the symcount is zero, free the + symbol table pointer. + + * rcparse.y: Add checks to avoid integer divide by zero. + * rescoff.c (read_coff_rsrc): Add check on the size of the + resource section. + (read_coff_res_dir): Add check on the nesting level. + Check for resource names overrunning the buffer. + * resrc.c (write_rc_messagetable): Update formatting. + Add check of 'elen' being zero. + +2015-01-23 Nick Clifton + + * nlmconv.c (powerpc_mangle_relocs): Fix build errors introduced + by recent delta, when compiling on for a 32-bit host. + +2015-01-21 Nick Clifton + + PR binutils/17512 + * addr2line.c (main): Call bfd_set_error_program_name. + * ar.c (main): Likewise. + * coffdump.c (main): Likewise. + * cxxfilt.c (main): Likewise. + * dlltool.c (main): Likewise. + * nlmconv.c (main): Likewise. + * nm.c (main): Likewise. + * objdump.c (main): Likewise. + * size.c (main): Likewise. + * srconv.c (main): Likewise. + * strings.c (main): Likewise. + * sysdump.c (main): Likewise. + * windmc.c (main): Likewise. + * windres.c (main): Likewise. + * objcopy.c (main): Likewise. + (copy_relocations_in_section): Check for relocs without associated + symbol pointers. + +2015-01-21 Ramana Radhakrishnan + + * MAINTAINERS: Add self to ARM maintainers list. + +2015-01-21 Nick Clifton + + PR binutils/17512 + * coffgrok.c (do_type): Check that computed ref exists. + (doit): Add range checks when computing section for scope. + +2015-01-12 H.J. Lu + + * dwarf.c (process_debug_info): Properly check abbrev size. + +2015-01-12 Nick Clifton + + PR binutils/17531 + * dwarf.c (process_debug_info): Check for abbrev_base being larger + than the section size. + (process_cu_tu_index): Use xcalloc2 to allocate the CU and TU + arrays. + (xcalloc2): New function. Like xcalloc, but checks for overflow. + (display_debug_addr): Use xcalloc to allocate the debug_addr_info + array. Check for an address_base that is too large. + + * dwarf.h (xcalloc2): Prototype. + +2015-01-12 Alan Modra + + * prdbg.c (print_debugging_info): Don't use void* for function + pointer param. + * budbg.h (print_debugging_info): Update prototype. + +2015-01-08 Nick Clifton + + PR binutils/17512 + * ojcopy.c (copy_object): Free the symbol table if no symbols + could be loaded. + (copy_file): Use bfd_close_all_done to close files that could not + be copied. + + * sysdump.c (getINT): Fail if reading off the end of the buffer. + Replace call to abort with a call to fatal. + (getCHARS): Prevetn reading off the end of the buffer. + + * nlmconv.c (i386_mangle_relocs): Skip relocs without an + associated symbol. + (powerpc_mangle_relocs): Skip unrecognised relocs. Check address + range before applying a reloc. + +2015-01-07 Nick Clifton + + PR binutils/17512 + * dlltool.c (scan_obj_file): Break loop if the last archive + displayed matches the current archive. + + * objdump.c (display_any_bfd): Add a depth limit to nested archive + display in order to avoid infinite loops. + * srconv.c: Replace calls to abort with calls to fatal with an + error message. + +2015-01-06 Nick Clifton + + PR binutils/17512 + * coffdump.c (dump_coff_section): Check for a symbol being + available before printing its name. + (main): Check the return value from coff_grok. + * coffgrok.c: Reformat and tidy. + Add range checks to most functions. + (coff_grok): Return NULL if the input bfd is not in a COFF + format. + * coffgrok.h: Reformat and tidy. + (struct coff_section): Change the nrelocs field to unsigned. + * srconv.c (main): Check the return value from coff_grok. + +2015-01-05 Nick Clifton + + PR binutils/17512 + * nm.c (print_symbol): Add 'is_synthetic' parameter. Use it to + help initialize the info.elfinfo field. + (print_size_symbols): Add 'synth_count' parameter. Use it to set + the is_synthetic parameter when calling print_symbol. + (print_symbols): Likewise. + (display_rel_file): Pass synth_count to printing function. + (display_archive): Break loop if the last archive displayed + matches the current archive. + * size.c (display_archive): Likewise. + +2015-01-05 Nick Clifton + + PR binutils/17531 + * dwarf.c (alloc_num_debug_info_entries): New variable. + (process_debug_info): Set it. Use it to avoid displaying + attributes for which there is no info. + (display_debug_abbrev): Check that the debug_info_entry index is + valid before using it. + (display_loc_list_dwo): Likewise. + (process_cu_tu_index): Add range check for an overlarge dw_sect + value. + (free_debug_memory): Reset alloc_num_debug_info_entries. + * readelf.c (slurp_ia64_unwind_table): Warn if the reloc could not + be indentified. + (dynamic_section_mips_val): Warn if the timestamp is invalid. + (print_mips_got_entry): Add a data_end parameter. Warn if a read + would go beyond the end of the data, and return an error value. + (process_mips_specific): Do not read options from beyond the end + of the section. + Correct code to display optional data at the end of an option. + Warn if there are too many GOT symbols. + Update calls to print_mips_got_entry, and handle error returns. + +2015-01-05 Daniel Klauer + + PR binutils/17489 + * doc/binutils.texi (dlltool): Correct description of --kill-at + option. + +2015-01-01 Alan Modra + + * version.c (print_version): Just print current year. + +2015-01-01 Alan Modra + + Update year range in copyright notice of all files. + +For older changes see ChangeLog-2014 + +Copyright (C) 2015 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2016 b/support/sdbinutils/binutils/ChangeLog-2016 new file mode 100644 index 0000000..49cdc50 --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2016 @@ -0,0 +1,988 @@ +2016-12-31 Dimitar Dimitrov + + * readelf.c (guess_is_rela): Add EM_TI_PRU. + (dump_relocations): Invoke elf_pru_reloc_type. + (get_machine_name): Handle EM_TI_PRU. + (is_32bit_abs_reloc): Handle R_PRU_BFD_RELOC_32. + (is_16bit_abs_reloc): Handle R_PRU_BFD_RELOC_16. + (is_none_reloc): Handle PRU_NONE and PRU_DIFF variants. + +2016-12-23 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips16-extend-insn.d: Update for + ASMACRO support. + +2016-12-23 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips16-extend-insn.d: New test. + * testsuite/binutils-all/mips/mips16-extend-insn.s: New test + source. + * testsuite/binutils-all/mips/mips.exp: Run the new tests. + +2016-12-23 Tristan Gingold + + * configure: Regenerate. + +2016-12-23 Tristan Gingold + + * NEWS: Add marker for 2.28. + +2016-12-23 Tristan Gingold + + * po/binutils.pot: Regenerate. + +2016-12-20 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips16-undecoded.s: Use `.module' + rather than `.set' to set the ISA level. + +2016-12-20 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips16-extend-noinsn.d: Adjust + test for separate EXTEND prefix disassembly. + +2016-12-20 Andrew Waterman + + * readelf.c (get_machine_flags): Use + EF_RISCV_FLOAT_ABI_{SOFT,SINGLE,DOBULE,QUAD) instead of + EF_RISCV_{SOFT,HARD}_FLOAT. + +2016-12-14 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips-ase-1.d: New test. + * testsuite/binutils-all/mips/mips-ase-2.d: New test. + * testsuite/binutils-all/mips/mips-ase-3.d: New test. + * testsuite/binutils-all/mips/mips-ase-1.s: New test source. + * testsuite/binutils-all/mips/mips-ase-2.s: New test source. + * testsuite/binutils-all/mips/mips.exp: Run the new tests. + +2016-12-13 Jiong Wang + + * readelf.c (is_32bit_abs_reloc): Recognize R_AARCH64_P32_ABS32. + +2016-12-13 Nick Clifton + + * MAINTAINERS (Past Maintainers): New section. Move Mark + Mitchell's name here. + +2016-12-09 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips16-extend-noinsn.d: New test. + * testsuite/binutils-all/mips/mips16-extend-noinsn.s: New test + source. + * testsuite/binutils-all/mips/mips.exp: Run the new test. + +2016-12-08 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips16-pcrel.d: New test. + * testsuite/binutils-all/mips/mips16-pcrel.s: New test source. + * testsuite/binutils-all/mips/mips.exp: Run the new test. + +2016-12-08 Étienne Buira + + * readelf.c (process_program_headers): Always use hex prefix when + displaying the segment alignment. + +2016-12-06 Nick Clifton + + PR binutils/20930 + * objcopy.c (mark_symbols_used_in_relocations): Check for a null + symbol pointer pointer before attempting to mark the symbol as + kept. + +2016-12-05 Jose E. Marchesi + + * MAINTAINERS: Add myself as maintainer for the SPARC targets. + +2016-12-05 Nick Clifton + + PR ld/20923 + * objcopy.c (mark_symbols_used_in_relocations): Check for a null + symbol pointer before attempting to mark the symbol as kept. + +2016-12-01 Luis Machado + + * nm.c (sort_symbols_by_size): Don't read symbol size if symbol + is synthetic. + +2016-11-30 Nick Clifton + + PR ld/20815 + * readelf.c (process_program_headers): Do not warn about out of + order PT_LOAD segments. + +2016-11-29 Claudiu Zissulescu + + * testsuite/binutils-all/arc/objdump.exp (Warning test): Update + test. + +2016-11-27 Ambrogino Modigliani + + * dwarf.c: Fix spelling in comments. + * dwarf.h: Fix spelling in comments. + * objcopy.c: Fix spelling in comments. + * od-macho.c: Fix spelling in comments. + * rclex.c: Fix spelling in comments. + * readelf.c: Fix spelling in comments. + * stabs.c: Fix spelling in comments. + +2016-11-23 Nick Clifton + + PR ld/20815 + * readelf.c (process_program_headers): Check PT_LOAD and PT_PHDR + segments for validity. + +2016-11-22 Ambrogino Modigliani + + * configure: Regenerate. + +2016-11-22 Alan Modra + + PR 20744 + * NEWS: Mention PowerPC VLE relocation error. + +2016-11-16 Mark Wielaard + + * cxxfilt.c (main): Recognize rust_demangling. + +2016-11-14 Rudy + + PR binutils/20814 + * dlltool.c (struct export): Remove hint field. + (make_one_lib_file): Store the ordinal value for IDATA6 not the + hint. + (gen_lib_file): Delete reference to hint field. + (mangle_defs): Delete computation of hint field. + +2016-11-11 Nick Clifton + + PR binutils/20751 + * nm.c (with_symbol_versions): New local variable. + (long_options): Add --with-symbol-versions. + (usage): Mention --with-symbol-versions. + (print_symbol): If with_symbol_versions is set then display the + version information associated with the symbol. + * NEWS: Mention the new feature. + * doc/binutils.texi (nm): Document the new option. + (objdump): Describe how symbol version information is displayed + for dynamic symbol dumps. + (readelf): Describe how symbol version information is displayed. + * testsuite/binutils-all/nm.exp: Add a test of the new feature. + +2016-11-08 Nick Clifton + + PR binutils/20794 + * readelf.c (process_section_headers): Fix off-by-one error when + checking for invalid sh_link and sh_info fields. + +2016-11-04 Andrew Burgess + + * objcopy.c (copy_section): Add extra calls to free for error + paths. + +2016-11-04 Tom Tromey + + * dwarf-mode.el (dwarf-browse): Set default-directory. Bump + version number. + +2016-11-04 Palmer Dabbelt + + * MAINTAINERS: Add myself and Andrew Waterman as maintainers for + the RISC-V target. + +2016-11-01 Palmer Dabbelt + Andrew Waterman + + Add support for RISC-V architecture. + * readelf.c (guess_is_rela): Add EM_RISCV. + (get_machine_name): Likewise. + (dump_relocations): Add support for riscv relocations. + (get_machine_flags): Add support for riscv flags. + (is_32bit_abs_reloc): Add R_RISCV_32. + (is_64bit_abs_reloc): Add R_RISCV_64. + (is_none_reloc): Add R_RISCV_NONE. + * testsuite/binutils-all/objdump.exp (cpus_expected): Add riscv. + Expect the debug_ranges test to fail. + +2016-10-17 Nick Clifton + + * readelf.c (apply_relocations): Fail if the symbol table section + linked to by the reloc section does not have either the SHT_SYMTAB + or SHT_DYNSYM type. + (print_gnu_note): Decode the contents of NT_GNU_HWCAP notes. + Print the contents of unknown note types. + (process_note): Add the file and section to the parameter list. + Use print_symbol to display the note name. + Display the contents of unknown note types. + (process_corefile_note_segment): Rename to process_notes_at. + Add section parameter. Apply relocations to the notes when + loading from a section. Display section name when processing + notes in a section. + * testsuite/binutils-all/readelf.n: Update expected output. + +2016-10-17 Nick Clifton + + * readelf.c (get_dynamic_type): Add DT_SYMTAB_SHNDX. + (get_machine_type): Add EM_CLOUDSHIELD, EM_COREA_1ST, + EM_COREA_2ND, EM_OPEN8, EM_VIDEOCORE5, EM_56800EX, EM_BA1, EM_BA2, + EM_XCORE, EM_MCHP_PIC, EM_KM32, EM_KMX32, EM_KMX16, EM_KMX8, + EM_KVARC, EM_CDP, EM_COGE, EM_COOL, EM_NORC, EM_CSR_KALIMBA, + EM_Z80, EM_AMDGPU, EM_RISCV. + (get_osabi_name): Add ELFOSABI_CLOUDABI and ELFOSABI_OPENVS. + (get_group_flags): Update to handle flags in the + GRP_MASKOS and GRP_MASKPROC ranges. + +2016-10-14 Luis Machado + + * testsuite/lib/utils-lib.exp (run_dump_test): Call remote_download + to copy file to remote host. + +2016-10-11 Nick Clifton + + * objdump.c (is_significant_symbol_name): New function. + (remove_useless_symbols): Do not remove significanr symbols. + (find_symbol_for_address): If an exact match for the specified + address has not been found, try scanning the dynamic relocs to see + if one of these matches the address. If so, use the symbol + associated with the reloc. + (objdump_print_addr_with_symbol): Do not print offsets to symbols + with no value. + (disassemble_section): Only use dynamic relocs if the user + requested this. + (disassemble_data): Always load dynamic relocs if they are + available. + +2016-10-06 Alan Modra + + * dlltool.c: Spell fall through comments consistently. + * objcopy.c: Likewise. + * readelf.c: Likewise. + * dwarf.c: Add missing fall through comments. + * elfcomm.c: Likewise. + * sysinfo.y: Likewise. + * readelf.c: Likewise. Also remove extraneous comments. + +2016-10-06 Alan Modra + + * cxxfilt.c (usage): Add ATTRIBUTE_NORETURN. + * elfedit.c (usage): Likewise. + * nm.c (usage): Likewise. + * objcopy.c (copy_usage, strip_usage): Likewise. + * srconv.c (show_usage): Likewise. + * strings.c (usage): Likewise. + * sysdump.c (show_usage): Likewise. + * srconv.c: Remove unneeded forward function declarations. + * strings.c: Likewise. + * sysdump.c: Likewise. + +2016-10-06 Alan Modra + + * coffdump.c (dump_coff_where): Add missing break. + * stabs.c (stab_xcoff_builtin_type): Likewise. + +2016-09-29 Alan Modra + + * readelf.c (process_arch_specific): Call process_power_specific + for EM_PPC64. + +2016-09-26 Vlad Zakharov + + * Makefile.am: Replace AM_CLFAGS with AM_CFLAGS_FOR_BUILD + when building with CC_FOR_BUILD compiler. + * Makefile.in: Regenerate. + * configure: Likewise. + * doc/Makefile.in: Likewise. + +2016-09-26 Alan Modra + + * readelf.c (display_power_gnu_attribute): Catch truncated section + for all powerpc attributes. Display long double ABI. Don't + capitalize words, except for names. Show known bits of tag values + when some unknown bits are present. Whitespace fixes. + +2016-09-26 Alan Modra + + * nm.c (get_elf_symbol_type): Don't use sprintf with translated + strings, use asprintf instead. + (get_coff_symbol_type): Likewise. + +2016-09-19 Alan Modra + + * nm.c (print_symbol): Remove is_synthetic param. Test sym->flags + instead. + (print_size_symbols, print_symbols): Adjust to suit, deleting + now unused synth_count param and fromsynth var. + (display_rel_file): Adjust, localizing synth_count. + +2016-09-14 Ed Maste + + * readelf.c (process_mips_specific): Fix typo in error message. + +2016-09-06 Nick Clifton + + * readelf.c (request_dump_bynumber): Only call memcpy if + dump_sects is not NULL. + +2016-08-29 H.J. Lu + + * readelf.c (load_specific_debug_section): Check the external + compression header size. + +2016-08-19 Nick Clifton + + * readelf.c (process_section_headers): Sanity check section headers. + (process_symbol_table): Don't warn on solaris binaries with local + symbols past symtab sh_info. + * testsuite/binutils-all/readelf.s: Adjust expected ordering of + sections. + * testsuite/binutils-all/readelf.s-64: Likewise. + +2016-08-12 Nick Clifton + + * readelf.c (process_symbol_table): Generate a warning if a local + symbol is found at and offste greater than or equal to the sh_info + field of it's section header. + +2016-08-08 Nick Clifton + + PR binutils/20440 + * dwarf.c (display_debug_lines_decoded): Add checks for running + off the end of the section when populating the directory table and + file table. + (frame_display_row): Set max_regs equal to ncols. + * readelf.c (load_specific_debug_section): If the section is + compressed, but it is not big enough to hold a compression + header then warn and return 0. + + PR binutils/20439 + * dwarf.c (display_debug_lines_decoded): Check directory and file + indicies before using them to access directory and file tables. + +2016-08-02 Nick Clifton + + PR binutils/17512 + * resbin.c (bin_to_res_version): Cast variables to correct type + for printing in error message. + +2016-07-28 Nick Clifton + + PR binutils/17512 + * rescoff.c (read_coff_res_dir): Fix detection of buffer overrun. + * resbin.c (bin_to_res_version): Allow for the padded length of a + version block to be longer than the recorded length. Skip padding + bytes. + +2016-07-21 H.J. Lu + + * configure: Regenerated. + +2016-07-20 Claudiu Zissulescu + + * doc/binutils.texi (objdump): Add ARC disassembler options. + * testsuite/binutils-all/arc/dsp.s: New file. + * testsuite/binutils-all/arc/objdump.exp: Likewise. + * NEWS: Mention the new feature. + +2016-07-20 Nick Clifton + + * doc/binutils.texi (objcopy): Note that the localize symbol + options do not affect unique symbols. + +2016-07-16 Alan Modra + + * ar.c: Include plugin-api.h. + * nm.c: Likewise. + +2016-07-16 Alan Modra + + * bucomm.c: Don't include libbfd.h. + (endian_string, display_target_list): Delete forward declaration. + (display_info_table, display_target_tables): Likewise. + (LONGEST_ARCH): Delete. + (struct display_target): New. + (do_display_target): New function. + (display_target_list, display_info): Rewrite functions. + (display_info_table): Delete. + (do_info_size, do_info_header, do_info_row): New functions. + +2016-07-16 Alan Modra + + * elfcomm.h (HOST_WIDEST_INT): Move to.. + * sysdep.h: ..here. + * od-macho.c: Don't include libbfd.h. Do include dwarf.h + (dump_dyld_info_rebase): Use read_leb128 rather than + read_unsigned_leb128. + (dump_dyld_info_bind, dump_dyld_info_export_1): Likewise. + (dump_segment_split_info): Likewise. + (dump_dyld_info): Rename vars to avoid shadowing dwarf.h enums. + (dump_load_command): Likewise. + +2016-07-16 Alan Modra + + * ar.c: Don't include libbfd.h. + * objcopy.c: Likewise. + * bucomm.c (bfd_get_archive_filename): Use xmalloc rather than + bfd_malloc. + +2016-07-15 Alan Modra + + * testsuite/binutils-all/remove-relocs-01.s: Use .dc.a, not .word. + +2016-07-14 Andrew Burgess + + * doc/binutils.texi (objcopy): Document 'remove-relocations'. + (strip): Likewise. + * objcopy.c (SECTION_CONTEXT_REMOVE_RELOCS): Define. + (enum command_line_switch): Add 'OPTION_REMOVE_RELOCS'. + (struct option strip_options): Add 'remove-relocations'. + (struct option copy_options): Likewise. + (copy_usage): Likewise. + (strip_usage): Likewise. + (handle_remove_relocations_option): New function. + (discard_relocations): New function. + (handle_remove_section_option): New function. + (copy_relocations_in_section): Use discard_relocations. + (strip_main): Use handle_remove_section_option for + 'remove-section', and handle 'remove-relocations' option. + (copy_main): Likewise. + * testsuite/binutils-all/objcopy.exp: Run new tests. + * testsuite/binutils-all/remove-relocs-01.d: New file. + * testsuite/binutils-all/remove-relocs-01.s: New file. + * testsuite/binutils-all/remove-relocs-02.d: New file. + * testsuite/binutils-all/remove-relocs-03.d: New file. + * testsuite/binutils-all/remove-relocs-04.d: New file. + * testsuite/binutils-all/remove-relocs-05.d: New file. + * testsuite/binutils-all/remove-relocs-06.d: New file. + * NEWS: Mention new option. + +2016-07-14 Andrew Burgess + + * objcopy.c (find_section_list): Handle section patterns starting + with '!' being a non-matching pattern. + * doc/binutils.texi (objcopy): Give example of using '!' with + --remove-section and --only-section. + (strip): Give example of using '!' with --remove-section. + * testsuite/binutils-all/data-sections.s: New file. + * testsuite/binutils-all/only-section-01.d: New file. + * testsuite/binutils-all/remove-section-01.d: New file. + * testsuite/binutils-all/objcopy.exp: Run new tests. + * NEWS: Mention new feature. + +2016-07-09 Alan Modra + + PR binutils/20337 + * objdump.c (compare_symbols): For ELF, sort same value/type + symbols according to size. + +2016-07-05 Andre Vieria + + * objdump.c (dump_section_header): Rename SEC_ELF_NOREAD + to SEC_ELF_NOREAD. + * readelf.c (get_elf_section_flags): Rename ARM_NOREAD to + ARM_PURECODE and SHF_ARM_NOREAD to SHF_ARM_PURECODE. + (process_section_headers): Rename noread to purecode. + + * section.c (SEC_ELF_NOREAD): Rename to ... + (SEC_ELF_PURECODE): ... this. + +2016-07-01 Nick Clifton + + * prdbg.c (pr_enum_type): Use a buffer big enough to hold an + extremely large decimal value. + (pr_range_type): Likewise. + (pr_array_type): Likewise. + (pr_struct_field): Likewise. + (pr_class_baseclass): Likewise. + (pr_class_method_variant): Likewise. + (pr_tag_type): Likewise. + (pr_int_constant): Likewise. + (pr_typed_constant): Likewise. + (pr_variable): Likewise. + (pr_function_parameter): Likewise. + (pr_start_block): Likewise. + (pr_lineno): Likewise. + (pr_end_block): Likewise. + (tg_enum_type): Likewise. + (tg_int_constant): Likewise. + (tg_typed_constant): Likewise. + (tg_start_block): Likewise. + +2016-07-01 Nick Clifton + + * testsuite/binutils-all/objcopy.exp + (objcopy_test_without_global_symbol): Expect this test to fail on + the AArch64 and ARM targets, since they preserve their mapping + symbols. + +2016-07-01 Tristan Gingold + + * NEWS: Add marker for 2.27. + +2016-07-30 Tristan Gingold + + * doc/binutils.texi (objdump): Fix mis-placement. + +2016-06-28 Nick Clifton + + * testsuite/binutils-all/ar.exp: Relax previous restriction on + Alpha targets. Allow ELF based Alpha targets. + +2016-06-28 Maciej W. Rozycki + + * testsuite/binutils-all/ar.exp: Use `supports_gnu_unique' with + the `unique_symbol' test. + +2016-06-28 Alan Modra + + PR 20304 + * objdump.c (objdump_print_symname): Don't attempt to retrieve + version info from synthetic symbols. + +2016-06-24 Alan Modra + + * objcopy.c (find_section_rename): Forward declare. Remove + ibfd and sec_ptr param. Add old_name param. Allow for NULL + returned_flags. Move read of section name and flags to.. + (setup_section): ..here. Update find_section_rename call. + (filter_symbols): Rename section symbols for renamed sections. + (copy_object): Call filter_symbols when renamed sections. + * testsuite/lib/binutils-common.exp (is_bad_symtab): New. + * testsuite/binutils-all/update-section.exp: Revert 96037eb0 + mips xfail. + * testsuite/binutils-all/objcopy.exp (copy_executable): Use + is_bad_symtab. + (localize-hidden-1): xfail if is_bad_symtab. + * testsuite/binutils-all/readelf.exp: Use is_bad_symtab to select + between mips/tmips. + +2016-06-24 Alan Modra + + * objdump.c (struct print_file_list): Add "max_printed". + (try_print_file_open): Init new field. + (show_line): Don't show 5 context lines when redisplaying source. + +2016-06-22 Nick Clifton + + * testsuite/binutils-all/ar.exp: Skip tests for Alpha target. + Skip bfdtest1 tests for tic30 target. + * testsuite/binutils-all/arm/objdump.exp: Skip for aout arm + target. + * testsuite/binutils-all/compress.exp: Expect some tests to fail + on the nds32. + * testsuite/binutils-all/copy-3.d: Skip for go32 targets. + * testsuite/binutils-all/copy-4.d: Skip for AIX and linuxecoff + targets. + * testsuite/binutils-all/nm.exp: Treat beos based targets as ELF + targets. + * testsuite/binutils-all/objcopy.exp: Only run reverse bytes tests + if the bintest.o file was created. Use the + get_standard_section_names proc to get the name of the data + section. + * testsuite/binutils-all/objdump.exp: Update regexps to allow for + RX section names. + * testsuite/binutils-all/readelf.exp: Use + get_standard_section_names proc to get the name of the data + section. + * testsuite/binutils-all/readelf.r: Allow for non standard text + section names. + * testsuite/binutils-all/readelf.s: Update regexps for tilepro. + * testsuite/binutils-all/size.exp: Allow for non standard section + names. + * testsuite/binutils-all/update-section.exp: Expect comapre 1vs4 + to fail on mips targets. + * testsuite/lib/utils-lib.exp (default_binutils_run): Use + get_standard_section_names proc. + (run_dump_test): Likewise. + (proc get_standard_section_names): New proc. + +2016-06-22 Nick Clifton + + * readelf.c (dynamic_section_mips_val): Increase size of timebuf. + (process_mips_specific): Likewise. + (process_gnu_liblist): Likewise. + +2016-06-21 Graham Markall + + * readelf.c (decode_ARC_machine_flags): Remove E_ARC_MACH_NPS400 + case. + +2016-06-15 Nick Clifton + + * readelf.c (is_24bit_abs_reloc): Add support for R_FT32_20 + reloc. + +2016-06-14 John Baldwin + + * objcopy.c (do_elf_stt_common): Use correct type. + +2016-06-14 Alan Modra + + * ar.c: Expand uses of bfd_my_archive. + * size.c: Likewise. + +2016-06-14 Alan Modra + + PR ld/20241 + * bucomm.c (bfd_get_archive_filename): Return file name within thin + archive. + +2016-06-02 Nick Clifton + + PR 20089 + * objcopy.c (group_signature): Fail if the input symbol table has + not been loaded, or if the sh_info field of the group header is 0. + + * dwarf.c (display_debug_frames): Do not display any + interpretation if the block consists solely of DW__CFA_NOPs. + +2016-05-31 Alan Modra + + * objcopy.c: Formatting, whitespace throughout. + (copy_main): Init newsym->othersym. + (parse_symflags): Make len a size_t. Adjust uses. + +2016-05-25 H.J. Lu + + PR binutils/14625 + * NEWS: Mention --enable-64-bit-archive. + +2016-05-18 Nick Clifton + + PR 20096 + * objcopy.c (copy_relocations_in_section): Also check for the + symbol pointed to by sym_ptr_ptr being NULL. + +2016-05-18 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mixed-mips16-micromips.d: New test. + * testsuite/binutils-all/mips/mixed-mips16-micromips.s: New test + source. + * testsuite/binutils-all/mips/mips.exp: Run the new test. + +2016-05-18 Nick Clifton + + * po/sv.po: Updated Swedish translation. + +2016-05-18 Maciej W. Rozycki + + * readelf.c (dynamic_section_mips_val) + + + + + : Use the + `d_val' rather than `d_ptr' member of the dynamic entry. + +2016-05-17 Maciej W. Rozycki + + * testsuite/lib/binutils-common.exp (supports_gnu_unique): New + procedure. + * testsuite/binutils-all/objcopy.exp: Use `supports_gnu_unique' + with the `strip-10' test. + +2016-05-16 Maciej W. Rozycki + + * testsuite/binutils-all/objcopy.exp: Don't skip the `strip-10' + test for the V850. + +2016-05-11 Andrew Bennett + + * readelf.c (print_mips_ases): Add DSPR3. + +2016-05-10 Thomas Preud'homme + + * readelf.c (display_arm_attribute): Add output for Tag_DSP_extension. + (arm_attr_public_tags): Define DSP_extension attribute. + +2016-05-10 Andrew Burgess + + * doc/binutils.texi (nm): Update description of --size-sort. + +2016-05-09 Nick Clifton + + PR binutils/20063 + * readelf.c (get_32bit_section_headers): Warn if an out of range + sh_link or sh_info field is encountered. + (get_64bit_section_headers): Likewise. + +2016-05-04 Senthil Kumar Selvaraj + + * testsuite/lib/binutils-common.exp (is_elf_format): Add avr-*-*. + +2016-05-03 Nick Clifton + + * po/sv.po: Updated Swedish translation. + +2016-04-29 Pitchumani Sivanupandi + + * readelf.c (is_32bit_pcrel_reloc): Return true if reloc is 32-bit + PC relocation for AVR target. + (is_none_reloc): Return true if reloc is any of AVR diff + relocations. + +2016-04-29 Nick Clifton + + PR 19938 + * readelf.c (get_solaris_segment_type): New function. + (get_segment_type): Call it. + +2016-04-28 Nick Clifton + + * po/zh_CN.po: Updated Chinese (simplified) translation. + +2016-04-28 Nick Clifton + + PR target/19722 + * testsuite/binutils-all/aarch64/illegal.s: New test. + * testsuite/binutils-all/aarch64/illegal.d: New test driver. + +2016-04-20 Trevor Saunders + + * resres.c: Likewise. + +2016-04-15 H.J. Lu + + * Makefile.in: Regenerated with automake 1.11.6. + * aclocal.m4: Likewise. + * doc/Makefile.in: Likewise. + +2016-04-14 Nick Clifton + + PR target/19938 + * testsuite/binutils-all/i386/compressed-1b.d: Allow for the + string sections possibly having the SHF_STRINGS flag bit set. + * testsuite/binutils-all/i386/compressed-1c.d: Likewise. + * testsuite/binutils-all/readelf.s: Likewise. + * testsuite/binutils-all/readelf.s-64: Likewise. + * testsuite/binutils-all/x86-64/compressed-1b.d: Likewise. + * testsuite/binutils-all/x86-64/compressed-1c.d: Likewise. + +2016-04-13 Nick Clifton + + PR target/19938 + * readelf.c (get_solaris_section_type): New function: Returns the + name of Solaris specific section types. + (get_solaris_dynamic_type): New function: Return the name of + Solaris specific dynamic types. + (get_dynamic_type): Use get_solaris_dynamic_type. + (get_section_type_name): Use get_solaris_section_type. + (get_solaris_symbol_visibility): New function: Returns Solaris + specific symbol visibilities. + (print_dynamic_symbol): Use get_solaris_symbol_visibility. + (process_symbol_table): Likewise. + +2016-04-13 Andreas Arnez + + * dwarf.h (init_dwarf_regnames_s390): Declare. + * dwarf.c (dwarf_regnames_s390): New. + (init_dwarf_regnames_s390): New. + (init_dwarf_regnames): Call it. + * objdump.c (dump_dwarf): Likewise. + +2016-04-11 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips16-undecoded.d: New test. + * testsuite/binutils-all/mips/mips16-undecoded.s: New test + source. + * testsuite/binutils-all/mips/mips.exp: Run the new test. + +2016-04-04 Nick Clifton + + PR 19872 + * dwarf.c (display_debug_aranges): Skip warning about unrecognised + version number if the version is zero. + +2016-03-29 Alan Modra + + * readelf.c (get_data): Use BFD_VMA_FMT to print bfd_size_type vars. + (get_dynamic_data): Likewise. + +2016-03-22 Nick Clifton + + PR 19851 + * dwarf.c (SAFE_BYTE_GET): Replace local dynamic array allocation + with run time size check. + + * configure: Regenerate. + +2016-03-21 Andrew Burgess + + * readelf.c (decode_ARC_machine_flags): Handle nps400. + +2016-03-21 Andrew Burgess + + * readelf.c (get_machine_flags): Move arc processing into... + (decode_ARC_machine_flags): ... new function. Remove use of + EF_ARC_CPU_GENERIC, change default case from "generic arc" to + "unknown arc". Merged ABI printing between two machine types. + +2016-03-21 Andrew Burgess + + * testsuite/binutils-all/objdump.exp (cpus_expected): Add ARC700 + to the architecture list. + +2016-03-21 Nick Clifton + + * dlltool.c: Replace use of alloca with call to xmalloc. + * dllwrap.c: Likewise. + * nlmconv.c: Likewise. + * objdump.c: Likewise. + * resrc.c: Likewise. + * winduni.c: Likewise. + * configure: Regenerate. + +2016-03-07 Nick Clifton + + PR binutils/19775 + * testsuite/binutils-all/ar.exp (proc empty_archive): New proc. + Run the new proc. + * testsuite/binutils-all/empty: New, empty, file. + +2016-03-04 Matthew Wahab + + * readelf.c (arm_attry_tag_FP_arch): Add "NEON for ARMv8.1". + +2016-02-26 H.J. Lu + + PR ld/19645 + * NEWS: Mention --elf-stt-common= for objcopy. + * doc/binutils.texi: Document --elf-stt-common= for objcopy. + * objcopy.c (do_elf_stt_common): New. + (command_line_switch): Add OPTION_ELF_STT_COMMON. + (copy_options): Add --elf-stt-common=. + (copy_usage): Add --elf-stt-common=. + (copy_object): Also check do_elf_stt_common for ELF targets. + (copy_file): Handle do_elf_stt_common. + (copy_main): Handle OPTION_ELF_STT_COMMON. + * readelf.c (apply_relocations): Support STT_COMMON. + * testsuite/binutils-all/common-1.s: New file. + * testsuite/binutils-all/common-1a.d: Likewise. + * testsuite/binutils-all/common-1b.d: Likewise. + * testsuite/binutils-all/common-1c.d: Likewise. + * testsuite/binutils-all/common-1d.d: Likewise. + * testsuite/binutils-all/common-1e.d: Likewise. + * testsuite/binutils-all/common-1f.d: Likewise. + * testsuite/binutils-all/common-2.s: Likewise. + * testsuite/binutils-all/common-2a.d: Likewise. + * testsuite/binutils-all/common-2b.d: Likewise. + * testsuite/binutils-all/common-2c.d: Likewise. + * testsuite/binutils-all/common-2d.d: Likewise. + * testsuite/binutils-all/common-2e.d: Likewise. + * testsuite/binutils-all/common-2f.d: Likewise. + * testsuite/binutils-all/objcopy.exp + (objcopy_test_elf_common_symbols): New proc. + Run objcopy_test_elf_common_symbols for ELF targets + +2016-02-16 H.J. Lu + + PR binutils/19647 + * readelf.c (get_section_type_name): Add a missing break. + +2016-02-16 Claudiu Zissulescu + + * readelf.c (is_32bit_pcrel_reloc): Add R_ARC_32_PCREL. + +2016-02-15 Nick Clifton + + * readelf.c (get_section_type_name): Add hex prefix to offsets + printed for LOPROC and LOOS values. Ensure that a result is + always returned for the V850 target, even when an unrecognised + processor specific value is encountered. + (process_section_headers): Display key values in the order in + which they appear to the user. Add the "C (compressed)" value to + the list. + +2016-02-12 H.J. Lu + + * doc/binutils.texi: Fix a typo. + +2016-02-05 Cupertino Miranda + + * testsuite/binutils-all/objdump.exp: Update expected default + architecture value for ARC binaries. + +2016-02-02 H.J. Lu + + PR binutils/19547 + * testsuite/binutils-all/objcopy.exp + (objcopy_test_without_global_symbol): New proc. + Run objcopy_test_without_global_symbol. + * testsuite/binutils-all/pr19547.c: New file. + +2016-01-28 H.J. Lu + + PR binutils/19523 + * Makefile.am (check-DEJAGNU): Pass CC and CC_FOR_BUILD to + runtest. + * Makefile.in: Regenerated. + * testsuite/binutils-all/compress.exp (test_gnu_debuglink): New + proc. + Run test_gnu_debuglink for native ELF build. + +2016-01-20 Nick Clifton + + PR 19495 + * testsuite/binutils-all/dlltool.exp: Fix tests for targets which + do not support inserting leading underscores. + +2016-01-20 Mickael Guene + + * readelf.c (get_elf_section_flags): Display y letter for section + with SHF_ARM_NOREAD section flag in readelf section output. + (process_section_headers): Add y letter in readelf section output + key mapping for ARM architecture. + * objdump.c (dump_section_header): Display NOREAD attributes as + well. + * doc/binutils.texi (objdump): Note that it is correct for + sections to have both the READONLY and NOREAD attributes. + +2016-01-19 John Baldwin + + * readelf.c (get_freebsd_elfcore_note_type): Remove unused variable. + +2016-01-19 John Baldwin + + * readelf.c (get_freebsd_elfcore_note_type): New + (process_note): Add support for FreeBSD core notes. + +2016-01-18 Miranda Cupertino + Zissulescu Claudiu + + * readelf.c (get_machine_flags): Add support for newer ARC ELF + header flags. + +2016-01-18 Alan Modra + + * configure: Regenerate. + +2016-01-17 Alan Modra + + * configure: Regenerate. + +2016-01-17 Alan Modra + + * testsuite/lib/binutils-common.exp (is_elf_format): Return true + for m68hc11/12 and xgate triples. + +2016-01-17 Alan Modra + + * readelf.c (is_32bit_abs_reloc): Add R_M68HC11_32. + +2016-01-01 Alan Modra + + Update year range in copyright notice of all files. + +For older changes see ChangeLog-2015 and testsuite/ChangeLog-1215 + +Copyright (C) 2016 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-2017 b/support/sdbinutils/binutils/ChangeLog-2017 new file mode 100644 index 0000000..714b20d --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-2017 @@ -0,0 +1,1886 @@ +2017-12-19 Nick Clifton + + PR 22587 + * readelf.c (process_section_headers): Do not complain about an + sh_info field of 0 in relocation sections of ET_EXEC or ET_DYN + type executables. + +2017-12-19 Alan Modra + + * testsuite/binutils-all/ar.exp (unique_symbol): Don't run AR + if assembly fails. + * testsuite/binutils-all/arc/objdump.exp (check_assembly): If + objfile is empty, fail test. + * testsuite/binutils-all/arm/objdump.exp: Don't return if assembly + fails for a test, continue on to other tests. + * testsuite/binutils-all/bfin/objdump.exp: Likewise. + * testsuite/binutils-all/hppa/objdump.exp: Likewise. + * testsuite/binutils-all/m68k/objdump.exp: Likewise. + * testsuite/binutils-all/vax/objdump.exp: Likewise. + * testsuite/binutils-all/size.exp: Likewise. + * testsuite/binutils-all/nm.exp: Likewise. Move PR12753 test. + * testsuite/binutils-all/objcopy.exp: Don't perror on assembly fail. + * testsuite/binutils-all/objdump.exp: Report assembly fails. + +2017-12-18 Nick Clifton + + PR 22532 + * dwarf.c (read_and_display_attr_value): Add attributes that might + use the DW_FORM_exprloc form, and if so, display the decoded + location expression list. + +2017-12-14 Alan Modra + + * testsuite/lib/utils-lib.exp (default_binutils_assemble_flags): + Don't perror on assembler diagnostic output. + * testsuite/binutils-all/nm.exp: Run unique symbol test on all + ELF targets. Resolve as "unsupported" on assembly failure. + +2017-12-11 Renlin Li + + * testsuite/binutils-all/aarch64/objdump.d: New. + * testsuite/binutils-all/aarch64/objdump.s: New. + +2017-12-08 Nick Clifton + + * objcopy.c (copy_relocations_in_section): Use the orelocations + field of the input section, if it has been initialised. + * testsuite/binutils-all/note-2-64.d: Skip test on Sparc64. + +2017-12-06 Jim Wilson + + PR 22465 + * objcopy.c (copy_section): New local extra. If isection->lma not + exactly divisible by interleave, then bias from. Also adjust + osection->lma if necessary. + +2017-12-06 Alan Modra + + PR 22552 + * readelf.c (process_file_header): Don't assume XINDEX case + value for e_shstrndx is within bounds. + (load_debug_section): Sanity test e_shstrndx before attempting + to read .shstrtab. Wrap long lines. + +2017-12-01 Oleksandr Pikozh + + * doc/binutils.texi: Add --strip-unneeded to objcopy synopsis. + +2017-11-30 Nick Clifton + + PR 22510 + * readelf.c (load_debug_section): Fail if there are no section + headers available. + +2017-11-29 Nick Clifton + + PR 22508 + * objdump.c (dump_relocs_in_section): Also check the section's + relocation count to make sure that it is reasonable before + attempting to allocate space for the relocs. + +2017-11-29 Stefan Stroe + + * po/Make-in (datadir): Define as @datadir@. + (localedir): Define as @localedir@. + (gnulocaledir, gettextsrcdir): Use @datarootdir@. + +2017-11-28 H.J. Lu + + PR binutils/22490 + * readelf.c (process_notes_at): Add an argument for note + alignment. If note alignment is less than 4, use 4 byte + alignment. Otherwise, skip notes if alignment isn't 4 nor + 8 bytes. + (process_corefile_note_segments): Pass segment alignment to + process_notes_at. + (process_note_sections): Pass section alignment to + process_notes_at. + (process_object): Call load_separate_debug_file only if + e_shstrndx != SHN_UNDEF. + +2017-11-27 Nick Clifton + + PR 22490 + * readelf.c (dump_section_as_bytes): Check for a NULL string + section pointer. + (process_notes_at): Compute the alignment to use if displaying + notes from a segment. + +2017-11-26 H.J. Lu + + * dwarf.c (load_separate_debug_info): Rename argument name from + link to xlink. + +2017-11-24 H.J. Lu + + PR binutils/22444 + * readelf.c (process_notes_at): Use ELF_NOTE_DESC_OFFSET to get + the offset of the note descriptor. Use ELF_NOTE_NEXT_OFFSET to + get the offset of the next note entry. + +2017-11-23 Pavel I. Kryukov + + PR 22485 + * readelf.c (process_archive): Use memset to initiaise + thin_filedata structure. + +2017-11-21 H.J. Lu + + PR binutils/22451 + * testsuite/binutils-all/x86-64/objects.exp: New file. + * testsuite/binutils-all/x86-64/pr22451.o.bz2: Likewise. + +2017-11-21 Claudiu Zissulescu + + * testsuite/binutils-all/arc/objdump.exp: Update pattern matching + expression. + +2017-11-21 Nick Clifton + + * dwarf.c (dwo_name, dwo_dir, dwo_id, dwo_id_len): New variables. + (read_and_display_attr_value): Record dwo variables if requested. + (display_augmentation_data): Rename to display_data and make + generic. + (load_dwo_file): New function. Loads a separate dwarf object + file. + (load_separate_debug_file): Add reporting and loading of separate + dwarf objet files. + * readelf.c (process_section_headers): Add do_debug_links to list + of flags requiring a debug dump. + (display_debug_section): Tidy up code. + * doc/debug.options.texi: Add note that dwo links will also be + followed. + * testsuite/binutils-all/debuglink.s: Tidy code. + * testsuite/binutils-all/dwo.s: New test file. + * testsuite/binutils-all/readelf.wk2: New file - expected output + from readelf. + * testsuite/binutils-all/readelf.exp: Run the new test. + +2017-11-18 Alan Modra + + PR 22443 + * nm.c (sort_symbols_by_size): Don't attempt to access + section symbol internal_elf_sym. + (print_symbol): Likewise. Don't call bfd_get_symbol_version_string + for section symbols. + * objdump.c (compare_symbols): Don't attempt to access + section symbol internal_elf_sym. + (objdump_print_symname): Don't call bfd_get_symbol_version_string + for section symbols. + +2017-11-17 Jim Wilson + + * readelf.c (elf/riscv.h): Alphabetize include. + (is_32bit_inplace_add_reloc, is_32bit_inplace_sub_reloc) + (is_64bit_inplace_add_reloc, is_64bit_inplace_sub_reloc) + (is_16bit_inplace_add_reloc, is_16bit_inplace_sub_reloc) + (is_8bit_inplace_add_reloc, is_8bit_inplace_sub_reloc): New. + (apply_relocations): New locals reloc_inplace and reloc_subtract. + Call the new functions and set the new locals. Call byte_get if + reloc_inplace. Subtract sym->st_value if reloc_subtract. + +2017-11-17 Nick Clifton + + PR 22449 + * ar.c (write_archive): Free the temporary file name. + +2017-11-17 Nick Clifton + + * readelf.c (process_archive): Include member name in the + file_name of the filedata structure. + +2017-11-15 Alan Modra + + PR 22426 + * objcopy.c (copy_main): Free tmpname. + +2017-11-15 Nick Clifton + + PR 15152 + * dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink, + gnu_debugaltlink and separate_debug_str. + (struct dwarf_section): Add filename field. + Add prototypes for load_separate_debug_file, close_debug_file and + open_debug_file. + * dwarf.c (do_debug_links): New. + (do_follow_links): New. + (separate_debug_file, separate_debug_filename): New. + (fetch_alt_indirect_string): New function. Retrieves a string + from the debug string table in the separate debug info file. + (read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt. + (load_debug_section_with_follow): New function. Like + load_debug_section, but if the first attempt fails, then tries + again in the separate debug info file. + (introduce): New function. + (process_debug_info): Use load_debug_section_with_follow and + introduce. + (load_debug_info): Likewise. + (display_debug_lines_raw): Likewise. + (display_debug_lines_decoded): Likewise. + (display_debug_macinfo): Likewise. + (display_debug_macro): Likewise. + (display_debug_abbrev): Likewise. + (display_debug_loc): Likewise. + (display_debug_str): Likewise. + (display_debug_aranges): Likewise. + (display_debug_addr); Likewise. + (display_debug_frames): Likewise. + (display_gdb_index): Likewise. + (process_cu_tu_index): Likewise. + (load_cu_tu_indexes): Likewise. + (display_debug_links): New function. Displays the contents of a + .gnu_debuglink or .gnu_debugaltlink section. + (calc_gnu_debuglink_ctc32):New function. Calculates a CRC32 + value. + (check_gnu_debuglink): New function. Checks the CRC of a + potential separate debug info file. + (parse_gnu_debuglink): New function. Reads a CRC value out of a + .gnu_debuglink section. + (check_gnu_debugaltlink): New function. + (parse_gnu_debugaltlink): New function. Reads the build-id value + out of a .gnu_debugaltlink section. + (load_separate_debug_info): New function. Finds and loads a + separate debug info file. + (load_separate_debug_file): New function. Attempts to find and + follow a link to a separate debug info file. + (free_debug_memory): Free the separate debug info file + information. + (opts_table): Add "follow-links" and "links". + (dwarf_select_sections_by_letters): Add "k" and "K". + (debug_displays): Reformat. Add .gnu-debuglink and + .gnu_debugaltlink. + Add an extra entry for .debug_str in a separate debug info file. + * doc/binutils.texi: Move description of debug dump features + common to both readelf and objdump into... + * objdump.c (usage): Add -Wk and -WK. + (load_specific_debug_section): Initialise the filename field in + the dwarf_section structure. + (close_debug_file): New function. + (open_debug_file): New function. + (dump_dwarf): Load and dump the separate debug info sections. + * readelf.c (struct filedata): New structure. Contains various + variables that used to be global: + (current_file_size, string_table, string_table_length, elf_header) + (section_headers, program_headers, dump_sects, num_dump_sects): + Move into filedata structure. + (cmdline): New global variable. Contains list of sections to dump + by number, as specified on the command line. + Add filedata parameter to most functions. + (load_debug_section): Load the string table if it has not already + been retrieved. + (close_file): New function. + (close_debug_file): New function. + (open_file): New function. + (open_debug_file): New function. + (process_object): Process sections in any separate debug info files. + * doc/debug.options.texi: New file. Add description of =links and + =follow-links options. + * NEWS: Mention the new feature. + * elfcomm.c: Have the byte get functions take a const pointer. + * elfcomm.h: Update prototypes. + * testsuite/binutils-all/dw5.W: Update expected output. + * testsuite/binutils-all/objdump.WL: Update expected output. + * testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk. + * testsuite/binutils-all/readelf.exp: Add test of -wK and -wk. + * testsuite/binutils-all/readelf.k: New file. + * testsuite/binutils-all/objdump.Wk: New file. + * testsuite/binutils-all/objdump.WK2: New file. + * testsuite/binutils-all/linkdebug.s: New file. + * testsuite/binutils-all/debuglink.s: New file. + +2017-11-10 Jim Wilson + + * testsuite/binutils-all/objdump.exp: Expect the debug_ranges test to + pass. + +2017-11-07 Jim Wilson + + * MAINTAINERS (RISC-V): Fix typo in my email address. + +2017-11-07 Palmer Dabbelt + + * MAINTAINERS (RISC-V): Add Jim Wilson as a maintainer. + Clean up Andrew's entry (remove trailing space, add tabs). + Change Palmer's email address, and clean up entry (add tabs). + +2017-11-07 Alan Modra + + * dwarf.c (read_uleb128): Properly pluralize messages. + (display_debug_lines_raw, display_debug_loc): Likewise. + (display_debug_names, process_cu_tu_index): Likewise. + * od-macho.c (dump_code_signature_superblob): Likewise. + * readelf.c (process_program_headers): Likewise. + (process_section_header, process_relocs): Likewise. + (hppa_process_unwind, arm_process_unwind): Likewise. + (process_dynamic_section, process_version_sections): Likewise. + (process_symbol_table, process_syminfo): Likewise. + (apply_relocations, process_mips_specific): Likewise. + (process_gnu_liblist, process_notes_at): Likewise. + (process_archive): Likewise. + * testsuite/binutils-all/dw2-1.W, + * testsuite/binutils-all/dw2-3.W, + * testsuite/binutils-all/dw2-3gabi.W, + * testsuite/binutils-all/dw5.S, + * testsuite/binutils-all/dw5.W, + * testsuite/binutils-all/i386/compressed-1a.d, + * testsuite/binutils-all/libdw2-compressedgabi.out, + * testsuite/binutils-all/objdump.W, + * testsuite/binutils-all/readelf.r, + * testsuite/binutils-all/readelf.r-64, + * testsuite/binutils-all/x86-64/compressed-1a.d: Update + for pluralization fixes. + +2017-11-07 Alan Modra + + * sysdep.h (textdomain, bindtextdomain): Use safer "do nothing". + (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. + +2017-11-03 Claudiu Zissulescu + + * doc/binutils.texi (ARC): Update disassembler options. + * testsuite/binutils-all/arc/hexprint.s: New file. + * testsuite/binutils-all/arc/objdump.exp: Test hex printing + feature. + +2017-11-03 Mingi Cho + Nick Clifton + + PR 22386 + * dwarf.c (read_cie): Use bfd_size_type for + augmentation_data_len. + (display_augmentation_data): New function. + (display_debug_frames): Use it. + Check for integer overflow when testing augmentation_data_len. + +2017-11-02 Mingi Cho + + PR 22384 + * readelf.c (print_gnu_property_note): Improve overflow checks so + that they will work on a 32-bit host. + +2017-11-01 James Bowman + + * readelf.c (is_16bit_abs_reloc): Add entry for FT32. + +2017-10-31 Nick Clifton + + * readelf.c (process_relocs): Tell users if no static relocs were + found, but if they had added --use-dynamic to the command line + then relocs would have been displayed. + +2017-10-28 Alan Modra + + PR 22361 + * readelf.c (process_archive_index_and_symbols): Ensure ar_size + field is zero terminated for strtoul. + (setup_archive, get_archive_member_name): Likewise. + +2017-10-27 Simon Marchi + + * dwarf.c (struct Frame_Chunk) : Change type to + unsigned int. + (display_debug_frames): Read CFA reg as an unsigned number. + +2017-10-25 Alan Modra + + * nm.c (filter_symbols): Match "__gnu_lto_slim" optionally prefixed + with "_". + +2017-10-18 Eric Botcazou + + * MAINTAINERS: Add myself as Visium maintainer. + +2017-10-18 Nick Clifton + + * README-how-to-make-a-release: A note about checking file and + directory permissions. + + * MAINTAINERS: Move Svein Seldal to Past Maintainers section. + +2017-10-18 Alan Modra + + PR 22303 + * readelf.c (print_core_note): Ensure "count" sanity check + calculation doesn't overflow. + (process_notes_at): Perform note namesz and descsz checks + using unsigned comparisons against data remaining. Catch + alignment overflow of namesz and descsz too. Don't allocate a + temp for terminating "name" when there is space available + before descdata. + +2017-10-17 Tom Tromey + + * MAINTAINERS: Add myself as dwarf-mode.el maintainer. + +2017-10-11 Peeter Joot + Nick Clifton + + * dwarf.c (read_and_display_attr_value): Handle DW_AT_endianity, + DW_END_default, DW_END_big, DW_END_little, DW_ATE_UCS, + DW_ATE_ASCII, DW_CC_pass_by_reference, DW_CC_pass_by_value, + DW_CC_GNU_renesas_sh, DW_CC_GNU_borland_fastcall_i386, + DW_AT_decimal_sign, DW_AT_defaulted, DW_AT_discr_list. + (get_TAG_name): Report user generated tag values. + * testsuite/binutils-all/dwarf-attributes.S: New test. + * testsuite/binutils-all/dwarf-attributes.W. Expected output from + readelf. + * testsuite/binutils-all/readelf.exp: Run the new test. + +2017-10-10 Tom Tromey + + * dwarf-mode.el: Bump to version 1.4. + +2017-10-10 Tom Tromey + + * dwarf-mode.el (dwarf--process, dwarf--deletion-region): New + defvar. + (dwarf--check-running, dwarf--sentinel, dwarf--invoke) + (dwarf--filter): New functions. + (dwarf-do-insert-substructure, dwarf-do-refresh): Call + dwarf--check-running, dwarf--invoke. + (dwarf-browse): Initialize new variables. + +2017-10-10 Tom Tromey + + * dwarf-mode.el: Set lexical-binding. + +2017-10-10 Tom Tromey + + * dwarf-mode.el (dwarf-mode-map): New defvar. + +2017-10-10 Tom Tromey + + PR 22249 + * dwarf.c (process_debug_info): Skip any comp unit that ends + before dwarf_start_die. + +2017-10-06 Alan Modra + + * dwarf.c (process_debug_info): Consolidate header length checks. + (display_debug_pubnames_worker): Use "start" to read header. + Properly check header length and report errors earlier. + Simplify loop printing pubnames. + (get_line_filename_and_dirname): Catch small negative "length" + values. + (display_debug_aranges): Likewise. Report header errors + earlier using standardized message. + (display_debug_names): Likewise. + +2017-10-05 Joseph Myers + + * readelf.c (decode_arm_unwind): Initialize res to TRUE. + +2017-10-05 Nick Clifton + + PR 22260 + * objcopy.c (strip_main): Add 'M' character to short options list + when calling getopt_long. + +2017-10-05 Nick Clifton + + PR 22262 + * readelf.c (dump_relocations): Do not truncate reloc names when + displaying output in wide mode. + +2017-10-05 Nick Clifton + + * README-how-to-make-a-release: Merge steps 3, 4 and 5, and insert + the git tag operation at the correct location. + +2017-10-05 Alan Modra + + PR 22239 + * dwarf.c (read_cie): Don't compare "start" and "end" pointers + after adding a possibly wild length to "start", compare the length + to the difference of the pointers instead. Remove now redundant + "negative" length test. + +2017-10-05 Tristan Gingold + + * MAINTAINERS: Update email address. Redirect release maintainer + to global maitainers. + +2017-10-01 Alan Modra + + PR 22232 + PR 22230 + * objdump.c (load_specific_debug_section): Introduce a temp to + stop bfd_get_full_section_contents NULLing out section->start. + +2017-10-01 Alan Modra + + PR 22230 + * objdump.c (load_specific_debug_section): Allocate an extra byte + for a terminating NUL. + +2017-09-30 Alan Modra + + PR 21978 + * objdump.c: Formatting. + (show_line): Reset prev_line when function name changes. + +2017-09-27 Nick Clifton + + PR 22219 + * dwarf.c (process_debug_info): Add a check for a negative + cu_length field. + +2017-09-27 Alan Modra + + PR 22216 + * readelf.c (process_symbol_table): Check that DT_HASH symbol + chains are only visited once, and report an error if not. Display + invalid symbol index if chain is out of range. Use the same logic + when calculating histograms rather than the PR 17531 fix. Delete + bogus check that chained index is less than number of buckets. + +2017-09-26 Nick Clifton + + PR 22154 + * dwarf.c (get_line_filename_and_dirname): Add extra checks for + buffer overruns. + +2017-09-26 Nick Clifton + + * README-how-to-make-a-release: New file. + +2017-09-26 Alan Modra + + PR 21732 + * dwarf.c (READ_ULEB): Don't use DWARF_VMA_FMT in translated string. + (READ_SLEB): Likewise. + * readelf.c (bfd_vmatoa): New function. + (get_data, get_dynamic_data): Use it for printing error messages. + +2017-09-25 H.J. Lu + + PR binutils/22203 + * nm.c (display_rel_file): Free memory returned from + bfd_get_synthetic_symtab. + +2017-09-22 Alexandre Oliva + + * dwarf.h (debug_info): Add loc_views and num_loc_views. + * dwarf.c (vm1): New constant. + (print_dwarf_view): New function. + (read_and_display_attr_value): Support DW_AT_GNU_locviews. + (process_debug_info): Keep num_loc_offsets and num_loc_views + in sync. + (display_view_pair_list): New function. + (display_loc_list_dwo): Take vstart_ptr; update it. Dump + location view pairs before the range they apply to, when a + viewlist augments the loc list. + (display_loc_list): Likewise. Check view numbers in range + tests. + (display_loclists_list): Likewise. Handle view pair entries, + and warn on trailing ones. + (loc_views): New variable. + (loc_offsets_compar): Compare loc_views if loc_offsets are the + same. + (display_debug_loc): Check and sort loc_views too. Accept + loc_view as expected_start. Skip if lists and views are the + same. Dump locview list separately in order, and pass the + locview list base to each list dump function. Warn and skip + overlap and hole checking if we find loclists and locviews to + not be adjacent. + * testsuite/binutils-all/locview-1.s: New. + * testsuite/binutils-all/readelf.locview-1: New. + * testsuite/binutils-all/locview-2.s: New. + * testsuite/binutils-all/readelf.locview-2: New. + * testsuite/binutils-all/readelf.exp: Run new tests. Fix + option spelling in pr18374 fail message. XFAIL dw5 test on + nds32*-elf. + +2017-09-22 Alan Modra + + * testsuite/binutils-all/readelf.exp: Don't perror and exit on + bintest.s assembly failure. Report tests unresolved instead. + Likewise for version note test, pr18374, decompress, and dw5 + tests. + (readelf_test): Set testname to include both option and binary + file name. Use for pass/fail. + +2017-09-21 Maciej W. Rozycki + + * readelf.c (get_machine_flags) : New case. + +2017-09-05 Nick Clifton + + PR 21995 + * readelf.c (process_mips_specific): Add checks for a NULL data + pointer. + +2017-09-05 Alexander Fedotov + Edmar Wienskoski + + PR 21994 + * readelf.c (process_version_sections ): Check + vd_aux and vda_next for sanity. Delete "end". Correct overflow + checks. + (process_version_sections ): Correct overflow + check. Don't report invalid vna_next on overflow. Do report + invalid vna_next on size less than aux info. + +2017-08-23 Alan Modra + + PR 21990 + * readelf.c (process_version_sections ): Check + for invalid vn_next field before adding to idx. Use unsigned + long for index vars. Move index checks. + : Likewise for vd_next. + +2017-08-17 Nick Clifton + + * testsuite/binutils-all/note-3-64.s: New test. Checks assembly + and decoding of version2 GNU build attribute notes. + * testsuite/binutils-all/note-3-32.s: New test. 32-bit version of + the above test. + * testsuite/binutils-all/note-3-64.d: New test driver. + * testsuite/binutils-all/note-3-32.d: New test driver. + * testsuite/binutils-all/objcopy.exp: Run the new test. + * readelf.c (is_64bit_abs_reloc): Add R_SPARC_64. + +2017-08-14 Gustavo Romero + + * readelf.c (get_note_type): Handle PPC note types available + since Linux 4.8. + +2017-08-12 Alan Modra + + * readelf.c (process_note): Qualify NT_GNU_BUILD_ATTRIBUTE notes + by name data. + +2017-08-08 Nick Clifton + + PR 21909 + * prdbg.c (pr_int_type): Increase size of local string buffer. + (pr_float_type): Likewise. + (pr_bool_type): Likewise. + +2017-08-02 Nick Clifton + + PR 21702 + * arsup.c (ar_addmod): Add plugin support for the MRI ADDMOD + command. + +2017-08-02 Nick Clifton + + * testsuite/binutils-all/objdump.exp (cpus_expected): Add am33-2. + +2017-08-02 Alan Modra + + * readelf.c (is_32bit_abs_reloc): Add R_IA64_SECREL32MSB and + R_IA64_DIR32MSB. + (is_64bit_abs_reloc): Add R_IA64_DIR64MSB. + (is_64bit_pcrel_reloc): Add R_IA64_PCREL64MSB. + +2017-08-01 Nick Clifton + + * po/sv.po: Updated Swedish translation. + +2017-07-31 Marty Plummer + + PR 21861 + * winduni.c (codepages): Use cp1252 for codepage 0. + +2017-07-25 Nick Clifton + + PR 21820 + * readelf.c (dump_section_as_strings): Do not fail if the section + was empty. + (dump_section_as_bytes): Likewise. + +2017-07-24 Nick Clifton + + PR 21813 + * rddbg.c (read_symbol_stabs_debugging_info): Check for an empty + string whilst concatenating symbol names. + +2017-07-21 Nick Clifton + + * po/fr.po: Updated French translation. + +2017-07-21 Simon Marchi + + * dwarf.c (last_pointer_size, warned_about_missing_comp_units): + Remove. + (load_debug_info): Remove assignments to those two variables. + +2017-07-21 Alexandre Oliva + + * dwarf.c (struct State_Machine_Registers): Add view field. + (reset_state_machine): Reset view. + (process_extended_line_op): Reset view when appropriate. + (display_debug_lines_raw): Increment or reset view when appropriate. + Print nonzero views. Support print view resets, disabled by default. + (display_debug_lines_decoded): Likewise. Disambiguate op_code tests, + enabling printing of end_sequence. + * testsuite/binutils-all/dw2-1.W: Add nonzero views. + * testsuite/binutils-all/dw2-3.W: Likewise. + * testsuite/binutils-all/dw2-3gabi.W: Likewise. + * testsuite/binutils-all/dw5.W: Add end sequence lines. + * testsuite/binutils-all/i386/compressed-1a.d: Add nonzero views. + * testsuite/binutils-all/libdw2-compressedgabi.out: Likewise. + * testsuite/binutils-all/objdump.W: Likewise. + * testsuite/binutils-all/objdump.WL: Add end sequence lines. + * testsuite/binutils-all/x86-64/compressed-1a.d: Add nonzero views. + +2017-07-19 Tristan Gingold + + * nm.c (show_stats): Remove variable. + (long_options): Remove --stats option. + (main): Remove handling of --stats. + +2017-07-18 Nick Clifton + + PR 21775 + * coffgrok.c: Fix spelling typos. + * readelf.c: Likewise. + * stabs.c: Likewise. + * testsuite/binutils-all/objcopy.exp: Likewise. + +2017-07-18 Nick Clifton + + * po/sv.po: Updated Swedish translation. + +2017-07-18 Hans-Peter Nilsson + + * dwarf.c (display_debug_names): Initialize hash_prev. + +2017-07-17 Nick Clifton + + PR 21433 + * ar.c (main): Skip check for no files on the command line when + running in MRI mode. + +2017-07-13 H.J. Lu + + * testsuite/binutils-all/objdump.exp: Always delete $testarchive + first. + +2017-07-12 Alan Modra + + * po/bg.po: Update from translationproject.org/latest/binutils/. + * po/ca.po: Likewise. + * po/da.po: Likewise. + * po/es.po: Likewise. + * po/fi.po: Likewise. + * po/fr.po: Likewise. + * po/hr.po: Likewise. + * po/id.po: Likewise. + * po/it.po: Likewise. + * po/ja.po: Likewise. + * po/ro.po: Likewise. + * po/ru.po: Likewise. + * po/sk.po: Likewise. + * po/sr.po: Likewise. + * po/sv.po: Likewise. + * po/tr.po: Likewise. + * po/uk.po: Likewise. + * po/vi.po: Likewise. + * po/zh_CN.po: Likewise. + * po/zh_TW.po: Likewise. + +2017-07-12 Nick Clifton + + Fix compile time warnings using gcc 7.1.1. + * dwarf.c (dwarf_vmatoa_1): Do not pass a NULL string pointer to + sprintf. + * srconv.c (walk_tree_type): Initialise the spare field of the + IT_dty structure. + +2017-07-11 Andreas Schwab + + * readelf.c (process_note): Print newline after description data + in narrow mode. + (print_core_note): Print newline if nothing was printed in wide + mode. + +2017-07-09 Rafael Fontenelle + + * dwarf.c (display_formatted_table): Fix error message typo. + +2017-07-07 John Baldwin + + * readelf.c (get_freebsd_elfcore_note_type): Handle + NT_FREEBSD_PTLWPINFO. + +2017-07-05 H.J. Lu + + * dwarf.c (display_debug_names): Replace index with xindex. + +2017-07-04 Tristan Gingold + + * configure: Regenerate. + +2017-07-04 Tristan Gingold + + * NEWS: Add marker for 2.29. + +2017-07-03 Tristan Gingold + + * po/binutils.pot: Regenerate. + +2017-07-03 Alan Modra + + * strings.c (filename_and_size_t): Delete. + (strings_a_section): Don't check section size against file size. + Use bdf_malloc_and_get_section. Report an error on failures. + Replace arg param with filename and got_a_section param. + (got_a_section): Move to.. + (strings_object_file): ..an auto var here. Iterate over sections + rather than calling bfd_map_over_sections. Adjust strings_a_section + call. + +2017-07-02 Jan Kratochvil + + * dwarf.c: Include assert.h. + (MAX, MIN, get_IDX_name, display_debug_names): New. + (debug_displays): Add .debug_names. + * dwarf.h: (enum dwarf_section_display_enum): Add debug_names. + * readelf.c (process_section_headers): Add ".debug_names". + +2017-07-01 Alan Modra + + PR binutils/21665 + * objdump.c (strtab): Make var a bfd_byte*. + (disassemble_section): Don't limit malloc size. Instead, use + bfd_malloc_and_get_section. + (read_section_stabs): Use bfd_malloc_and_get_section. Return + bfd_byte*. + (find_stabs_section): Remove now unnecessary cast. + * objcopy.c (copy_object): Use bfd_malloc_and_get_section. Free + contents on error return. + * nlmconv.c (copy_sections): Use bfd_malloc_and_get_section. + +2017-06-30 Nick Clifton + + PR binutils/21665 + * objdump.c (disassemble_section): Move check for an overlarge + section to just before the allocation of memory. Do not check + section size against file size, but instead use an arbitrary 2Gb + limit. Issue a warning message if the section is too big. + +2017-06-30 Maciej W. Rozycki + + * NEWS: Mention microMIPS XPA support. + +2017-06-30 Maciej W. Rozycki + + * NEWS: Mention microMIPS Release 5 ISA support. + +2017-06-30 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips-xpa-virt-1.d: New test. + * testsuite/binutils-all/mips/mips-xpa-virt-2.d: New test. + * testsuite/binutils-all/mips/mips-xpa-virt-3.d: New test. + * testsuite/binutils-all/mips/mips-xpa-virt-4.d: New test. + * testsuite/binutils-all/mips/mips-xpa-virt.s: New test source. + * testsuite/binutils-all/mips/mips.exp: Run the new tests. + +2017-06-29 Anton Kolesov + + * testsuite/binutils-all/arc/double_store.s: New file. + * testsuite/binutils-all/arc/objdump.exp: Tests for disassembler + options. + (do_objfile): New function. + (check_assembly): Likewise. + +2017-06-29 Andreas Arnez + + * readelf.c (get_note_type): Add NT_S390_GS_CB and NT_S390_GS_BC. + +2017-06-28 H.J. Lu + + * objdump.c (dump_relocs_in_section): Cast to ufile_ptr when + comparing against bfd_get_file_size return. + +2017-06-28 Nick Clifton + + * objcopy.c (merge_gnu_build_notes): Add support for version 2 notes. + * readelf.c (print_gnu_build_attribute_name): Likewise. + +2017-06-28 Maciej W. Rozycki + Matthew Fortune + + * readelf.c (get_machine_flags) : New case. + (print_mips_isa_ext) : Likewise. + * NEWS: Mention Imagination interAptiv MR2 processor support. + +2017-06-26 Nick Clifton + + PR binutils/21665 + * objdump.c (disassemble_section): Skip any section that is bigger + than the entire file. + +2017-06-26 Nick Clifton + + PR binutils/21659 + * bucomm.c (get_file_size): Explicitly warn if the file is a + directory. + +2017-06-24 Thomas Preud'homme + + * readelf.c (arm_attr_tag_CPU_arch): Fill value for ARMv8-R. + +2017-06-23 Nick Clifton + + PR binutils/21659 + * strings.c (strings_file): Warn about attempts to run strings on + a directory. + +2017-06-22 H.J. Lu + + * readelf.c (decode_x86_feature): Decode + GNU_PROPERTY_X86_FEATURE_1_SHSTK. + * testsuite/binutils-all/i386/shstk.d: New file. + * testsuite/binutils-all/i386/shstk.s: Likewise. + * testsuite/binutils-all/x86-64/shstk-x32.d: Likewise. + * testsuite/binutils-all/x86-64/shstk.d: Likewise. + * testsuite/binutils-all/x86-64/shstk.s: Likewise. + +2017-06-22 H.J. Lu + + * readelf.c (decode_x86_feature): New. + (print_gnu_property_note): Call decode_x86_feature on + GNU_PROPERTY_X86_FEATURE_1_AND. + * testsuite/binutils-all/i386/empty.d: New file. + * testsuite/binutils-all/i386/empty.s: Likewise. + * testsuite/binutils-all/i386/ibt.d: Likewise. + * testsuite/binutils-all/i386/ibt.s: Likewise. + * testsuite/binutils-all/x86-64/empty-x32.d: Likewise. + * testsuite/binutils-all/x86-64/empty.d: Likewise. + * testsuite/binutils-all/x86-64/empty.s: Likewise. + * testsuite/binutils-all/x86-64/ibt-x32.d: Likewise. + * testsuite/binutils-all/x86-64/ibt.d: Likewise. + * testsuite/binutils-all/x86-64/ibt.s: Likewise. + +2017-06-21 H.J. Lu + + * dwarf.c (READ_ULEB): Use DWARF_VMA_FMT to report error. + (READ_SLEB): Likewise. + +2017-06-21 Nick Clifton + + PR binutils/21648 + * dwarf.c (LEB): Rename to SKIP_ULEB and READ_ULEB. Add check for + reading a value that is too big for the containing variable. + (SLEB): Rename to SKIP_SLEB and READ_SLEB. Add similar check. + Replace uses of LEB and SLEB with appropriate new macro. + (display_debug_frames): Use an unsigned int for the 'reg' + variable. Use a signed long for the 'l' variable. + +2017-06-20 Andreas Krebbel + + * readelf.c (get_s390_segment_type): Add support for the new + segment type PT_S390_PGSTE. + (get_segment_type): Call get_s390_segment_type. + +2017-06-19 Nick Clifton + + PR binutils/21619 + * objdump.c (disassemble_bytes): Check that there is sufficient + data available before attempting to display it. + +2017-06-06 Simon Marchi + + * sysinfo.y: Free memory allocated by token NAME. + +2017-05-30 Anton Kolesov + + * doc/binutils.texi: Document new cpu=... disassembler options for ARC. + +2017-05-30 H.J. Lu + + PR binutils/21519 + * objdump.c (dump_relocs_in_section): Replace get_file_size + with bfd_get_file_size to get archive element size. + * testsuite/binutils-all/objdump.exp (test_objdump_f): New + proc. + (test_objdump_h): Likewise. + (test_objdump_t): Likewise. + (test_objdump_r): Likewise. + (test_objdump_s): Likewise. + Add objdump tests on archive. + +2017-05-24 Yao Qi + + * objdump.c (disassemble_data): Caller update. + +2017-05-19 Jose E. Marchesi + + * objcopy.c (merge_gnu_build_notes): Remove workaround that + prevented deleting relocations in duplicated notes in mips64 and + sparc. + +2017-05-19 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips-note-2.d: New test. + * testsuite/binutils-all/mips/mips-note-2r.d: New test. + * testsuite/binutils-all/mips/mips-note-2-n32.d: New test. + * testsuite/binutils-all/mips/mips-note-2-n64.d: New test. + * testsuite/binutils-all/mips/mips-note-2r-n32.d: New test. + * testsuite/binutils-all/mips/mips-note-2r-n64.d: New test. + * testsuite/binutils-all/mips/mips.exp: Define `has_newabi'. + Run the new tests. + +2017-05-19 Maciej W. Rozycki + + * testsuite/lib/utils-lib.exp (run_dump_test): Handle the `dump' + option. + +2017-05-19 Jose E. Marchesi + + * NEWS: Mention the SPARC M8 support. + +2017-05-19 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips.exp: Bail out right away if + non-ELF. + +2017-05-18 Alan Modra + + * strings.c: Don't compare boolean values against TRUE or FALSE. + +2017-05-15 Jeff Law + + * readelf.c (display_arc_attribute): Avoid implicit fallthru. + +2017-05-15 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips16-undecoded.d: Add `-mips3' + to `as' flags. + * testsuite/binutils-all/mips/mips16e2-undecoded.d: New test. + * testsuite/binutils-all/mips/mips16e2-extend-insn.d: New test. + * testsuite/binutils-all/mips/mips16-undecoded.s: Remove + `.module mips3'. + * testsuite/binutils-all/mips/mips.exp: Run the new tests. + +2017-05-15 Maciej W. Rozycki + + * readelf.c (print_mips_ases): Handle MIPS16e2 ASE. + * NEWS: Mention MIPS16e2 ASE support. + +2017-05-12 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips16-extend-insn.d: Adjust BREAK + and SDBBP disassembly. + +2017-05-10 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips.exp: Define `tempfile' and + `copyfile' variables. + +2017-05-10 Claudiu Zissulescu + + * readelf.c (decode_ARC_machine_flags): Recognize OSABI v4. + (get_arc_section_type_name): New function. + (get_section_type_name): Use the above function. + (display_arc_attribute): New function. + (process_arc_specific): Likewise. + (process_arch_specific): Handle ARC specific information. + +2017-05-09 Kaz Kojima + + * MAINTAINERS (SH): Remove myself as SH maintainer. + +2017-05-02 H.J. Lu + + * objcopy.c (merge_gnu_build_notes): Cast relcount to unsigned + long when comparing with sec->reloc_count. + +2017-05-02 Nick Clifton + + * objcopy.c (merge_gnu_build_notes): Disable merge if there are + more internal relocs than external relocs. + +2017-05-02 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips16-undecoded.d: Adjust the + disassembly of PC-relative LA and LW synthetic instructions. + +2017-05-02 Nick Clifton + + PR 21440 + * objdump.c (dump_relocs_in_section): Check for an excessive + number of relocs before attempting to dump them. + +2017-05-01 Alan Modra + + * objcopy.c (merge_gnu_build_notes): Correct code deleting + relocs. + +2017-04-28 Nick Clifton + + PR binutils/21439 + * readelf.c (print_gnu_build_attribute_name): Allow for an empty + name field. + +2017-04-28 Nick Clifton + + PR binutils/21437 + * readelf.c (process_version_sections): Check for underflow when + computing the start address of the auxillary version data. + +2017-04-28 Nick Clifton + + PR binutils/21438 + * dwarf.c (process_extended_line_op): Do not assume that the + string extracted from the section is NUL terminated. + (fetch_indirect_string): If the string retrieved from the section + is not NUL terminated, return an error message. + (fetch_indirect_line_string): Likewise. + (fetch_indexed_string): Likewise. + +2017-04-26 Nick Clifton + + PR binutils/21433 + * bucomm.c (get_file_size): Return -1 if file_name is NULL. + * ar.c (main): Fail with usage() invocation if no file names are + provided. + +2017-04-26 Nick Clifton + + * readelf.c (process_section_headers): Warn about overlarge + sections. + (print_gnu_build_attribute_name): Print the number of unrecognised + note types. Fix formatting in the presence of errors. + (testsuite/binutils-all/note-2-32.s): Fix encoding of numeric notes. + (testsuite/binutils-all/note-2-64.s): Likewise. + +2017-04-26 Maciej W. Rozycki + + * readelf.c (process_mips_specific): Add static GOT support. + +2017-04-25 Maciej W. Rozycki + + * readelf.c (process_mips_specific): Remove error reporting from + GOT[1] processing. + +2017-04-25 Maciej W. Rozycki + + * readelf.c (process_mips_specific): Remove null GOT data check. + +2017-04-25 Maciej W. Rozycki + + * testsuite/binutils-all/mips/mips16-alias.d: New test. + * testsuite/binutils-all/mips/mips16-noalias.d: New test. + * testsuite/binutils-all/mips/mips16-alias.s: New test source. + * testsuite/binutils-all/mips/mips.exp: Run the new tests. + +2017-04-23 Alan Modra + + PR 21418 + * ar.c (main): Check -a, -b, -i and -N args are given. + +2017-04-23 Alan Modra + + PR 21417 + * ar.c (main): Check that an archive file is given after options. + +2017-04-23 Alan Modra + + PR 21415 + * objdump.c (disassemble_section): Check bfd_get_section_contents + status. + +2017-04-23 Alan Modra + + PR 21408 + * dwarf.c (display_debug_lines_decoded): Don't segfault on NULL + file_table. + +2017-04-21 Nick Clifton + + PR binutils/21378 + * readelf.c (print_gnu_build_attribute_name): Check for an + overlarge name field. + +2017-04-13 Nick Clifton + + PR binutils/21379 + * readelf.c (process_dynamic_section): Detect over large section + offsets in the DT_SYMTAB entry. + +2017-04-13 Nick Clifton + + PR binutils/21345 + * readelf.c (process_mips_specific): Catch an unfeasible memory + allocation before it happens and print a suitable error message. + +2017-04-13 Nick Clifton + + * objcopy.c: Add --no-merge-notes option to disable note merging. + Add --[no-]merge-notes option to strip, and enable it by default. + (num_bytes): New function. + (merge_gnu_build_notes): Add code to merge stack size notes. + * binutils.texi: Update strip and objcopy documentation. + * readelf.c (print_gnu_build_attribute_name): Use defined + constants for note types. + +2017-04-10 John Delsignor + + PR binutils/21319 + * dwarf.c (display_gdb_index): Correct test for a corrupt address + table size. + +2017-04-05 Jiong Wang + + * objcopy.c (struct redefine_node): Delete the field "next". + (redefine_sym_list): Deleted. + (redefine_specific_htab): New hash table. + (redefine_specific_reverse_htab): Likewise. + (eq_string_redefnode): New function. + (htab_hash_redefnode): Likewise. + (create_symbol2redef_htab): Likewise. + (add_specific_symbol_node): Likewise. + (create_symbol_htabs): Create redefine_specific_htab and + redefine_specific_reverse_htab. + (lookup_sym_redefinition): Use hash table instead of list. + (redefine_list_append): Likewise, and rename to add_redefine_and_check. + (copy_main): Use redefine_specific_htab instead of redefine_sym_list. + Update comments. + +2017-04-04 H.J. Lu + + * NEWS: Mention support for ELF SHF_GNU_MBIND and + PT_GNU_MBIND_XXX. + * readelf.c (get_segment_type): Handle PT_GNU_MBIND_XXX. + (get_elf_section_flags): Handle SHF_GNU_MBIND. + (process_section_headers): Likewise. + * testsuite/binutils-all/mbind1.s: New file. + * testsuite/binutils-all/objcopy.exp: Run readelf test on + mbind1.s. + +2017-04-03 Nick Clifton + + PR binutils/21345 + * readelf.c (get_program_headers): Check for there being too many + program headers before attempting to allocate space for them. + +2017-04-03 Nick Clifton + + PR binutils/21344 + * readelf.c (process_mips_specific): Check for an out of range GOT + entry before reading the module pointer. + +2017-04-03 Nick Clifton + + PR binutils/21343 + * readelf.c (get_unwind_section_word): Fix snafu checking for + invalid word offsets in ARM unwind information. + +2017-03-31 Pip Cet + + * NEWS: Use "WebAssembly" consistently. + * testsuite/binutils-all/wasm32/wasm32.exp: Fix copyright notice. + +2017-03-30 Pip Cet + + * readelf.c: Add support for wasm32 ELF format WebAssembly files. + (guess_is_rela): Likewise. + (dump_relocations): Likewise. + (is_32bit_abs_reloc): Likewise. + (is_none_reloc_): Likewise. + * NEWS: Mention the new support. + * testsuite/lib/binutils-common.exp (is_elf_format): Mark wasm32 + as ELF target. + (supports_gnu_unique): Mark wasm32 as supporting STB_GNU_UNIQUE. + * testsuite/binutils-all/nm.exp: Mark wasm32 as requiring .size annotations. + * testsuite/binutils-all/wasm32: New directory. + * testsuite/binutils-all/wasm32/create-wasm.d: New file. + * testsuite/binutils-all/wasm32/create-wasm.s: Likewise. + * testsuite/binutils-all/wasm32/custom-section.d: Likewise. + * testsuite/binutils-all/wasm32/custom-section.s: Likewise. + * testsuite/binutils-all/wasm32/invalid-wasm-1.d: Likewise. + * testsuite/binutils-all/wasm32/invalid-wasm-1.s: Likewise. + * testsuite/binutils-all/wasm32/long-sections.d: Likewise. + * testsuite/binutils-all/wasm32/long-sections.s: Likewise. + * testsuite/binutils-all/wasm32/parse-wasm.d: Likewise. + * testsuite/binutils-all/wasm32/parse-wasm.s: Likewise. + * testsuite/binutils-all/wasm32/parse-wasm-2.d: Likewise. + * testsuite/binutils-all/wasm32/parse-wasm-2.s: Likewise. + * testsuite/binutils-all/wasm32/prepared-section.d: Likewise. + * testsuite/binutils-all/wasm32/prepared-section.s: Likewise. + * testsuite/binutils-all/wasm32/wasm32.exp: New file, run tests. + +2017-03-29 Alan Modra + + * doc/binutils.texi (objdump): Document PowerPC -M options. + +2017-03-21 Andi Kleen + + * objdump.c (unwind_inlines): Add. + (option_values): Add OPTION_INLINES. + (show_line): Unwind inlines if requested. + (main): Parse OPTION_INLINES. + (usage): Document --inlines. + * doc/binutils.texi: Document --inlines. + * NEWS: Likewise. + +2017-03-21 Nick Clifton + + * readelf.c (print_gnu_build_attribute_name): Allow stack + protection notes to contain numeric values. Use a colon rather + than a space to separate a string name from its values. Decode + the numeric value of a stack protection note. + * objcopy.c (merge_gnu_build_notes): Allow version notes to + contain extra text after the protocol version number. + +2017-03-20 Mark Wielaard + + * readelf.c (process_program_headers): Move dynamic_addr check + after .dynamic section cross check. + +2017-03-17 Nick Clifton + + * readelf.c (print_gnu_build_attribute_name): Fix off by one error + printing the value for a build note with an ascii name. + +2017-03-16 Nick Clifton + + * readelf.c (print_gnu_build_attribute_name): Add support for + GNU_BUILD_ATTRIBUTE_SHORT_ENUM. + +2017-03-14 Nick Clifton + + * readelf.c (print_gnu_build_attribute_description): Move symbol + printing code to... + (print_symbol_for_build_attribute): New function. ...here. + Add to find the best symbol to associate with an OPEN note. + Add code to cache the symbol table and string table, so that they + are not loaded every time a note is displayed. + * testsuite/binutils-all/note-2-32.s: Add a function symbol. + * testsuite/binutils-all/note-2-64.s: Likewise. + * testsuite/binutils-all/note-2-32.d: Update expected note output. + * testsuite/binutils-all/note-2-64.d: Likewise. + +2017-03-13 Alan Modra + Taeung Song + + * objdump.c (update_source_path): Add abfd param. Add struct + stat var. Pass to try_print_file_open. Warn if source is more + recent than object. + (try_print_file_open, slurp_file): Add struct stat param to + return fstat. + (show_line): Call update_source_path with bfd. + +2017-03-10 Chia-Hao Lo + + PR binutils/21235 + * objdump.c (main): Set do_wide with --wide. + +2017-03-10 Nick Clifton + + * readelf.c (get_machine_name): Rearrange switch table in order of + increasing machine number. Add missing entries. + +2017-03-08 H.J. Lu + + PR binutils/21231 + * readelf.c (decode_x86_isa): Change argument to unsigned int. + (print_gnu_property_note): Retrieve property type and datasz as + 4-byte integer. Consolidate property datasz check. Check + GNU_PROPERTY_LOPROC and GNU_PROPERTY_LOUSER. + * testsuite/binutils-all/i386/pr21231a.d: New file. + * testsuite/binutils-all/i386/pr21231a.s: Likewise. + * testsuite/binutils-all/i386/pr21231b.d: Likewise. + * testsuite/binutils-all/i386/pr21231b.s: Likewise. + * testsuite/binutils-all/x86-64/pr21231a.d: Likewise. + * testsuite/binutils-all/x86-64/pr21231a.s: Likewise. + * testsuite/binutils-all/x86-64/pr21231b.d: Likewise. + * testsuite/binutils-all/x86-64/pr21231b.s: Likewise. + +2017-03-06 Nick Clifton + + * readelf.c (print_gnu_build_attribute_name): Read byte values + from the name string as unsigned bytes. + (process_notes_at): Use memcpy to copy an unterminated name + string. + +2017-03-06 Sam Thursfield + + * configure.ac (AC_CHECK_DECLS): Add asprintf. + * config.in: Regenerate. + * configure: Regenerate. + +2017-03-02 Nick Clifton + + * readelf.c (print_gnu_build_attribute_description): Use global + symbols for OPEN attributes if at all possible. + * objcopy.c (is_merged_note_section): Support build note sections + without the SHF_GNU_BUILD_NOTE section flag set. + +2017-03-02 Jan Kratochvil + + * dwarf.c (debug_displays_assert): New static assertion. + +2017-03-02 Jan Kratochvil + + * dwarf.h (enum dwarf_section_display_enum): Add loclists and rnglists. + +2017-03-01 Nick Clifton + + * readelf.c (get_note_type): Add support for GNU_BUILD_NOTEs. + (get_gnu_elf_note_type): Add support for GNU_PROPERTY_NOTEs. + (decode_x86_isa): New function. + (print_gnu_property_note): New function. + (print_gnu_note): Handle GNU_PROPERTY_NOTEs. + (print_gnu_build_attribute_description): New function. + (print_gnu_build_attribute_name): New function. + (process_note): Add support for GNU_BUILD_NOTEs. + * objcopy.c (--merge-notes): New command line option. + (copy_options): Add merge-notes. + (copy_usage): Likewise. + (is_merge_note_section): New function. + (merge_gnu_build_notes): New function. + (copy_object): Merge note sections if asked to do so. + (skip_section): Add skip_copy parameter. Add support for skipping + merged note sections. + (copy_relocations_in_section): Update call to skip_section. + (copy_section): Likewise. + (copy_main): Add support for merge-notes option. + * doc/binutils.texi: Document the new option to objcopy. + * NEWS: Mention the new feature. + * testsuite/binutils-all/note-2-32.d: New test. Checks note + merging on 32-bit targets. + * testsuite/binutils-all/note-2-32.s: New test source file. + * testsuite/binutils-all/note-2-64.d: New test. Like note-2-32.d + but for 64-bit targets. + * testsuite/binutils-all/note-2-64.s: New test source file. + * testsuite/binutils-all/objcopy.exp: Run the new test. + +2017-02-28 Peter Bergner + + * objdump.c (main): Use remove_whitespace_and_extra_commas. + +2017-02-27 Jan Kratochvil + + Fix compilation with GCC 4.4.7. + * dwarf.c (display_loclists_list, display_debug_rnglists_list): + Initialize begin and end. + +2017-02-25 Alan Modra + + * testsuite/binutils-all/dw5.S: Replace .string with .asciz. + Support hpux .comm variant. + * testsuite/binutils-all/readelf.exp: Define HPUX when assembling + dw5 test for hppa64-hpux. + +2017-02-24 Nick Clifton + + * readelf.c (show_name, do_dynamic, do_syms, do_dyn_syms, + (do_reloc, do_sections, do_section_groups, do_section_details, + (do_segments, do_unwind, do_using_dynamic, do_header, do_dump, + (do_version, do_histogram, do_debugging, do_arch, do_notes, + (do_archive_index, is_32bit_elf, decompress_dumps): Use + bfd_boolean type. + (parse_args): Treat the do_* variables as booleans. + (print_vma): Return an unsigned int. + (print_symbol): Change width parameter to signed int. + (is_ia64_vms): Change return type to bfd_boolean. + (guess_is_rela): Likewise. + (slurp_rela_relocs): Likewise. + (slurp_rel_relocs): Likewise. + (dump_relocations): Likewise. + (process_file_header): Likewise. + (get_program_headers): Likewise. + (process_program_headers): Likewise. + (process_section_headers): Likewise. + (process_section_groups): Likewise. + (dump_ia64_vms_dynamic_fixups): Likewise. + (dump_ia64_vms_dynamic_relocs): Likewise. + (process_ia64_vms_dynamic_relocs): Likewise. + (process_relocs): Likewise. + (dump_ia64_unwind): Likewise. + (ia64_process_unwind): Likewise. + (dump_hppa_unwind): Likewise. + (slurp_hppa_unwind_table): Likewise. + (hppa_process_unwind): Likewise. + (decode_arm_unwind_bytecode): Likewise. + (decode_tic6x_unwind_bytecode): Likewise. + (decode_arm_unwind): Likewise. + (dump_arm_unwind): Likewise. + (arm_process_unwind): Likewise. + (process_unwind): Likewise. + (get_32bit_dynamic_section): Likewise. + (get_64bit_dynamic_section): Likewise. + (process_dynamic_section): Likewise. + (process_version_sections): Likewise. + (process_symbol_table): Likewise. + (process_syminfo): Likewise. + (apply_relocations): Likewise. + (disassemble_section): Likewise. + (dump_section_as_strings): Likewise. + (dump_section_as_bytes): Likewise. + (load_specific_debug_section): Likewise. + (load_debug_section): Likewise. + (display_debug_section): Likewise. + (process_section_contents): Likewise. + (process_attributes): Likewise. + (process_nds32_specific): Likewise. + (process_gnu_liblist): Likewise. + (print_core_note): Likewise. + (print_gnu_note): Likewise. + (print_v850_note): Likewise. + (process_netbsd_elf_note): Likewise. + (print_stapsdt_note): Likewise. + (print_ia64_vms_note): Likewise. + (process_note): Likewise. + (process_notes_at): Likewise. + (process_corefile_note_segments): Likewise. + (process_v850_notes): Likewise. + (process_note_sections): Likewise. + (process_notes): Likewise. + (process_arch_specific): Likewise. + (get_file_header): Likewise. + (process_object): Likewise. + (process_archive): Likewise. + (process_file): Likewise. + (section_subset): Make static. + (get_mips_reg_size): Return a signed integer. + (process_object): Reverse the logic of the return value. + (process_archive): Likewise. + (process_file): Likewise. + (process_program_headers): Fix snafu - if the program headers are + not available then this is not a cause to fail. + (process_corefile_note_segments): Likewise. + +2017-02-24 Maciej W. Rozycki + + * readelf.c (get_ver_flags): Tidy the formatting of the string + returned + +2017-02-24 Maciej W. Rozycki + + * readelf.c (process_version_sections) : Make + `isum' unsigned. + : Likewise. + +2017-02-24 Maciej W. Rozycki + + * readelf.c (process_version_sections) : Limit + the number of entries processed by the section size. Don't + break out of the loop if `ent.vd_next' is 0. + +2017-02-23 Jan Kratochvil + + * testsuite/binutils-all/dw5.S: New file. + * testsuite/binutils-all/dw5.W: New file. + * testsuite/binutils-all/readelf.exp (readelf -wiaoRlL): New test. + +2017-02-23 Jan Kratochvil + + * dwarf.c (read_and_display_attr_value): Support DW_FORM_data16. + +2017-02-23 Jan Kratochvil + + * dwarf.c (display_debug_macro): Support DWARF-5. Rename + DW_MACRO_GNU_*. + +2017-02-23 Jan Kratochvil + + * dwarf.c (decode_location_expression): Support DW_OP_implicit_pointer, + DW_OP_const_type, DW_OP_regval_type, DW_OP_deref_type, DW_OP_convert + and DW_OP_reinterpret. + (read_and_display_attr_value): Support DW_AT_call_value, + DW_AT_call_data_value, DW_AT_call_target and + DW_AT_call_target_clobbered. + +2017-02-23 Jan Kratochvil + + * dwarf.c (fetch_indirect_line_string): New function. + (abbrev_attr): New field implicit_const. + (add_abbrev_attr): New parameter implicit_const. + (process_abbrev_section): Support DW_FORM_implicit_const. + (decode_location_expression): Support DW_OP_entry_value. + (read_and_display_attr_value): Add parameter implicit_const. Support + DW_FORM_line_strp and DW_FORM_implicit_const. + (read_and_display_attr): Add parameter implicit_const. + (process_debug_info): Support line_str and DWARF-5. + (read_debug_line_header): Support DWARF-5. + (display_formatted_table): New function. + (display_debug_lines_raw): New parameter file. Support DWARF-5. + (display_debug_lines_decoded): New parameter fileptr. Support DWARF-5. + (display_debug_lines): Pass file parameter. + (display_debug_macro): Update read_and_display_attr_value caller. + (display_debug_abbrev): Support DW_FORM_implicit_const. + (display_loclists_list): New function. + (display_loc_list): Support .debug_loclists. + (display_debug_ranges_list): New function from display_debug_ranges. + (display_debug_rnglists_list): New function. + (display_debug_ranges): Support .debug_rnglists. + (debug_displays): Add .debug_line_str, .debug_loclists and + .debug_rnglists. + * dwarf.h: Include dwarf2.h + (DWARF2_Internal_LineInfo): Add li_offset_size. + (DWARF2_Internal_CompUnit): Add cu_unit_type. + (enum dwarf_section_display_enum): Add line_str. + * readelf.c (process_section_headers): Add rnglists and loclists. + +2017-02-23 Jan Kratochvil + + * dwarf.c (display_block): Add parameter delimiter. + (decode_location_expression): Update display_block callers. + (read_and_display_attr_value): Add parameter delimiter. + (read_and_display_attr, display_debug_macro): Update + read_and_display_attr_value caller. + +2017-02-23 Jan Kratochvil + + * dwarf.c (display_loc_list): Use dwarf_vma for offset, base_address + and off. + (display_loc_list_dwo): Use dwarf_vma for offset. + (display_debug_loc): Use dwarf_vma for offset, base_address. + (struct range_entry, range_entry_compar): Use dwarf_vma for + ranges_offset. + (display_debug_ranges): Use dwarf_vma for ranges_offset, offset and + base_address. + +2017-02-23 Nick Clifton + + * readelf.c (display_tag_value): Use an explicit signed type for + the tag parameter. + (display_gnu_attributes): Use an unsigned integer type for + attribute tags. + (display_power_gnu_attribute): Likewise. + (display_s390_gnu_attribute): Likewise. + (display_sparc_hwcaps): Likewise. + (display_sparc_hwcaps2): Likewise. + (display_sparc_gnu_attribute): Likewise. + (display_mips_gnu_attribute): Likewise. + (display_tic6x_attribute): Likewise. + (display_raw_attribute): Likewise. + (process_attributes): Likewise. + (process_arm_specific): Delete redundant function. + (process_power_specific): Likewise. + (process_s390_specific): Likewise. + (process_sparc_specific): Likewise. + (process_tic6x_specific): Likewise. + (process_msp430x_specific): Likewise. + (display_public_gnu_attributes): New function. Displays known + information about an unknown gnu attribute. + (display_generic_attribute): New function. Calls + display_tag_value for non-nul tags. + (process_arch_specific): Call process_attributes even for + architectures not known to specifically support gnu attributes. + +2017-02-22 Jan Kratochvil + + * dwarf.c (decode_location_expression): Display also OP. + +2017-02-22 Maciej W. Rozycki + + * readelf.c (process_version_sections) : Print a + new line between the heading and the first version definition + entry. + +2017-02-20 Nick Clifton + + PR binutils/21156 + * dwarf.c (cu_tu_indexes_read): Move into... + (load_cu_tu_indexes): ... here. Change the variable into + tri-state. Change the function into boolean, returning + false if the indicies could not be loaded. + (find_cu_tu_set): Return NULL if the indicies could not be + loaded. + +2017-02-17 Nick Clifton + + PR binutils/21156 + * readelf.c (find_section_in_set): Test for invalid section + indicies. + +2017-02-17 Nick Clifton + + * readelf.c (get_section_type_name): Add decoding of GNU section + types. + +2017-02-15 Nick Clifton + + * MAINTAINERS: (MIPS, MN10300): Move Eric Christopher to Past + Maintainers section. + +2017-02-14 Nick Clifton + + PR binutils/21159 + * readelf.c (dump_section_as_strings): Reset the start address if + no decompression is perfromed. + (dump_section_as_bytes): Likewise. + +2017-02-14 Nick Clifton + + PR binutils/21158 + * rddbg.c (read_symbol_stabs_debugging_info): Check for a null or + empty symbol name. + +2017-02-14 Nick Clifton + + PR binutils/21157 + * stabs.c (parse_stab_enum_type): Check for corrupt NAME:VALUE + pairs. + (parse_number): Exit early if passed an empty string. + +2017-02-14 Nick Clifton + + PR binutils/21155 + * readelf.c (IN_RANGE): New macro. Tests for an address + offset + being within a given range. + (target_specific_reloc_handling): Use macro to test for underflow + as well as overflow of reloc offset. + +2017-02-13 Nick Clifton + + PR binutils/21150 + * nm.c (file_symbol): Add test of string length before testing + string characters. + +2017-02-13 Nick Clifton + + PR binutils/21135 + * readelf.c (dump_section_as_bytes): Handle the case where + uncompress_section_contents returns false. + (dump_section_as_bytes, load_specific_debug_section): Likewise. + +2017-02-13 Nick Clifton + + PR binutils/21149 + * readelf.c (get_compression_header): Add size parameter. Check + size against sizeof compression header before attempting to + extract the header. + (process_section_headers): Pass size to get_compression_header. + (dump_section_as_strings): Likewise. + (dump_section_as_bytes): Likewise. + (load_specific_debug_section): Likewise. + +2017-02-13 Nick Clifton + + PR binutils/21148 + * readelf.c (process_version_sections): Include size of auxillary + version information when checking for buffer overflow. + +2017-02-13 Nick Clifton + + PR binutils/21147 + * readelf.c (process_section_contents): Fix off by one error + reporting un-dumped sections. + +2017-02-13 Nick Clifton + + PR binutils/21139 + * readelf.c (target_specific_reloc_handling): Add num_syms + parameter. Check for symbol table overflow before accessing + symbol value. If reloc pointer is NULL, discard all saved state. + (apply_relocations): Pass num_syms to target_specific_reloc_handling. + Call target_specific_reloc_handling with a NULL reloc pointer + after processing all of the relocs. + +2017-02-13 Nick Clifton + + PR binutils/21137 + * readelf.c (target_specific_reloc_handling): Add end parameter. + Check for buffer overflow before writing relocated values. + (apply_relocations): Pass end to target_specific_reloc_handling. + +2017-01-27 Dilyan Palauzov + Nick Clifton + + PR 20343 + * doc/binutils.texi (ar): Extend documentation of the --plugin + option. Include a description of where the plugins should be + located. + (nm): Likewise. + +2017-01-23 Nick Clifton + + * MAINTAINERS: Add Bernd to Past Maintainers section. + (SCORE): Remove Mei Ligang as maintainer. Add to Past Maintainers + section. + +2017-01-23 Bernd Schmidt + + * MAINTAINERS (BFIN): Remove myself as Blackfin maintainer. + +2017-01-20 Andrew Burgess + + * objdump.c (dump_section_header): Extract max section name length + from data parameter, use this when formatting output. + (find_longest_section_name): New function. + (dump_headers): Calculate longest section name when in wide mode, + reformat to unify printing of header line. + +2017-01-18 Bernhard Rosenkranzer + + PR 21059 + * arlex.l: Support processing with flex 2.6.3. + * deflex.l: Likewise. + +2017-01-17 Dmitry Timoshkov + + * resbin.c: Optional dialog control data immediately follows + the control description without alignment. + * testsuite/binutils-all/windres/controldata.rc: New test. + source. + * testsuite/binutils-all/windres/controldata.rsd: New test. + +2017-01-12 Nick Clifton + + PR binutils/20876 + * NEWS: Mention the new feature. + * testsuite/binutils-all/objdump.exp (test_build_id_debuglink): + New proc to test the location of separate debug info files using + the build-id method. + +2017-01-10 Nick Clifton + + PR 21034 + * stabs.c (parse_stab_members): Fix thinko checking for g++ + version 1 stabs information. + +2017-01-09 Nick Clifton + + * objdump.c (display_file): Add new parameter 'last_file'. If + last_file is true, do not call bfd_close at the end of the + function. + (main): Set the value of the last_file parameter when calling + display_file. + +2017-01-09 Alan Modra + + * readelf.c (process_section_headers): Correct .rel.dyn/.rela.dyn + comment. + +2017-01-06 Nick Clifton + + * MAINTAINERS: Move Paul Brook to the Past Maintainers section. + +2017-01-04 Dilan Palauzov + + PR 20958 + * syslex.l (option): Add noyywrap + (yywrap): Delete. + +2017-01-02 Alan Modra + + Update year range in copyright notice of all files. + +For older changes see ChangeLog-2016 + +Copyright (C) 2017 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-9197 b/support/sdbinutils/binutils/ChangeLog-9197 new file mode 100644 index 0000000..883aa5c --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-9197 @@ -0,0 +1,5223 @@ +Mon Dec 29 16:58:05 1997 Ian Lance Taylor + + From Matthew Bellantoni : + * ar.c (get_pos_bfd): Add default_posname parameter. Change all + callers. + (replace_members): Default to replacing in the same position. + +Mon Dec 22 11:27:22 1997 Ian Lance Taylor + + * rclex.l: Don't permit a comma in a STRING. + * rcparse.y (acc_entry): Warn if an inappropriate modifier is used + with a non VIRTKEY. + (acc_event): For a control character, set VIRTKEY, and force the + character to uppercase. + (acc_options): Don't require a comma separator. + +Tue Dec 9 13:25:42 1997 Michael Meissner + + * size.c (size_number): New function to provide size of field. + ({l,r}print_number): For octal and hex fields, print field using + '0' and '0x' suffixes. Do not include following tab. + (sysv_internal_sizer): Size section name, section size, and vma + address fields. + (sysv_internal_printer): Use calculated sizes for the columns. + (print_sysv_format): Size columns before printing. + (print_berkeley_format): Print tabs between numbers now that + {l,r}print_number doesn't. Print fields right justified. + +Mon Dec 8 11:22:04 1997 Nick Clifton + + * objdump.c (objdump_print_addr_with_sym): Remove call to + disasm_symaddr() as this function no longer exists. + +Tue Dec 2 10:23:50 1997 Nick Clifton + + * objdump.c (objdump_print_addr_with_sym): Call disasm_symaddr() + to allow backend to know which symbol has just been displayed. + +Tue Dec 2 13:06:46 1997 Ian Lance Taylor + + * windres.h (ESCAPE_*): Define standard escape sequences. + * rclex.l (handle_quotes): Handle standard escape sequences. Warn + about an unrecognized escape character. + * windres.c (unicode_print): Print standard escape sequences. + * rcparse.y (acc_event): Initialize $$.next. + * resbin.c (bin_to_res_menuitems): Don't set MENUITEM_POPUP or + MENUITEM_ENDMENU in the menu item flags. + (bin_to_res_accelerators): Allocate a structure (the old code + never worked). + (res_to_bin_accelerator): Correct the test for setting ACC_LAST. + (res_to_bin_dialog): Save the extended style rather than saving + the style twice. Remove useless shadowing length variable. Set + the length of control data correctly. + * resrc.c (write_rc_dialog): Don't print the class or menu if the + string length is zero. + +Mon Nov 24 18:52:43 1997 Andreas Schwab + + * stabs.c (parse_stab_argtypes): Don't try to parse the name of a + destructor as mangled argument types. + +Mon Nov 10 17:51:41 1997 Gavin Koch + + * addr2line.c (translate_addresses): Use bfd_scan_vma rather + than strtol to scan addresses. + +Sun Nov 9 11:01:31 1997 Jeffrey A Law (law@cygnus.com) + + * Makefile.am (bin_PROGRAMS): Don't use line continuations here. + +Tue Nov 4 11:56:14 1997 Ian Lance Taylor + + * objcopy.c (copy_section): Don't crash if there is no particular + information for a section. + +Mon Nov 3 12:36:19 1997 Ian Lance Taylor + + * objcopy.c (parse_flags): Make flag check case insensitive. + Check for `contents' flag. Give an error for unrecognized flags. + (copy_section): If the contents flag was set for a section that + had no contents, zero out the new contents. + * binutils.texi (objcopy): Document contents section flag. + +Sun Nov 2 14:49:56 1997 Ian Lance Taylor + + * objcopy.c: Move new struct and variable definitions to top of + file. Remove obsolete add_strip_symbol and is_strip_symbol + declarations. Add prototype declarations for add_specific_symbol + and is_specified_symbol. + +Mon Oct 20 15:31:43 1997 Klaus K"ampf + + * configure.com (HAVE_SBRK): Undefine. + +Tue Oct 14 16:14:35 1997 Nick Clifton + + * objdump.c (objdump_symbol_at_address): New function. Returns + true if a symbol can be found at the address passed in. + (disassemble_data): Set the symbol_at_address_func field to point + to objdump_symbol_at_address. + +Fri Oct 10 14:13:09 1997 Richard Henderson + + * objcopy.c, objcopy.1, binutils.texi: "localize" is a better name + than "privatize". Update all references. + +Thu Oct 9 15:57:29 1997 Ian Lance Taylor + + * binutils.texi (strip): Remove duplicate --target. From Marty + Leisner . + + * nm.c (lineno_cache_bfd): New file static variable. + (lineno_cache_rel_bfd): New file static variable. + (display_archive): Clear lineno_cache_bfd and lineno_cache_rel_bfd + when closing a BFD. + (display_file): Likewise. + (print_symbol): Use lineno_cache_bfd and lineno_cache_rel_bfd + instead of cache_bfd and cache_rel_bfd. Make seccount static, and + only set it when setting relocs. + +Wed Oct 8 21:19:11 1997 Richard Henderson + + * objcopy.c (keep_specific_list, privatize_specific_list, + weaken_specific_list): New variables. + (keep_symbols): Removed. + (add_specific_symbol): New function from the carcas of + add_strip_symbol. Takes a list as an argument. + (is_specified_symbol): Likewise from is_strip_symbol. + (filter_symbols): Honor the new privatize and weaken lists. + Optimize bfd_asymbol_name handling. + (copy_object, copy_options, copy_usage): Add privatize-symbol & + weaken-symbol options. + + * objcopy.1, binutils.texi: Update docs. + +Sun Oct 5 09:05:44 1997 Frank Ch. Eigler + + * objdump.c (disassemble_data): Make "--prefix-addresses" + disassembly adjust to mixed-length instructions. + (objdump_print_addr_with_sym): Add "0x" prefix for hexadecimal + symbol-offsets in disassembly. + +Fri Oct 3 12:04:25 1997 Ian Lance Taylor + + * objcopy.c (set_times): New static function, replacing + make_same_dates. + (strip_main): If preserve_dates, stat the input file before + copying it, and call set_times afterward. + (copy_main): Likewise. + + * wrstabs.c (write_stabs_in_sections_debugging_info): Cast p to + char * when calling strcpy and strlen. + +Wed Sep 24 11:34:05 1997 Ian Lance Taylor + + * binutils.texi (ar cmdline): Document that q now works like r. + From Marty Leisner . + + * binutils.texi (size): The object file argument is optional. + From Marty Leisner . + + * aclocal.m4: Rebuild with new libtool. + * configure: Rebuild. + +Tue Aug 26 17:48:34 1997 Ian Lance Taylor + + * Makefile.am (EXEEXT_FOR_BUILD): New variable. Use it in all + references to the sysinfo program. + * configure.in: Rebuild with new bfd/acinclude.m4. + * Makefile.in: Rebuild. + +Fri Aug 8 15:32:49 1997 Ian Lance Taylor + + * windres.c: Include . + (define_resource): Set a timestamp for the resource. + +Wed Aug 6 13:37:58 1997 Ian Lance Taylor + + * configure.in: Define TARGET in header file. + * acconfig.h (TARGET): Add #undef. + * Makefile.am (version.o, bucomm.o): Remove special targets. + * bucomm.c (target): Remove. + * nm.c (program_name): Don't declare. + (target): Make static. + * size.c (target): Make static. + * configure, config.in, Makefile.in: Rebuild. + +Tue Aug 5 00:01:41 1997 Ian Lance Taylor + + * Makefile.am (check-DEJAGNU): Export r. + (.dep1): Use $(INCLUDES) rather than $(ALL_CFLAGS). + * Makefile.in: Rebuild. + + * nlmheader.y: Use VERSIONK rather than VERSION. + + * Makefile.am (STRIP_PROG): Change from strip.new to strip-new. + (NM_PROG): Change from nm.new to nm-new. + (TOOL_PROGS, install-exec-local): Adjust accordingly. + * Makefile.in: Rebuild. + +Mon Aug 4 11:47:31 1997 Ian Lance Taylor + + * configure.in: Remove AC_ARG_PROGRAM; it's invoked by + AM_INIT_AUTOMAKE. + * configure: Rebuild. + + * Makefile.am (install-exec-local): Create $(tooldir)/bin before + trying to install anything into it. + * Makefile.in: Rebuild. + + * Makefile.am (TOOL_PROGS): Use an explicit $(EXEEXT). + (install-exec-local): When handling $(noinst_PROGRAMS), only use + $(EXEEXT) on the installed file. When handling $(TOOL_PROGS), + handle $(EXEEXT) correctly. + * configure.in: Add an explicit $(EXEEXT) when substituting for + the name of a program to build. + * Makefile.in, configure: Rebuild. + + * aclocal.m4, configure, Makefile.in: Rebuild with new automake + patches. + + * deflex.l, defparse.y: Use VERSIONK rather than VERSION. + * rclex.l, rcparse.y: Likewise. + * Makefile.am (windres_SOURCES): Add $(BULIBS). + * Makefile.in: Rebuild. + +Fri Aug 1 13:08:39 1997 Ian Lance Taylor + + * acinclude.m4: Include bfd/acinclude.m4, not bfd/acmacros.m4. + * aclocal.m4, configure: Rebuild with new libtool. + +Thu Jul 31 11:51:35 1997 Ian Lance Taylor + + * Makefile.am: New file, based on old Makefile.in. + * acinclude.m4: New file, from old aclocal.m4. + * configure.in: Call AM_INIT_AUTOMAKE and AM_PROG_LIBTOOL. Remove + shared library handling; now handled by libtool. Replace + AC_CONFIG_HEADER with AM_CONFIG_HEADER. Call AC_PROG_YACC, + AC_PROG_LEX, AC_DECL_YYTEST, AM_MAINTAINER_MODE, AM_CYGWIN32, and + AM_EXEEXT. Replace AC_PROG_INSTALL with AM_PROG_INSTALL. Remove + stamp-h handling in AC_OUTPUT. + * acconfig.h: Mention PACKAGE and VERSION. + * stamp-h.in: New file. + * Makefile.in: Now built with automake. + * aclocal.m4: Now built with aclocal. + * config.in, configure: Rebuild. + + From Ton van Overbeek : + * rcparse.y (dialog): Default menu and class to be named. + (styles): If FONT is seen, set DS_SETFONT in dialog style. + * resbin.c (res_to_bin_dialog): Correct computation of font + information length. + +Wed Jul 30 11:21:06 1997 Ian Lance Taylor + + From Ton van Overbeek : + * resbin.c (res_to_bin_menu): Correct computation of menu + vs. menuex length. + * resrc.c (define_stringtable): Add 1 to resource ID. + +Tue Jul 29 11:06:03 1997 Ian Lance Taylor + + * resbin.c (bin_to_res_string): Correct adjustment of data and + length. From Ton van Overbeek . + +Tue Jul 22 18:01:23 1997 Ian Lance Taylor + + * nlmconv.c (link_inputs): Call libiberty pexecute function. + (pexecute) [multiple versions]: Remove. + +Tue Jul 22 16:19:34 1997 Robert Hoehne + + * bucomm.c (make_tempname): If we might be using a DOS filesystem, + check for a backslash as well as a slash. + +Thu Jun 26 13:53:17 1997 Ian Lance Taylor + + * windres.c (main): Quit if we didn't get any resources. + (usage): Fix --yydebug usage message. + * rescoff.c (write_coff_file): Don't free the relocation array + until after we've closed the BFD. + (read_coff_rsrc): Quit rather than try to read standard input. + (write_coff_file): Quit rather than try to write to standard + output. + * rcparse.y: Add a couple of missing semicolons (accepted by bison + but not byacc). + * binutils.texi: Document windres. + +Wed Jun 25 20:57:06 1997 Ian Lance Taylor + + * resbin.c: New file. + * rclex.l, rcparse.y, rescoff.c, resrc.c, windres.c, windres.h: + Numerous fixes and improvements. + * Makefile.in: Rebuild dependencies. + (CFILES): Add resbin.c. + (WINDRES_OBJS): Add resbin.o. + +Sun Jun 22 17:29:41 1997 Ian Lance Taylor + + First stab at Windows resource compiler: + * windres.h: New file. + * windres.c: New file. + * resrc.c: New file. + * rcparse.y: New file. + * rclex.l: New file. + * rescoff.c: New file. + * configure.in: Define and substitute BUILD_WINDRES. + * configure: Rebuild. + * Makefile.in: Rebuild dependencies. + (WINDRES_PROG): New variable. + (PROGS): Add @BUILD_WINDRES@. + (HFILES): Add dlltool.h and windres.h. + (CFILES): Add windres.c and resrc.c. + (GENERATED_CFILES): Add rcparse.c and rclex.c. + (WINDRES_OBJS): New variable. + $(WINDRES_PROG): New target. + (rcparse.c, rcparse.h, rclex.c): New targets. + +Thu Jun 12 12:27:51 1997 Ian Lance Taylor + + * dlltool.c (export_type): Add data field. + (def_exports): Add data parameter. Change all callers. + (dump_def_info): Print data field. + (gen_def_file): Likewise. + (make_one_lib_file): Handle data field by not emitting simple + label and not emitting anything in SEC_TEXT. + (dtab): Print data field. + (process_duplicates): Merge data field. + * dlltool.h (def_exports): Update declaration. + * defparse.y (expline): Accept opt_DATA. Pass it to def_exports. + (opt_DATA): New non-terminal. + +Wed Jun 11 17:15:47 1997 Ian Lance Taylor + + * dlltool.h: New file. + * deflex.l: Include dlltool.h and libiberty.h. Don't declare + strdup. Use xstrdup rather than strdup. + * defparse.y: Include bfd.h, bucomm.h, and dlltool.h. + * dlltool.c: Include dlltool.h and time.h. Make a lot of + variables and functions static. Make a lot of char * variables + and parameters const. Add declarations for static functions. Do + some reindenting. Hide more PowerPC stuff inside DLLTOOL_PPC. + +Wed Jun 11 12:05:52 1997 H.J. Lu + + * ar.c (bfd_special_undocumented_glue): Add const. + +Mon May 12 22:09:35 1997 Bob Manson + + * Makefile.in (check): Pass CC_FOR_TARGET and CFLAGS_FOR_TARGET + to runtest. + +Mon May 12 13:14:22 1997 Ian Lance Taylor + + * configure.in: Don't clear OPCODES when --enable-commonbfdlib is + used on HP/UX. + * configure: Rebuild. + +Fri Apr 25 14:22:08 1997 H.J. Lu + + * Makefile.in (maintainer-clean realclean): Change *.info* + to binutils.info* to save sysroff.info. + +Tue Apr 15 13:42:22 1997 Ian Lance Taylor + + * Makefile.in (INSTALL): Set to @INSTALL@. + (INSTALL_XFORM, INSTALL_XFORM1): Remove. + (install): Depend upon installdirs. Use $(program_transform_name) + directly, rather than using $(INSTALL_XFORM) and + $(INSTALL_XFORM1). + (installdirs): New target. + (install-info): Run mkinstalldirs. + +Mon Apr 14 11:52:39 1997 Ian Lance Taylor + + * Makefile.in (INSTALL): Change install.sh to install-sh. + + From Thomas Graichen : + * Makefile.in: Always use $(SHELL) when running move-if-change. + * configure.in: Use ${CONFIG_SHELL} when running $ac_config_sub. + * configure: Rebuild. + +Fri Apr 4 13:28:02 1997 Ian Lance Taylor + + * configure.in: Add AC_FUNC_ALLOCA. + * configure, config.in: Rebuild. + * bucomm.h: Add alloca handling, copied from gas/as.h. + * dlltool.c: Add #pragma alloca for AIX to start of file. + * nlmconv.c: Likewise. + + * Makefile.in (distclean): Remove site.exp and site.bak. Remove + everything that clean removes. + +Thu Apr 3 13:18:39 1997 Ian Lance Taylor + + * Makefile.in (VERSION): Set to 2.8.1. + + * Branched binutils 2.8. + +Tue Apr 1 16:21:44 1997 Klaus Kaempf + + * configure.com: New file. + * config.h-vms: Remove file. + * makefile.vms: Update for new configure scheme. + +Mon Mar 31 15:30:43 1997 Philippe De Muyter + + * objcopy.c (make_same_dates): Use statbuf, not buf, if not + HAVE_GOOD_UTIME_H. + +Fri Mar 28 17:57:53 1997 Alan Modra + + * Makefile.in ($(OBJDUMP_PROG)): Don't link against BFDLIB twice. + * configure.in: Add AC_ARG_ENABLE for commonbfdlib. If it is set, + set OPCODES to empty. + * configure: Rebuild. + +Thu Mar 27 16:03:02 1997 Ian Lance Taylor + + Based on patch from Marty Leisner : + * objcopy.c: Include or . + (strip_options): Add "preserve-dates". + (copy_options): Likewise. + (copy_usage): Mention -p and --preserve-dates. + (strip_usage): Likewise. + (make_same_dates): New static function. + (strip_main): Handle -p. + (copy_main): Likewise. + * binutils.texi, strip.1, objcopy.1: Document new option. + + addr2line.c contributed by Ulrich Lauther + : + * addr2line.c: New file. + * Makefile.in: Rebuild dependencies. + (ADDR2LINE_PROG): New variable. + (MANPAGES): Add addr2line. + (PROGS): Add $(ADDR2LINE_PROG). + (CFILES): Add addr2line.c. + ($(ADDR2LINE_PROG)): New target. + * binutils.texi: Document addr2line. + * addr2line.1: New file. + + * version.c (print_version): Update copyright date. + +Mon Mar 24 10:52:45 1997 Andreas Schwab + + * objdump.c (disassemble_data): Don't exit if a file cannot be + disassembled, instead just return. + +Thu Mar 20 21:16:51 1997 Jeffrey A Law (law@cygnus.com) + + * size.c (usage): Make definition match its prototype. + (display_bfd, lprint_number, rprint_number): Likewise. + (print_berkeley_format, sysv_internal_printer): Likewise. + (print_sysv_format): Likewise. + * nm.c (set_print_radix, set_output_format): Likewise. + * objcopy.c (filter_bytes): Likewise. + +Tue Mar 18 16:39:55 1997 H.J. Lu + + * Many files: Add function prototypes. + * ar.c (mri_emul, get_pos_bfd): Make static. + * arlex.l: Include "libiberty.h". Don't declare strdup. Use + xstrdup rather than strdup. + * arparse.y (yyerror): Make argument const. Correct typo. + * arsup.c (strdup): Don't declare. + (ar_save): Use xstrdup rather than strdup. + * filemode.c: Include "bucomm.h". + * nm.c (usage): Make static. + (print_symname): Make format and name const. + * objcopy.c (cat): Remove. + (copy_archive): Make output_target const. Use concat, not cat. + (copy_file, simple_copy, smart_rename): Make arguments const. + * objdump.c (read_section_stabs): Likewise. + (print_section_stabs): Likewise. + (display_target_tables): Don't declare getenv. + * strings.c (strings_object_file): Change file to const. + (print_strings): Change filename to const. + * Makefile.in: Rebuild dependencies. + +Tue Mar 18 11:37:24 1997 Ian Lance Taylor + + * configure.in: Add BFD_NEED_DECLARATION(getenv). + * acconfig.h: Add NEED_DECLARATION_GETENV. + * bucomm.h (getenv): Declare if NEED_DECLARATION_GETENV. + * configure, config.in: Rebuild. + * nlmconv.c (getenv): Don't declare. + + * Makefile.in: Rebuild dependencies. + +Sat Mar 15 15:35:56 1997 Ian Lance Taylor + + Based on patches from Jamie Lokier : + * objdump.c: Include "demangle.h". + (do_demangle): New static variable. + (usage): Mention -C/--demangle. + (long_options): Add "demangle". + (objdump_print_symname): New static function. + (objdump_print_addr_with_sym): Use objdump_print_symname. + (disassemble_bytes): Likewise. + (dump_reloc_set): Likewise. + (dump_symbols): Demangle symbol name. + (main): Handle -C. + * binutils.texi, objdump.1: Document -C/--demangle. + + * objdump.c (usage): Mention --no-show-raw-insn. + (long_options): Add "no-show-raw-insn". + (disassemble_bytes): Handle --no-show-raw-insn. + * binutils.texi, objdump.1: Document --no-show-raw-insn. + +Wed Mar 12 11:42:00 1997 Andreas Schwab + + * rddbg.c (free_saved_stabs): Set the strings to NULL after being + freed. + +Fri Feb 28 17:18:45 1997 Ian Lance Taylor + + * bucomm.c (set_default_bfd_target): New function. + * bucomm.h (set_default_bfd_target): Declare. + * ar.c (main): Call set_default_bfd_target. + * nlmconv.c (main): Likewise. + * nm.c (main): Likewise. + * objcopy.c (main): Likewise. + * objdump.c (main): Likewise. + * size.c (main): Likewise. + * strings.c (main): Likewise. + * Makefile.in (bucomm.o): New target, to define TARGET. + +Tue Feb 25 21:28:38 1997 Ian Lance Taylor + + * objdump.c (adjust_section_vma): New static variable. + (usage): Mention --adjust-section-vma. + (OPTION_ADJUST_VMA): Define. + (long_options): Add "addjust-vma". + (display_bfd): If adjust_section_vma is not 0, add it to all the + section addresses. + (main): Handle OPTION_ADJUST_VMA. + * binutils.texi, objdump.1: Document --adjust-vma. + +Fri Feb 14 18:46:47 1997 Ian Lance Taylor + + * nm.c (print_symbol): Cache the BFD as well as the symbols and + relocs, and don't try to use the symbols or relocs with a + different BFD. + +Thu Feb 13 21:34:43 1997 Klaus Kaempf (kkaempf@progis.de) + + * config.h-vms: sbrk() is provided on openVMS/Alpha. + * makefile.vms: allow compiling with current gcc snapshot. + +Thu Feb 13 20:14:40 1997 Ian Lance Taylor + + * arsup.c, coffgrok.c, dlltool.c, nlmconv.c: Use xmalloc rather + than malloc. + +Wed Feb 12 16:12:02 1997 Ian Lance Taylor + + * objdump.c (disassemble_data): Correct VMA argument to + find_symbol_for_address. Improve handling of code with no symbol + followed by code with a symbol. + +Wed Feb 12 12:16:47 1997 Andreas Schwab + + * objdump.c (disassemble_bytes): Make output of raw instructions + work better for non-standard values of bytes_per_chunk and + bytes_per_line. + +Thu Feb 6 14:14:59 1997 Martin M. Hunt + + * objdump.c (disassemble_bytes): Added code to allow some control + over the way raw instructions are displayed. + +Thu Feb 6 12:36:03 1997 Ian Lance Taylor + + * stabs.c (struct bincl_file): Add next_stack field. + (push_bincl): Put the new file on both bincl_list and + bincl_stack. Clear the file_types field. + (pop_bincl): Use the next_stack field when popping the stack. + Don't put the file on bincl_list. + (find_excl): Include the file name when warning about an unfound + N_EXCL. + + * debug.c (debug_type_samep): Don't crash if we are passed NULL. + +Thu Feb 6 11:54:24 1997 Alan Modra + + * objcopy.1: Add missing space after .B. + +Fri Jan 31 10:33:07 1997 Andreas Schwab + + * objdump.c (disassemble_data): Initialize `aux.require_sec'. + +Wed Jan 29 13:21:21 1997 Ian Lance Taylor + + * objdump.c (objdump_print_value): Add skip_zeroes parameter. + Change all callers. + (objdump_print_addr_with_sym): Likewise. Call objdump_print_value + to print address. + (objdump_print_addr): New static function. + (objdump_print_address): Just call objdump_print_addr. + (disassemble_bytes): Print real address, not function offset. + Skip a certain number of leading zeroes. + + * objdump.c (disassemble_zeroes): New static variable. + (usage): Mention --disassemble-zeroes. + (long_options): Add "disassemble-zeroes". + (disassemble_bytes): Check disassemble_zeroes. + +Tue Jan 28 16:47:26 1997 Ian Lance Taylor + + * objdump.c (disassemble_bytes): Don't skip zeroes if the + disassembler has told us that we are in a branch delay slot. + +Mon Jan 20 14:24:04 1997 Ian Lance Taylor + + * size.c (berkeley_sum): Rewrite. Skip sections which are not + SEC_ALLOC. Count SEC_READONLY sections as text. + +Tue Jan 14 15:14:14 1997 Ian Lance Taylor + + * Makefile.in (maintainer-clean realclean): Remove *.info*, not + just *.info. From H.J. Lu . + +Tue Dec 31 15:42:54 1996 Ian Lance Taylor + + * Makefile.in (ALL_CFLAGS): Add -D_GNU_SOURCE. + +Fri Dec 27 11:19:26 1996 Ian Lance Taylor + + * configure.in: Work around bug in AC_FUNC_VFORK in autoconf 2.12. + * configure: Rebuild. + +Thu Dec 19 13:11:20 1996 Ian Lance Taylor + + Based on patch from Andrew J Klossner : + * objcopy.c (OPTION_WEAKEN): Define. + (copy_options): Add "weaken". + (copy_usage): Mention --weaken. + (weaken): New static variable. + (filter_symbols): Handle weaken. + (copy_object): Call filter_symbols if weaken. + (copy_main): Handle OPTION_WEAKEN. + * binutils.texi, objcopy.1: Document --weaken. + +Wed Dec 18 22:49:13 1996 Stan Shebs + + * mpw-make.sed: Use NewFolderRecursive for installation. + +Sat Dec 7 10:17:25 1996 Jeffrey A Law (law@cygnus.com) + + * Makefile.in (install): Add "else true" clause to cater to + broken "make" on some systems. + +Fri Dec 6 17:21:41 1996 Ian Lance Taylor + + * ieee.c (parse_ieee_bb): Always initialize namcopy to avoid gcc + warning about uninitialized variable. + (ieee_read_cxx_class): Likewise, for pf. + (ieee_enum_type): Likewise, for i. + +Tue Nov 26 17:01:25 1996 Ian Lance Taylor + + * wrstabs.c (stab_array_type): Add casts when printing + bfd_signed_vma values. + + * configure: Rebuild with autoconf 2.12. + +Mon Nov 25 16:53:18 1996 Ian Lance Taylor + + * objdump.c (disassemble_data): Don't crash if there is no + symbol. + +Fri Nov 22 17:29:14 1996 Andreas Schwab + + * ar.c (open_inarch): Don't call bfd_openr with a null name. + +Fri Nov 1 12:08:13 1996 Ian Lance Taylor + + * binutils.texi: Add section on reporting bugs. + +Thu Oct 31 18:20:53 1996 Ian Lance Taylor + + * stabs.c (struct stab_handle): Add bincl_list field. + (parse_stab): Pass value to push_bincl. Call find_excl for + N_EXCL. + (struct bincl_file): Add hash, file and file_types fields. + (push_bincl): Add hash parameter. Save it in the new hash field. + Save the file number in the new file field. + (pop_bincl): Put the bincl_file on bincl_list, rather than freeing + it. Save the file types in the new file_types field. + (find_excl): New static function. + + * ieee.c (ieee_lineno): Don't compare line number addresses to + info->highaddr (undo part of October 28 patch). + +Tue Oct 29 16:40:22 1996 Ian Lance Taylor + + * objdump.c (objdump_print_value): Don't print the empty string + for zero. + +Mon Oct 28 16:58:14 1996 Ian Lance Taylor + + * stabs.c (struct stab_handle): Add function_end field. + (start_stab): Initialize function_end. + (finish_stab): Pass info->function_end to debug_end_function. + (parse_stab): If info->function_end is set, use it as the address + which ends a function. + + * ieee.c (ieee_array_type): Remember the correct size. + + * ieee.c (ieee_finish_compilation_unit): Permit coalescing ranges + that are up to 0x1000 bytes apart, not just 64. + (ieee_add_bb11_blocks): Don't bother to emit a BB11 that is less + than 0x100 bytes. + (ieee_lineno): Only emit line numbers that are less than + info->highaddr. + +Fri Oct 25 12:12:17 1996 Ian Lance Taylor + + * ieee.c (struct ieee_defined_enum): Add defined field. + (ieee_enum_type): If the enum tag has been seen before but not + defined, reuse the same type index, and define it. + (ieee_tag_type): If this enum has not been defined, add an + undefined entry to the list of enums. + + * objdump.c (disassemble_bytes): Let the disassembler override the + number of bytes printed on a line. + +Thu Oct 24 16:42:10 1996 Ian Lance Taylor + + * objdump.c (prefix_addresses): New static variable. + (long_options): Add "prefix-addresses". + (compare_symbols): Sort BSF_FUNCTION symbols before other + symbols. + (find_symbol_for_address): New static function, broken out of + objdump_print_address. + (objdump_print_addr_with_sym): New static function, broken out of + objdump_print_address. + (objdump_print_address): Call new functions. + (disassemble_bytes): New static function, broken out of + disassemble_data. Change disassembly format, unless + prefix_addresses is set. + (disassemble_data): Call disassemble_bytes. Unless + prefix_addresses is set, disassemble in chunks headed by a + symbol. + * binutils.texi, objdump.1: Document --prefix-addresses. + + * rddbg.c (read_section_stabs_debugging_info): Preserve the + backslash when concatenating multiple stabs strings. + +Thu Oct 10 11:36:31 1996 Doug Evans + + * dlltool.c (scan_open_obj_file): Fix loop exit test. + Add missing parameter to def_exports. + +Tue Oct 8 12:06:17 1996 Ian Lance Taylor + + * Makefile.in (LEX_OPTIONS): Set to empty string. -I -Cem is the + default for flex, and is not recognized by lex. + +Thu Oct 3 17:41:23 1996 Ian Lance Taylor + + * binutils.texi (Target Selection): Document that you can now + specify targets using configuration triplets. + + * ar.c (usage): Declare. Make sure all callers pass an argument. + +Thu Oct 3 15:39:42 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (clean): Remove config.log. + +Wed Oct 2 15:49:16 1996 Klaus Kaempf + + * makefile.vms: Bump version date. + +Tue Oct 1 15:00:59 1996 Ian Lance Taylor + + * version.c (print_version): New function. + * bucomm.h (print_version): Declare. + * ar.c (program_version): Don't declare. + (do_show_version): Remove. + (usage): Add help parameter. Print bug report address. + (main): Set is_ranlib at start. Check for --help and --version. + Call print_version, not do_show_version. + * nlmconv.c (program_version): Don't declare. + (main): Call print_version. + (show_usage): Print bug report address. + * nm.c (program_version, print_version): Don't declare. + (usage): Print bug report address. + (main): Call print_version. + * objcopy.c (program_version): Don't declare. + (copy_usage): Print bug report address. + (strip_usage): Likewise. + (strip_main): Call print_version. + (copy_main): Likewise. + * objdump.c (program_version): Don't declare. + (usage): Print bug report address. + (main): Call print_version. + * size.c (program_version): Don't declare. + (usage): Print bug report address. + (main): Call print_version. + * strings.c (program_version): Don't declare. + (main): Call print_version. + (usage): Print bug report address. + * Makefile.in: Update dependencies. + +Thu Sep 19 14:53:15 1996 Ian Lance Taylor + + * ieee.c: Revert Monday's reflocalp patch, and apply this patch + instead: + (write_ieee_debugging_info): Write a dummy type at the end of the + global type block. + +Mon Sep 16 15:30:54 1996 Ian Lance Taylor + + * ieee.c (struct ieee_write_type): Add reflocalp field. + (ieee_pointer_type): Set reflocalp after pushing type. + (ieee_function_type): If reflocalp is set, make this type local. + (ieee_range_type, ieee_array_type, ieee_set_type): Likewise. + (ieee_const_type, ieee_volatile_type): Likewise. + (ieee_struct_field, ieee_class_baseclass): Likewise. + + * ieee.c (struct ieee_info): Add global_types field. + (parse_ieee_bb): When starting a BB1, initialize the types field + to the global_types field. + (parse_ieee_be): When ending a BB2, copy the types field to the + global_types field. + +Fri Sep 13 17:32:21 1996 Ian Lance Taylor + + * objcopy.c (change_leading_char): New static variable. + (OPTION_CHANGE_LEADING_CHAR): Define. + (copy_options): Add "change-leading-char". + (copy_usage): Mention --change-leading-char. + (filter_symbols): Add obfd parameter. Change all callers. + Implement change_leading_char. + (copy_object): Call filter_symbols if change_leading_char. + (copy_main): Handle OPTION_CHANGE_LEADING_CHAR. + * binutils.texi, objcopy.1: Document --change-leading-char. + +Tue Sep 3 14:05:29 1996 Ian Lance Taylor + + * ieee.c (ieee_enum_type): Don't check index into a NULL names + array. + * nm.c (sort_symbols_by_size): Always initialize next. + * rdcoff.c (parse_coff_type): Warn about an incomprehensible + type rather than crashing. + * rddbg.c (read_symbol_stabs_debugging_info): Initialize f. + * stabs.c (parse_stab_members): Set context in all cases. + +Thu Aug 29 16:56:52 1996 Michael Meissner + + * configure.in (i[345]86-*-*): Recognize i686 for pentium pro. + * configure: Regenerate. + +Thu Aug 29 11:29:20 1996 Ian Lance Taylor + + * objdump.c (L_tmpnam): Never define. + (display_target_list): Use choose_temp_base instead of tmpnam. + (display_info_table): Likewise. + +Tue Aug 27 18:15:01 1996 Ian Lance Taylor + + * stabs.c (parse_stab): An N_FUN symbol with an empty string + indicates the end of a function. + +Thu Aug 22 17:08:00 1996 Ian Lance Taylor + + * wrstabs.c (struct string_hash_entry): Add next field. + (struct stab_write_handle): Change strings to a pointer to + string_hash_entry. Add last_strings field. Remove strings_alloc + field. + (string_hash_newfunc): Initialize next field. + (stab_write_symbol): Copy string into hash table rather than into + buffer. Keep a list of hash table entries. + (write_stabs_in_sections_debugging_info): Initialize last_string. + Copy strings from list of hash table entries in memory. + (stab_modify_type): If the entry on the stack is a definition, + make a new definition rather than failing an assert. + (stab_array_type): The size is only zero if high is strictly less + than low. + + * ieee.c (struct ieee_info): Add saw_filename field. + (parse_ieee): Initialize saw_filename. + (parse_ieee_bb): Set saw_filename for a BB1 or BB2. In a BB1, + discard the current variables and types. In a BB10, if no + filename has been seen, call debug_set_filename. + (parse_ieee_ty): In case 'g', the type is optional. + + * prdbg.c (pr_fix_visibility): Don't abort on + DEBUG_VISIBILITY_IGNORE. + + * debug.c (debug_name_type): Correct error message. + + * configure.in: Substitute HLDENV. + * configure: Rebuild. + * Makefile.in (HLDENV): New variable. Use it whenever linking a + program. + +Thu Aug 15 19:30:41 1996 Stan Shebs + + * mpw-make.sed: Add symbolic doublequotes around the version + number. + +Thu Aug 8 12:27:52 1996 Klaus Kaempf + + * makefile.vms: Add better support for DEC C compilation. + Add new macros as in Makefile.in. + +Wed Aug 7 14:27:33 1996 Philippe De Muyter + + * configure.in: Call BFD_NEED_DECLARATION on strstr and sbrk. + * acconfig.h (NEED_DECLARATION_STRSTR): New macro. + (NEED_DECLARATION_SBRK): New macro. + * configure, config.in: Rebuild. + * bucomm.h (strstr): Declare if NEED_DECLARATION_STRSTR. + (sbrk): Declare if HAVE_SBRK and NEED_DECLARATION_SBRK. + + * prdbg.c (pr_end_struct_type): Avoid using a string constant in + assert, for the benefit of broken assert macros. + +Fri Jul 26 14:06:50 1996 Ian Lance Taylor + + * objdump.c (disassemble_data): Set disasm_info.flavour from + abfd. + +Tue Jul 23 13:59:54 1996 Ian Lance Taylor + + * dlltool.c (secdata): In non DLLTOOL_PPC case, change alignment + of .text section to 2. + +Mon Jul 22 08:46:15 1996 Stu Grossman (grossman@lisa.cygnus.com) + + * objdump.c (dump_section_stabs): Fix test for stabs sections + ending with numbers. This fixes a problem with .stab being + confused with .stab.index. + +Wed Jul 10 13:32:28 1996 Ian Lance Taylor + + * stabs.c (stab_demangle_fund_type): Return a void * for a + template, rather than simply aborting. + +Mon Jul 8 15:28:05 1996 Ian Lance Taylor + + * ar.c (open_inarch): Add file parameter. Change all callers. If + this is a newly created archive, set the target based on the + file. + * arsup.h (open_inarch): Update declaration. + +Thu Jul 4 12:00:55 1996 Ian Lance Taylor + + * Makefile.in (VERSION): Set to cygnus-2.7.1. + + * Released binutils 2.7. + + * rdcoff.c (parse_coff): Get address to pass to debug_end_function + from function size, not value of .ef symbol. From Ning + Mosberger-Tang . + +Sat Jun 29 21:18:09 1996 Ian Lance Taylor + + * objcopy.c (strip_main): Add -o option, and handle it. + (strip_usage): Mention -o. + * binutils.texi, strip.1: Mention -o. + +Mon Jun 24 17:19:02 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (bindir, libdir, datadir, mandir, infodir, includedir, + INSTALL_PROGRAM, INSTALL_DATA): Use autoconf set values. + (docdir): Removed. + * configure.in (AC_PREREQ): Autoconf 2.5 or higher. + +Mon Jun 24 11:59:13 1996 Ian Lance Taylor + + * objdump.c (endian): New static variable. + (usage): Mention -EB/-EL/--endian. + (long_options): Add "endian". + (disassemble_data): If endianness was specified, replace + abfd->xvec with a copy of itself with the given endianness. + (main): Handle -EB/-EL/--endian. + * binutils.texi, objdump.1: Mention -EB/-EL/--endian. + + * objdump.c: Make most variables and functions static. + + * configure.in: On alpha*-*-osf*, link against libbfd.a if not + using shared libraries. + * configure: Rebuild with autoconf 2.10. + +Sun Jun 23 14:47:36 1996 Kim Knuttila + + * dlltool.c (secdata): Changed .rdata to .reldata so .reloc will work. + (make_one_lib_file): Removed cruft. (#if 1) + +Wed Jun 19 14:46:38 1996 Ian Lance Taylor + + * objdump.c (stabs): Change from struct internal_nlist * to + bfd_byte *. + (print_section_stabs): Fetch stabs information directly, rather + than assuming that struct internal_nlist is the right size. + + * binutils.texi: Document change to binary format: file position + based on load address, not section VMA. + + * bucomm.h: Define SEEK_SET, SEEK_CUR, and SEEK_END if they are + not already defined. + +Tue Jun 18 18:25:00 1996 Ian Lance Taylor + + * Makefile.in (DISTSTUFF): Add deflex.c. + +Tue Jun 18 15:03:44 1996 Klaus Kaempf + + * config.h-vms, makefile.vms: New files. + +Mon Jun 17 09:47:31 1996 Ian Lance Taylor + + * dlltool.c (make_one_lib_file): Use BFD_RELOC_RVA rather than + BFD_RELOC_32 in IDATA7. + +Wed Jun 12 11:52:06 1996 Ian Lance Taylor + + * nm.c (struct get_relocs_info): Define. + (line_numbers): New static variable. + (long_options): Add "line-numbers". + (usage): Mention -l and --line-numbers. + (main): Handle -l. + (print_symbol): Print line numbers if requested. + (get_relocs): New static function. + * binutils.texi, nm.1: Document -l/--line-numbers. + +Tue Jun 11 20:12:15 1996 Ian Lance Taylor + + * objdump.c (dump_reloc_set): Add sec parameter. Change all + callers. If with_line_numbers is set, display line numbers of + relocation entries. + * binutils.texi, objdump.1: Document -l with -r. + +Mon Jun 10 23:42:59 1996 Ian Lance Taylor + + * ar.c (open_inarch): Report BFD error message if an archive can + not be recognized. List matching formats if the file is + ambiguously recognized. + (ranlib_touch): Likewise. + +Thu Jun 6 13:56:14 1996 Ian Lance Taylor + + * README: Add notes on how to build if you don't have ar. + + * Makefile.in: Remove old incorrect setting of CC. + +Tue Jun 4 10:52:49 1996 Tom Tromey + + * Makefile.in (install): Don't check to see if tooldir exists. + Make $(tooldir) and $(tooldir)/bin. + +Mon Jun 3 17:40:23 1996 Michael Meissner + + * strings.c (main): Make main an int function, not void. + +Fri May 31 13:59:24 1996 Ian Lance Taylor + + * nm.c (filter_symbols): Check for BSF_WEAK as well as + BSF_GLOBAL. + * objcopy.c (filter_symbols): Likewise. + +Wed May 8 16:57:20 1996 Ian Lance Taylor + + * objcopy.c (copy_object): Make clear that it is only a warning + when the output file can not represent the architecture. + +Fri May 3 11:30:17 1996 Ian Lance Taylor + + * objdump.c (disassemble_data): Don't refer to bytes past the end + of data. + +Wed Apr 24 14:10:21 1996 Ian Lance Taylor + + * rddbg.c (read_symbol_stabs_debugging_info): Move call to + free_saved_stabs outside the loop over the symbols. + +Tue Apr 23 12:56:11 1996 Ian Lance Taylor + + * objdump.c (compare_symbols): Sort symbols whose names start with + `.' after other symbols. If no other decision can be made, sort + symbols by name. + +Thu Apr 18 16:02:11 1996 Ian Lance Taylor + + * dep-in.sed: Substitute $(BFDDIR) for @BFDDIR@. + * Makefile.in: Rebuild dependencies. + (dep.sed): Substitute $(BFDDIR) for @BFDDIR@. + +Tue Apr 16 13:50:22 1996 Ian Lance Taylor + + * rdcoff.c: New file. + * rddbg.c (read_debugging_info): Read COFF symbols if COFF flavour + and no stabs were found. + * budbg.h (parse_coff): Declare. + * Makefile.in: Rebuild dependencies. + (CFILES): Add rdcoff.c. + (DEBUG_OBJS): Add rdcoff.o. + +Mon Apr 15 15:55:01 1996 Doug Evans + + * nlmconv.c (choose_temp_base{,_try}): Delete, in libiberty now. + (link_inputs): Update call to choose_temp_base. + +Mon Apr 8 14:40:05 1996 Ian Lance Taylor + + * configure.in: Permit --enable-shared to specify a list of + directories. + * configure: Rebuild. + +Fri Mar 29 16:11:33 1996 Ian Lance Taylor + + * objdump.c (dump_section_header): Print the SEC_LINK_ONCE flag + and the SEC_LINK_DUPLICATES field. + +Fri Mar 29 11:35:55 1996 J.T. Conklin (jtc@lisa.cygnus.com) + + * nlmconv.1: Changed to be recognized by catman -w on Solaris. + +Thu Mar 28 14:17:02 1996 Ian Lance Taylor + + * wrstabs.c (stab_enum_type): Set buf before using it. + +Fri Mar 22 15:49:08 1996 Ian Lance Taylor + + * stabs.c (struct stab_handle): Add field abfd. + (start_stab): Add abfd parameter. + (parse_stab_string): Skip the symbol leading char when searching + for the value of a global symbol. + * budbg.h (start_stab): Update declaration. + * rddbg.c (read_section_stabs_debugging_info): Pass abfd to + start_stab. + (read_symbol_stabs_debugging_info): Likewise. + +Thu Mar 21 12:40:48 1996 Ian Lance Taylor + + * wrstabs.c (stab_function_type): Output an empty typedef for an + unused argument, rather than making up a meaningless name. + (stab_variable): Use N_RSYM for a DEBUG_REGISTER variable. + + * ieee.c (struct ieee_info): Add global_vars field. + (parse_ieee_be): When ending the global typedef block, copy the + variables into info->global_vars. + (parse_ieee_atn): Don't require an NN record for a pmisc ATN. + (ieee_read_reference): Search the global variables after the local + variables. + +Wed Mar 20 18:08:19 1996 Andreas Schwab + + * objdump.c (disassemble_data): Make sure sym_name is always set. + (dump_section_header): Always put a space after the section name. + (dump_bfd_header): Terminate output with newline. + +Wed Mar 20 16:35:20 1996 Ian Lance Taylor + + * wrstabs.c: New file. + * budbg.h (write_stabs_in_sections_debugging_info): Declare. + * objcopy.c (write_debugging_info): For COFF or ELF, output stabs + in sections. + * Makefile.in: Rebuild dependencies. + (CFILES): Add wrstabs.c. + (WRITE_DEBUG_OBJS): New variable. + ($(OBJCOPY_PROG)): Use $(WRITE_DEBUG_OBJS), not $(DEBUG_OBJS). + ($(STRIP_PROG)): Likewise. + + * stabs.c (parse_stab_members): Make type stub detection more like + gdb. + + * ieee.c (struct ieee_handle): Add fields complex_float_index and + complex_double_index. + (ieee_complex_type): Cache type index in complex_float_index and + complex_double_index, depending upon size. Set size on type stack + to size * 2. + + * ieee.c (ieee_empty_type): Use builtin_unknown, not 0. + (ieee_void_type): Use builtin_void, not 1. + + * ieee.c (parse_ieee_ty): Handle 'V' type code. + (parse_ieee_atn): Don't require two numbers for type 10. + + * ieee.c (parse_ieee_be): Add one to offset at end of function or + block. + + * ieee.c (struct ieee_block): Add field skip. + (parse_ieee_bb): Don't call debug_record_function for __XRYCPP + function, and set skip field. + (parse_ieee_be): Don't call debug_end_function if skip is set. + + * debug.c (struct debug_handle): Add fields current_write_lineno + and current_write_lineno_index. + (debug_write): Initialize current_write_lineno and + current_write_lineno_index for each unit. Call + debug_write_linenos rather than writing out the line numbers + directly. + (debug_write_function): Call debug_write_linenos. + (debug_write_block): Likewise. + (debug_write_linenos): New static function. + + * debug.c (debug_write_type): For DEBUG_KIND_FUNCTION, push return + type before arguments. + +Mon Mar 18 18:05:33 1996 Ian Lance Taylor + + * configure.in: Add AC_FUNC_VFORK. + * configure, config.in: Rebuild. + * dlltool.c, nlmconv.c: Include if HAVE_VFORK_H is + defined. + + * stabs.c (parse_stab_range_type): A complex type is defined as a + subrange of itself with the high bound zero. + * ieee.c (ieee_complex_type): Don't crash on sizes of 12 or 16. + +Tue Mar 12 12:09:43 1996 Ian Lance Taylor + + * ieee.c (ieee_write_undefined_tag): Switch to global_types even + if it is not empty. + (ieee_tag_type): For an enum, look through info->enums. + + * configure: Rebuild with autoconf 2.8. + + * debug.c (debug_type_samep): Don't loop endlessly in + DEBUG_KIND_ENUM case. From Eric Baur . + +Mon Mar 11 12:35:03 1996 Ian Lance Taylor + + * rddbg.c (read_section_stabs_debugging_info): Call save_stab for + each stab entry, call stab_context on an error, and call + free_saved_stabs before rturning. + (read_symbol_stabs_debugging_info): Likewise. + (SAVE_STABS_COUNT): Define. + (struct saved_stab): Define. + (saved_stabs, saved_stabs_index): New static variables. + (save_stab, stab_context, free_saved_stabs): New static functios. + + * objdump.c (stab_name): Remove. + (struct stab_print): Remove. + (stab_print): Remove. + (dump_stabs): Don't initialize stab_name. + (print_section_stabs): Call bfd_get_stab_name rather than using + the stab_name array. + +Tue Feb 27 19:52:01 1996 Ian Lance Taylor + + * prdbg.c (pr_int_constant): Initialize info correctly. + (pr_float_constant): Likewise. + +Mon Feb 26 18:11:37 1996 Stan Shebs + + * mpw-make.sed: Update to handle shared library support. + +Sat Feb 24 11:21:49 1996 Alan Modra : + + * Makefile.in ($(OBJDUMP_PROG)): Search $(BFDLIB) before + $(OPCODES). + +Thu Feb 15 12:44:45 1996 Ian Lance Taylor + + * configure.in: Don't tamper with LDFLAGS. Call AC_PROG_CC before + configure.host. + * configure: Rebuild. + + * configure.in: Substitute RPATH_ENVVAR. + * configure: Rebuild. + * Makefile.in (RPATH_ENVVAR): New variable. + (check): Use $(RPATH_ENVVAR) rather than LD_LIBRARY_PATH. + + * objcopy.c (smart_rename): Rather than doing chmod then chown, do + chmod without setuid, then chown, then chmod with setuid. + +Wed Feb 14 16:46:42 1996 Martin Anantharaman + + * arsup.c (map_over_list): Reindent. Don't assume that the + function does not delete the BFD. + (ar_addlib_doer): Don't set prev->next if prev is NULL. + +Wed Feb 14 15:12:17 1996 Ian Lance Taylor + + * ieee.c (ieee_regno_to_genreg): Convert register numbers for m68k + and i960. + (ieee_genreg_to_regno): Likewise. + +Mon Feb 12 14:19:59 1996 Ian Lance Taylor + + * ieee.c: Extensive changes to write code to put types in the + global type block when possible, to output ranges for all memory + occupied by the module, and to improve efficiency. + + * debug.c (struct debug_handle): Remove class_mark field. Add + id_list and compare_list fields. + (struct debug_class_id): Define. + (struct debug_type_compare_list): Define. + (debug_write): Initialize info->id_list + (debug_write_name): Remove reference to info->class_mark. + (debug_write_type): Get id for all structs and classes. Simplify + test for whether struct has already been written. + (debug_write_class_type): Get id for all classes. Simplify test + for whether class has already been written. + (debug_write_block): Don't write out blocks other than the top + level block if they have no local variables. + (debug_set_class_id): New static function. + (debug_type_samep): New static function. + (debug_class_type_samep): New static function. + * prdbg.c (pr_start_struct_type): Always print id. + (pr_start_class_type): Likewise. + (pr_tag_type): Likewise. + + * stabs.c (struct stab_handle): Add syms and symcount fields. + (start_stab): Add syms and symcount parameters. Change all + callers. + (parse_stab_string): Look up global variables in the symbol table + to get the right value. + * budbg.h (start_stab): Update declaration. + * rddbg.c (read_section_stabs_debugging_info): Add syms and + symcount parameters. Change all callers. + + * stabs.c (parse_stab_array_type): If the index type is 0, use + int. + +Wed Feb 7 14:17:45 1996 Ian Lance Taylor + + * ieee.c (ieee_start_compilation_unit): Clear modified and + modified_alloc fields of info. + + * configure.in: Check for --enable-shared. Substitute new + variables BFDLIB and OPCODES. + * configure: Rebuild. + * Makefile.in (BFDLIB): Set to @BFDLIB@. + (OPCODES): Set to @OPCODES@. + +Mon Feb 5 16:18:42 1996 Ian Lance Taylor + + Support for building bfd and opcodes as shared libraries, based on + patches from Alan Modra : + * configure.in (HLDFLAGS): New substitution. + * configure: Rebuild. + * Makefile.in (HLDFLAGS): New variable. Make all links use + $(HLDFLAGS) before $(CFLAGS) and $(LDFLAGS). + (BFDLIB_DEP): New variable. Replace all occurrences of $(BFD) as + a dependency with $(BFDLIB_DEP). Remove $(BFD) as a dependency if + there is also a dependency on $(ADDL_DEPS). + (BFDLIB): Rename from BFD; change all uses; set to -L../bfd -lbfd. + (OPCODES_DEP): New variable. Replace all occurrends of $(OPCODES) + as a dependency with $(OPCODES_DEP). + (OPCODES): Set to -L../opcodes -lopcodes. + (ADDL_DEPS): New variable. Replace all occurrences of + $(ADDL_LIBS) as a dependency with $(ADDL_DEPS). + (check): Set LD_LIBRARY_PATH in the environment. + (config.status): Depend upon BFD configure.host and config.bfd. + +Fri Feb 2 17:02:59 1996 Doug Evans + + * objdump.c: #include stdarg.h or varargs.h. + (objdump_print_value): Change FILE* arg to struct disassemble_info*. + All callers updated. Use fprintf_func. + (objdump_print_address): Consistently use fprintf_func. + (objdump_sprintf): New function. + (disassemble_data): Print insn into a buffer, print raw insn ourselves, + then print insn mnemonic. + +Fri Feb 2 16:48:55 1996 Ian Lance Taylor + + * configure: Regenerate. + +Thu Feb 1 09:38:18 1996 Steve Chamberlain + + * configure.in (i[3-6]86-*-win32): Becomes i[3-6]86-*-cygwin32. + (powerpc*-*-cygwin32): New. + * configure: Regenerated. + +Wed Jan 31 13:22:03 1996 Richard Henderson + + * Makefile.in (distclean): Remove $(DEMANGLER_PROG).1. + +Mon Jan 29 17:36:29 1996 Ian Lance Taylor + + Based on patches from H J Lu : + * objcopy.c (remove_leading_char): New static variable. + (OPTION_REMOVE_LEADING_CHAR): Define. + (copy_usage): Mention --remove-leading-char. + (filter_symbols): If remove_leading_char, and the first character + of a global symbol matches the symbol leading char of the BFD, + remove the first character. + (copy_object): Filter the symbols if remove_leading_char is set. + (copy_main): Handle --remove-leading-char. + * binutils.texi, objcopy.1: Document --remove-leading-char. + +Sat Jan 27 15:40:13 1996 Michael Meissner + + * objdump.c (fprintf): Add prototype to avoid compiler warning on + SunOS. + +Fri Jan 26 11:53:42 1996 Ian Lance Taylor + + * binutils.texi (nm): Improve documentation on symbol types. + (objdump): Reference the stabs manual from the discussion of the + --stabs option. + +Thu Jan 25 11:21:46 1996 Raymond Jou + + * mpw-make.sed: Add a "stamps" target. + +Thu Jan 25 13:51:44 1996 Ian Lance Taylor + + * objdump.c (dump_headers, dump_section_header): Change objdump -h + output to be simpler and to include section file offsets. + +Wed Jan 24 12:06:05 1996 Ian Lance Taylor + + * stabs.c (parse_stab_members): Don't adjust voffset. + + * ieee.c (ieee_read_cxx_class): Don't multiply voffset by 4. + (struct ieee_write_type): Add name field. + (struct ieee_type_class): Remove name field. Change all uses to + use new name field in type instead. + (struct ieee_name_type): Likewise. + (ieee_start_struct_type): Initialize name field of type. + (ieee_start_class_type): Don't initialize classdef entry of tag. + (ieee_class_method_var): Don't adjust voffset. + (ieee_end_class_type): Likewise. + (ieee_tag_type): Initialize new name field of type. + (ieee_typdef): Set name after copying in type information. + + * debug.c (VOFFSET_STATIC_METHOD): Define as -1, not 1. + + * ieee.c (struct ieee_modified_type): Define. + (struct ieee_handle): Add modified and modified_alloc fields. + (ieee_get_modified_info): New static function. + (ieee_pointer_type): Cache type index. + (ieee_const_type): Likewise. + (ieee_volatile_type): Likewise. + + * ieee.c (ieee_define_named_type): When creating a tag for an + anonymous struct, copy the name into memory. + (ieee_tag_type): Likewise. + * debug.c (debug_write_type): Only check and set id field for an + unnamed object. + (debug_write_class_type): Likewise. + + * ieee.c: Various changes to write out types for functions and + references, and to not write out unnecessary function types. + + * ieee.c (struct ieee_var): Remove variable field. Add kind + field, and define some enum constants for it. + (parse_ieee_ty): Set kind field of variable for 'x' and 'X' types. + (parse_ieee_atn): Make an indirect slot for an external variable, + although we otherwise don't record it. Set kind field rather than + variable field of pvar. + (ieee_read_cxx_class): Try to get the type of a static member. + (ieee_read_reference): Check kind field rather than variable + field. + +Tue Jan 23 15:54:18 1996 Ian Lance Taylor + + * ieee.c: Various changes to handle reading C++ reference type + information. + + * debug.h (enum debug_var_kind): Add DEBUG_VAR_ILLEGAL. + (enum debug_parm_kind): Add DEBUG_PARM_ILLEGAL. + * debug.c (debug_get_parameter_types): Handle DEBUG_KIND_FUNCTION. + + * ieee.c: Various changes to write out definitions of C++ classes. + + * debug.c (debug_append_filename): Remove. + * debug.h (debug_append_filename): Don't declare. + + * stabs.c (struct stab_handle): Remove last_type field. Add + so_string and so_value fields. + (finish_stab): Call stab_emit_pending_vars before calling + debug_end_function. Don't warn about pending variables. + (parse_stab): Accumulate N_SO strings until a non N_SO symbol is + seen, rather than calling debug_append_filename. Call + stab_emit_pending_vars before calling debug_end_function. Don't + set info->last_type. + +Tue Jan 23 09:53:54 1996 Doug Evans + + * objdump.c (disassemble_data): Handle unknown endianness. + Pass fprintf to INIT_DISASSEMBLE_INFO. + +Mon Jan 22 16:46:43 1996 Doug Evans + + Add new option --show-raw-insn. + * objdump.c (show_raw_insn): New global. + (usage): Update. + (long_options): Update. + (disassemble_data): Set disasm_info.flags if --show-raw-insn. + + * objdump.c (disassemble_data): Set new arch,mach,endian fields in + disasm_info. + +Mon Jan 22 19:29:36 1996 Ian Lance Taylor + + * ieee.c: Extensive changes to pass a single info argument around + in the reading routines, rather than several arguments. Add code + to read C++ debugging records. + + * debug.h (debug_get_type_size): Declare. + (debug_get_field_name): Declare. + (debug_get_field_bitpos): Declare. + (debug_get_field_bitsize): Declare. + (debug_get_field_visibility): Declare. + (debug_get_field_physname): Declare. + * debug.c (debug_get_real_type): Handle DEBUG_KIND_TAGGED. + (debug_get_type_size): New function. + (debug_get_field_name): New function. + (debug_get_field_bitpos): New function. + (debug_get_field_bitsize): New function. + (debug_get_field_visibility): New function. + (debug_get_field_physname): New function. + (debug_write_type): Make sure we pass the real kind, not INDIRECT, + to tag_type. Pass the name recursively for INDIRECT. + +Fri Jan 19 12:31:57 1996 Ian Lance Taylor + + * debug.h (struct debug_write_fns): Remove ellipsis_type. Add int + and boolean parameters to function_type. Add boolean parameter to + method_type. + (debug_make_ellipsis_type): Don't declare. + (debug_make_function_type): Add debug_type * and boolean + parameters. Change all callers. + (debug_make_method_type): Add boolean parameter. Change all + callers. + (debug_get_parameter_types): Add boolean * parameter. Change all + callers. + (debug_get_target_type): Declare. + * debug.c (struct debug_function_type): Add fields arg_types and + varargs. + (struct debug_method_type): Add field varargs. + (debug_ellipsis_type, ELLIPSIS_P): Remove. + (debug_make_ellipsis_type): Remove. + (debug_make_function_type): Add arg_types and varargs parameters. + (debug_make_method_type): Add varargs parameter. + (debug_get_parameter_types): Add pvarargs parameter. + (debug_get_target_type): New function. + (debug_write_type): In case DEBUG_KIND_FUNCTION, push argument + types and pass count to function_type. In DEBUG_KIND_METHOD, use + a signed int for the count, don't call ellipsis_type, and pass + varargs to method_type. + * stabs.c (struct stab_demangle_info): Add varargs field. + (stab_demangle_argtypes): Add pvarargs parameter. Change all + callers. + (stab_demangle_args): Likewise. + (stab_demangle_type): In case 'F', pick up argument types. + * prdbg.c (pr_ellipsis_type): Remove. + (pr_function_type): Add argcount and varargs parameters. + (pr_method_type): Add varargs parameter. + * ieee.c (ieee_ellipsis_type): Remove. + (ieee_function_type): Add argcount and varargs parameters. + (ieee_method_type): Add varargs parameter. Remove most of + function body, and just call ieee_function_type. + + * stabs.c: Include "demangle.h". Added several new static + functions not listed below to demangle argument types; they are + all called via stab_demangle_argtypes. + (finish_stab): If the kind of an undefined tag is + DEBUG_KIND_ILLEGAL, use DEBUG_KIND_STRUCT instead. Warn if there + are any pending variable. + (parse_stab): Don't close the function when the block depth goes + to zero. Pass value to debug_end_function. + (parse_stab_string): In case 'T', pass the name to + parse_stab_type. + (parse_stab_type): In case 'x', use stab_find_tagged_type. In + case '#', handle functions with variable numbers of arguments. + (parse_stab_struct_type): Add tagname parameter. Change all + callers. + (parse_stab_members): Add tagname and typenums parameters. Change + all callers. If the type of a method is a stub, call + parse_stab_argtypes to demangle the argument types and get the + physical name of the function. + (parse_stab_argtypes): New static function. + (stab_record_variable): For a DEBUG_GLOBAL or DEBUG_STATIC + variable, call debug_record_variable immediately. + (stab_find_tagged_type): New static function. + + * debug.h (enum debug_type_kind): Add DEBUG_KIND_ILLEGAL. + (struct debug_write_fns): Add field ellipsis_type. Add id + parameter to start_struct_type, start_class_type, and tag_type. + (debug_make_ellipsis_type): Declare. + (debug_find_named_type): Declare. + (debug_get_type_kind): Declare. + (debug_get_return_type): Declare. + (debug_get_parameter_types): Declare. + (debug_get_fields): Declare. + (debug_get_field_type): Declare. + * debug.c (struct debug_handle): Add fields class_id and base_id. + (struct debug_class_type): Add field id. + (struct debug_method_variant): Rename argtypes to physname. + Change all uses. + (debug_ellipsis_type): New static variable. + (ELLIPSIS_P): New macro. + (debug_make_ellipsis_type): New function. + (debug_make_method_variant): Rename argtypes to physname. + (debug_make_static_method_variant): Likewise. + (debug_name_type): Always put types in the global namespace. + (debug_find_named_type): New function. + (debug_find_tagged_type): Treat DEBUG_KIND_ILLEGAL specially, + rather than DEBUG_KIND_VOID. + (debug_get_real_type): New static function. + (debug_get_type_kind): New function. + (debug_get_return_type): New function. + (debug_get_parameter_types): New function. + (debug_get_fields): New function. + (debug_get_field_type): New function. + (debug_write): Initialize base_id. + (debug_write_type): Pass new id argument to tag_type. Handle + DEBUG_KIND_ILLEGAL. Use id for DEBUG_KIND_STRUCT and + DEBUG_KIND_UNION. Handle ellipsis for method arguments. + (debug_write_class_type): Don't dereference kclass if it is NULL. + Use id. + * prdbg.c (pr_fns): Add pr_ellipsis_type. + (pr_ellipsis_type): New static function. + (pr_pointer_type): If this is a pointer to an array, parenthesize + it correctly. + (pr_start_struct_type): Add id parameter. + (pr_start_class_type): Likewise. + (pr_tag_type): Likewise. + (pr_fix_visibility): Add the visibility to the top of the stack, + not the second element on the stack. + (pr_struct_field): Pop the stack before calling pr_fix_visibility. + (pr_class_static_member): Likewise. + (pr_class_start_method): Don't push a type, just set the method + name in the type on the top of the stack. + (pr_class_end_method): Don't pop the stack. + (pr_class_method_variant): Rename argtypes parameter to physname. + Append const and volatile rather than prepending them. Add a + space after the physname. + (pr_class_static_method_variant): Likewise. + * ieee.c (ieee_fns): Add ieee_ellipsis_type. + (ieee_define_named_type): Use DEBUG_KIND_ILLEGAL rather than + DEBUG_KIND_VOID. + (write_ieee_debugging_info): Likewise. + (ieee_typdef): Likewise. + (ieee_ellipsis_type): New static function. + (ieee_start_struct_type): Add id parameter. + (ieee_start_class_type): Likewise. + (ieee_tag_type): Likewise. + (ieee_class_method_variant): Rename name to physname. + (ieee_class_static_method_variant): Likewise. + + * Makefile.in (DEBUG_OBJS): Remove prdbg.o. + ($(OBJDUMP_PROG)): Depend upon, and link against, prdbg.o. + +Thu Jan 18 17:35:06 1996 Kim Knuttila + + * dlltool.c (make_tail): Changed the order of the sections to avoid + an alignment problem. + +Wed Jan 17 14:23:00 1996 J.T. Conklin + + * srconv.c (wr_du): Set du.stackfrmt to 0. + (wr_un, wr_sc): Emit all sections, even those with 0 size. + +Tue Jan 16 16:15:49 1996 J.T. Conklin + + * srconv.c (wr_hd): Space size within segment was being + stored in segment identifier field. + +Tue Jan 16 12:07:25 1996 Stan Shebs + + * mpw-config.in (BUILD_NLMCONV, BUILD_SRCONV, SYSINFO_PROG, + BUILD_DLLTOOL): Put definitions for these into makefile when + configuring, instead of always clearing in mpw-make.sed. + * mpw-make.sed: Edit out any host_alias or target_alias settings, + fix pathname to BFD internal include files, remove dependency + calculation rules. + +Thu Jan 11 17:31:38 1996 Michael Meissner + + * objdump.c (dump_section_header): Add new section flags + SEC_{EXCLUDE,SORT_ENTRIES}. + +Thu Jan 11 11:45:34 1996 Ian Lance Taylor + + * objcopy.c (filter_symbols): NULL terminate the output symbols. + (copy_object): Allocate space for a possible extra NULL pointer. + + * debug.c (debug_make_undefined_tagged_type): Make sure we are + given a kind of type we can handle. + (debug_write_type): Handle undefined enums and structs. + (debug_write_class_type): Handle undefined classes. + * prdbg.c (pr_enum_type): Handle an undefined enum. + * ieee.c (ieee_enum_type): Likewise. + +Wed Jan 10 15:33:18 1996 Ian Lance Taylor + + * Makefile.in: Updated dependencies. + (ALLOCA, MALLOC): Remove variables. + (ADDL_LIBS): Remove $(MALLOC) from definition. + * alloca.c, gmalloc.c: Remove. + +Mon Jan 8 18:02:29 1996 Ian Lance Taylor + + * ieee.c: Add global function write_ieee_debugging_info and a + bunch of static functions and structs used to write out IEEE + debugging information. + * budbg.h (write_ieee_debugging_info): Declare. + + * ieee.c (struct ieee_type): Add pslot field. + (enum builtin_types): Define. + (ieee_builtin_type): For a pointer, return a pointer to the named + type. Use enum values rather than numbers. + (ieee_alloc_type): New static function. + (ieee_read_type_index): Use ieee_alloc_type. + (parse_ieee_bb): Likewise. + (parse_ieee_ty): Likewise. Use ieee_builtin_type for array range, + rather than making a new integer type. Store the new type in the + slot, if there is one. + (parse_ieee_atn): Treat ATN10 as defining a register variable. + (ieee_regno_to_genreg): Rename from ieee_regno_to_gen. Change all + callers. + (ieee_genreg_to_regno): New static function. + + * stabs.c (parse_stab_type): Add new typename parameter. Change + all callers. + (parse_stab_range_type): Add new typename parameter. Change all + callers. + + * debug.h (struct debug_write_fns): Add tag parameter to + enum_type, start_struct_type, and start_class_type. + * debug.c (debug_write_type): Pass any tag name to + start_struct_type, debug_write_class_type, and enum_type. If + DEBUG_KIND_TAGGED, pass the name in the recursive call. + (debug_write_class_type): Accept a new tag parameter, and pass it + to start_class_type. + * prdbg.c (pop_type): Don't remove '+' character. + (pr_enum_type): Accept and use tag parameter. + (pr_start_struct_type): Likewise. + (pr_start_class_type): Likewise. + (pr_class_baseclass): Adjust algorithm used to find where to put + the baseclass name. + (pr_tag): Don't bother to insert the tag name. + + * objcopy.c: Include budbg.h. + (convert_debugging): New static variable. + (OPTION_DEBUGGING): Define. + (copy_options): Add "debugging". + (copy_usage): Mention --debugging. + (is_strip_section): Skip debugging sections if convert_debugging. + (setup_section, copy_section): Likewise. + (filter_symbols): Skip debugging symbols if convert_debugging. + (copy_object): If convert_debugging, read and write debugging + information. + (write_debugging_info): New static function. + (copy_main): Handle --debugging. + * Makefile.in (DEBUG_OBJS): New variable. + ($(OBJCOPY_PROG)): Depend upon and link against $(DEBUG_OBJS). + ($(STRIP_PROG)): Likewise. + (OBJDUMP_OBJS): Remove variable. + ($(OBJDUMP_PROG)): Use objdump.o $(DEBUG_OBJS) rather than + $(OBJDUMP_OBJS). + * binutils.texi, objcopy.1: Document --debugging. + +Thu Jan 4 16:31:21 1996 Ian Lance Taylor + + * ieee.c: New file with code to read IEEE debugging information. + * budbg.h (parse_ieee): Declare. + * rddbg.c (read_debugging_info): Handle IEEE flavour files. + (read_ieee_debugging_info): New static function. + * Makefile.in: Rebuild dependencies. + (CFILES): Add ieee.c. + (OBJDUMP_OBJS): Add ieee.o. + + * bucomm.h (xrealloc): Change type of first parameter from char * + to PTR. + +Tue Jan 2 17:44:07 1996 Ian Lance Taylor + + * Makefile.in: Add targets to automatically rebuild dependencies. + Remove targets which just listed dependencies of .o files. + (DEP): New variable. + (HFILES, GENERATED_HFILES): New variables. + (CFILES, GENERATED_CFILES): New variables. + (underscore.c): Don't do anything, just depend upon stamp-under. + (stamp-under): New target; do what underscore.c used to do. + (nlmconv.o): Depend upon sym.h and ecoff.h. + (.dep, .dep1, dep.sed, dep, dep-in): New targets. + (stage1, stage2, stage3, against, comparison): Remove. + (de-stage1, de-stage2, de-stage3): Remove. + (clean, distclean): Remove stamp-under and dep.sed. + * dep-in.sed: New file. + + Implement generic debugging support. Implement a stabs reader and + a generic printer. + * budbg.h, debug.c, debug.h, prdbg.c, rddbg.c, stabs.c: New files. + * objdump.c: Include "debug.h" and "budbg.h". + (dump_debugging): New global variable. + (usage): Mention --debugging. + (long_options): Add "debugging". + (display_bfd): Handle --debugging. + * Makefile.in (OBJDUMP_OBJS): New variable. + ($(OBJDUMP_PROG)): Use $(OBJDUMP_OBJS). + * binutils.texi, objdump.1: Document --debugging. + +Sat Dec 30 09:59:51 1995 Jeffrey A Law (law@cygnus.com) + + * nm.c ( long_options): Add "--defined-only" option. + (usage): Update for new "--defined-only" option. + (filter_symbols): Handle "--defined-only". + +Fri Dec 29 16:04:56 1995 Ian Lance Taylor + + * arparse.y: Include "bucomm.h", not . + * nlmheader.y: Don't include "sysdep.h". + +Tue Dec 26 18:23:18 1995 Ian Lance Taylor + + * nm.c (print_symdef_entry): Check return value of + bfd_get_elt_at_index. + +Sat Dec 23 11:03:16 1995 Michael Meissner + + * configure.in (DLLTOOL_DEFS): Build dlltool for PowerPC if target + is powerpc*-*-win* in addition to powerpc*-*-*pe*. + +Fri Dec 15 16:30:57 1995 Ian Lance Taylor + + * objdump.c (endian_string): New static function. + (display_target_list): Use it. + * nlmconv.c (main): Use new bfd_big_endian macro. + +Fri Dec 15 07:51:34 1995 steve chamberlain + + * dlltool.c (fill_ordinals): Start from 1 if no other instructions + given. + +Tue Dec 12 12:05:21 1995 Ian Lance Taylor + + * Makefile.in (clean): Remove $(DEMANGLER_PROG).1. From Ronald + F. Guilmette . + +Mon Dec 11 14:33:05 1995 Stan Shebs + + * mac-binutils.r: Fix copyright and version strings. + + * Makefile.in (version): Remove, no longer used. + +Fri Dec 1 14:41:56 1995 Stan Shebs + + * mpw-make.sed (install, install-only): Edit in Mac-specific + install procedure. + +Thu Nov 30 20:26:02 1995 Kim Knuttila + + * dlltool.c (ppc_jtab): The binary glue for PowerPC dll linkage, + including the return instruction. + sinfo: added a preferred alignment field. + (secdata): section data for the PowerPC version. + (make_one_lib_file): More symbols, More sections (pdata, rdata) + (make_tail): Use idata$6 instead of idata$7 for ppc. Also added a + NULL idata$3 descriptor (temporary). + +Tue Nov 28 17:23:44 1995 Doug Evans + + * dlltool.c (fill_ordinals): Don't reference d_export_vec if + there are no exported functions. + +Mon Nov 27 13:05:59 1995 Ian Lance Taylor + + * configure: Regenerate with autoconf 2.7. + +Wed Nov 22 13:17:15 1995 Ian Lance Taylor + + * dlltool.c (fill_ordinals): Start assigning ordinals at 1. + + * Makefile.in (EXPECT): Use $$r, not $${rootme}. + (check): Set r, not rootme. + +Tue Nov 21 18:04:09 1995 Ian Lance Taylor + + * configure.in: Use BFD_NEED_DECLARATION. + * acconfig.h: Put NEED_DECLARATION_FPRINTF in @TOP@ section. + * configure, config.in: Rebuild with autoconf 2.6. + +Fri Nov 17 10:34:37 1995 Ian Lance Taylor + + * Makefile.in (CC_FOR_TARGET): Use @host@ and @target@, not + $(host_canonical) and $(target_canonical). + +Thu Nov 16 03:39:20 1995 Ken Raeburn + + Version 2.6 released. + * Makefile.in (VERSION): Update to 2.6. + +Wed Nov 15 12:14:17 1995 Ian Lance Taylor + + * Makefile.in (CC_FOR_TARGET): Define. + (check): Pass CC and CFLAGS to runtest. + + * nm.c (display_rel_file): Don't require a DYNAMIC object when + dumping the dynamic symbol table. + + * objdump.c (compare_symbols): Sort global symbols before local + symbols before debugging symbols. + (objdump_print_address): Don't futz around looking for a global + symbol with the same value. + +Tue Nov 14 17:19:11 1995 Ian Lance Taylor + + * dlltool.c: Use FOPEN_* macros rather than "r" or "w". + + * dlltool.c (fill_ordinals): Correct memset call. + +Sun Nov 12 12:56:05 1995 Stan Shebs + + * mpw-make.sed (DEMANGLER_PROG): Edit out attempts to do anything + with the man page. + +Fri Nov 10 11:41:22 1995 Ian Lance Taylor + + * objcopy.c (setup_section): Copy the section lma independently of + the vma. + +Wed Nov 8 11:33:00 1995 Ian Lance Taylor + + * arsup.c (ar_open): Cast malloc return value. + +Tue Nov 7 09:01:26 1995 Kim Knuttila + + * configure.in, configure (DLLTOOL_DEFS): Added ppc target. + * dlltool.c (MPPC): Added basic PPC definitions. + +Tue Nov 7 14:02:57 1995 Ian Lance Taylor + + * configure.in: Don't treat rs6000-*-lynx* specially. + * configure: Rebuild. + * config/rslynx: Remove. + * Makefile.in: Remove @target_makefile_fragment@. + +Mon Nov 6 15:00:50 1995 Ian Lance Taylor + + * bucomm.h: Include . + * ar.c: Don't include or . + * bucomm.c, dlltool.c, nlmconv.c, objcopy.c, objdump.c: Likewise. + +Fri Nov 3 12:38:09 1995 Ian Lance Taylor + + * objdump.c: Include . + + Permit user to override DEMANGLER_PROG from command line. From + Manfred Hollstein . + * Makefile.in ($(DEMANGLER_PROG)): Depend upon + $(DEMANGLER_PROG).1. + (install): Don't depend upon $(DEMANGLER_PROG).1. Only install + $(DEMANGLER_PROG).1 if $(DEMANGLER_PROG) is not empty. + +Wed Nov 1 15:04:57 1995 Manfred Hollstein KS/EF4A 60/1F/110 #40283 + + * Makefile.in (syslex.o): add -I$(srcdir) if compiling in a + separate directory. + +Mon Oct 30 14:24:18 1995 Ian Lance Taylor + + * objdump.c (objdump_print_value): New static function. + (objdump_print_address): Use it. If we need the right section for + the symbol, and we can't find it, print an offset from the section + rather than using a symbol from some other section. + +Thu Oct 26 10:23:14 1995 steve chamberlain + + * dlltool.c (no_idata4, no_idata5): New. + (arm_jtab): Use correct encoding of jump instruction. + (usage, main, make_head, make_tail): Act on no_idata4, no_idata5. + +Wed Oct 25 12:10:07 1995 Stan Shebs + + * mpw-make.sed: Edit paths to generated y.tab.[ch] files. + +Fri Oct 20 18:40:34 1995 Ian Lance Taylor + + * binutils.texi: Change --with-targets to --enable-targets. + +Thu Oct 19 17:47:41 1995 Fred Fish + + * Makefile.in: Remove extraneous tab on otherwise empty line, + which confuses many non-GNU versions of "make". + +Wed Oct 18 16:31:58 1995 steve chamberlain + + * dlltool.c (i386_jtab, arm_jtab): New + (gen_lib_file): Rewritten to use bfd. + +Fri Oct 13 16:10:07 1995 Michael Meissner + + * Makefile.in (install): Don't give error message if dlltool + wasn't built. + +Fri Oct 13 11:04:37 1995 steve chamberlain + + * deflex.l: Allow quoting of IDs. + * defparse.y (%union): string deleted. + (command): DESCRIPTION takes ID. + * dlltool.c (gen_def_file): Quote outgoing name if + necessary. Preserve NONAME. + (gen_lib_file): Run ranlib. + (workout_prefix): Deleted. + (main, usage, long_options): Add --as, --ranlib, --ar options. + +Wed Oct 11 13:36:13 1995 steve chamberlain + + * dlltool.c (mtable): HOW_ALIGN_LONG, new. + (d_ord): Deleted. + (d_low_ord, d_high_ord, d_named_funcs): New. + (gen_exp_file): Create noname entries correctly. + (gen_lib_file): Dump exports alphabetically. + (process_duplicates): Count nonamed functions. + (fill_ordinals): Keep track of highest ord too. + (mangle_defs): Create alphabetically ordered list of names. + +Tue Oct 10 09:39:09 1995 steve chamberlain + + * Makefile.in (TOOL_PROGS): Include DLLTOOL_PROG. + +Mon Oct 9 13:06:31 1995 steve chamberlain + + * dlltool.c (add_underscore): New. + (xlate): Use new name. + (main, usage): Update. + +Fri Oct 6 14:08:51 1995 Ken Raeburn + + * sysinfo.y: Eliminate unused terminals "[" and "]" and unused + nonterminal "name". One s/r conflict remains. + + Mon Sep 25 22:49:32 1995 Andreas Schwab + + * nm.c (print_symname): Don't try to demangle an empty + name. + * objdump.c (slurp_symtab): Reset symcount if there are + no symbols. + (slurp_dynamic_symtab): Likewise, for dynsymcount. + (disassemble_data): Fix memory leak: free sorted_syms when done. + (display_bfd): Likewise, for syms and dynsyms. + (dump_relocs): Don't print header before possibly generating an + error message. + (dump_dynamic_relocs): Likewise. + + * ar.1, nm.1, objdump.1, size.1, strings.1, strip.1: Fix typos and + formatting bugs. + +Fri Oct 6 12:00:25 1995 Ian Lance Taylor + + * ar.c (do_quick_append): Comment out. + (replace_members): Add quick argument. + (main): Don't call do_quick_append. + (open_inarch): Don't call quick_append to create an empty archive. + Instead call bfd_openw/bfd_set_format/bfd_close. + +Thu Oct 5 20:53:08 1995 Ken Raeburn + + * bucomm.c: Always include time.h. + +Thu Oct 5 17:25:21 1995 Ian Lance Taylor + + * objdump.c (compare_symbols): Sort gnu_compiled and gcc2_compiled + symbols after other symbols with the same value. Likewise for + symbols which look like file names. + (objdump_print_address): Always chose the first reasonable symbol + with a given value. + +Tue Oct 3 22:38:55 1995 Ian Lance Taylor + + * arsup.c (ar_save): Use rename, not unlink/link/unlink. + +Mon Oct 2 12:10:25 1995 Ian Lance Taylor + + * strings.c (main): Exit with zero status if no files are given + and standard input is read. + +Thu Sep 28 20:03:07 1995 Stan Shebs + + * mpw-config.in: Calculate underscore and put into makefile + fragment, generate config.h. + * mpw-make.sed: New file, sed commands to edit Unix makefile + into MPW syntax. + * mpw-make.in: Remove. + * mac-binutils.r: New file, Mac resources. + +Thu Sep 28 15:49:00 1995 steve chamberlain + + * dlltool.c: (gen_exp_file): Always emit a .reloc section if + relocatable. + (imp_name_lab): New. + (gen_def_file): New. + (gen_lib_file): Use imp_name_lab. + (main): Initialize imp_name_lab. + +Mon Sep 25 12:05:34 1995 Ian Lance Taylor + + * configure.in: Call AC_HEADER_SYS_WAIT. + * configure: Rebuild. + * config.in: Rebuild. + * dlltool.c: Include "libiberty.h" and "bucomm.h". Don't include + , , or . Don't include . + Include . Use HAVE_SYS_WAIT_H to control whether to + include or define the wait macros by hand. Don't + declare xmalloc. + (gen_lib_file): Don't assume that sprintf returns the number of + characters; use strlen instead. + +Fri Sep 22 17:16:41 1995 Ian Lance Taylor + + * objdump.c (disassemble_data): Don't use the old BFD based + disassembler interface. Make info a const pointer. + +Wed Sep 13 18:33:44 1995 Ian Lance Taylor + + * objdump.c (start_address): New variable. + (stop_address): New variable. + (usage): Mention --start-address and --stop-address. + (OPTION_START_ADDRESS, OPTION_STOP_ADDRESS): Define. + (long_options): Add "start-address" and "stop-address". + (disassemble_data): Handle start_address and stop_address. + (dump_data, dump_reloc_set): Likewise. + (main): Don't set seenflag for -l. Handle OPTION_START_ADDRESS + and OPTION_STOP_ADDRESS. + * objcopy.c (parse_vma): Move to bucomm.c. + * bucomm.c (parse_vma): New function, moved in from objcopy.c. + * bucomm.h (parse_vma): Declare. + * binutils.texi, objdump.1: Document new objdump options. + +Tue Sep 12 12:37:39 1995 Ian Lance Taylor + + * Makefile.in (maintainer-clean): New target. + + * ar.c (replace_members): Don't call write_archive if nothing + changed. + + * objdump.c (disassemble_data): Add casts to avoid gcc warnings. + +Thu Sep 7 12:12:17 1995 Ian Lance Taylor + + * config.in: Rename from config.h.in. + * configure.in: Call AC_CONFIG_HEADER with config.h:config.in. + Check for config.h:config.in when creating stamp-h. + * configure: Rebuild. + * Makefile.in (stamp-h): Depend upon config.in rather than + config.h.in. Set CONFIG_HEADERS to config.h:config.in when + calling config.status. + + * Makefile.in (distclean): Remove config.h, stamp-h, and + config.log. + + * nm.c (value_format): Initialize based on BFD64 and + BFD_HOST_64BIT_LONG. + (print_radix): New static variable. + (set_print_radix): Set print_radix. Adjust changes to + value_format. + (print_value): New static function, to print 64 bit octal and + decimal values correctly. + (print_symbol_info_bsd): Check BFD64, not BFD_HOST_64_BIT. Use + print_value. + (print_symbol_info_sysv): Use print_value. + (print_symbol_info_posix): Likewise. + +Wed Sep 6 15:02:55 1995 Ian Lance Taylor + + * Makefile.in (*.o): Remove incorrect dependencies on + $(BFDDIR)/hosts/std-host.h. + + * Makefile.in (INSTALL_DATA): Add -m 644. + (INSTALL_XFORM1): Likewise. + (CC_FOR_BUILD): Set to @CC_FOR_BUILD@ rather than $(CC). + (mostlyclean): Remove config.log. + (distclean): Remove config.cache. + + * configure.in: Call BFD_CC_FOR_BUILD and BFD_BINARY_FOPEN. + * configure: Rebuild. + +Tue Sep 5 20:22:42 1995 Ian Lance Taylor + + * configure.in: Rewrite to use autoconf. + * aclocal.m4: New file. + * configure: New file, built by autoconf. + * acconfig.h: New file. + * config.h.in: New file, built by autoheader. + * Makefile.in: Various changes for new configure script. Also: + (PROGS): Remove $(SYSINFO_PROG). + (ALL_CFLAGS): Remove $(TDEFINES). + (version.o): Use $(ALL_CFLAGS). + (cplus-dem.o, dlltool.o, nlmconv.o): Likewise. + (sysdump.o): Depend upon bucomm.h and config.h. + (srconv.o, arsup.o, strings.o): Depend upon config.h. + (filemode.o): Don't depend upon ../bfd/sysdep.h. + (bucomm.o): Depend upon config.h, not ../bfd/sysdep.h. + (size.o, objdump.o, nm.o, ar.o, objcopy.o): Likewise. + (nlmheader.o, nlmconv.o): Likewise. + (distclean): Don't remove sysdep.h. + * bucomm.h: Include "ansidecl.h", , and "config.h". + Include "fopen-same.h" or "fopen-bin.h", based on + USE_BINARY_FOPEN. Include , and declare errno if it is + not a macro. Include , , , + , and if they are present. Declare strchr, + strrchr, and strstr if no string header file exists. Include + if it exists and does not. Define + O_RDONLY and O_RDWR if necessary. + * ar.c: Don't include "sysdep.h". Do include and + . Use HAVE_GOOD_UTIME_H rather than POSIX_UTIME. Use + HAVE_UTIMES rather than !USE_UTIME. Don't include , and + don't declare errno. + * arsup.c: Don't include . + * bucomm.c: Don't include "sysdep.h". Include , + , and . Include if it defines + time_t. Define time_t if necessary. + * coffdump.c: Don't include "sysdep.h". + * coffgrok.c, filemode.c, nlmconv.c, size.c: Likewise. + * srconv.c, strings.c: Likewise. + * nm.c: Don't include "sysdep.h". Don't try to define HAVE_SBRK. + * objcopy.c: Don't include "sysdep.h". Include and + . + (simple_copy): Use creat rather than assuming that O_CREAT is + defined. + * objdump.c: Don't include "sysdep.h". Use + NEED_DECLARATION_PRINTF rather than !FPRINTF_ALREADY_DECLARED. + * sysdump.c: Include "bfd.h" and "bucomm.h". Don't include + "sysdep.h" or . + (dump_symbol_info): Rename from symbol_info. Change all callers. + +Mon Sep 4 14:30:00 1995 Ian Lance Taylor + + * configure.in (host_makefile_frag): Don't set. Substitute for + @CC@, @CFLAGS@, @HDEFINES@ and @LDFLAGS@ in Makefile. + * Makefile.in (AR_FLAGS): Set to rc rather than qv. + (CC): Define as @CC@. + (CFLAGS): Set to @CFLAGS@. + (LDFLAGS): Define as @LDFLAGS@. + (ALL_CFLAGS): Use @HDEFINES@ rather than $(HDEFINES). + + * configure.in: Don't bother to call config.bfd for each target. + Just call it for the default target, and use the shell variable to + decide whether underscores are used. + +Thu Aug 31 19:21:48 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * configure.in: match i[3-6]86-*-win32, not just i386-*-win32. + +Thu Aug 31 16:30:22 1995 steve chamberlain + + * dlltool.c (add_indirect): New. + (asm_prefix): New + (gen_exp_file): Timestamp should be 0. Insert prefix when + needed. New code for indirection. + (gen_lib_file): Timestamp should be 0. Insert prefix + when needed. + (usage): Document --add-indirect. + (main): Cope with new option. + + * objdump.c (dump_private_headers): New. + (usage): Document new option. + (long_option): Add private-headers. + (dump_bfd_private_header): New. + (main): Cope with new option. + +Thu Aug 31 04:09:16 1995 Doug Evans + + * dlltool.c (run): Add missing 3rd arg to waitpid. + +Wed Aug 30 11:02:11 1995 steve chamberlain + + * Makefile.in (TOOL_PROGS): Include dlltool if needed. + +Tue Aug 29 13:25:21 1995 steve chamberlain + + * dlltool.c (rva): Deleted. + (rvaafter, rva_before): Use new assembler pseudo. + (flush_page, gen_exp_file, gen_lib_file): Use new way of RVAing. + (gen_exp_file): Don't generate .edata if no need. + (gen_lib_file): Don't make timestamp. + Put _iname in idata$7. + (workout_prefix): Fix memory initialization bug. + (usage): Tidy up, delete many single char options. + (main): rva option is gone. + +Mon Aug 21 18:41:28 1995 steve chamberlain + + * dlltool.c (options): image-base is a synonym for rva. + (gen_lib_file): Put dll name into ibase$7. + +Sun Aug 20 09:59:00 1995 steve chamberlain + + Modified to generate archives and objects rather than .s files. + * dlltool.c (run) New function. + (gen_exp_file, gen_lib_file): Use run. + (workout_prefix): New. + (usage): Document new options. + (main): Parse new options. + +Wed Aug 16 16:26:52 1995 steve chamberlain + + * dlltool.c (gen_exp_file): Fix RVA handling. + (rva_s, rva_n): Delete. + +Fri Aug 11 18:27:18 1995 Ian Lance Taylor + + * nm.c (main): Ignore -e. + +Thu Aug 10 17:35:00 1995 Ken Raeburn + + * Makefile.in (config.texi): New target. Write out a setting for + texinfo variable VERSION. + (binutils.dvi, binutils.info): Depend on it. + * binutils.texi: Include it, and reference @value{VERSION} instead + of explicitly specifying 2.2(!). + +Thu Aug 10 16:07:53 1995 Ian Lance Taylor + + * coffgrok.c (do_type): Handle array dimensions the same way gdb + does. + +Tue Aug 8 17:10:42 1995 steve chamberlain + + * dlltool.c (mtable): New fields. + (ASM_RVA_BEFORE, ASM_RVA_AFTER): New. + (flush_page): Use new macros. + +Sat Aug 5 00:16:37 1995 Jeff Law (law@snake.cs.utah.edu) + + * objcopy.c (mark_symbols_used_in_relocations): Handle sections + with no relocations. + * coffgrok.c (do_sections_p1): Likewise. + +Mon Jul 31 12:51:06 1995 Ian Lance Taylor + + * strings.c (print_strings): For compatibility with existing + strings programs, print strings which are not terminated with a + null byte or a newline. + * binutils.texi, strings.1: Update documentation accordingly. + + * ar.c (replace_members): For compatibility with existing ar + programs, permit users to add the same file multiple times. + +Tue Jul 25 11:21:53 1995 Ian Lance Taylor + + * strings.c (DATA_FLAGS): Remove SEC_DATA. + (main): If no file names are given, scan standard input. + * binutils.texi, strings.1: strings now scans non-data sections by + default. + +Mon Jul 24 13:52:28 1995 J.T. Conklin + + * srconv.c (wr_hd): Set afl field to 4 for bfd_arch_sh. + (writeINT): When size == -2, use 2 bytes for the h8300 and 4 bytes + for the sh. + + * sysdump.c (fillup): Return size - 1, the last byte is a checksum + and shouldn't be counted. + * sysroff.info (hd): Changed segment identifier from a byte to a 1 + bit field. The sysroff 2.0-01 specification seems to be in error + here. Reduce width of following "spare" field from 4 to 3 bits. + (rl): Changed order and width of first 4 bitfields to correspond + to sysroff specification. + (dln_head, dln_inside, dln_tail): Removed. + +Tue Jul 18 23:00:03 1995 Fred Fish + + * nm.c (sort_symbols_by_size): Enclose expression being casted + in parens so result is casted, not just first operand. Can't + do pointer arithmetic on void* pointers. + +Fri Jul 14 13:42:42 1995 J.T. Conklin + + * sysdump.c (dh): Changed format of output to be 16 hex digits + followed by 16 ascii characters, similar to Emacs' hexl-mode, + to make it easier to read. + (xcalloc): fix typo. + +Thu Jul 13 15:27:44 1995 J.T. Conklin + + * srconv.c (wr_tr): Write out handcrafted tr block. + (walk_tree_symbol): Use evallen and evalue instead of + vallen & value because of corresponding changes in + sysroff.info. + + * sysdump.c (sysroff_swap_tr_in, sysroff_print_tr_out): New + functions. + + * sysroff.info (tr): the tr block is a special case --- a block + without contents --- which can't be handled by generated code. + (den, dpp): only first byte is present for DENend, DPPend. + (dsy): describe a conditional portion of block, rename some fields. + (dps): describe a conditional portion of block. + (dfl): removed. + + * sysinfo.y (yyerror): write error message to standard error. + +Thu Jul 13 10:43:59 1995 Ian Lance Taylor + + * Makefile.in (DISTSTUFF): Add arparse.h and sysinfo.h. + (mostlyclean): Remove y.output. + (clean): Remove sysroff, sysroff.c, sysroff.h, and sysinfo. + + * nlmconv.c (powerpc_mangle_relocs): Cast memset arg to size_t. + * objcopy.c (copy_object): Likewise. + + * nm.c (HAVE_SBRK): Define except on amigados and WINDOWS_NT. + (struct size_sym): Define. + (show_stats): New static variable. + (long_options): Add undocumented option "stats". + (main): Print memory stats if requested. + (sort_bfd, sort_dynamic, sort_x, sort_y): New static variables. + (numeric_forward): Use minisymbols rather than asymbols. + (non_numeric_forward): Likewise. + (size_forward1): Rename from size_forward. Use minisymbols. + (size_forward2): New static function. + (sort_symbols_by_size): Take new arguments dynamic, size, and + symsizep. Use minisymbols. Don't store the size back in the + symbol; store in a newly allocate struct size_sym array. + (display_rel_file): Read minisymbols rather than asymbols. Set + sort_* variables. Call print_size_symbols if sorting by size. + (filter_symbols): Take new arguments dynamic and size. Use + minisymbols. + (print_symbols): Likewise. Call print_symbol for actual printing. + (print_size_symbols): New static function. + (print_symbol): New static function. + +Wed Jul 12 10:43:05 1995 Ian Lance Taylor + + * objdump.c (dump_section_stabs): Only print each stabs section + once. + (compare_relocs): Make it clear to gcc that this always returns a + value. + +Wed Jul 12 10:40:23 1995 H.J. Lu + + * objcopy.c (simple_copy): Preserve errno on failure. + (smart_rename): Print error mesage if simple_copy fails. + +Tue Jul 11 13:10:52 1995 J.T. Conklin + + * sysdump.c: re-indented file. + (module): read blocks sequentially instead of trying to parse + them, as that would require changing the parser recognize the + difference between a DPSstart and DPSend block. + (getone): Add break's between switch blocks as appropriate. + (object_body_list): parse blocks according to sysroff spec. + +Mon Jul 10 12:37:25 1995 J.T. Conklin + + * sysroff.info: re-indented file, prior formatting was confusing + because it was indentation did not reflect nesting of conditional + records. Change "space size within segment" record in hd record + from bit to byte. + + * sysinfo.y (cond_it_field): Use xcalloc instead of calloc. + + * srconv.c (wr_cs): Reformatted cs header array, tag each byte + with a comment describing the field. + (wr_unit_info): Use SEEK_SET macro instead of constant 0. + (main): Use FOPEN_WB macro instead of literal "wb". + * sysroff.info: Remove fdl (dfl) field from cs block. Compare + ptr->type with ED_TYPE_CONST instead of constant 2 in ed block. + +Tue Jul 4 14:48:42 1995 Ian Lance Taylor + + * nm.c (size_forward): Check yf against yn, not xn. + + * objcopy.c (copy_archive): Record all output BFD's, and close + them before unlinking them and removing the temporary directory, + to avoid NFS problems. + + * ar.c (replace_members): In verbose messages, use 'r' when + replacing a member, and 'a' when adding one. + + * ar.c (ar_truncate): New static variable. + (normalize): Change return type to const char *. Add abfd + argument. Change all callers. If ar_truncate, chop the filename + to abfd->ar_max_namelen. + (main): For the 'f' modifier, set ar_truncate to true. Don't + change quick_append to replace if ar_truncate is true. + (do_quick_append): If ar_truncate, set BFD_TRADITIONAL_FORMAT. + (write_archive): Likewise. + * binutils.texi, ar.1: Document 'f' modifier. + + * objcopy.c (enum strip_action): Define strip_unneeded. + (OPTION_STRIP_UNNEEDED): Define. + (strip_options): Add "strip-unneeded". + (copy_options): Likewise. + (copy_usage): Mention --strip-unneeded. + (strip_usage): Likewise. + (is_strip_section): Strip debugging sections if strip_unneeded. + (filter_symbols): If strip_unneeded, only keep BSF_KEEP symbols. + (copy_object): If strip_all, discard symbols without checking + discard_locals. + (copy_object): Call filter_symbols if strip_unneeded. + (setup_section): Strip debugging sections if strip_unneeded. + (copy_section): Likewise. + (strip_main): Handle OPTION_STRIP_UNNEEDED. + (copy_main): Likewise. + * binutils.texi, objcopy.1, strip.1: Document --strip-unneeded. + +Mon Jul 3 14:16:47 1995 Steve Chamberlain + + * configure.in (i386-*-win32): New configuration. + * dlltool.c (killat, xlate, usage, long_options, main): + Understand and cope with -k option. + +Sat Jul 1 12:25:15 1995 Fred Fish + + * ar.c: (extract_file): Change "#if POSIX_UTIME" to + "#ifdef POSIX_UTIME" to match other tests of POSIX_UTIME + and avoid lossage when POSIX_UTIME is not defined at all. + +Wed Jun 28 17:51:24 1995 Steve Chamberlain + + * ar.c: (print_contents.c, extract_file, do_quick_append): + Malloc buffers rather than allocate on stack (so it works + on NT). + * deflex.l: Names can have an @ in them. + * dlltool.c: Loads of stuff. Can now generate .imp files which + work with NT .dlls. + +Thu Jun 22 19:10:50 1995 Stan Shebs + + * mpw-make.in (demangle.c.o): Remove. + (arparse.h): Depend on arparse.c instead of arparse.y. + +Wed Jun 21 17:32:45 1995 Ken Raeburn + + * Makefile.in (DISTSTUFF): Don't include info here. + (diststuff): Include it here. + (realclean): Remove *.info. + + * objdump.c (compare_relocs): If relocation entries have the same + address, keep them in file order. + +Mon Jun 19 09:06:49 1995 Steve Chamberlain + + * dlltool.c: Change names of generated files. .*.s-> -*.s + + * objdump.c (dump_section_stabs): Check for names + which are supersets of selected names. + +Wed Jun 14 19:43:52 1995 Doug Evans + + * dlltool.c (mtable, ARM jump): Must redirect via pc offsetable ptr. + +Wed Jun 14 13:27:22 1995 Steve Chamberlain + + * deflex.l, defparse.y, dlltool.c: New files. + * Makefile.in, configure.in: Support for them. + +Mon Jun 12 11:27:54 1995 Steve Chamberlain + + * sysdump.c: Include sysdep.h + (main): Open input with FOPEN_RB. + +Fri Jun 9 17:26:11 1995 Michael Meissner + + * objdump.c (wide_output): New flag variable. + (usage): Print new -w, --wide options. + (long_options): Add --wide support. + (dump_section_header): If --wide, don't print a newline between + the section's first line and the flags. + (objdump_print_address): Use unsigned comparisons for the binary + search, not signed. + (disassemble_data): If --wide, don't put a \n between the + disassembly output and relocation information. + (main): Support -w option being the same as --wide. + +Thu Jun 1 17:09:27 1995 Ken Raeburn + + Sat May 6 08:52:24 1995 H.J. Lu (hjl@nynexst.com) + + * objcopy.c (smart_rename): make it smarter, clean up + if rename () fails. + +Tue May 30 14:24:15 1995 Ken Raeburn + + * Makefile.in: Delete lines with lots of #### because four or more + indicate a point for makefile fragment substitution. + +Tue May 9 17:17:05 1995 Michael Meissner + + * configure.in: Don't build nlmconv on PowerPC eabi any more, it + is not needed. + +Thu Apr 27 20:21:24 1995 Doug Evans + + * Makefile.in (EXPECT): Define. + (RUNTEST): Use one in source tree if present. + (check): Set `rootme' for $(EXPECT). + +Wed Apr 26 18:26:21 1995 Steve Chamberlain + + * srconv.c (main): Add support for -n option which disables + prescan of common symbols. + (wr_ob): If reading past the end of a section, fill with zeros. + +Tue Apr 25 19:14:37 1995 Ken Raeburn + + * objdump.c (dump_section_header): Display load address after + virtual memory (run-time) address. + +Wed Apr 19 09:44:06 1995 Jason Merrill + + * Makefile.in (cplus-dem.o): Pass -DVERSION='"$(VERSION)"' to the + compile. + (DEMANGLER_PROG): No longer uses version.o. + +Mon Apr 10 13:29:49 1995 Stan Shebs + + Merge in support for Mac MPW as a host. + (Old change descriptions retained for informational value.) + + * mpw-config.in (TDEFINES): Define as empty in makefile frag. + + * mpw-config.in: Create mk.tmp, define ARCHDEFS in it. + + * mpw-config.in: New file, MPW configure fragment for binutils. + * mpw-make.in (install-only): New target. + (install): Also depend on install-only. + + * mpw-make.in (cplusfilt): Renamed from c++filt. + (INCLUDES): Add more paths. + + * mpw-make.in: New file, MPW makefile fragment for binutils. + (Normally automatically generated from Makefile.in.) + +Mon Mar 27 11:52:57 1995 Ian Lance Taylor + + * ar.c (write_archive): Call make_tempname to get output file + name, rather than using a fixed name based on the input file. + + * objcopy.c (make_tempname): Copy from here... + * bucomm.c (make_tempname): ...to here, and make global. + * bucomm.h (make_tempname): Declare. + +Fri Mar 24 11:47:42 1995 Ian Lance Taylor + + * strings.c: Include "bfd.h" before other headers. Include + "sysdep.h". + * bucomm.c (print_arelt_descr): Cast st_uid and st_gid to long, + and print them with %ld. + +Fri Mar 10 13:09:42 1995 Ian Lance Taylor + + * objcopy.c (strip_options): Add --keep-symbol. + (copy_options): Likewise. + (copy_usage): Mention --keep-symbol and -K. + (strip_usage): Likewise. + (keep_symbols): New static variable. + (is_strip_symbol): Adjust the return value according to + keep_symbols. + (strip_main): Handle -K. For -N, check that -K was not given. + (copy_main): Likewise. + * binutils.texi, objcopy.1, strip.1: Document -K. + +Mon Mar 6 13:33:47 1995 Stan Shebs + + * objcopy.c (copy_archive): Check result of mkdir. + (copy_main): Cast an xmalloc result. + + * objdump.c (usage): Break long format string into shorter ones. + +Mon Mar 6 13:46:12 1995 Ian Lance Taylor + + * bucomm.c (list_supported_targets): New function. + * bucomm.h (list_supported_targets): Declare. + * ar.c (usage): Call list_supported_targets. + * nm.c (usage): Likewise. + * objcopy.c (copy_usage, strip_usage): Likewise. + * objdump.c (usage): Likewise. + * size.c (usage): Likewise. + * strings.c (usage): Likewise. + +Tue Feb 28 15:13:58 1995 Ian Lance Taylor + + * bucomm.c (print_arelt_descr): Cast st_size to long before + passing it to fprintf. + +Fri Feb 17 13:36:45 1995 Ian Lance Taylor + + * objcopy.c (struct section_list): Add fields remove, set_flags, + and flags. Change adjust from boolean to enum. + (remove_sections): Remove static variable. + (sections_removed): New static variable. + (copy_options): Add --set-section-flags. + (copy_usage): Mention --set-section-flags. + (parse_flags): New static function. + (find_section_list): New static function. + (is_strip_symbol): Change return type from int to boolean. + (is_strip_section): New static function. + (filter_symbols): Call is_strip_section. + (copy_object): When adding sections, check for specified flags or + VMA. Call filter_symbols if any sections are being removed. + (setup_section): Use find_section_list function rather than + looking through remove_sections and adjust_sections. Handle + --set-section-flags. + (copy_section): Use find_section_list rather than looking through + remove_sections. + (strip_main): Use find_section_list instead of adding items to + sections_removed. + (copy_main): Use find_section_list instead of adding items to + sections_removed and adjust_sections. Handle --set-section-flags. + * binutils.texi, objcopy.1: Document --set-section-flags. + +Tue Feb 14 18:03:03 1995 Ian Lance Taylor + + * objdump.c (with_source_code): New global variable. + (usage): Mention -S/--source. + (long_options): Add --source. + (prev_functionname, prev_line): New static variables. + (struct print_file_list): Define. + (print_files): New static variable. + (skip_to_line, show_line): New static functions. + (disassemble_data): Call show_line to handle -l and -S. + (main): Handle -S. + * binutils.texi, objdump.1: Document -S/--source. + +Thu Feb 9 16:11:53 1995 Ian Lance Taylor + + * objcopy.c (copy_usage): Rename parameter to avoid shadowing. + (strip_usage): Likewise. + + * objcopy.c (struct section_add): Define. + (add_sections): New static variable. + (copy_options): Accept --add-section. + (copy_usage): Mention --add-section. + (copy_object): Add sections from the add_sections list. + (copy_main): Handle --add-section. + * binutils.texi, objcopy.1: Document --add-section. + +Wed Feb 1 15:04:57 1995 Ken Raeburn + + * objdump.c (disassemble_data): Pass section offset, not absolute + address, to bfd_find_nearest_line. + + * nlmconv.c (powerpc_mangle_relocs): Don't use const with + reloc_howto_type. + +Thu Jan 26 18:50:06 1995 Ian Lance Taylor + + * objdump.c (compare_symbols): Use bfd_asymbol_value (VAR) rather + than VAR->value. + (objdump_print_address): Likewise. + (disassemble_data): Don't change the symbol values. It can + confuse bfd_canonicalize_reloc. + +Thu Jan 26 12:03:56 1995 Michael Meissner + + * configure.in: Add support for powerpc-*-ebai. + +Wed Jan 18 10:02:12 1995 Steve Chamberlain + + * coffdump.c: Include sysdep.h. + (dump_coff_type): Handle coff_secdef_type. + * coffgrok.c : Include sysdep.h. + * srconv.c: Include libiberty.h + (absolute_p, dty_start, dty_end, dump_tree_structure): Remove. + +Wed Jan 18 12:24:14 1995 Ian Lance Taylor + + * coffdump.c (dump_coff_scope): Cast pointer to unsigned long for + printf. + * coffgrok.c: Include bucomm.h. Don't declare xmalloc. + (push_scope): Declare type of parameter link. + * size.c: Include libiberty.h. + * srconv.c: Include bucomm.h. + (find_base): Declare at top of file. + (wr_hd): Add default case to architecture switch. + (wr_dps_start): Declare type of parameter nest. + (wr_du): Comment out variables used only in commented out blocks. + (wr_dus): Remove unused variable i. + (wr_sc): Remove unused variables myinfo, low, and high. + * strings.c: Include libiberty.h. + * sysdump.c: Include . + +Tue Dec 20 19:13:44 1994 Ian Lance Taylor + + * ar.c (main): Ignore 'f' modifier used on HP/UX 9. + +Thu Dec 15 17:34:12 1994 Stan Shebs + + * ar.c, nm.c, objcopy.c, objdump.c: Include progress.h. + * ar.c, nm.c, objcopy.c, objdump.c (main): Add START_PROGRESS + and END_PROGRESS. + * ar.c (map_over_members, open_inarch): Call PROGRESS. + * nm.c (main, display_archive, filter_symbols, print_symbols): + Call PROGRESS. + + * objcopy.c (copy_usage): Break up long usage string. + +Wed Dec 14 15:51:56 1994 Ken Raeburn + + * objcopy.c (copy_object): Don't bother setting status after + nonfatal() "call", because it won't return. + +Fri Dec 9 00:22:54 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (powerpc_mangle_relocs): Don't switch a reloc to use + the section symbol if the symbol is undefined. + +Thu Dec 8 14:45:50 1994 Ken Raeburn + + * objcopy.c (add_strip_symbol): Cast return value of xmalloc. + +Wed Nov 30 11:05:43 1994 Ian Lance Taylor + + * ar.c (replace_members): Pass current->filename to normalize when + checking for duplicates, because the filename of a newly added + file will not have been normalized yet. + +Thu Nov 17 15:00:13 1994 Ian Lance Taylor + + * ar.c (main): Don't call do_quick_append if any of the archive + names are longer than 14 characters. + + * objcopy.c (main): Fix is_strip test. From + pirker@eiunix.tuwien.ac.at (Martin Pirker). + +Thu Nov 17 15:37:19 1994 Mark W. Eichin + + * objcopy.c (add_strip_symbol): New function, adds a name to an + explicit list of symbols to strip. + (is_strip_symbol): New function, reports whether the name argument + is in the explicit list. + (filter_symbols): Check against is_strip_symbol above all. + (strip_main): Recognize -N option. If used, don't default to + strip_all. + (copy_main): Recognize -N option. + (strip_usage): Document -N and --strip-symbol options. + (copy_usage): Ditto. + * objcopy.1, strip.1, binutils.texi: Document -N and + --strip-symbol options. + +Tue Nov 8 13:12:54 1994 Ian Lance Taylor + + * objdump.c (display_target_list, display_info_table): Pass an + array to tmparg, rather than NULL, since some systems can't handle + NULL. + + * objcopy.c (copy_archive): Keep a list of the names of the + temporary files we created. Close each input BFD after we open + its successor. + +Mon Nov 7 15:48:39 1994 Ken Raeburn + + * Makefile.in (VERSION): Bump to 2.5.3. + +Thu Nov 3 19:04:34 1994 Ken Raeburn + + * Makefile.in (install-info): Install info files from whatever + directory they were found in. + + Patch from DJ Delorie: + * configure.bat: do c++filt -> cxxfilt right + + * sysinfo.y: Include system header files early, so any potential + declaration of abort() occurs before its use. + + * strings.c (strings_file): Try opening the file in binary mode + first. + +Wed Nov 2 15:44:13 1994 Ian Lance Taylor + + * ar.c (main): Treat ar qs like ar rs. + +Tue Oct 25 16:19:25 1994 Ian Lance Taylor + + * objcopy.c (gap_fill): Explicitly initialize, for clarity. + (pad_to_set, pad_to): New static variables. + (copy_options): Accept --pad-to. + (copy_usage): Mention --pad-to. + (copy_object): Support --pad-to. + (compare_section_vma): Sort non loadable sections to the front. + Sort sections with the same VMA by size. + (copy_main): Handle --pad-to. + * binutils.texi, objcopy.1: Document --pad-to. + +Thu Oct 20 13:51:31 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objcopy.c (gap_fill_set, gap_fill): New static variables. + (copy_options): Accept --gap-fill. + (copy_usage): Mention --gap-fill. + (copy_object): Support --gap-fill. + (get_sections, compare_section_vma): New static functions. + (copy_main): Handle --gap-fill. + * binutils.texi, objcopy.1: Document --gap-fill. + +Wed Oct 19 14:09:16 1994 Ian Lance Taylor + + * Makefile.in (check): Add a dummy else clause to the if + statement. + + * objcopy.c (copy_object): Revert yesterday's change. + * binutils.texi, objcopy.1: Remove special mention of --set-start + and `binary' output format. + +Tue Oct 18 11:12:01 1994 Ian Lance Taylor + + * objcopy.c (copy_object): If the output file format is `binary', + and the start address was not set using --set-start, default the + start address to zero. This hack is because the `binary' output + file format uses the start address to set the virtual address of + the first byte in the file. + * binutils.texi, objcopy.1: Add some notes on generating S-records + and binary files. + + * nm.c (print_symdef_entry): Call print_symname to print the + symbol name, so that --demangle works. + + * Makefile.in (mostlyclean): Remove tmpdir. + + * objcopy.c (struct section_list): Add fields used, adjust, val. + (adjust_start, set_start_set, set_start): New static variables. + (adjust_section_vma, adjust_sections): New static variables. + (copy_options): Add --adjust-start, --adjust-vma, + --adjust-section-vma, --adjust-warnings, --no-adjust-warnings, + --set-start. + (parse_vma): New static function. + (copy_usage): Mention new options. + (copy_object): Handle --set-start and --adjust-start. + (setup_section): Correct type of last argument to PTR. Set used + field if section is removed. Handle --adjust-vma and + --adjust-section-vma. + (copy_section): Correct type of last argument to PTR. + (mark_symbols_used_in_relocations): Likewise. + (strip_main): Clear used field when handling -R. + (copy_main): Handle new options. + * binutils.texi (objcopy): Document new options. + * objcopy.1: Document new options. + +Fri Oct 14 14:38:13 1994 Ian Lance Taylor + + * configure.in (configdirs): Remove definition--testsuite is no + longer configured. + * Makefile.in (testsuite): Remove target. + (site.exp): New target. + (check): Rewrite. + (clean, distclean): Don't recur into testsuite directory. + +Thu Oct 13 19:24:09 1994 Ken Raeburn + + * Makefile.in (VERSION): Updated to 2.5. + * Version 2.5 released. + +Tue Oct 11 15:26:42 1994 Ian Lance Taylor + + * Makefile.in (sysdump.o): Depends upon sysroff.c. + +Mon Oct 10 13:50:30 1994 J.T. Conklin (jtc@rtl.cygnus.com) + + * nlmconv.c (link_inputs): Pass -Ur flag to ld so that the + ctor/dtor tables needed by C++ programs are built. + +Sun Oct 9 18:04:00 1994 Jim Wilson (wilson@sphagnum.cygnus.com) + + * Makefile.in (srconv.o): Add dependence on sysroff.c. + +Tue Oct 4 12:19:51 1994 Ian Lance Taylor + + * configure.in: Use ${config_shell} when running config.bfd. + + * Makefile.in (sysroff.h): Split target away from sysroff.c. + (srconv.o, sysdump.o): New targets. + (srconv, sysdump): Don't depend upon sysroff.c. + +Wed Sep 28 13:04:34 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * Makefile.in (arparse.c): Don't ignore errors from mv. + (sysinfo.c): Likewise. Also, depend upon arparse.c, to prevent a + parallel make from trying to build both arparse.c and sysinfo.c + simultaneously. + (nlmheader.c): Similar change. + (arparse.h): Separate target from arparse.c, so that a parallel + make does not try to build both at once. Depend upon arparse.c. + (sysinfo.h): Similar change. + + * objdump.c (disassemble_data): Pass the reloc buffer to free, not + the pointer used to loop over the relocs. + +Sat Sep 24 16:16:57 1994 Stan Shebs (shebs@andros.cygnus.com) + + * objdump.c (disassemble_data): Cast result of xmalloc. + +Wed Sep 21 19:30:35 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * objdump.c (sorted_syms, sorted_symcount): New global variables. + (objdump_print_address): Use sorted_syms and sorted_symcount + instead of syms and symcount. + (disassemble_data): Don't bother to get the relocs before looping + over the sections. Before filtering and sorting the symbol table, + copy it into sorted_syms. + +Fri Sep 16 11:27:39 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * objdump.c (struct objdump_disasm_info): Add field require_sec. + (objdump_print_address): If aux->require_sec, require that the + symbol be in aux->sec even if HAS_RELOC is not set. If we can't + find a smaller symbol in the right section, look for a larger one. + (disassemble_data): Set aux.require_sec around the + objdump_print_address call for the instruction address. + +Thu Sep 15 21:43:17 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ar.c: Call xexit rather than exit. + (output_filename, output_file, output_bfd): New static variables. + (remove_output): New static function. + (main): Call xatexit (remove_output). Call xexit rather than + returning. + (extract_file): Set output_filename and output_file while output + file is open. + (write_archive): Likewise, but use output_bfd, not output_file. + * arsup.c: Include libiberty.h. Call xexit rather than exit. + * bucomm.c: Likewise. + + * objdump.c (disassemble_all): New global variable. + (usage): Document --disassemble-all. + (long_options): Add disassemble-all as a synonym for -D. + (compare_symbols): Make pointers const. + (compare_relocs): New static function. + (disassemble_data): Rename disassemble to disassemble_fn to avoid + shadowing. If dump_reloc_info, print relocs along with + disassembly. Skip sections which are not SEC_CODE unless + disassemble_all or only is set. + (display_bfd): Don't call dump_relocs if disassemble is set. + (main): Accept and handle -D. + * binutils.texi: Document -D/--disassemble-all. + * objdump.1: Likewise. + +Wed Sep 14 12:19:07 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * objdump.c (disassemble_data): Initialize prevline to 0. Make + prev_function non const. Copy functionname into an malloc buffer + when setting prev_function, instead of assuming that the string + will last forever. + + * nm.c: Include libiberty.h. + (sort_by_size): New static variable. + (long_options): Add --size-sort. + (usage): Mention --size-sort. + (numeric_forward): Make static. Change from void * to PTR. + (numeric_reverse): Likewise. + (non_numeric_forward, non_numeric_reverse): Likewise. + (sorters): Change declaration from void * to PTR. + (size_forward, sort_symbol_by_size): New static functions. + (display_rel_file): Handle sort_by_size. + (filter_symbols): If sort_by_size, discard absolute and undefined + symbols. + * binutils.texi (nm): Document --size-sort. + * nm.1: Document --size-sort. + +Tue Sep 13 21:06:06 1994 Jeff Law (law@snake.cs.utah.edu) + + * objcopy.c (copy_main): Initialize input_filename and + output_filename to NULL. + +Tue Sep 13 14:17:24 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * Makefile.in (version.o): Depend upon Makefile, so that version.o + gets rebuilt when make variable VERSION is changed. + + * objdump.c (dump_section_header): Print the SEC_NEVER_LOAD flag. + +Wed Aug 24 12:40:09 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * configure.in: Change i[34]86 to i[345]86. + +Tue Aug 23 11:00:40 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * ar.c (ranlib_touch): Don't update the archive map if there isn't + one. + +Mon Aug 22 16:02:18 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * ar.c: Include libiberty.h. + (inarch): Remove variable. + (map_over_members): Make static. Add arch argument, and use it + instead of inarch. Change all callers. + (main): Treat --version as -v. Accept -t argument. Accept any + number of archive arguments. Catch and use open_inarch return + value, rather than using inarch. + (open_inarch): Return newly opened BFD, rather than using inarch. + (do_quick_append): Make archive_filename const. + (write_archive): Add iarch argument, and use it instead of inarch. + Change all callers. + (delete_members, move_members, replace_members): Likewise. + (ranlib_only): Don't exit on success. Catch and use open_inarch + return value. + (ranlib_touch): New function. + * arsup.h (map_over_members): Don't declare. + (ar_end, ar_extract): Declare. + (open_inarch): Change return value in declaration to bfd *. + * arsup.c (map_over_list): Make static. Always pass two arguments + to function. Add arch argument, and use it instead of inarch. + Change all callers. + (ar_directory_doer): Make static. Add ignored second argument. + Change all callers. + (ar_directory): Use open_inarch return value rather than inarch. + (ar_addlib_doer): Make static. + (ar_addlib): Use open_inarch return value rather than inarch. + (ar_extract): Remove unused local variable abfd. + +Thu Aug 11 14:55:57 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + Add support for removing named sections to objcopy and strip. + * objcopy.c (struct section_list): Define. + (remove_sections): New static variable. + (strip_options, copy_options): Add remove-section. + (copy_usage, strip_usage): Mention -R and --remove-section. + (setup_section): If section is in remove_sections list, ignore it. + (copy_section): Likewise. + (strip_main, copy_main): Handle -R. + * binutils.texi, objcopy.1, strip.1: Document new options. + +Wed Aug 10 10:19:55 1994 Stan Shebs (shebs@andros.cygnus.com) + + * nlmconv.c (powerpc_mangle_relocs): Rename symvalue to sym_value, + so as not to conflict with the symvalue typedef in bfd.h. + +Mon Aug 1 13:19:09 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * nlmheader.y: Per current NetWare docs, accept a revision number + of 0 and treat a revision number greater than 26 as 0. + +Mon Jul 25 12:58:36 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * objdump.c (objdump_print_address): Correct handling of end of + symbols when looking for next symbol with a different value. + +Fri Jul 22 16:48:34 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * nm.c (numeric_forward): Treat undefined symbols as "less than" + defined symbols with zero values. If numeric values are equal, or + both symbols are undefined, sort alphabetically. Don't assume + that the difference of two bfd_vma values will truncate to "int" + and still have the same sign. + (numeric_reverse): Call numeric_forward and negate the result. + (print_symbol_info_bsd): For undefined symbols, print leading + spaces equivalent to the width of a printed bfd_vma, rather than + assuming that 8 will look right. + +Fri Jul 22 10:36:50 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * coffgrok.c (doit): Zero all fields of new structure. + * srconv.c (sysroff_swap_*_out): Remove redundant trailing arg. + * sysinfo.y: Generate sysroff_swap_*_out without requiring extra + arg. + +Fri Jul 22 10:09:53 1994 J.T. Conklin (jtc@phishhead.cygnus.com) + + * nlmheader.y: Make "stack" and "stacksize" synonyms in the lexer + rather than the parser. + +Thu Jul 21 10:25:09 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * config/mh-alphaosf, config/mh-apollo68v, config/mh-delta88: + Remove; obsolete. + +Sat Jul 16 22:34:39 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * objdump.c (slurp_dynamic_symtab): Try to get the dynamic symbols + even if the bfd is not marked DYNAMIC. ELF executables are not + marked DYNAMIC, but do have dynamic symbols. + +Fri Jul 15 01:41:35 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * coffgrok.c (do_where): Make data with no type 'int'. + (do_define): Keep info on source file of a symbol. + * coffgrok.h (coff_symbol): New field. + * srconv.c (PROGRAM_VERSION): Now 1.3 + (wr_rl): Use external ref number for symbol. + (wr_dus): Only keep one source file per debug unit. + (wr_dln): Always emit line numbers for first source file, + (wr_globals): Emit globals in the du of their owning source file. + +Mon Jul 11 15:59:03 1994 J.T. Conklin (jtc@phishhead.cygnus.com) + + * nlmheader.y: Null terminate var_hdr->threadName. + +Fri Jul 8 17:33:22 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * Makefile.in (syslex.o, sysinfo.o): Permit C source files to be + in $(srcdir), as they will be for FSF releases. + +Wed Jul 6 01:13:14 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (setup_sections): Preserve existing section flags when + copying in flags from a new section. + +Tue Jul 5 15:56:01 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * objcopy.c: Include libiberty.h. + (copy_file): If output_target is NULL, set it to the target of the + input file. + +Wed Jun 29 17:17:14 1994 J.T. Conklin (jtc@phishhead.cygnus.com) + + * nlmconv.c (link_inputs): Fixed memory allocation bug. + +Thu Jun 23 12:52:46 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * configure.in: Change --with-targets to --enable-targets. + +Tue Jun 21 12:53:21 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * Makefile.in (sysinfo): Does not depend upon $(ADDL_LIBS). + + * nlmconv.c (powerpc_build_stubs): Don't generate the PowerPC + NetWare custom header; no longer needed. + (powerpc_mangle_relocs): Convert relocs against the uninitialized + data section into relocs against the data section. + + * configure.in: Set nlmconv_defs to -DNLMCONV_cputype for all the + netware targets. Write it into Makefile as NLMCONV_DEFS. + * Makefile.in (nlmconv.o): Pass $(NLMCONV_DEFS) to $(CC). + * nlmconv.c: Only compile code for specific CPU types if + NLMCONV_cputype is defined. + + * nlmconv.c (main): Change uses of bfd_abs_section, etc., to use + bfd_abs_section_ptr or bfd_is_abs_section, etc. + (i386_mangle_relocs, alpha_mangle_relocs): Likewise. + (powerpc_build_stubs): Likewise. + * nm.c (filter_symbols, print_symbols): Likewise. + * objcopy.c (filter_symbols): Likewise. + (mark_symbols_used_in_relocations): Likewise. + * objdump.c (remove_useless_symbols, dump_relocs): Likewise. + * size.c (sysv_internal_printer): Likewise. + +Mon Jun 20 16:43:03 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * Makefile.in (MANPAGES): Remove $(DEMANGLER_PROG). + (install): Install it explicitly, from build dir, not srcdir. + +Mon Jun 20 16:29:54 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * objdump.c: Don't include elf/internal.h. + (bfd_elf_find_section): Don't declare. + (read_section_stabs): No special handling for ELF. Always read + using BFD sections. + +Thu Jun 16 17:25:20 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in: Set UNDERSCORE in Makefile based on result of + invoking config.bfd with a second argument of ``_''. + * Makefile.in (underscore.c): Depend upon Makefile. Don't try to + run $(CC) and $(NM), just use $(UNDERSCORE). Create via temporary + file. + (demangle.o): Remove target. + ($(NM_PROG)): Don't depend upon demangle.o, and don't link against + demangle.o. It's in libiberty anyhow. + (cplus-dem.o): Don't depend upon demangle.o. + * binutils.texi: Mention -n and --no-strip-underscores arguments + to c++filt. + +Wed Jun 15 12:10:31 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nm.c (long_options): Add --no-demangle to turn off --demangle, + and --no-cplus for Linux compatibility. + (usage): Mention --no-demangle. + * binutils.texi: Document --no-demangle. + +Fri Jun 10 15:41:25 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nm.c: HOST_64_BIT was renamed to BFD_HOST_64_BIT. + + * objcopy.c (copy_archive): Make the temporary directory in the + same directory as the output BFD, since we may not have write + permission on the current directory. Set the permissions of the + new directory to 0700, not 0777. + +Mon Jun 6 21:36:43 1994 D. V. Henkel-Wallace (gumby@cygnus.com) + + * configure.in: if this is an rs6000 (and we're not building for + any other bfd targets) then build only nm (collect needs it on + rs6000-lynx). + + * Makefile.in: define TOOL_PROGS which the list of programes to + install in $tooldir -- replaces a hard-coded list. + +Fri Jun 3 10:59:18 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objdump.c (display_target_list): Remove unused local ok. + +Thu May 26 18:05:52 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * config/mh-alphaosf (CFLAGS): Don't specify both -g and -O; + they're not compatible under native cc. Use -O1 instead. + + * Makefile.in (VERSION): Updated to cygnus-2.4.1. + + Changes from binutils-2.4 net release: + + * Makefile.in (MANPAGES): Use $(DEMANGLER_PROG). + ($(DEMANGLER_PROG).1): Build from cxxfilt.man, using sed. + * cxxfilt.man: Renamed from c++filt.1, replaced "c++filt" with + magic token to be replaced by sed. + + Wed May 11 22:32:00 1994 DJ Delorie (dj@ctron.com) + + * configure.bat: update for latest makefile.in + +Fri May 13 23:25:13 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * bucomm.c: Check ANSI_PROTOTYPES rather than __STDC__. + +Tue May 10 18:22:06 1994 Jason Molenda (crash@sendai.cygnus.com) + + * objcopy.c (copy_section): Set section size correctly if using + interleave. + +Sat May 7 16:49:36 1994 Steve Chamberlain (sac@cygnus.com) + + * Makefile.in: Add rule for sysinfo.h + +Fri May 6 12:18:33 1994 Steve Chamberlain (sac@cygnus.com) + + * Makefile.in (SRCONV_PROG): Define. + (PROGS): Use $(SRCONV_PROG) too. + +Thu May 5 19:41:43 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * Makefile.in (DISTSTUFF): Add sysinfo.c, syslex.c, in case + someone configures with `targets=all'. + (distclean): Remove y.*. + (syslex.o): Depend on sysinfo.h. + (sysinfo.c): Rename y.tab.h to sysinfo.h. + (install-info): Don't try to install into $(infodir)/$(srcdir). + * syslex.l: Include sysinfo.h, not y.tab.h. + +Thu May 5 11:50:55 1994 Ken Raeburn (raeburn@kr-pc.cygnus.com) + + * syslex.l (yywrap): Define as function if not defined as a macro. + + * Makefile.in (objdump.o): Deleted special rule. + * configure.in: Don't bother building ARCHDEFS variable for + Makefile. + * objdump.c (ARCH_*): Deleted handling. + (disassemble_data): Call `disassembler' from opcodes library. + +Thu May 5 13:28:42 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * Makefile.in (install): Correct handling of $(tooldir) and + $(bindir) being on different devices. + +Fri Apr 29 09:50:38 1994 Steve Chamberlain (sac@cygnus.com) + + * sysdump.c (h8300, sh): Add declarations. + +Wed Apr 27 11:25:18 1994 Steve Chamberlain (sac@cygnus.com) + + * Makefile.in (syslex, sysinfo): Use CC_FOR_BUILD. + * coffdump.c, coffgrok.c, coffgrok.h, srconv.c, sysdump.c, + sysroff.info: Major changes. + +Tue Apr 26 18:18:24 1994 Stan Shebs (shebs@andros.cygnus.com) + + * objdump.c (print_section_stabs): Indicate the stab header symbol + more clearly, print numbers of unrecognized stab n_type values. + +Tue Apr 26 16:22:55 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (copy_sections): Copy arelent pointers, not arelents. + +Mon Apr 25 16:14:32 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * Makefile.in (distclean): Remove $(PROGS) and underscore.c. + +Fri Apr 22 11:14:19 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (setup_sections): Remove special handling of .reginfo + section. + (copy_sections): Likewise. + (alpha_mangle_relocs): Use bfd_ecoff_get_gp_value rather than the + special ECOFF .reginfo section. + + * objcopy.c (copy_object): Call bfd_copy_private_bfd_data after + copying everything else, to let it fiddle with the file in its + final state. + + * objdump.c: Include libiberty.h. + (display_target_list): If a format fails, just go on to the next + one. Check return value of bfd_set_format. + (display_info_table): Likewise. Don't increment loop variable in + for loop test, since that skips the first element. + (display_target_tables): Rewrite loop for clarity. Ensure that it + always prints at least one element. + + * nlmconv.c (main): Use CyGnUsEx rather than CyGnUsSeCs for + sections header. Rename from cygnus_sections to cygnus_ext. + +Thu Apr 21 12:12:26 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objdump.c (_DUMMY_NAME_): Don't define. + (display_target_list): Use tmpnam to get a file name rather than + using _DUMMY_NAME_. Unlink it when done. + (display_info_table): Likewise. + + * nlmconv.c (secsec): New static variable. + (main): Create .nlmsections section in output BFD. Store + information about it in sections header. + (setup_sections): Allocate space in sections header. + (copy_sections): Copy zero sized sections. Put information about + each section in the sections header. + +Wed Apr 20 14:34:51 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (powerpc_build_stubs): Take new outbfd argument. + Change caller. Create custom header for new PowerPC NetWare + format. + + * Makefile.in (nlmheader.o, nlmconv.o): Update dependencies. + * nlmconv.c: Include bfd.h and libiberty.h with "", not <>. + * nlmheader.y: Include bfd.h with "", not <>. + +Wed Apr 13 10:52:50 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objdump.c: Do an ifdef on __GO32__, not unix. + +Wed Apr 6 21:54:49 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + Added -D (--dynamic) option to nm and -T (--dynamic-syms) and -R + (--dynamic-reloc) arguments to objdump. + * nm.c (dynamic): New static variable. + (long_options): Added "dynamic". + (usage): Mention -D and --dynamic. + (main): Add D to getopt string. Handle -D by setting dynamic. + (display_rel_file): If dynamic is non-zero, read dynamic symbols + rather than normal symbols. + * nm.1: Updated for -D (--dynamic) option. + * objdump.c (dump_dynamic_symtab): New global variable. + (dump_dynamic_reloc_info): New global variable. + (dynsyms, dynsymcount): New global variables. + (usage): Mention -R, -T, --dynamic-syms and --dynamic-reloc. + (long_options): Added "dynamic-reloc" and "dynamic-syms". + (slurp_symtab): If no symbols, return rather than exit. + (slurp_dynamic_symtab): New function. + (display_bfd): Handle dump_dynamic_symtab and + dump_dynamic_reloc_info. + (dump_symbols): Take new dynamic argument, indicating whether to + display dynamic symbols. + (dump_relocs): Move most printing into dump_reloc_set. + (dump_dynamic_relocs): New function. + (dump_reloc_set): New function, extracted from dump_relocs. + (main): Add R and T to getopt string. Handle -T by setting + dump_dynamic_symtab and -R by setting dump_dynamic_reloc_info. + * objdump.1: Updated for -R (--dynamic-reloc) and -T + (--dynamic-syms) options. + * binutils.texi: Updated for new nm and objdump options. + +Wed Mar 30 15:52:40 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + Update for recent BFD changes to symbol and reloc reading. Rename + all uses of get_symtab_upper_bound to bfd_get_symtab_upper_bound. + Also: + * coffgrok.c (symcount): Change to long. + (do_sections_p1): Check for error return from + bfd_get_reloc_upper_bound. Change relcount to long, and check for + error from bfd_canonicalize_reloc. + (coff_grok): Change storage to long. Check for error from + bfd_get_symtab_upper_bound and bfd_canonicalize_symtab. + * nlmconv.c (main): Change symcount, newsymalloc, newsymcount, and + i to long. Check for error from bfd_get_symtab_upper_bound and + bfd_canonicalize_symtab. + (copy_sections): Change reloc_size and reloc_count to long. Check + for error from bfd_get_reloc_upper_bound and + bfd_canonicalize_reloc. + (mangle_relocs, i386_mangle_relocs, alpha_mangle_relocs): Change + reloc_count_ptr argument to long *. Make corresponding changes to + variables loaded from *reloc_count_ptr. + * nm.c (display_rel_file): Change storage and symcount to long. + Check for errors from bfd_get_symtab_upper_bound and + bfd_canonicalize_symtab. + * objcopy.c (filter_symbols): Change symcount, src_count and + dst_count to long. + (copy_object): Change symcount to long. Pass another argument to + fprintf. Check for errors from bfd_get_symtab_upper_bound and + bfd_canonicalize_symtab. + (copy_section): Change relcount to long. Check for errors from + bfd_get_reloc_upper_bound and bfd_canonicalize_reloc. + (mark_symbols_used_in_relocations): Change relcount and i to long. + Check for errors form bfd_get_reloc_upper_bound and + bfd_canonicalize_reloc. + * objdump.c (storage): Remove global variable. + (symcount): Changed to long. + (slurp_symtab): New local variable storage. Check for errors from + bfd_get_symtab_upper_bound and bfd_canonicalize_symtab. + (remove_useless_symbols): Change return value and count to long. + (objdump_print_address): Change min, max, thisplace and i to long. + (disassemble_data): Change i to long. + (dump_symbols): Change count to long. + (dump_relocs): Change relcount to long. Check for errors from + bfd_ret_reloc_upper_bound and bfd_canonicalize_reloc. + (display_info_table): Add casts when passing LONGEST_ARCH for + printf %* argument. + +Tue Mar 29 14:59:04 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nm.c (display_archive): Close each archive element after it has + been displayed. + * objdump.c (display_file): Likewise. + +Mon Mar 28 13:04:08 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in: Change error message to refer to bfd/config.bfd + rather than bfd/configure.in. + +Sun Mar 27 16:23:39 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * More fixes for object formats which allow multiple sections + with the same name: + * objcopy.c (setup_section): Make a new output section even if + one already exists with the given name. + (copy_section): Use isection->output_section rather than trying + to look the output section up by its (possibly non-unique) name. + + * Makefile.in (install-info): Look for binutils.info in the + current directory, then in $(srcdir). Don't use $<. + +Mon Mar 21 12:55:45 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objdump.c (objdump_print_address): Make static. Declare with + prototype. Change vardiff from int to bfd_signed_vma. Correct + binary search termination condition. When looking for same + section symbol in relocatable file, handle final symbol correctly. + +Sun Mar 20 11:26:36 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * Makefile.in: Avoid bug in hpux sed. + + * objcopy.c: Changes to keep it from stripping symbols used + in output relocations. + (mark_symbols_used_in_relocations): New function. Mark symbols + used in output relocations with BSF_KEEP. + (filter_symbols): Do not strip symbols marked with BSF_KEEP. + (copy_object): Reorder actions. First setup sections, then + build the output symbol table, then copy the section contents. + +Fri Mar 18 10:53:55 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ar.c (write_archive): Allocate space for the null byte. From + Robert Lipe . + +Thu Mar 17 16:20:28 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * Makefile.in: Built nm.new and strip.new to avoid problems with + collect when . is in PATH. + (STRIP_PROG): Change from strip to strip.new. + (NM_PROG): Change from nm to nm.new. + (install): Remove the .new when installing. + +Wed Mar 16 16:27:05 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (powerpc_build_stubs): Set BSF_DYNAMIC flag for each + symbol for which we build a stub. + (powerpc_mangle_relocs): Only reset TOC pointer for a call to a + symbol with BSF_DYNAMIC flag set. + +Tue Mar 15 23:04:13 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * objcopy.c (filter_symbols): Use bfd_is_local_label to determine + if a symbol represents a compiler-generated local label. + (copy_object): Give the BFD backends a chance to copy any private + bfd data from the input BFD to the output BFD. + (setup_section): Give the BFD backends a chance to copy any private + section data from the input section to the output section. + +Mon Mar 14 11:15:58 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * objcopy.c (mangle_section): Delete unused function. + (setup_section): Set osection here instead of calling + mangle section to do it. + +Mon Mar 14 12:11:01 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ar.c (write_archive): Close inarch before unlinking it. + +Fri Mar 11 22:20:48 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (main): For PowerPC, call powerpc_build_stubs and + powerpc_resolve_stubs. Use __GOT0, not __toc_start. Handle it if + the start and end symbols are not in the text section. + (struct powerpc_stub): New struct definition. + (powerpc_stubs, powerpc_stub_insns): New static variables. + (powerpc_initial_got_size): New static variable. + (powerpc_build_stubs): New function. + (powerpc_resolve_stubs): New function. + (powerpc_mangle_relocs): Clear extraneous data in .got section. + Rearrange reloc handling to handle ELF relocs that are not + partial_inplace. Resolve PC relative relocs. + +Wed Mar 9 13:48:11 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * ar.c (move_members): Fix it so that the abi positional modifiers + don't delete all archive members following the insert point. + +Tue Mar 8 13:14:43 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * coffgrok.[ch]: New files, understand coff objects. + * coffdump.c: Uses coffgrok to dump out the debug info of a coff + file. + * sysroff.info: Description of a SYSROFF object file. + * sysinfo.y, syslex.l: Parse info file, generate a reader, writer, + header files and a printer. + * srconv.c: Uses coffgrok.c and sysroff.info to convert a coff + file to a SYSROFF file. + +Sat Feb 26 13:35:26 1994 Stan Shebs (shebs@andros.cygnus.com) + + * ar.c (do_quick_append): Pad with a genuine character 10, + rather than whatever '\n' might happen to be. + +Tue Feb 22 18:25:52 1994 Ian Lance Taylor (ian@cygnus.com) + + * nlmconv.c (main): Ignore debugging symbols when looking for + special symbols by name. + +Sun Feb 20 18:47:42 1994 Ian Lance Taylor (ian@lisa.cygnus.com) + + * nlmconv.c: Include libiberty.h. + + Support for PowerPC NetWare. + * nlmconv.c (main): For PowerPC NetWare, automatically define the + special symbols __toc_start. + (select_output_format): Handle bfd_arch_powerpc. + (mangle_relocs): Likewise. + (powerpc_mangle_relocs): New function. + +Thu Feb 17 09:28:23 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * ar.c, bucomm.c, nlmconv.c, nm.c, objcopy.c, objdump.c, + size.c: Use bfd_get_error and bfd_set_error and new error names. + +Fri Feb 11 15:54:51 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * objcopy.c (strip_main, copy_main): Add missing 'break' in switch. + +Mon Feb 7 19:45:52 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objdump.c (disassemble_data): Handle bfd_arch_powerpc. + +Sun Feb 6 22:08:20 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * strings.c objdump.c nlmconv.c objcopy.c nm.c ar.c size.c (main): + Call xmalloc_set_program_name. + +Fri Feb 4 10:46:01 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * objcopy.c (filter_bytes): Make MEMHUNK a char *, not PTR, so we + can do arithmetic on it. + +Thu Feb 3 14:06:41 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * objdump.c (dump_section_stabs, read_section_stabs, + print_section_stabs): Functions broken out of dump_stabs_1. + Free the stabs and strings when done with them. + +Wed Feb 2 13:42:23 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * nlmconv.c (main): Use bfd_get_flavour instead of struct member. + * ar.c (print_contents, extract_file), size.c + (print_berkeley_format, print_sysv_format): Use bfd_get_filename and + bfd_my_archive instead of dereferencing the structs directly. + + * ar.c: Use bfd_fatal and bfd_nonfatal instead of bfd_perror and exit. + Indent. Remove DEFUNs. + + * nlmconv.c (main), objcopy.c (copy_file): Print matching formats + if ambiguous match. + * nm.c (display_file, display_archive), size.c (display_bfd): + Eliminate gotos. + Print matching formats if there is an ambiguous match. Use + bfd_nonfatal instead of hardcoded error message if nothing matches. + + * arsup.c, ar.c, objdump.c: Use bfd_get_filename instead of + abfd->filename. + + * nm.c (display_archive): New function, from code in display_file. + (display_rel_file): Renamed from do_one_rel_file. + + * size.c: Indent. + (display_archive): New function from code in display_file. + (display_file): Check bfd_close error return. + + * strings.c (strings_object_file): Check bfd_check_format + error return. + + * strings.c, objdump.c, size.c: Use bfd_nonfatal instead of bfd_perror. + + * bucomm.c: Delete references to exit_handler. It wasn't set + anywhere, and now that we're using the libiberty xmalloc, it + wouldn't always get called before exiting. + (list_matching_formats): Function moved from objdump.c. + * bucomm.h: Declare it. + + * objdump.c (disassemble_data): Move some variable decls closer to + their use. Add some comments. Replace a nested block with a + return. + +Mon Jan 31 18:50:41 1994 Stan Shebs (shebs@andros.cygnus.com) + + * objdump.c (display_target_list, display_info_table): Check that + the bfd of the dummy output file is not null. + +Wed Jan 26 13:13:18 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * objcopy.c (filter_bytes): New function. + (copy_section): Call it. + (copy_options, copy_usage, copy_main): Add --byte option to + activate it. Appropriate the -b option (which was an undocumented + synonym for -F) for it, also. Add --interleave, -i option for + additional control. + (setup_section, copy_section, mangle_section): Renamed with no `s' + on the end. + * objcopy.1, binutils.texi: Document the new options. + + * objdump.c (display_target_tables, display_target_list): + New functions broken out of display_info. + Eliminate some magic constants. Use more meaningful variable names. + (dump_bfd_header): New function broken out of display_bfd. + (dump_section_header): New function broken out of dump_headers. + (remove_useless_symbols): Don't shadow global variable name with + parameter. + (objdump_print_address): Fix backward test. + +Tue Jan 25 19:40:54 1994 Stan Shebs (shebs@andros.cygnus.com) + + * bucomm.c (print_arelt_descr): Change decl of `when' to time_t. + * objdump.h: Removed. + +Mon Jan 24 13:29:02 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * objdump.c (display_file): Remove call to list_matching_formats. + It would never be called. + (list_matching_formats): Take an arg giving the list of matching + formats. + (display_bfd): Pass the arg, and get it filled in by calling + bfd_check_format_matches instead of bfd_check_format. + (display_info, display_info_table): target_vector was renamed to + bfd_target_vector. + + * binutils.texi (objdump): Note some limitations of -h section + address printing. + +Sat Jan 22 16:20:46 1994 Stan Shebs (shebs@andros.cygnus.com) + + * Makefile.in (MALLOC): Set to emptiness by default. + (ALL_CFLAGS): Add and use. + (arparse.h): Make it depend on arparse.y. + * ar.c (libbfd.h): Don't require to be in ../bfd. + * objdump.c (comp): Rename to compare_symbols. + +Fri Jan 21 20:22:30 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * objdump.c (list_matching_formats): If the file format is ambiguous, + print the matching names so the user can choose one. + (display_bfd): Call it. + (display_file): Call it. + +Fri Jan 21 19:17:25 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objdump.c (disassemble_data): Support bfd_arch_rs6000. + +Mon Jan 17 13:57:25 1994 Stan Shebs (shebs@andros.cygnus.com) + + * objdump.c (stab_name): Allocate dynamically. + (stab_print): Use pointers to strings instead of char arrays. + (dump_stabs): Change alloc and init of arrays appropriately. + (dump_stabs_1): Always decide whether to print stab_name or + the stab's type number, if unnamed. + +Fri Jan 14 14:42:48 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objcopy.c (strip_main, copy_main): Don't clobber the input file + if copy_file fails. + + * nlmconv.c (main): Warn about an attempt to use a shared library + with uninitialized data. + + * nlmconv.c (setup_sections): Make sure that we align the + output_offset of each input section appropriately. + +Thu Jan 13 17:32:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objdump.c (dump_relocs): Don't crash if section name is NULL. + +Tue Jan 11 19:46:33 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * filemode.c (filemodestring): Commented out; not used. + (mode_string): Use POSIX definitions. + (ftypelet): Likewise. + (rwx): Removed; no longer used. + * bucomm.c: Include bucomm.h. + (bfd_nonfatal, bfd_fatal): Argument is const. + (fatal): Make __STDC__ version. + * bucomm.h (mode_string): Declare. + * Makefile.in (bucomm.o): Depend upon bucomm.h + +Sun Jan 9 12:03:20 1994 Ken Raeburn (raeburn@rtl.cygnus.com) + + * bucomm.c (xmalloc, xrealloc): Deleted. + * bucomm.h (xmalloc, xrealloc): Fix prototypes, to correspond to + libiberty version of functions. + +Thu Jan 6 06:18:15 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * binutils.texi: Add a chapter summarizing the ways to select + aspects of the target for each program. + + * objdump.c (long_options, usage): Add long equivalents for all + remaining short options that lacked them. + * binutils.texi objdump.1: Document them. + + * size.c (usage): Tweak usage message. + * size.1: Add missing `=' in examples. + + * binutils.texi strip.1 objcopy.1 nlmconv.1 objcopy.c nlmconv.c: + Use "--target=bfdname" as the option to select the BFD target, + like nm and size already do. + Reserve "--format=format" for textual output selection options, but + for now keep old option names as obsolete for backward compatibility. + + * strings.c (main, strings_object_file, usage): Add --target option. + * binutils.texi strings.1: Document it. + +Sat Jan 1 13:58:24 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * ar.c (main): Add \n in error message. + +Thu Dec 23 12:23:11 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + gcc -Wall lint: + * ar.c (main): Put parens around assignment used as truth value. + * objcopy.c (strip_main): Remove unused variables. Return 0. + (copy_main): Remove unused variables. Return 0. + * objdump.c (display_bfd): Declare return value as void. + (stab_print): Use "" instead of 0 to initialize array. + (dump_stabs_1): Print vma using printf_vma. + (display_info): Put parens around assignment used as truth value. + * strings.c (print_strings): Cast printf arguments. + + * objcopy.c (copy_main): Use copy_options, not strip_options. + + * nlmheader.y (command): Warn about illegal date values. + +Wed Dec 15 11:18:03 1993 David J. MacKenzie (djm@frosty.eng.umd.edu) + + * bucomm.c bucomm.h: Run through indent. De-ansidecl-ify. + (bfd_nonfatal): New function. + (bfd_fatal): Call it. + + * objcopy.c (smart_rename): Do a copy if the dest file has + multiple hard links. Remove source file on successful copy. + Try to preserve mode and owner on successful rename. + + * objcopy.c: Run through indent. Clean up a bit. + Make global variables static. + Make {input,output}_{target,filename}, show_version local + to various functions. + New global variable `status' for exit status. + (strip_main, copy_main): New functions with code from main. + (nonfatal): New macro. Use it globally instead of bfd_perror and + bfd_fatal. + + (copy_object): Call mangle_sections with bfd_map_over_sections. + (mangle_sections): Adjust for new calling convention. + +Fri Dec 10 11:28:11 1993 Ian Lance Taylor (ian@deneb.cygnus.com) + + * nlmheader.y (command): Accept MAP and FULLMAP without arguments. + * nlmconv.c (main): Change error message for MAP and FULLMAP. + +Thu Dec 9 17:47:19 1993 Ian Lance Taylor (ian@deneb.cygnus.com) + + * nlmconv.c (main): Warn about imported symbols that are not in + the IMPORT list even if the IMPORT keyword is not used. + + * nlmconv.c (debug, unlink_on_exit): New static variables. + (long_options): Add "debug" and "linker". + (main): Handle -d and -l arguments. Make command line input and + output files optional. Parse the command file before opening the + BFD's, which requires storing more information in local variables. + If INPUT names multiple files, link them together. Use OUTPUT for + the output file name if not named on command line. + (show_usage): Changed for new options. + (link_inputs): New function to automatically invoke linker to + handle multiple INPUT files. + (choose_temp_base_try, choose_temp_base, pexecute): New functions, + mostly copied from gcc/gcc.c. + * nlmconv.h (input_files, output_file): Declare. + * nlmheader.y (input_files, output_file): Define. + (command): Support INPUT with a string_list argument. Support + OUTPUT. + (string_list): Renamed from module_list. + * Makefile.in (nlmconv.o): Define LD_NAME based on + program_transform_name. + +Wed Dec 8 10:09:04 1993 Ian Lance Taylor (ian@deneb.cygnus.com) + + * nlmheader.y (nlmheader_identify): New function. Use it to print + the program name just once, instead of with every error message. + +Mon Dec 6 16:11:32 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (long_options): Changed --header-info to --header-file + to match documentation and usage message. + +Sun Dec 5 01:31:01 1993 Jeffrey A. Law (law@snake.cs.utah.edu) + + * objdump.c (dump_relocs): Avoid dereferencing a NULL sym_ptr_ptr + in a relocation. + +Thu Dec 2 16:00:06 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (main): Change various types from bfd_size_type to + size_t, since they have to be arguments to fread and fwrite. + Change set from char * to unsigned char *. + (select_output_format): Make mach argument unsigned. Handle + bfd_arch_alpha. + (setup_sections): Don't copy the .reginfo section of an ECOFF + file. Call bfd_set_reloc to initialize the relocation fields. + (copy_sections): Don't copy the .reginfo section of an ECOFF file. + Combine all relocs for a section. + (mangle_relocs): Change type of relocs to permit specific + functions to change it. Call alpha_mangle_relocs for alpha, + default_mangle_relocs for other architectures. + (default_mangle_relocs): New function. Adjust the address of all + relocs by the output_offset. + (i386_mangle_relocs): Change type of relocs argument. Cast length + argument to memmove to size_t. + (alpha_mangle_relocs): New function. + +Wed Nov 17 17:38:58 1993 Sean Eric Fagan (sef@cygnus.com) + + * nlmconv.c (select_output_format): Use nlm32-sparc for + bfd_arch_sparc. + +Wed Nov 17 14:41:35 1993 Jeffrey Osier (jeffrey@thepub.cygnus.com) + + * nlmconv.1: added man page + * objcopy.1: fixed format errors + +Wed Nov 17 12:03:41 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * Makefile.in: Use CFLAGS as well as LDFLAGS when linking. + +Wed Nov 17 04:50:55 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * strings.1: Fix typo. + +Mon Nov 15 12:03:20 1993 Ken Raeburn (raeburn@rtl.cygnus.com) + + * Makefile.in (DISTSTUFF): Build "info". + (VERSION): Updated to cygnus-2.3.1; 2.3 has gone out. + +Sun Nov 14 00:27:24 1993 Jeffrey A. Law (law@snake.cs.utah.edu) + + * objdump.c (dump_stabs): Handle stabs-in-som as implemented + by the new BFD SOM assembler. + +Sat Nov 13 07:14:05 1993 David J. Mackenzie (djm@rtl.cygnus.com) + + * ar.1 c++filt.1 nm.1 objcopy.1 objdump.1 ranlib.1 size.1 + strings.1 strip.1: Replace \(em in NAME section with \- so + makewhatis can grok it. + +Tue Nov 9 15:22:12 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (i386_mangle_relocs): Adjust reloc address by + section output_offset. + +Fri Nov 5 12:11:52 1993 Jeffrey Osier (jeffrey@thepub.cygnus.com) + + * binutils.texi: added nlmconv chapter + +Wed Nov 3 16:10:50 1993 Jeffrey Wheat (cassidy@cygnus.com) + + * Makefile.in: Change RUNTESTFLAGS to RUNTEST_FLAGS + +Wed Nov 3 15:09:23 1993 Ken Raeburn (raeburn@rover.cygnus.com) + + * Makefile.in (distclean): Don't get rid of dvi or info files. + +Tue Nov 2 13:29:59 1993 David J. Mackenzie (djm@rtl.cygnus.com) + + * objcopy.c (S_ISLNK): Define as 0 if there's no S_IFLNK. + +Fri Oct 29 16:02:34 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * binutils.texi: Move objcopy docs into alphabetical order. + + * objdump.c: Use xmalloc instead of malloc. + +Fri Oct 29 11:11:14 1993 Stan Shebs (shebs@rtl.cygnus.com) + + * objdump.c (info): Rename to formats_info. + (dump_stabs_1): Better comments and formatting. + +Thu Oct 28 19:43:16 1993 Stan Shebs (shebs@rtl.cygnus.com) + + * ar.c (main): Always create the archive when quick appending, + even if no input files have been given. + +Wed Oct 27 12:03:06 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (main): Set sharedDebugRecordOffset and + sharedDebugRecordCount fields in extended header. + + * nlmconv.c (main): Force moduleName field to upper case. + +Mon Oct 25 16:45:42 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objcopy.c (main): Give a usage message if there are too many + arguments. + +Mon Oct 25 10:37:08 1993 Ken Raeburn (raeburn@rover.cygnus.com) + + * Makefile.in (install-info): Rewrite to take advantage of VPATH, + so FSF distributions (with info files in $(srcdir)) install + properly. + (DISTSTUFF): Build nlmheader.c too. + +Fri Oct 22 11:43:23 1993 Ken Raeburn (raeburn@rover.cygnus.com) + + * ar.c (program_name): Don't define here. + * objdump.c: Include "bucomm.h". + (xmalloc): Don't declare here. + (program_name): Don't define here. + (program_version): Fixed type in declaration. + * size.c: Include "bucomm.h". + (program_name): Don't declare here. + +Fri Oct 22 14:10:41 1993 Mark Eichin (eichin@cygnus.com) + + * objdump.c (fprintf): hide declaration in FPRINTF_ALREADY_DECLARED + +Fri Oct 1 12:43:00 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (i386_mangle_relocs): Resolve and remove PC relative + relocs against defined symbols in the same section. + +Thu Sep 30 16:46:26 1993 Roland H. Pesch (pesch@fowanton.cygnus.com) + + * Makefile.in (binutils.dvi): use TEXIDIR to find texinfo.tex + +Sat Sep 25 18:09:29 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * objcopy.c (simple_copy, smart_rename): New functions. + (main): Use them. + +Fri Sep 24 15:38:29 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * Makefile.in (clean, distclean): Recurse into testsuite. + +Thu Sep 23 01:05:06 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objcopy.c (setup_sections, copy_sections): If stripping, don't + copy SEC_DEBUGGING sections. + * objdump.c (dump_headers): Print SEC_DEBUGGING flag. + + * objdump.c (usage): Mention --stabs. + + * objcopy.c (copy_object): Copy all applicable file flags. + (copy_file): Don't copy EXEC_P specially here. + +Mon Sep 20 19:28:57 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (main): Adjust data section size to correspond to bss + alignment adjustment. Clear BSF_SECTION_SYM if symbol is moved to + a different section. Use time_t for time variable. + (setup_sections): Only put sections with contents in output NLM. + (i386_mangle_relocs): No symbols are common at this point. Add + casts to avoid warnings. + +Fri Sep 10 11:00:40 1993 Stan Shebs (shebs@rtl.cygnus.com) + + * objdump.c: Made the --stabs option work for stabs-in-coff. + (ELF_STAB_DISPLAY): Removed. + (dump_elf_stabs): Renamed to dump_stabs, changed to run for + any object file format. + (dump_elf_stabs_1): Renamed to dump_stabs_1, added calls to + generic BFD routines for non-ELF case, changed format of message + for no-section-found case. + (display_bfd): Always call dump_stabs if requested. + (dump_data): Call bfd_section_size to get section size. + +Fri Sep 10 08:12:23 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * Makefile.in (install): Don't put strings in tooldir/bin. + +Mon Sep 6 15:39:04 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (total_bss_size): Removed. + (main): Set the bss vma to always follow the data section. Move + symbols into new sections, and adjust values by output_offset. + (setup_sections): Don't copy all sections, but instead point all + text sections to .text, all data sections to .data, and all bss + sections to .bss. + (copy_sections): Adjust accordingly. + +Thu Sep 2 12:34:03 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + Only build nlmconv if configured for a NetWare target. + * configure.in: If we have some *-*-netware* target, or are using + all targets, set BUILD_NLMCONV to $(NLMCONV_PROG) in Makefile. + * Makefile.in (PROGS): Use $(BUILD_NLMCONV) rather than + $(NLMCONV_PROG). + +Tue Aug 31 14:13:35 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * objdump.c (ARCH_all): Define ARCH_hppa too. + (dump_headers): Don't test for SEC_BALIGN if it's not defined by + bfd.h. + +Tue Aug 31 13:29:12 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * nlmconv.c (main): Force creation of .bss section. Set up the + sections before looking at the symbols. Move all common symbols + into .bss section. Automatically define _edata and _end. Only + export symbols in the export list, with multiple prefixes if + necessary. Warn if no version. Always create extended header. + Set date automatically if not already set. + (setup_sections): Count size of bss sections. + (mangle_relocs, i386_mangle_relocs): Accept section argument, and + take reloc_count as a changeable pointer; changed callers. + (i386_mangle_relocs): Remove PC relative relocs within a section, + as they require no adjustment. + * nlmheader.y: Fixed memory allocation throughout: token STRING is + now allocated on the heap, and freed if not needed. Null + terminated copyright message. Accept version with only two + strings. + (symbol_list_opt): New nonterminal, either symbol_list or empty. + (symbol_list): Use left recursion to avoid overflowing parser + stack. + (yylex): Rearranged beginning of line check. Accept quoted + strings using single quotes. End generic argument at comment + character or parentheses. + (string_list_append): Fixed. + (string_list_append1): New function. + + * bucomm.h: The first argument to xrealloc is PTR, not char *. + * bucomm.c (xrealloc): Use PTR rather than char *. + * Makefile.in (objdump.o): Depend upon config.status to notice + --with-targets changes. + (nlmconv.o): Depend upon bucomm.h. + +Tue Aug 17 09:46:01 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * configure.in: Don't pass cpu to config.bfd. + +Thu Aug 12 16:43:04 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * Makefile.in ($(NM_PROG)): Depend on demangle.o. + (demangle.o): New target. + (cplus-dem.o): Depend on it, to force compilation order when doing + parallel compiles. + + * nm.c (print_symbol_info_{bsd,sysv,posix}): Take a bfd arg. + (struct output_fns print_symbol_info): Ditto. + (long_options, usage, main): Add -C --demangle option. + (print_symname): New function, demangling if requested. + (print_symbols, print_symbol_info_{bsd,sysv,posix}): Use it. + +Wed Aug 11 22:57:23 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * Makefile.in: Put CFLAGS last in compilation rules and omit from + linking rules. Use ARCHDEFS to compile objdump.c. + Update dependencies. + * configure.in: Construct ARCHDEFS based on the BFD target makefile + fragments. + * objdump.c: Conditionalize calls to the print_insn_ARCH functions + according to ARCHDEFS. + +Thu Aug 12 08:06:15 1993 Ian Lance Taylor (ian@cygnus.com) + + * ar.c: Removed obsolete and non-functional GNU960 code. + +Wed Aug 11 13:08:26 1993 Ian Lance Taylor (ian@cygnus.com) + + * size.c (berkeley_sum): New function. + (bsssize, datasize, textsize): New global variables. + (bss_section_name, data_section_name, text_section_name): Removed. + (print_berkeley_format): Map berkeley_sum over all the sections, + rather than only reporting sizes of specifically named sections. + * Makefile.in ($(OBJDUMP_PROG)): Removed dependency on size.o. + +Tue Aug 10 10:46:01 1993 Ian Lance Taylor (ian@cygnus.com) + + * nlmconv.c, nlmconv.h, nlmheader.y: New files for program to + convert object files into NetWare Loadable Modules. + * Makefile.in (NLMCONV_PROG): New macro, define to be nlmconv. + (PROGS): Add NLMCONV_PROG. + (nlmheader.c, nlmheader.o, nlmconv.o, $(NLMCONV_PROG)): New + targets. + +Thu Aug 5 15:48:32 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * Makefile.in: define MAKEOVERRIDES to an empty string + +Wed Aug 4 17:08:08 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * objcopy.c (copy_file): Make failures to process a file nonfatal. + +Mon Aug 2 11:28:23 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * nm.c: Add -B option, like --format=bsd. + +Tue Jul 27 16:29:54 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objcopy.c (copy_file): If the file is neither an object nor an + archive, give an error rather than returning success. + +Mon Jul 19 16:13:40 1993 Ken Raeburn (raeburn@rtl.cygnus.com) + + * objdump.c (objdump_print_address): Prefer non-local symbols over + local ones, and especially discriminate against debugging symbols. + Also, for relocateable files, try to find a symbol in the current + section, instead of picking one from some random section with a + convenient value (read, section offset). + (disassemble_data): Cast argument to malloc to size_t first. + (dump_data): Likewise. + (dump_relocs): If a single section name is specified, show relocs + only for that section. Otherwise, silently omit sections without + relocs. Format table nicely even if values are printed using 16 + digits instead of 8. + +Fri Jul 16 15:19:59 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * nm.c: Changes for final version of POSIX.2. + (print_symbol_filename_{bsd,sysv,posix}): New functions. + (formats): Add an element for a pointer to them. + (print_symbols): Call it. + (print_object_filename_posix, print_archive_member_posix): Produce + output according to new POSIX.2 spec. + + * strings.c (print_strings): Handle STREAM being NULL. + (strings_a_section): Pass a NULL. + (main): Don't open /dev/null. + +Thu Jul 15 12:44:09 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objdump.c (disassemble_data): Handle the m88k. + (display_bfd): Use bfd_errmsg, rather than just claiming that the + bfd is not an object file. + +Mon Jul 12 17:55:34 1993 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in (TAGS): make work again by naming directories + explicitly rather than depending on undefined macros. + (INSTALL_XFORM): correct bad install target. + +Fri Jul 2 16:58:34 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * strings.c: Doc fixes. + +Sun Jun 27 13:35:24 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * Makefile.in: Note dependencies on bucomm.h. + (cplus-dem.o): Link c++filt with version.o. + + * strings.c: Include bucomm.h and add prototypes to other decls. + Remove -h option. + + * bucomm.h: Declare xrealloc. + + * nm.c, objcopy.c, objdump.c, size.c, strings.c (main, usage): Add + --help option. Put "GNU" in the version message. + (usage): Take stream and exit status as args. + (main): Pass new args to usage. + +Fri Jun 25 23:12:12 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * strings.c, strings.1: New files. + * binutils.texi: Document strings. + * Makefile.in: Add rules for it. + +Fri Jun 25 20:44:43 1993 Ken Raeburn (raeburn@poseidon.cygnus.com) + + * objdump.c: Use size-independent bfd elf section names. + +Sun Jun 20 23:09:06 1993 Ken Raeburn (raeburn@poseidon.cygnus.com) + + * objdump.c (objdump_print_address): Handle wide offsets by + calling sprintf_vma. + +Fri Jun 18 14:29:12 1993 Per Bothner (bothner@deneb.cygnus.com) + + * objdump.c (syms2): Removed unused variable. + * objdump.c (remove_useless_symbols): New function. + * objdump.c (comp): Simplify. + * objdump.c (dis-assemble_data): Make simpler and more + efficient how we filter out useless symbols: Just filter + BEFORE the sort (using remove_useless_symbols). + * objdump.c (objdump_print_address): Simplify. + Change output syntax to match gdb. + +Thu Jun 17 16:53:56 1993 david d `zoo' zuhn (zoo@cygnus.com) + + * Makefile.in: canonicalize install.sh; for use within + this directory (and subdirs) + +Mon Jun 14 12:13:22 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com) + + * Makefile.in (install, install-info): remove parentdir support, + use INSTALL_XFORM; define INSTALL_XFORM + +Thu Jun 10 17:29:21 1993 Per Bothner (bothner@cygnus.com) + + * objcopy.c (copy_object): Fix bad size passed to xmalloc(). + +Mon Jun 7 12:41:12 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in (INCLUDES): Add -I../bfd for sysdep.h and bfd.h. + * configure.in: No longer need to configure to get sysdep.h. + * objcopy.c (copy_object): Fix symbol table handling. + +Fri Jun 4 17:20:03 1993 Per Bothner (bothner@cygnus.com) + + * objcopy.c (filter_symbols): Cannot filter the symbols + in place, because that confuses the relocs, so take separate + parameter for output array. + * objcopy.c (sympp): Make two variables: isympp and osympp. + * objcopy.c (copy_object): Allocate separate array (osympp) + for filtered symbols. + +Fri Jun 4 10:51:44 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: change recursion test to presence of a configured + testsuite directory + +Thu Jun 3 14:05:57 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * Makefile.in (underscore.c): Hack the backquoted command so it + doesn't cause Solaris make to bomb. + +Thu Jun 3 10:40:19 1993 Jeffrey Osier (jeffrey@cygnus.com) + + * Makefile.in: added c++filt and objcopy to MANPAGES variable + +Thu Jun 3 00:32:52 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: rename LOADLIBES to EXTRALIBS + +Wed Jun 2 18:30:24 1993 Jeffrey Osier (jeffrey@cygnus.com) + + * c++filt.1, objcopy.1: new man pages + +Fri May 28 15:01:24 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in (install): Also install ar and ranlib in + $(tooldir)/bin; needed for building libgcc.a. + * objdump.c (objdump_print_address): Fix the check + "coincidental" label matches by dis-allowing undefined + or com symbols. + +Thu May 27 16:58:31 1993 Jeffrey Osier (jeffrey@cygnus.com) + + * binutils.texi: revised c++filt chapter + +Wed May 26 17:24:17 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (FLAGS_TO_PASS): Pass down CC and CFLAGS. + +Tue May 25 00:26:47 1993 Ken Raeburn (raeburn@cygnus.com) + + * objdump.c (slurp_symtab): Print warning for bad symbol table. + (bfd_elf32_find_section, Elf32_Internal_Shdr): Updated + declarations and uses. + + * Makefile.in (DISTSTUFF): Don't build binutils.mm. + +Fri May 21 10:51:19 1993 David J. Mackenzie (djm@rtl.cygnus.com) + + * nm.c: Add -f/--format, -P/--portability, -t/--radix options. + Make global variables static. + (main): Make -v like -n, not -V, and make -A like -o, for POSIX.2. + (set_print_radix, set_output_format, + print_{object_filename,archive_filename,archive_member,symbol_info} + {bsd,sysv,posix}): New functions. + (display_file, print_symbols): Call them. + + * ar.c: Improve error messages. + + * nm.c (main): Handle long options that just set a flag. + + * nm.c (main), ar.c (do_show_version), objcopy.c (main), size.c + (main): Exit after printing the version number, per the GNU coding + standards. + +Mon May 17 13:20:25 1993 Per Bothner (bothner@cygnus.com) + + * README, Makefile.in: Minor updates for 2.2. + +Fri May 14 11:12:26 1993 Per Bothner (bothner@cygnus.com) + + * Makefile.in (underscore.c): Automatically generate + (using nm) a file with the variable prepends_underscore. + * Makefile.in (c++filt): Link underscore.o with cplus-dem.o + so that initial underscores get removed iff appropriate. + * binutils.texi: Preliminary documentation for c++filt. + * Makefile.in, binutils.texi: Set to version 2.2. + + * NEWS: Mention copy->objcopy renaming and new c++filt program. + +Wed May 12 12:05:36 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (cplus-dem.o, $(DEMANGLER_PROG)): Build the + demangler via cplus-dem.o, rather than directly from the .c file. + + * objcopy.c: Renamed from copy.c, updated comments accordingly. + * Makefile.in, binutils.texi: Renamed copy to objcopy. + * is-strip.c, maybe-strip.c, not-strip.c: Updated comments for + rename of copy to objcopy. + +Mon May 10 17:20:18 1993 Per Bothner (bothner@cygnus.com) + + * binutils.texi (strip, -v option): Fix typo. + +Fri May 7 13:57:50 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (RUNTEST): Define. + (FLAGS_TO_PASS): Pass down RUNTEST. + +Tue May 4 10:06:50 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (DEMANGLER_PROG): Name it c++filt. + (PROG): Also build and install COPY_PROG. + +Mon May 3 19:11:48 1993 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Change definition of $(tooldir) to match FSF. + +Wed Apr 28 23:41:32 1993 David J. Mackenzie (djm@rtl.cygnus.com) + + * size.c (usage): Add missing options. + (main): Clean up option parser. + + * objdump.c (usage): Add missing options. + (display_file): Print program name before calling + bdf_perror. + + * nm.c (usage): Add missing options. + (main): Clean up option parser. + (display_file): Print program name before calling + bdf_perror. + + * copy.c (copy_usage, strip_usage): Add missing options. + + * ar.c (usage): New function. + (main): Call it. + (open_inarch, do_quick_append): Print program name before calling + bdf_perror. + +Thu Apr 22 15:01:35 1993 Ian Lance Taylor (ian@cygnus.com) + + * nm.c (main): Accept and ignore -A and -B for MIPS compatibility. + +Mon Apr 19 14:06:59 1993 Rob Savoye (rob@cygnus.com) + + * Makefile.in: Added FLAGS_TO_PASS so tests get run on freshly + built binaries if they exist. (otherwise the path) + +Wed Apr 7 22:22:50 1993 Rob Savoye (rob@cygnus.com) + + * Makefile.in: Changed check target to use DejaGnu. + +Thu Apr 1 12:37:13 1993 Jim Kingdon (kingdon@cygnus.com) + + * Makefile.in: Remove am29k-pinsn.c, i960-pinsn.c. + objdump.c: a29k and i960 are `disassemble' not `print'. + + * objdump.c: Rename print_address to objdump_print_address + and change parameters. + (disassemble_data): Use objdump_print_address. + +Wed Mar 31 10:25:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * objdump.c (disassemble_data): print_insn_sparc is now a + `disassemble' not a `print'. + Makefile.in: Remove sparc-pinsn.c (now in libopcodes.a). + + * objdump.c (disassemble_data): Use new read_memory_func stuff. + +Thu Mar 25 10:38:11 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * objdump.c (fprintf): Declaration of variadic function had better + be a prototype for ANSI C systems. + +Mon Mar 22 23:19:46 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: rename test-install to install-check + +Fri Mar 19 14:40:08 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + * objdump.c (disassemble_data): Add H8500. + +Fri Mar 19 10:56:51 1993 Jim Kingdon (kingdon@cygnus.com) + + * objdump.c (usage): Mention long options. + +Thu Mar 18 14:22:17 1993 Per Bothner (bothner@rtl.cygnus.com) + + * nm.c: Modify behavior of -o flag for archives to match + BSD4.4 and Sunos 4: Prefix archive name before each line. + + * m68k-pinsn.c: Removed. Subsumed by ../opcodes/m68k-dis.c. + * i386-pinsn.c: Removed. Subsumed by ../opcodes/i386-dis.c. + * Makefile.in: Adjust accordingly. + * objdump.c: Support new-style disassemblers (ones that use + the interface of ../include/dis-asm.h). + +Thu Feb 25 15:57:00 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: When making tar file, remove texinfo/*, + except for texinfo/texinfo.tex. + * ardup.c: Add extern declaration of strdup. + * Makefile.in (testsuite): Add 'else true' since otherwise + Ultrix /bin/sh complains. + +Wed Feb 24 19:44:18 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Set VERSION to 2.1. + * README, NEWS: Updates. + * nm.c: Add -v as a synonym for -V. + +Tue Feb 23 19:00:50 1993 Mike Werner (mtw@poseidon.cygnus.com) + + * configure.in: added testsuite to configdirs. + * Makefile.in: added support for building testsuite. + +Mon Feb 22 22:52:10 1993 Per Bothner (bothner@rtl.cygnus.com) + + * objdump.c (disassemble_data): Print function names when + given by bfd_find_nearest_line. If not - still print + line numbers. + +Mon Feb 22 07:54:03 1993 Mike Werner (mtw@poseidon.cygnus.com) + + * testsuite: made modifications to testcases, etc., to allow + them to work properly given the reorganization of deja-gnu and the + relocation of the testcases from deja-gnu to a "tool" subdirectory. + +Mon Feb 22 10:27:24 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * objdump.c (dump_data): Free up section contents each time + through the loop. Reported by minyard@bnr.ca. + +Sun Feb 21 10:55:55 1993 Mike Werner (mtw@poseidon.cygnus.com) + + * testsuite: Initial creation of binutils/testsuite. + Migrated dejagnu testcases and support files for testing nm to + binutils/testsuite from deja-gnu. These files were moved "as is" + with no modifications. This migration is part of a major overhaul + of dejagnu. The modifications to these testcases, etc., which + will allow them to work with the new version of dejagnu will be + made in a future update. + +Fri Feb 12 10:05:20 1993 Fred Fish (fnf@cygnus.com) + + * Makefile.in (LIBIBERTY_SRC_DIR, LIBIBERTY_BIN_DIR): New macros. + * Makefile.in (LIBIBERTY): Use LIBIBERTY_BIN_DIR. + * Makefile.in (DEMANGLER_PROG): New program to build. Add macro + and rule. + * Makefile.in (PROGS): Add DEMANGLER_PROG. + +Tue Jan 26 11:56:33 1993 Ian Lance Taylor (ian@cygnus.com) + + * copy.c, nm.c, objdump.c, size.c: Use new bfd_is_com_section + macro rather than checking for equality to bfd_com_section. + +Fri Jan 8 15:50:05 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objdump.c (disassemble_data): Fix code to find first useless + symbol. + +Thu Jan 7 13:13:31 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * objdump.c (disassemble_data): Use mips_print_insn for MIPS. + Don't core dump if bfd_find_nearest_line returns false. + +Wed Jan 6 17:14:01 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + * objdump.c (disassemble_data): know how to disassemble z8000s + too. + +Wed Jan 6 15:16:27 1993 Per Bothner (bothner@cygnus.com) + + * arsup.h (interactive), bucomm.h (program_name): Prefix + with 'extern', to avoid warnings from some compilers. + +Wed Jan 6 15:14:11 1993 Per Bothner (bothner@rtl.cygnus.com) + + * arparse.y: fix unnecessary shift/reduce + +Tue Dec 22 15:46:56 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Make check depend on all. + * Makefile.in (distclean): Remove sysdep.h. + * size.c: Use %u format where appropriate. + * objdump.c: Standardize: L_SET -> SEEK_SET. + * objdump.c: Use new macro bfd_asymbol_bfd. + * configure.in: Allow std-host as the default ${mys_host}. + +Thu Dec 17 19:38:19 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: added dvi target, define and use TEXI2DVI + +Tue Dec 15 18:05:07 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in (dist): Fix permissions before release. + * size.c: Use bfd_size_type (and long) where appropriate. + * ar.c: Make writing a map the default, to be compatible + with SYSV and Posix.2. Remove some bogus kludges that + handled __.SYMDEF directly. + * NEWS: New file. + +Mon Nov 9 13:36:53 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: flex no longer needs the -S flag + +Sat Nov 7 15:06:13 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * ar.c (extract_file): utime needs a pointer to a utimbuf + + * Makefile.in: handle -I includes better, adding $(BASEDIR)/bfd to + the list (since some of the bfd/hosts/*.h files include other + files from that directory) + +Fri Nov 6 00:12:51 1992 John Gilmore (gnu@cygnus.com) + + * i960-pinsn.c (MEM_MAX, MEM_SIZ): Set upper bound properly. + +Thu Nov 5 03:37:15 1992 John Gilmore (gnu@cygnus.com) + + Clean up some old BFD ansification macros. + + * arsup.h, bucomm.h, objdump.h: Remove EXFUN from binutils. + It still remains as a local macro in gmalloc.c, which is derived + from some other copy of GNU Malloc somewhere (FIXME). + + * ar.c, objdump.c, size.c: Replace EXFUN with PROTO. Make static + fns really static. + * arsup.h: Declare extract_files. + +Mon Nov 2 12:42:11 1992 Ian Lance Taylor (ian@cygnus.com) + + * ar.c (extract_file): instead of checking USG: if POSIX_UTIME, + use utime and utimbuf structure, otherwise if USE_UTIME use utime + and array of two longs, otherwise use utimes. + +Thu Oct 15 13:57:35 1992 Per Bothner (bothner@cygnus.com) + + * binutils.texi: Document yesterday's changes to strip and copy. + +Wed Oct 14 13:22:14 1992 Per Bothner (bothner@cygnus.com) + + * copy.c: Re-do command-line parsing to use getopt_long(). + Add long option names. Re-think option letters to be more + consistent. + * copy.c: New function filter_symbols() for stripping only + debug-symbols and/or local symbols. Use these to support + the previously-missing options of the old FSF strip. + +Tue Oct 13 01:24:20 1992 John Gilmore (gnu@cygnus.com) + + * configure.in (host): Use ${srcdir}/../bfd/configure.host rather + than repeating a copy of it here. + +Wed Oct 7 12:53:52 1992 Ken Raeburn (raeburn@cygnus.com) + + * copy.c (main): Even if is_strip, accept -d argument indicating + alternate output format. Needed by gdb for Nindy. + + * m68k-pinsn.c (print_insn_arg): Handle new "`" operand type. + +Tue Oct 6 16:33:56 1992 Jeffrey Osier (jeffrey@cygnus.com) + + * binutils.texi: added documentation for "copy" + +Tue Oct 6 14:22:56 1992 Per Bothner (bothner at PersSony) + + * Makefile.in (*clean rules): Some cleaning up. + * Makefile.in (dist): Make diststuff in gprof for a dist. + + * ar.c (do_show_version): New function. + * ar.c (main): Fix so "ar -V" works. + +Thu Oct 1 22:44:45 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: now uses the cpu-vendor-os triple instead of + nested cases. + +Fri Sep 25 22:41:08 1992 John Gilmore (gnu@cygnus.com) + + * i960-pinsn.c: Change bzero to memset. + * sparc-pinsn.c: Change index to strchr. + +Mon Sep 21 14:39:56 1992 Ian Lance Taylor (ian@cygnus.com) + + * m68k-pinsn (print_insn_arg, fetch_arg): added support for + operands to memory management instructions, from WRS. + +Tue Sep 15 15:26:38 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (install): if $(tooldir) exists, install nm and + strip in $(tooldir)/bin. + +Thu Sep 3 11:57:40 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Let's call it version 2.0. + +Wed Sep 2 00:25:13 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Bump to version 0.98. + * TODO, README: Minor updates. + + * Makefile.in: Added mostlyclean, distclean rules, + and cleaned up clean, realclean. + +Sun Aug 30 21:18:59 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: map program names through program_transform_name + when installing. + +Sun Aug 30 18:09:03 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Bump to versions 1.97.90. + * cplus-dem.c: Removed. Was nowhere used - and if some + programs are changed to to demangling should now use the + versions in libiberty. + +Thu Aug 27 12:58:09 1992 Brendan Kehoe (brendan@cygnus.com) + + * configure.in: add we32k + +Mon Aug 24 14:53:42 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ar.c (map_over_members): if the element of the archive has a + null name, fill it in. + + * nm.c (do_one_rel_file): only warn if a bfd's flags say there + will be symbols and there aren't any. + +Wed Aug 19 11:20:25 1992 Ian Lance Taylor (ian@cygnus.com) + + * m68k-pinsn.c: handle new operand type 'r', introduced for cas2. + +Tue Aug 18 20:45:48 1992 Rob Savoye (rob@cygnus.com) + + * nm.c objdump.c: Added support for a +version (-V) + to print the version number. + + * ar.c, copy.c: Added support for a -V option to print + the version number. + +Tue Aug 18 13:28:44 1992 Ian Lance Taylor (ian@cygnus.com) + + * config/mh-apollo68v: removed -g from CC definition. + + * Makefile.in: always create installation directories. + +Mon Aug 17 18:33:41 1992 Per Bothner (bothner@rtl.cygnus.com) + + * m68k-pinsn.c: Minor fix in style of output (don't use + range to indicate floating point control registers). + +Tue Aug 11 23:42:21 1992 Per Bothner (bothner@cygnus.com) + + * ar.c (main): Don't *always* set the verbose flag! + +Wed Aug 5 11:25:27 1992 Per Bothner (bothner@rtl.cygnus.com) + + * copy.c: When is_strip (because it is invoked as the strip + program), follow traditional argv processing: + 'strip file1 file2' now strips file1 and file2, rather + than stripping file1 (as input), leaving output in file2. + +Mon Jul 27 16:28:08 1992 Per Bothner (bothner@rtl.cygnus.com) + + * objdump.c (display_info, display_info_table): Call + bfd_set_format() on dummy bfd before using it (twice). + * ar.c: Make sure archive is created on command 'r' + even when no elements are inserted. (Clean up and + simplify some non-working related code.) + +Mon Jul 20 02:48:38 1992 D. V. Henkel-Wallace (gumby@cygnus.com) + + * configure.in: hppa support doesn't assume hp OS (from sef). + +Sat Jul 18 14:35:22 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: recognize hppa hosts (bsd & hpux), error messages + to stderr, not stdout + +Fri Jul 17 18:39:44 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * ar.1, binutils.texi, i960-pinsn.c, nm.1, objdump.1, ranlib.1, + size.1, sparc-pinsn.c, strip.1: removed rcsid's. + +Thu Jul 16 16:55:24 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.dos: removed rcsid. + +Thu Jul 16 08:23:07 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * objdump.c (display_bfd): print state of BFD_IS_RELAXABLE too + +Tue Jun 30 20:26:15 1992 D. V. Henkel-Wallace (gumby@cygnus.com) + + * Makefile.in: Add program_suffix (parallel to program_prefix) + +Thu Jun 25 04:52:45 1992 John Gilmore (gnu at cygnus.com) + + * nm.c (sorters): Lint. Remove excess whitespace. + +Wed Jun 24 13:48:07 1992 Per Bothner (bothner@cygnus.com) + + * nm.c (valueof macro): Add missing parentheses. + (Their lack screwed up numeric_forward().) + +Sun Jun 14 10:33:27 1992 John Gilmore (gnu at cygnus.com) + + * objdump.c (dump_elf_stabs): Also dump .stab.index and + .stab.excl sections. + (dump_elf_stabs_1): Split out main body of old dump_elf_stabs. + * objdump.1, binutils.texi: Document new sections dumped. + +Fri Jun 12 22:23:35 1992 John Gilmore (gnu at cygnus.com) + + * size.c, objdump.c, bucomm.c: Lint. + +Thu Jun 11 01:19:06 1992 John Gilmore (gnu at cygnus.com) + + * objdump.c (dump_elf_stabs): New feature: --stabs prints out a + .stab section from an ELF file. Installed under #ifdef + ELF_STAB_DISPLAY so it can be easily disabled, since it requires + bfd-internals header files and such. + * objdump.1, binutils.texi: Update for --stabs. Also fix + objdump's doc to use -- rather than + for long options. + (FIXME: Not yet fixed everywhere in binutils.texinfo.) + +Wed Jun 10 07:53:24 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * objdump.c(display_info), patches from + mohring@informatik.tu-muenchen.de to print the table much more + nicely. + +Thu May 28 13:36:16 1992 Per Bothner (bothner@rtl.cygnus.com) + + * objdump.c: Add another enum->int cast, for the sake of + old compilers (such as PCC). + +Wed May 27 13:01:44 1992 Per Bothner (bothner@rtl.cygnus.com) + + * arlex.l: Don't include (unneeded conflicts). + Add declaration of strdup(). + +Fri May 22 13:40:37 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Use srcdir instead of VPATH in ldgram/ldlex + rules, since these are used when building a distribution. + * Makefile.in (arlex.c): Don't re-direct output, since that + leaves a bogus output files if it fails. + + * arlex.l: Make work with lex, for what it's worth. + * Makefile.in: Better lex support. + * Makefile.in (dist): Generate flex and bison outputs + for distribution. + +Thu May 14 17:17:59 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.in: get BISON definition right. + +Fri May 8 07:47:08 1992 K. Richard Pixley (rich@cygnus.com) + + * sanity.sh: default TMPDIR to ".". + +Thu May 7 12:34:50 1992 Roland H. Pesch (pesch@fowanton.cygnus.com) + + * binutils.texi: add doc for ar command language. + +Wed May 6 18:05:36 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * arparse.y: make END call ar_end + * arsup.c (ar_end): added, deletes temp file if archive session + aborted. + + +Wed May 6 11:08:53 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.in: use bison & flex from ../ if they exist. Also, + FLEX->LEX. + + * sanity.sh: remove temporary directory when finished. + +Tue May 5 12:00:58 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Bump to version 1.97. + * ar.c: Declare errno for machines that need it. + +Mon May 4 23:29:51 1992 John Gilmore (gnu@cygnus.com) + + * objdump.c (display_info): Handle error cases without coredump. + Close the dummy temporary file we open in the loop. + * Makefile.in (arsup.o): Add kludge to build with Sun Make. + +Fri May 1 16:20:23 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: added test-install target. + + * sanity.sh: new file. + + * Makefile.in: use sanity test on make check. + +Tue Apr 21 13:38:37 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: rework CFLAGS so that they can be passed on the + command line to make. Remove MINUS_G. Default CFLAGS to -g. + +Wed Apr 15 14:33:07 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * arsup.c, arsup.h, arparse.y, arlex.l: support for archive + scripting language. + +Fri Mar 6 21:54:53 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: added check target. + +Thu Mar 5 21:35:49 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: added clean-info target. + +Tue Mar 3 15:36:37 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.in: remove $(COPY_PROG) from PROGS. It shouldn't be + installed. added tooldir and program_prefix. + +Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in, configure.in: removed traces of namesubdir, + -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced + copyrights to '92, changed some from Cygnus to FSF. + +Sun Feb 16 12:53:02 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in: Bump version to 1.96, and remove -beta + suffix from distribution name. + * m68k-pinsn.c: New macro COERCE_SIGNED_CHAR to extract + the signed value of a character (even if chars are unsigned). + * sparc-pinsn.c: Add new operand types. + +Thu Feb 6 12:14:19 1992 Steve Chamberlain (sac at rtl.cygnus.com) + + * objdump.c (disassemble_data): don't print a section's contents + if it's not loadable (eg bss) + +Tue Jan 28 11:11:06 1992 Steve Chamberlain (sac at rtl.cygnus.com) + + * m68k-pinsn.c (print_insn_arg): fixed so that -ve branch + displacements don't get printed as large +ve ones. + +Fri Jan 24 14:47:53 1992 Steve Chamberlain (sac at rtl.cygnus.com) + + * copy.c, nm.c, objdump.c, size.c : changed to use the + new reloc scheme. + + +Mon Dec 30 18:34:41 1991 Per Bothner (bothner at cygnus.com) + + * bucomm.c (print_arelt_descr): Tweek the output format + so that 'ar tv' output follows Posix 1003.2/D11. + Output is now also identical to Sun's (except __.SYMDEF). + +Mon Dec 30 06:09:53 1991 John Gilmore (gnu at cygnus.com) + + * Makefile.in: Make `make' output more readable. + +Wed Dec 18 15:04:45 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in: Bump to version 1.94. + +Wed Dec 11 16:48:09 1991 Steve Chamberlain (sac at cygnus.com) + + * ar.c: added "b" to fopens for dos + * configdj.bat, makefile.dos new files from DJ + +Tue Dec 10 04:07:26 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * Makefile.in: infodir belongs in datadir. + +Sat Dec 7 17:09:37 1991 Steve Chamberlain (sac at rtl.cygnus.com) + + * bucomm.h: created to hold prototypes of bucomm.c + * objdump.h: created to hold prototyes of objdump.c + * am29k-pinsn.c: include objdump.h + * ar.c: include bucomm.h, get ar.h from the right place and + include libbfd.h + * bucomm.c: defunize bfd_fatal + * copy.c: include bucomm.h, lint. + * i960-pinsn.h: include bucomm.h + * m68k-pinsn.h: lint + * nm.c: include bucomm.h, lint + * objdump.c: lint + * sparc-pinsn.c: include objdump.h + + + +Fri Dec 6 23:02:14 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * Makefile.in: added standards.text support. install using + INSTALL_PROGRAM and INSTALL_DATA. + + * configure.in: configure now does all of it's work from objdir so + make file existence tests against ${srcdir}. + +Thu Dec 5 22:46:22 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * Makefile.in: idestdir and ddestdir go away. Added copyrights + and shift gpl to v2. Added ChangeLog if it didn't exist. docdir + and mandir now keyed off datadir by default. + +Wed Dec 4 22:42:03 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in: Bump to version 1.93. + * Makefile.in: Add make-strip.o:maybe-strip.c dependency + for make versions that provide half-baked VPATH-support (e.g. Sun's). + * size.c: Improvements suggested by + "david d [zoo] zuhn" : + - Don't emit (Berkeley) headers if no files were found. + - Return a non-zero return code on failure. + +Sat Nov 30 21:34:19 1991 Steve Chamberlain (sac at rtl.cygnus.com) + + Changes due to include file renaming: + * am29k-pinsn.c: a29k-opcode.h -> opcode/a29k.h + * sparc-pinsn.c: sparc-opcode.h -> opcode/sparc.h + * m68k-pinsn.c: m68k-opcode.h -> opcode/m68k.h + * nm.c: stab.gnu.h -> aout/stab_gnu.h + +Tue Nov 19 19:20:43 1991 Per Bothner (bothner at cygnus.com) + + * README: Mention MINIMIZE flag for bfd's make. + +Mon Nov 18 12:05:37 1991 Per Bothner (bothner at cygnus.com) + + * README: Various improvements. + +Sun Nov 17 23:40:59 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in: Bump to version 1.92. + * version.c, Makefile.in: Get version string from Makefile. + * copy.c, is-strip.c, not-strip.c, maybe-strip.c, Makefile.in: + Make the same change that we earlier did for ar/ranlib: + Generate two different binaries for strip and copy and use + a global variable with different values to distinguish + ostrip from copy. (-1 means to use argv[0] to decide, + so you can get the old behavior, but it is no longer the default). + * copy.c (copy_file): Set EXEC_P of output bfd if input is so. + * copy.c (main): If is_strip==-1, compare last 5 chars + of argv[0], not the whole path. + * copy.c (main): Return 0, not 1. + * copy.c (setup_sections): Fix due to change in bfd_make_section + now failing if asked for a duplicate section. + * strip.c, ostrip.c: Removed obsolete files. + * ar.c, not-ranlib.c, maybe-ranlib.c: + Change encoding of is_ranlib variable to be consistent + with is_strip for strip.copy (i.e -1 to means use argv[0]). + +Thu Nov 14 20:11:02 1991 Per Bothner (bothner at cygnus.com) + + * version.c (program_version): Update to version 1.92. + +Tue Nov 12 16:17:53 1991 Per Bothner (bothner at cygnus.com) + + * ar.c (get_pos_bfd): Previous fix was missing a "break". + +Thu Nov 7 08:55:56 1991 Steve Chamberlain (sac at cygnus.com) + + * am29k-pinsn.c: Fixed bug in mtacc, dmac and fmac instruction + encodings. (Thaks to David Wood) + +Sun Nov 3 14:50:23 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in ($(DIST_NAME).tar.Z), TODO: Various fixes. + * ar.c (get_pos_bfd): Fix to handling of before/after + positioning options. + * bucomm.c (fatal): MISSING_VFPRINTF is no longer an issue, + since libiberty contains vfprintf etc if otherwise missing. + * m68k-pinsn.c (print_insn_arg): Support BB/BW/BL + type operands, as used by branch instructions. + * nm.c: Delegate printing of symbols to BFD, + by using bfd_print_symbol to do the formatting. + +Mon Oct 28 11:20:47 1991 Steve Chamberlain (steve at cygnus.com) + + * ar.c (write_archive.c): added unlink before rename since some + systems can't rename onto an existant file. + +Mon Oct 21 09:47:23 1991 Steve Chamberlain (steve at rtl.cygnus.com) + + * nm.c: now doesn't crash if a symbol with no section and no + SEC_ABS appears. + +Thu Oct 17 15:25:50 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in, version.c: Bump to version 1.91. + +Wed Oct 16 11:45:36 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in, ar.c, bucomm.c, copy.c, cplus-dem.c, filemode.c, + i960-pinsn.c, m68k-pinsn.c, nm.c, objdump.c, size.c, sparc-pinsn.c, + * strip.c: Add or update Copyright notice. + * TODO: Add note on 'nm -a'. + * version.c: Update version number to 1.90. + * Makefile.in: Fix making of documentation for dist. + +Tue Oct 15 00:17:17 1991 Per Bothner (bothner at cygnus.com) + + * README: New file. + * Makefile.in: New kludgy rules for making a tarfile. + * Makefile.in: Fix bindir path. + +Mon Oct 14 17:34:29 1991 Roland H. Pesch (pesch at cygnus.com) + + * Makefile.in: add targets binutils.mm, binutils.me + +Fri Oct 11 22:44:21 1991 John Gilmore (gnu at cygnus.com) + + * Makefile.in: Avoid Sun Make VPATH bugs by adding dependencies. + +Fri Oct 11 12:51:33 1991 Roland H. Pesch (pesch at cygnus.com) + + * Makefile.in: add target "binutils.ms" + + * binutils.texinfo: minor restructuring for texi2roff comfort. + +Fri Oct 11 04:12:28 1991 John Gilmore (gnu at cygnus.com) + + Restructure configuration scheme for bfd, binutils, ld. + + * configure.in: Revise to symlink sysdep.h to ../bfd/hosts/h-xxx.h. + Change some config names to match other dirs. + * *.c: Include bfd.h before sysdep.h, so ansidecl and PROTO() + get defined first. + * Makefile.in: Use -I. to get sysdep.h. + +Wed Oct 9 22:42:56 1991 Per Bothner (bothner at cygnus.com) + + * nm.c (print_symbols): Handle NULL name field of symbol. + * Makefile.in: Removed spurious comment. + +Tue Oct 8 16:55:03 1991 Roland H. Pesch (pesch at cygnus.com) + + * binutils.texinfo: minor typos, phrasing, formatting fixes. + +Tue Oct 8 15:13:20 1991 Per Bothner (bothner at cygnus.com) + + * configure.in: Get host file from ../bfd/config, not config. + * config/*: Remove config directory and its files. + +Tue Oct 8 13:58:59 1991 Roland H. Pesch (pesch at cygnus.com) + + * Makefile.in: new targets binutils.dvi, binutils.info + + * binutils.texinfo: remove most remaining FIXME's, delete + references to __.SYMDEF by name + + +Tue Oct 8 10:23:44 1991 Steve Chamberlain (steve at cygnus.com) + + * objdump.c (print_address) Print addresses nicely. + +Mon Oct 7 11:31:05 1991 Per Bothner (bothner at cygnus.com) + + * ar.c, Makefile.in, new files {is,not,maybe}-ranlib.c: + Make two different binaries for ar and ranlib, instead of + distinguishing them at run time using argv[0]. + (Old behavior is still available if you "make ar_with_ranlib", + but it is not the default.) + * ranlib.sh (new): An alternative one-line + shell implementation of ranlib. + +Fri Oct 4 21:49:44 1991 John Gilmore (gnu at cygnus.com) + + * objdump.c: Cope with renames of a few BFD types & enums. + +Fri Oct 4 19:08:09 1991 Roland H. Pesch (pesch at cygnus.com) + + * binutils.texinfo: add new file (rudimentary docn) + +Mon Sep 30 12:30:39 1991 Per Bothner (bothner at cygnus.com) + + * config/hmake-news: Add new file (for Sony NEWSOS3). + * bucomm.c (fatal): Conditionally compile fatal() depending on + MISSING_VFPRINTF, and don't confuse the issue with NO_VARARGS. + * objdump.c (dump_headers): Trivial output format change. + * objdump.c (display_info): Loop over integers, not enums, + to appease old compilers. + +Mon May 20 16:14:07 1991 Steve Chamberlain (steve at cygint.cygnus.com) + + *objdump.c *nm.c *copy.c: Changed some types to work with 64 bit + object files. + +Thu May 16 16:06:55 1991 Steve Chamberlain (steve at cygint.cygnus.com) + from bother + * objdump.c (print_address): Make disasembled output more + consistent with gdb and as: Add 0x when printing hex. + Don't print extra leading zeros. + Attempt to not print "filename.o". + * objdump.c: Add some enum-to-int casts to accommodate old compilers. + + +Fri May 3 22:21:44 1991 John Gilmore (gnu at cygint.cygnus.com) + + * copy.c: Change =& constructs to = &, since they confuse older + C compilers. + + +Copyright (C) 1991-1997 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/ChangeLog-9899 b/support/sdbinutils/binutils/ChangeLog-9899 new file mode 100644 index 0000000..75f231e --- /dev/null +++ b/support/sdbinutils/binutils/ChangeLog-9899 @@ -0,0 +1,1914 @@ +1999-12-28 Nick Clifton + + * readelf.c: Update with new constants added by Oct 4, 1999 + ELF ABI draft. + (guess_is_rela): Add new machine codes, but leave + rel type undetermined. + (get_machine_name): Add new machine codes. + (get_section_type_name): Add new section types. + (get_elf_section_flags): New function: Decode section flags. + (process_section_headers): Call get_elf_section_flags() in + order to decode flags in section header. + (get_dynamic_flags): New function: Decode dynamic section + flags. + (process_dynamic_section): Display flags (if present). + (get_symbol_type): Add STT_COMMON. + (get_symbol_visibility): New function: Decode a symbol's + visibility. + (process_symbol_table): Call get_symbol_visibility(). + (get_note_type): Add NT_PRXFPREGS. + +1999-12-26 Ian Lance Taylor + + * strings.c (main): Correct handling of numeric argument. + +1999-12-23 Andrew Haley + + * dlltool.c (mtable): mcore how_jtab_roff is 4 bytes into the + jtab; was 8. + +1999-12-17 Nick Clifton + + * dlltool.c (mtable): Stop compile time warnings about missing + initialisers. + (yyerror): Stop compile time warnings about unused paramater. + (INIT_SEC_DATA): New macro: initialise an entry in the secdata + array. + (secdata): Stop ccompile time warnings about uninitialised + fields. + (dtab): Stop compile time warnings about unused parameter. + (long_options): Stop compile time warning about missing + initialiser. + +1999-12-10 Nick Clifton + + * readelf.c (print_vma): Support native 64bit ELF systems. + +1999-12-09 Nick Clifton + + * dlltool.c (mtable): Add epoc-arm specific entry. + Make default arm entry pass -mpacs-26 to assembler. + (flush_page): Do not mangle null entries. + +1999-12-07 H . J . Lu hjl@valinux.com + + * readelf.c: Fix compile time warnings. Support more than 999 + symbols. + +1999-12-03 Nick Clifton + + * readelf.c (enum print_mode): New type. + (print_vma): New function. + (dump_relocations): Use print_vma to display bfd_vma values. + (process_file_header): Use print_vma to display bfd_vma values. + (process_program_headers): Use print_vma to display bfd_vma values. + (process_section_headers): Use print_vma to display bfd_vma values. + (dynamic_segment_parisc_val): Use print_vma to display bfd_vma values. + (process_dynamic_segment): Use print_vma to display bfd_vma values. + (process_symbol_table): Use print_vma to display bfd_vma values. + (process_mips_specific): Use print_vma to display bfd_vma values. + +1999-11-25 Fred Fish + + * readelf.c (process_note): Change arg from Elf_External_Note + to Elf32_Internal_Note, which also turns the function body + into little more than a call to printf. + (process_corefile_note_segment): Substantially rewritten + to properly handle case where target and host are different + endianness, handle note sections with padding, and add some + cruft to handle notes with unterminated name data. + +1999-11-22 Nick Clifton + + * objcopy.c (copy_usage): Reformat. + (strip_usage): Reformat. + +1999-11-21 Nick Clifton + + * objdump.c (usage): Overhaul output: One line per switch. + Textual description of each switch. Distinguish between + optional switches and required switches. + (long_options): Add 'g', 'G' and 'z' short options. + (main): Distinguish between optional switches and required + switches. + + * binutils.texi: Add -g -G and -z short options for + --debugging, --stabs and --disassemble-zeroes. + +1999-11-03 Nick Clifton + + * dlltool.c (flush_page): Clip short values to prevent warnings + from the assembler. + Change default mcore machine name to 'mcore-le' and rename + big-endian version to 'mcore-be'. + +1999-10-27 Fred Fish + + * objdump.c (display_bfd): Break into two functions. The + actual dumping code moves to dump_bfd. If bfd is not + unambiguously recognized as a bfd_object, attempt to dump + it as a bfd_core. + (dump_bfd): New function. + +1999-10-26 Nick Clifton + + * dlltool.c (assemble_file): Remove spurious test of exp_name. + +1999-10-22 Nick Clifton + + * dlltool.c (struct mac): Add new field 'how_default_as_switches'. + (mtable): Initialise new field. Some machines have a non empty + string for this field. + (HOW_BFD_TARGET): Undefine and replace with... + (HOW_BFD_READ_TARGET): New macro: bfd target to use when opening a + file for reading. This is set to 0 so that any recognisable bfd + format can be read. + (HOW_BFD_WRITE_TARGET): New macro: bfd target to use when opening + a file for writing. This is set to the target machine type. + (ASM_SWITCHES): New macro: default switches to use when assembling + a file. + (assemble_file): New function: Assemble a source file into a + destination object file. + (gen_exp_file): Use assemble_file to create the exp file. + (make_one_lib_file): Use assemble_file to create the lib file. + Open output file use HOW_BFD_WRITE_TARGET and input files using + HOW_BFD_READ_TARGET. + (make_head): Use assemble_file to create the head file. + (make_tail): Use assemble_file to create the tail file. + (gen_lib_file): Open output file use HOW_BFD_WRITE_TARGET. + +1999-10-15 Ian Lance Taylor + + * ar.c (normalize): Fix full_pathname code. + +1999-10-08 Ben Elliston + + * binutils.texi: Some rewording and clarifications. + +1999-09-15 Ulrich Drepper + + * readelf.c (dynamic_segment_parisc_val): Print 0 for DLD_FLAGS if + the value is zero. + (process_symbol_table): Don't print histogram if hash table is empty. + +1999-09-15 Ulrich Drepper + + * readelf.c (get_parisc_dynamic_type): Handle DT_HP_GST_* values. + +1999-09-02 Ulrich Drepper + + * readelf.c (get_symbol_type): Add support for HPUX and PARISC + specific symbol types. + + * readelf.c: Add HPUX and PARISC extensions to dynamic and program + header table printing. + + * readelf.c (get_machine_flags): Add handling of PARISC. + +1999-09-29 Mumit Khan + + * dlltool.c (scan_drectve_symbols): Handle type tags in exported + symbols. + (scan_filtered_symbols): Likewise. + +1999-09-19 Ian Lance Taylor + + * resrc.c (write_rc_rcdata): Fix local variable shadowing + problem. If RCDATA_BUFFER data can be read as strings, modify + code to print the strings as comments. + * resres.c: Add casts to avoid warnings. + (write_res_data, read_res_data): Don't put the program name in the + error message; fatal already puts it there. + +1999-09-14 Michael Meissner + + * configure.in (Canonicalization of target names): Remove adding + ${CONFIG_SHELL} in front of $ac_config_sub, since autoconfig 2.14 + generates $ac_config_sub with a ${CONFIG_SHELL} already. + * configure: Regenerate. + +1999-09-12 Ian Lance Taylor + + * ar.c (main): Clear output_file if we don't change the archive. + (delete_members, replace_members): Likewise. + +1999-09-12 Donn Terry + + * objdump.c (dump_headers): If wide_output, print Flags header. + + * objdump.c (dump_section_header): Print any comdat information. + + * objcopy.c (parse_flags): Handle "noload", "debug", and "share". + * binutils.texi, objcopy.1: Document new flags. + + * ar.c (counted_name_mode): New static variable. + (counted_name_counter): New static variable. + (map_over_members): Handle counted mode. + (usage): Mention N modifier. + (main): Handle N modifier. + (delete_members): Handle counted mode. + * binutils.texi, ar.1: Document N modifier. + + * ar.c (print_contents): Change printing of member name for + POSIX.2 conformance. + + * ar.c (output_filename): Make const. + (open_inarch): If creating a new empty archive, set + output_filename. + +1999-09-12 Ian Lance Taylor + + * ar.c (full_pathname): New static variable. + (map_over_members): Call normalize on command line parameter. + (usage): Mention P modifier. + (normalize): If full_pathname is true, don't do anything. + (main): Accept P modifier. + (delete_members): Call normalize on command line parameter. + * binutils.texi, ar.1: Document P modifier. + +1999-09-09 Andreas Schwab + + * binutils.texi: Add info dir entries for all programs described + here. Fix arguments of @var to not contain punctuation. + +1999-09-06 Donn Terry + + * nm.c (print_symbol_info_bsd): Check for 'w' as well as 'U'. + (print_symbol_info_sysv): Likewise. + (print_symbol_info_posix): Likewise. + +1999-09-04 Steve Chamberlain + + * readelf.c: Include "elf/pj.h". + (dump_relocations): Handle EM_PJ. + (get_machine_name): Likewise. + (get_machine_flags): Likewise. + +1999-08-31 Scott Bambrough + + * readelf.c (get_note_type): New function: Decode the e_type + value of a note. + (process_note): New function: Display the contents of a core note. + (process_corefile_note_segment): New function. + (process_corefile_note_segments): New function. + (process_corefile_contents): New function. + (process_file): Add call to process_corefile_contents. + (parse_args): Add parsing of -n/--notes command line switch. + (usage): Document new command line switch. + + * binutils.texi: Documemnt new command line switch to readelf. + +1999-08-31 Ian Lance Taylor + + * binutils.texi (Bug Reporting): Clarify that large files should + not be sent to bug-gnu-utils. + +1999-08-28 Stephane Carrez + + * readelf.c (process_extended_line_op): New parameter pointer_size, + read the address according to pointer_size. + (debug_line_pointer_size): New global to indicate the + size of address in .debug_line section. + (debug_displays, prescan_debug_info): Prescan the .debug_info section + to record the size of address in `debug_line_pointer_size'. + (process_section_contents): Before dumping any section, execute + the pre-scan operation defined for some debug sections. + +1999-08-27 Jim Wilson + + * readelf.c (display_debug_lines): Use i-1 not i in standard_opcodes + access. + (display_debug_aranges): New local excess. Use for calculating padding + and add that into ranges. Break from loop only if length is also 0. + +1999-08-27 Jim Wilson + + * readelf.c (display_debug_lines, case DW_LNS_const_add_pc): Multiply + adv by info.li_min_insn_length. + +1999-08-26 Jakub Jelinek + + * readelf.c (get_sparc64_dynamic_type): New function. + (get_dynamic_type): Use it. + +1999-08-26 Jim Wilson + + * readelf.c (display_debug_lines, case default): Change second line + setting adv to use = not +=. + +1999-08-19 Nick Clifton + + * dlltool.c: Added more examples to the comment at the start. + +1999-08-18 Nick Clifton + + * dlltool.c (make_head): Only emit interworking directive if + necessary. + +Thu Jul 15 22:44:21 1999 Hans-Peter Nilsson + + * readelf.c (process_abbrev_section): Handle standard-conforming + single zero at the end of the section. + +1999-08-09 Ian Lance Taylor + + * objdump.c (exit_status): New static variable. + (nonfatal): New static function. + (disassemble_data): Set exit_status on error. + (read_section_stabs): Likewise. + (display_bfd): Likewise. Call nonfatal rather than bfd_nonfatal. + (display_file): Call nonfatal rather than bfd_nonfatal. + (display_target_list, display_info_table): Likewise. + (main): Return exit_status rather than 0. + +1999-08-08 Ian Lance Taylor + + * objdump.c (dump_section_header): Update for renaming of + SEC_SHORT to SEC_SMALL_DATA. Print SEC_SHARED flag. + + From Eli Zaretskii : + * binutils.texi: Document cxxfilt as MS-DOS name for c++filt. + + * configure.in: Define and substitute DEMANGLER_NAME. + * Makefile.am (DEMANGLER_PROG): Set to cxxfilt. + (man_MANS): Use DEMANGLER_NAME rather than DEMANGLER_PROG. + (bin_PROGRAMS): Remove $(DEMANGLER_PROG). + (noinst_PROGRAMS): Add $(DEMANGLER_PROG). + (cxxfilt_SOURCES): Rename from c__filt_SOURCES. + (cxxfilt_LDADD): Rename from c__filt_LDADD. + ($(DEMANGLER_NAME).1): Rename from $(DEMANGLER_PROG).1. Use + DEMANGLER_NAME rather than DEMANGLER_PROG in substitution. + (MOSTLYCLEANFILES): Use DEMANGLER_NAME rather than + DEMANGLER_PROG. + (install-exec-local): When installing noinst_PROGRAMS, change + cxxfilt to $(DEMANGLER_NAME). + * configure, Makefile.in: Rebuild. + + * Makefile.am: Rename .dep* files to DEP*. Change DEP variable to + MKDEP. + * Makefile.in: Rebuild. + +1999-08-05 Donn Terry + + * Makefile.am (YACC): If bison is not in the source tree, use + @YACC@ rather than bison -y. + (LEX): If flex is not in the source tree, use @LEX@ rather than + flex. + * configure.in: Build dlltool for i[3-6]86-*-interix. + * Makefile.in, configure: Rebuild. + +1999-07-21 Ian Lance Taylor + + From Mark Elbrecht: + * configure.bat: Remove; obsolete. + +1999-07-16 Jakub Jelinek + + * readelf.c (get_machine_flags): Print EF_SPARC_SUN_US3. + +1999-07-15 Ian Lance Taylor + + * configure.in: Bump version number to 2.9.5. + * configure: Rebuild. + +1999-07-14 Richard Henderson + + * objdump.c (dump_section_header): Print SEC_SHORT. + +1999-07-11 Ian Lance Taylor + + * Many files: Changes to avoid gcc warnings: Add ATTRIBUTE_UNUSED + as appropriate. Add variable initializations. Add casts. + * objdump.c (disassemble_bytes): Change j to bfd_vma. + * readelf.c (process_syminfo): Change i to unsigned int. + (display_debug_info): Change abbrev_number to unsigned long. + (process_mips_specific): Change fcnt to size_t. + +1999-07-09 Nick Clifton + + * readelf.c: Only support decoding 64bit ELF files if the compiler + supports a 64 bit data type. + Add -I equivalent for --histogram. + Add -A command-line option to display architecture specific information. + +1999-07-08 Jakub Jelinek + + * readelf.c (guess_is_rela): Sparcv9 and v8plus use rela. + (dump_relocations): Use ELF64_R_TYPE_ID for Sparc, for R_SPARC_OLO10 + print the secondary addend. + (get_machine_flags): Print Sparc machine flags. + (get_symbol_type): Print STT_REGISTER. + +1999-07-08 Ian Lance Taylor + + * stabs.c (parse_stab_type): Fix handling of template names with + template parameters containing `::'. + (stab_demangle_type): Handle a qualified name in a pointer to + member. + +1999-06-23 Ian Lance Taylor + + * Makefile.am (dlltool_SOURCES): Add dyn-string.c. + * Makefile.in: Rebuild. + +1999-06-23 Mumit Khan + + * configure.in (HAVE_EXECUTABLE_SUFFIX): Define. + * dlltool.c (look_for_prog): Use HAVE_EXECUTABLE_SUFFIX. + * dllwrap.c (look_for_prog): Likewise. + * resrc.c (look_for_default): Likewise. + * configure, config.in: Rebuild. + +1999-06-22 Ian Lance Taylor + + Based on patches from Mumit Khan : + * configure.in: Define EXECUTABLE_SUFFIX. + * dlltool.c: Include "dyn-string.h". Include based on + ANSI_PROTOTYPES, not __STDC__. + (outfile): Remove. + (gen_exp_file): Change uses of outfile to use alloca. + (make_one_lib_file, make_head, make_tail): Likewise. + (gen_lib_file): Likewise. + (look_for_prog): New static function. + (deduce_name): Rewrite to use look_for_prog. + (mcore_elf_gen_out_file): Use dyn_string_t rather than outfile. + * dllwrap.c: Don't include , , , + , or . Include and either + or . + (driver_name): Initialize to NULL, not "gcc". + (dlltool_name): Initialize to NULL, not "dlltool". + (display, inform, look_for_prog, deduce_name): New static + functions. + (usage): Mention -mno-cygwin. + (OPTION_MNO_CYGWIN): Define. + (main): Handle -mno-cygwin. Deduce driver_name and dlltool_name. + * resrc.c (look_for_default): Make static. Remove unused local + path. Check using EXECUTABLE_SUFFIX. + (read_rc_file): Allocate enough space to hold EXECUTABLE_SUFFIX. + * Makefile.am: Rebuild dependencies. + (dllwrap_LDADD): Add $(INTLLIBS). + * configure, Makefile.in, config.in: Rebuild. + +Mon Jun 21 16:49:11 1999 Jeffrey A Law (law@cygnus.com) + + * readelf.c (dump_relocations): Use elf_hppa_reloc_type instead of + elf32_hppa_reloc_type. + +1999-06-17 Nick Clifton + + * dlltool.c (mcore_elf_gen_out_file): Link object files with the + .exp file, not the .lib file. + +Fri Jun 18 20:17:51 1999 Mumit Khan + + * deflex.l: Accept single-character symbol names. + +1999-06-16 Nick Clifton + + * readelf.c (get_symbol_type): Detect ARM symbols typed as Thumb + functions. + +1999-06-14 Nick Clifton + + * objdump.c (disassembler_options): New variable. + (usage): Document new -M/--disassembler-options option. + (long_options): Add --disassembler-options. + (disassemble_data): Initialise disassembler_options field of + disassembler_info structure. + (main): Add parsing of -M option. + + * binutils.texi: Document new command line switch to objdump. + + * NEWS: Describe new command line switch to objdump. + + +Mon Jun 14 10:27:54 1999 Andreas Schwab + + * binutils.texi: Fix typos. + +1999-06-13 Ian Lance Taylor + + * objdump.c (disassemble_bytes): If the disassembler returns an + error, print out anything it may have printed to the buffer. From + H.J. Lu . + + * defparse.y (explist): Remove separate expline to eliminate + shift/reduce conflict. + + From Kai-Uwe Rommel : + * defparse.y: Add tokens NONSHARED, SINGLE, MULTIPLE, + INITINSTANCE, INITGLOBAL, TERMINSTANCE, and TERMGLOBAL. + (command): Add option_list after LIBRARY. + (attr): Accept and ignore NONSHARED, SINGLE, and MULTIPLE. + (option_list, option): New nonterminals. + * deflex.l: Recognize NONSHARED, SINGLE, MULTIPLE, INITINSTANCE, + INITGLOBAL, TERMINSTANCE, and TERMGLOBAL. + +1999-06-12 Ian Lance Taylor + + * ar.c (O_BINARY): Define as 0 if not defined. + (ranlib_touch): Open file with O_BINARY. + + * rename.c (O_BINARY): Define as 0 if not defined. + (simple_copy): Open files with O_BINARY. + + Based on patch from H. Peter Anvin : + * objcopy.c (struct section_list): Add copy field. + (sections_copied): New static variable. + (copy_options): Add "only-section". + (copy_usage): Mention -j and --only-section. + (find_section_list): Initialize copy field. + (is_strip_section): Check for copying sections. + (copy_object): Check sections_copied when calling filter_symbols. + (setup_section): Check for copying sections. + (copy_section): Likewise. + (copy_main): Handle -j/--only-section. + * binutils.texi, objcopy.1: Document -j/--only-section. + + * configure.in: If frexp is not available, check in -lm. + * configure: Rebuild. + + * readelf.c (get_elf_class): Use correct printf format for type. + (get_data_encoding): Likewise. + (get_osabi_name): Likewise. + (process_file_header): Don't pass an extra argument to printf. + (process_dynamic_segment): Cast dynamic_size to long before + printing. + (decode_location_expression): Cast byte_get to long before + printing. + +Wed Jun 9 11:40:16 1999 Andreas Schwab + + * readelf.c (dump_section): Cast values from byte_get to + [unsigned] long for printing, in case it is wider than long. + (display_block): Likewise. + (read_and_display_attr): Likewise. + (decode_location_expression): Likewise. Don't depend on + evaluation order. + +Mon Jun 7 12:14:57 1999 Andreas Schwab + + * windres.c (usage): Fix typo. + +1999-06-04 Nick Clifton + + * readelf.c: Use 64bit wide fields in internal structures even if + targetting a 32bit architecture. + (dump_relocations): Take a new parameter - the number of symbols + in the symbol table. + +1999-06-04 Nick Clifton + + * readelf.c: Add support for 64bit ELF files. + +1999-06-03 Nick Clifton + + * dlltool.c (mcore_elf_gen_out_file): Use constants for temporary + file names. + +Wed Jun 2 12:34:36 1999 Richard Henderson + + * dlltool.c (gen_exp_file): Revert 19990411 change. + +Mon May 31 09:56:22 1999 Andreas Schwab + + * readelf.c (process_relocs): Determine type of reloc from + DT_PLTREL and from section type. + +1999-05-29 Nick Clifton + + * readelf.c (get_elf_class): Display unknown class number. + (get_data_encoding): Display unknown encoding number. + (get_osabi_name): Display unknown ABI number. + (process_file_header): Display unknown version number. + +1999-05-29 Nick Clifton + + * readelf.c (dump_relocations): Fix typo. + +1999-05-28 Nick Clifton + + * readelf.c (dump_relocations): Add extra parameter: is_rela to + specify the kind of relocations to be dumped. Call guess_is_rela + if this parameter has a value of UNKNOWN. + (guess_is_rela): New function: Guess the kind of reloc being used + baced on the machine number. + (process_relocs): Determine type of reloc before calling + dump_relocations. + +1999-05-28 Ian Lance Taylor + + * readelf.c: Include "elf/i960.h". + (dump_relocations): Handle EM_960. + +Thu May 27 11:58:33 1999 Andreas Schwab + + * objcopy.c (copy_archive): Preserve dates of archive members if + requested. + + * readelf.c (dump_relocations): Always print the addend on RELA + systems even if there is no symbol. + (process_program_headers): Reset dynamic_size before looping + through the program headers. + (process_version_sections): Cast sh_offset to unsigned long for + printing in case bfd_vma is wider. + (process_symbol_table): Use get_symbol_index_type when printing + st_shndx. + +1999-05-17 DJ Delorie + + * windres.c: add verbose option + (main): process verbose option + * resrc.c (look_for_default): new. Look for the default + preprocessor in a given location. + (read_rc_file): for foo/bar-windres, look for foo/bar-gcc, + foo/gcc (in case of foo/windres), and then gcc (the old default). + +1999-05-16 Nick Clifton + + * dlltool.c (deduce_name): New function: Deduce name of program to + run. + (mcore_elf_out_file): New variable: Name of mcore-elf output file. + (mcore_elf_linker): New variable: Name of linker to use. + (mcore_elf_linker_flags): New variable: Linker flags to pass. + (scan_obj_file): Cache filenames if necessary. + (usage): Document new command line options. + (main): Support new command line options: -M (generate an + mcore-elf output file) -L (name of linker to use) -F (flags to + pass to linker). + (mcore_elf_cache_filename): Store a filename in a cache. + (mcore_elf_gen_out_file): New function: Generate an output file + per the mcore-elf spec. + +1999-05-15 Nick Clifton + + * configure.in (BUILD_MISC): Build dlltool for mcore + * configure: Regenerate. + * dlltool.c: Update example in comment. + (DLLTOOL_MCORE): Define. + (DLLTOOL_MCORE_ELF): Define. + (DRECTVE_SECTION_NAME): Define. + (mcore_be_jtab, mcore_le_jtab): Binary for performing an mcore + jump to address. + (mtable): Add entries for mcore variants. + (rvaafter, rvabefore, asm_prefix): Add mcore suppport. + (scan_drectve_symbols): Use DRECTVE_SECTION_NAME. + (make_head, make_tail): Cope if file cannot be created. + (usage): Improve layout. + +1999-05-13 DJ Delorie + + * rclex.l: add code to suppress certain output from cpp, replace + all returns with MAYBE_RETURN + (MAYBE_RETURN): new, implement the suppression by returning + IGNORED_TOKEN as needed. + (cpp_line): remember which file we're in, mark data from included + *.h files for suppression. + * rcparse.y (input): allow IGNORED_TOKEN outside of known constructs + +1999-05-10 DJ Delorie + + * windres.c (quot): Quote shell metacharacters in a string + (main): quote parameters to cpp that might have metacharacters in + them. Allow -D as an alias for --define to allow for sharing make + macros with gcc. + + * objdump.c (dump_reloc_set): don't core if howto->name is NULL + + * Makefile.am: Give rescoff.c a cpu-specific -D so it can set + the correct BFD. + * Makefile.in: ditto + * rescoff.c (write_coff_file): Set the correct BFD + +1999-05-06 Ian Lance Taylor + + * rename.c (smart_rename): Fix test of whether file exists. + +1999-05-06 Nick Clifton + + * objdump.c (disassemble_data): Set display_endian based on target + endianism. + +1999-05-05 Catherine Moore + + * dlltool.c (interwork): Remove. + (arm_interwork_jtab): Use bx insn. + (thumb_jtab): Likewise. + (MARM_INTERWORK): New machine type. + (rvaafter): Handle it. + (rvabefore) Likewise. + (asm_prefix): Likewise. + (gen_exp_type): Check machine type instead of + interwork flag. + (make_one_lib_file): Likewise. + (make_head): Likewise. + (make_tail): Likewise. + (usage): Update machine types. + (main): Remove -interwork support. + +1999-05-05 Catherine Moore + + * readelf.c (get_machine_flags): Check for EF_CPU32. + (get_data_encoding): Fix typo. + +1999-04-26 Tom Tromey + + * aclocal.m4, configure: Updated for new version of libtool. + +1999-04-18 Ian Lance Taylor + + * stabs.c (parse_stab_range_type): Correct parenthesization in + BFD64 case. + + * readelf.c (get_section_type_name): Use correct types in printf + formats. + (process_relocs): Likewise. + (process_dynamic_segment): Likewise. + (process_symbol_table): Likewise. + (process_mips_specific): Likewise. + +Tue Apr 13 21:22:00 1999 Catherine Moore + + * dlltool.c (make_one_lib_file): Mark thumb functions as + C_THUMBEXTFUNC. + +1999-04-11 Richard Henderson + + * bucomm.h (environ): Declare it, if needed. + (alloca) [C_ALLOCA]: Don't use gcc's builtin or . + * configure.in (environ): Detect declaration. + * nm.c (main): Don't declare environ. + * configure, config.in: Rebuild. + + * dlltool.c (gen_exp_file): Pad out the .reloc section to a + 32-byte boundary with dummy relocations, to make the BeOS loader + happy. Patch from Bob Manson . + +1999-04-08 Tom Tromey + + * binutils.texi (c++filt): Updated for -j/--java, and hp/edg + formats. + +1999-04-08 Nick Clifton + + * readelf.c: Add ability to decode new constants found in April 25 + 1998 Draft of System V ABI spec. + +1999-04-06 Ian Lance Taylor + + * bucomm.h (LC_MESSAGES): Never define. + * addr2line.c (main): Don't pass LC_MESSAGES to setlocale if the + system does not define it. + * ar.c (main): Likewise. + * coffdump.c (main): Likewise. + * dlltool.c (main): Likewise. + * nlmconv.c (main): Likewise. + * nm.c (main): Likewise. + * objcopy.c (main): Likewise. + * objdump.c (main): Likewise. + * size.c (main): Likewise. + * srconv.c (main): Likewise. + * strings.c (main): Likewise. + * sysdump.c (main): Likewise. + * windres.c (main): Likewise. + * readelf.c (main): Call locale setting functions. + +1999-04-05 Nick Clifton + + * readelf.c (decode_location_expression): Fix DW_OP_const8{s|u} + decodes. + +1999-04-04 Ian Lance Taylor + + * rename.c: New file, copied out of objcopy.c with a few changes. + * bucomm.h (set_times, smart_rename): Declare. + * ar.c: Don't include . + (extract_file): Call set_times rather than utime. + (write_archive): Call smart_rename rather than unlink and rename. + * objcopy.c: Don't include . + (simple_copy, smart_rename, set_times): Move to rename.c. + (strip_main): Update smart_rename call for new parameter. + (copy_main): Likewise. + * Makefile.am: Rebuild dependencies. + (CFILES): Add rename.c. + (objcopy_SOURCES, strip_new_SOURCES): Add rename.c. + (ar_SOURCES, ranlib_SOURCES): Add rename.c. + * Makefile.in: Rebuild. + + * Makefile.am: Rebuild dependencies. + (EXTRA_PROGRAMS): Remove backslash which troubles current version + of automake. + * Makefile.in: Rebuild. + + * dllwrap.c (main): Expect correct type in format string. + * resres.c: Include "bfd.h", "bucomm.h", "libiberty.h", and + . Don't include and . + (write_res_file): Remove unused locals e and i. + (read_resource_entry): Remove unused locals rtype and n. + (read_unistring): Remove unused local n. + +1999-04-03 Ian Lance Taylor + + * arparse.y: Declare yylex. + * objdump.c (disassemble_bytes): Initialize bytes. Add comment + for incorrect use of bytes. + * readelf.c: Change many formats to avoid warnings. + +1999-04-01 Nick Clifton + + * readelf.c (reset_state_machine): New function. Resets the + registers of the source line number state machine. + (process_extended_line_op): Use state machine. + (display_debug_lines): Use state machine. Handle multiple line + number blocks within the same section. + +1999-03-29 Jason Merrill + + * readelf.c (process_extended_line_op): end_sequence also resets + the line number. + (display_debug_lines): advance_line takes a signed operand. + (read_and_display_attr): Print refs as <%x>, addresses as %#x, + others as %d. Handle other location expression attributes. + (display_debug_info): Handle nesting. Always print the offset. + +1999-03-23 Ian Lance Taylor + + * objcopy.c (filter_symbols): When checking whether to keep a + symbol, check the BFD section symbol for a symbol with + BSF_SECTION_SYM set. + +1999-03-10 Ulrich Drepper + + * readelf.c (process_dynamic_segment): Print new Solaris dynamic + section entries. Correct printing of DT_POSFLAG_1 and DT_FLAGS_1. + +1999-03-10 Nick Clifton + + * readelf.c (request_dump): New function. + Removed arbitary limit on the number of sections that can be + dumped. + +Wed Mar 10 15:10:14 1999 Stan Cox + + * dlltool.c (make_one_lib_file): Use %05d to output the stub name so + order in the import library is preserved. + +1999-02-19 Nick Clifton + + * readelf.c: Fix compile time warings. + +1999-02-17 DJ Delorie + + * resbin.c (res_to_bin_versioninfo): Instead of entering a value + length of zero in a version info string, enter the appropriate + length. + +Tue Feb 16 16:00:33 1999 Ian Lance Taylor + + * configure.in: Require autoconf 2.13. Change AM_PROG_INSTALL to + AC_PROG_INSTALL. Add comments for AC_DEFINE calls. + * acconfig.h: Remove. + * aclocal.m4: Rebuild. + * configure: Rebuild. + * Makefile.in: Rebuild. + * config.in: Rebuild. + +1999-02-02 Nick Clifton + + * readelf.c (read_and_display_attr): Add display of basic type + encodings. + (display_debug_aranges): New function: Display the contents of a + .debug_aranges section. + (display_debug_info): Dump tags found after compunit entry. + + * binutils.texi: Fixed bug in readelf documentation. + +Mon Feb 1 12:38:01 1999 Catherine Moore + + * readelf.c (dump_relocations): Handle EM_ARM as REL. + +1999-01-29 Nick Clifton + + * readelf.c (process_symbol_table): Do not produce a histogram of + bucket chains if none were found. + +1999-01-27 Nick Clifton + + * version.c: Add 1999 copyright. + + * binutils.texi (readelf): Document new command line options + --debug-dump and --histogram. + + * readelf.c: Add ability to display contents of some or all of the + Dwarf2 debug sections. {Work only partially completed}. + (display_debug_section): New function. + (display_debug_info): New function. + (display_debug_not_supported): New function. + (display_debug_line): New function. + (display_debug_abbrev): New function. + (process_abbrev_section): New function. + (read_leb128): New function. + (process_extended_line_op): New function. + (get_TAG_name): New function. + (get_AT_name): New function. + (get_FORM_name): New function. + (free_abbrevs): New function. + (add_abbrev): New function. + (add_abbrev_attr): New function. + (read_and_display_attr): New function. + (display_block): New function. + +Thu Jan 14 23:36:11 1999 Jeffrey A Law (law@cygnus.com) + + * coffdump.c (xcalloc): Remove, in libiberty now. + * srconv.c (xcalloc): Likewise. + * sysdump.c (xcalloc): Likewise. + +1999-01-14 Nick Clifton + + * readelf.c (process_section_headers): Omit trailing space at end + of section header contents line. + +Wed Dec 16 17:20:05 1998 Doug Evans + + * aclocal.m4: Regenerate. + +Mon Dec 14 12:55:36 1998 Jim Wilson + + * dllwrap.c: Include bfd.h and bucomm.h. Move getopt.h include + after libiberty.h include. + +Tue Dec 8 16:29:43 1998 Ian Lance Taylor + + * objdump.1: Fix typo (-d to -D). From Nokubi Hirotaka + . + +Sun Dec 6 13:28:09 1998 Ian Lance Taylor + + * objdump.c (SFILE): Add size field. + (objdump_sprintf): Merge both versions into one. Increase buffer + size as needed to avoid overflow. + (disassemble_bytes): Change buf from 1000 bytes to 50. Change + initialization and use of sfile to match changes to + objdump_sprintf. + + * strip.1: Fix typo (-V to -v). From Issei Hirayama + . + +1998-12-03 Ulrich Drepper + + * readelf.c (process_dynamic_segment): Improve output format for + various DT_* values. + +1998-12-02 Ulrich Drepper + + * readelf.c (process_mips_specific): Print .conflict section + content. + + * readelf.c (process_mips_specific): Print l_flags in liblist in + textual form. + +1998-11-30 Nick Clifton + + * ar.c (extract_file): Add some paranoia checks for negatively + sized files. + +Tue Nov 24 09:39:24 1998 Nick Clifton + + * stabs.c (DIR_SEPARATOR): Define as '\\' if WIN32 is defined. + +Tue Nov 17 10:25:26 1998 Nick Clifton + + * Makefile.in: Regenerate. + +Mon Nov 16 19:17:23 1998 Dave Brolley + + * po/binutils.pot: Regenerate. + +Mon Nov 16 10:18:53 1998 Nick Clifton + + * Makefile.am: Regernated dependencies. + * aclocal.m4: Regenerated. + * configure: Regenerated. + +Sat Nov 14 14:50:56 1998 Ian Lance Taylor + + * debug.c (debug_name_type): Correct return type from false to + DEBUG_TYPE_NULL. + +Sat Nov 14 14:48:21 1998 Andreas Schwab + + * objdump.c (disassemble_data): Skip over relocs below start + address. + +Tue Nov 10 15:31:52 1998 Nick Clifton + + * Makefile.am: Add dependency of readelf.c on elf/fr30.h + * Makefile.in: Regenerate. + +Wed Nov 4 16:25:55 1998 Nick Clifton + + * readelf.c: Add support for the FR30. + +Mon Nov 2 14:59:33 1998 Geoffrey Noer + + * configure.in: detect cygwin* instead of cygwin32* + * configure: regenerate + +Fri Oct 30 15:14:49 1998 Geoffrey Noer + + * dllwrap.c: change all references to cygwin32_ to cygwin_, + change Cygwin target def to CYGWIN. + +Wed Oct 28 10:31:19 1998 Nick Clifton + + * objdump.c (disassemble_data): Replace 'unsigned long' with + 'bfd_vma'. + +Tue Oct 27 14:39:00 1998 Nick Clifton + + * objdump.c (disassemble_bytes): Applied this patch from Philip + Blundell : Make address variables unsigned to + avoid problems when disassembling code at high-bit-set addresses. + +Mon Oct 26 14:07:59 1998 Mumit Khan + + * dllwrap.c (strhash): New function. + (main): Use it to supply image base if not supplied by user. + (program_version): Up to 0.2.4. + +Mon Oct 26 14:07:59 1998 Mumit Khan + + * dlltool.c (add_stdcall_alias): New global. + (long_options): Add --add-stdcall-alias option. + (main): Handle it. + (scan_drectve_symbols): Add alias if --add-stdcall-alias is + specified. + (scan_filtered_symbols): Likewise. + (gen_def_file): Output alias for stdcall syms if appropriate. + + * binutils.texi (dlltool): Document --add-stdcall-alias option. + + * dllwrap.c (long_options): Add --add-stdcall-alias option. + (main): Handle it. + + * defparse.y (opt_name): Allow "." in name. + * dlltool.c (def_name): Set dll_name from NAME entry in def file. + (def_library): Set dll_name from LIBRARY entry in def file. + +Mon Oct 26 14:07:59 1998 Mumit Khan + + * dllwrap.c (long_options): --implib synonym for --output-lib. + (main): Pass --export-all to dlltool only if specified. + (program_version): Up to 0.2.3. + +Mon Oct 26 14:07:59 1998 Mumit Khan + + * dllwrap.c (mybasename): New function. + (main): Run dlltool to create export definition file and import + library file if necessary. + Change exp_file_name so that it's based on the dll name. + +Sun Oct 25 10:37:45 1998 Mumit Khan + + * dlltool.c (scan_all_symbols): Fix patch error. + +Fri Oct 16 22:56:20 1998 Felix Lee + + * nm.c (display_rel_file): fix "no symbols" messages. + * objdump.c (slurp_symtab): ditto. + * po/POTFILES.in, po/binutils.pot: rebuilt + +Mon Oct 12 14:28:03 1998 Nick Clifton + + * readelf.c (dump_relocations): Rename field from Value to Info to + match name of field in ELF structures. + +Thu Oct 8 15:33:08 1998 Geoffrey Noer + + * configure.in: call AC_EXEEXT instead of AM_EXEEXT and + AM_CYGWIN32. + * aclocal.m4: remove local AM_EXEEXT/AM_CYGWIN32 macros. + * configure: regenerate + +Thu Oct 8 15:33:08 1998 Geoffrey Noer + + From Mumit Khan : + * dlltool.c (scan_all_symbols): Don't re-export symbols exported + by other DLLs. + +Thu Oct 8 15:33:08 1998 Geoffrey Noer + + * Makefile.am (BUILD_DLLWRAP): Add. + (BUILD_DLLWRAP, DLLWRAP_PROG): Add. + (bin_PROGRAMS): Add dllwrap. + * Makefile.in: regenerate with automake + + From Mumit Khan : + * dllwrap.c: New file from dllhelpers v0.2.1. + (print_version): New function. + (long_options): Add --version. + (main): Handle. + * dyn-string.h, dyn-string.c: New files from egcs-1.1/gcc. + * configure.in (BUILD_DLLWRAP): Add. + * configure: Regenerate. + +Tue Oct 6 18:20:10 1998 Geoffrey Noer + + * Makefile.am (windres_SOURCES): Add resres.c. + (windres_OBJECTS): Add resres.o. + * Makefile.in: regenerate with automake + + From Anders Norlander . + * resres.c: New file. Implementation of read_res_file and + write_res_file functions for windres. + * rcparse.y: Handle CONTROL's with named classes. + * resbin.c: Bug in res_to_bin_dialog and bin_to_res_dialog + when dialog is extended: The version and signature fields should + be reversed (despite what the docs say). Id is 32 bits long in + extended dialogs. + * resrc.c (write_rc_dialog): properly print controls with named + classes. + * windres.c (read_res_file, write_res_file): Remove stubs. + * resres.c (write_res): Rename RT_ACCELERATORS to RT_ACCELERATOR. + +Sun Oct 4 20:34:42 1998 Ian Lance Taylor + + From Nokubi Hirotaka : + * objcopy.1: Fix typo in --remove-leading-char docs. + * objdump.1: Fix formatting in --stabs docs. + +Sat Sep 19 23:33:56 1998 Ian Lance Taylor + + * rcparse.y (memflags_move): Correct recursion. + +1998-09-10 Ulrich Drepper + + * readelf.c (process_symbol_table): Print in histogram how many + symbols are covered by the current chain length. + +Sun Sep 6 16:15:47 1998 Nick Clifton + + * readelf.c (process_section_contents): Do not try to dump empty + sections. + +Sat Sep 5 19:17:10 1998 Mumit Khan + + * dlltool.c (scan_all_symbols): Don't re-export symbols exported + by other DLLs. + +1998-09-02 14:50 Ulrich Drepper + + * readelf.c (process_dynamic_segment): Print DT_* value only if + do_dynamic. + (do_histogram): New variable. + (options): New long option histogram. Set do_histogram if this + option is used. + (usage): Document --histogram. + (parse_args): Handle 0 return value from getopt_long. Enable + do_histogram for -a. + (process_symbol_table): Read hash table also if only do_histogram. + Add code to print hash table histogram. + +1998-08-25 16:45 Ulrich Drepper + + * readelf.c (process_dynamic_segment): Read syminfo section if + available. + (process_syminfo): New function. Print syminfo information. + (process_file): Call process_syminfo and free syminfo data at the end. + +Wed Aug 19 16:19:51 1998 Ian Lance Taylor + + * dlltool.c (usage): Add file parameter. Change all callers. + (main): Don't treat '?' as a special case in getopt return. + + * binutils.texi (dlltool): Document new options. Add some uses of + @var. + +Wed Aug 19 16:19:07 1998 Mumit Khan + + * dlltool.c (gen_def_file): Plug memory leak. Don't print + demangled name if it is NULL. + + Support for exporting all symbols to an output export def file: + * dlltool.c ({export_all_symbols, no_default_excludes, + no_default_excludes, excludes}): New file static variables. + (struct string_list): Type to hold list of symbols to exclude. + (scan_drectve_symbols): Renamed from scan_open_obj_file. + (scan_filtered_symbols): New static function. + (add_excludes): New static function. + (match_exclude): New static function. + (set_default_excludes): New static function. + (filter_symbols): New static function. + (scan_all_symbols): New static function. + (scan_open_obj_file): New static function. + (usage): Document new options. + (long_options): Add new options. + (main): Handle new options. + +1998-07-31 21:24 Ulrich Drepper + + * readelf.c (process_program_headers): Print p_offset value with + six hex digits. + (dynamic_segment_mips_val): Add support for DT_MIPS_FLAGS, + DT_MIPS_IVERSION, and DT_MIPS_TIME_STAMP. + (process_mips_specific): Also print seconds of time stamp. + +Fri Jul 31 10:04:23 1998 Catherine Moore + + * readelf.c (dump_relocations): EM_ARM uses rela relocs. + +1998-07-30 16:25 Ulrich Drepper + + * readelf.c (get_dynamic_type): Don't used gettext on the names. + Add new DT_* values from Solaris. Don't print nuemric value in + case of an unknown entry. + (process_dynamic_segment): Handle new DT_* entries. Print numeric + values in decimal, not hex. + +Fri Jul 24 16:28:57 1998 Jeff Holcomb + + * readelf.c (get_dynamic_type): Remove empty default from switch + statement. + +Fri Jul 24 16:28:12 1998 Ian Lance Taylor + + * Makefile.am (install-exec-local): Don't remove the file before + checking whether $(bindir) == $(tooldir)/bin. From Maciej + W. Rozycki . + * Makefile.in: Rebuild. + +Fri Jul 24 09:38:59 1998 Nick Clifton + + * objcopy.c: Removed spurious inclusion of elf/internal.h and + elf-bfd.h. + +1998-07-22 Ulrich Drepper + + * readelf.c: Consistantly use elf_ prefix for *_reloc_type + functions. + +Wed Jul 22 16:29:12 1998 Nick Clifton + + * readelf.c (dump_relocations): Add dumps of HPPA and ARC + relocations. + + (process_relocs): Do not abort if no string table can be found. + +1998-07-22 14:58 Ulrich Drepper + + * readelf.c: Remove definition of functions to return relocation + symbol strings. They now get implicitly defined when include the + system specific ELF header. + +1998-07-22 13:51 Ulrich Drepper + + * readelf.c: Before include system specific ELF header define + START_RELOC_NUMBERS, RELOC_NUMBER, and END_RELOC_NUMBERS. For now + used for ppc, mips, and mn10300. + +Wed Jul 22 10:26:32 1998 Nick Clifton + + * readelf.c (dump_relocations): Display number of unrecognised + relocations. + +1998-07-21 13:13 Ulrich Drepper + + * readelf.c: Use symbolic names of relocation entries for the various + architectures. Correct more layout details. + Print names of MIPS specific section types. Print Alpha, ARM, and + MIPS relocation type names. + +1998-07-20 Vladimir N. Makarov + + * objcopy.c (filter_symbols): Add code for strip all symbols case. + (copy_objects): Strip all case is now processed also through + filter_symbols. No marking symbols used in relocations when strip + all symbols case. + (copy_section): When strip all symbols case, remove relocations + which are not in keep strip specific list. + (strip_main): Remove guard `strip_specific_list == NULL' for + setting up strip all symbols by default. + +Mon Jul 20 12:51:16 1998 Andreas Schwab + + * addr2line.c (find_address_in_section): Only consider a section + if the pc value is completely contained within it. + (translate_addresses): Don't crash if functionname or filename are + null. + +1998-07-20 07:45 Ulrich Drepper + + * readelf.c (process_symbol_table): Fix little alignment problem + in printed table header. + +1998-07-20 07:14 Ulrich Drepper + + * readelf.c: Correct reading of .dynamic section. + (dynamic_section): Now a global variable. + (process_mips_fpe_exception, process_mips_specific, + process_arch_specific): New functions. + (get_file_header): Call process_arch_specific. + +1998-07-19 15:15 Ulrich Drepper + + * readelf.c: Fix several versioning related bugs. Produce nicer + output. + Add support for processor specific information on MIPS. + +Fri Jul 10 15:57:58 1998 Nick Clifton + + * readelf.c: Switch prototypes from unsigned short to unsigned + int. + +Fri Jul 10 16:17:50 1998 Ian Lance Taylor + + From Christian Holland : + * ieee.c (parse_ieee): Initialize info.global_vars and + info.global_types. + (parse_ieee_atn): Ignore register lifetime information reportedly + emitted by MRI compiler. + +Thu Jul 9 13:08:01 1998 Ian Lance Taylor + + * Makefile.am (MAINTAINERCLEANFILES): Define. + * Makefile.in: Rebuild. + +Tue Jul 7 21:48:54 1998 Jeffrey A Law (law@cygnus.com) + + * readelf.c (byte_get): Use PARAMS in prototype. + (error): Make it work with non-ANSI compilers. + (warn): Likewise. + (get_ver_flags): Don't use an ANSI prototype in the definition. + +Tue Jul 7 13:26:13 1998 Ian Lance Taylor + + * objcopy.c (filter_bytes): Set size correctly if the size of the + section is not an even multiple of the interleave. Based on patch + from Brion Stone . + +Thu Jul 2 14:01:34 1998 Klaus Kaempf + + * configure.com: Add vax/vms support. + * makefile.vms-in: Renamed from makefile.vms. Add substitutions + now done by configure.com. + +Wed Jul 1 20:43:52 1998 Ian Lance Taylor + + * stabs.c (parse_stab_range_type): Handle 4 and 8 byte signed + integers with real upper bounds. Handle a lower bound one larger + than the upper bound as a signed integer. Handle 8 byte signed + integers. + (stab_demangle_template): Optionally return the demangled name of + the template. + (stab_demangle_qualified): Treat a template name as a tagged + type. + (stab_demangle_fund_type): Likewise. + +Wed Jul 1 16:29:50 1998 Nick Clifton + + * objcopy.c: Minor formatting improvements. + * readelf.c: Minor output formatting improvement. + +Wed Jul 1 14:23:48 1998 Ian Lance Taylor + + * rclex.l: Add casts and change types to avoid warnings. + * rcparse.y: Likewise. + * resbin.c: Likewise. + * rescoff.c: Likewise. + * resrc.c: Likewise. + + * Makefile.am: Rebuild dependencies. + (HFILES): Remove readelf.h. + * Makefile.in: Rebuild. + + Based on patches from Andrew Kozin + : + * winduni.h: New file, from windres.h. + * winduni.c: New file, from windres.c. + * windres.c: Move Unicode functions into winduni.c. + * windres.h: Move Unicode declarations into winduni.h. Include + winduni.h. + (RT_ACCELERATOR): Rename from RT_ACCELERATORS to match Windows + macro. Change all uses. + (RT_PLUGPLAY, RT_VXD): Correct values. + * Makefile.am (HFILES): Add windres.h. + (CFILES): Add winduni.c. + (windres_SOURCES): Add winduni.c. + +Mon Jun 29 17:01:21 1998 Nick Clifton + + * readelf.c: Use BFD Internal and External Elf structures. + * readelf.h: Removed - no longer needed. + * Makefile.in: Remove readelf.c's dependency upon readelf.h. + +1998-06-26 Vladimir N. Makarov + + * objcopy.c (strip_main): keep_specific_list == NULL as additional + condition to set up strip all symbols by default. + (copy_archive): don't change archive when error in object files of + the archive. + +Wed Jun 24 17:53:47 1998 Ian Lance Taylor + + * stabs.c (parse_number): Sign extend negative values correctly if + bfd_vma is larger than unsigned long. + +Tue Jun 23 14:55:05 1998 Mike Stump + + * Makefile.am (install-exec-local): Don't let EXEEXT interfere + with the program transform name. + * Makefile.in: Rebuild. + +Tue Jun 23 11:08:53 1998 Nick Clifton + + * readelf.c: Rewrite to use fopen/fread ratehr than mmap. + + Add --section-headers command line switch, which is an alias for + --sections. + + Incorporate improvemnts made by Andreas Schwab + including output + formatting and version info display. + + * binutils.texi: Document --section-headers switch to readelf. + +Mon Jun 22 18:28:19 1998 Ian Lance Taylor + + * readelf.c: Include bfd.h and bucomm.h before system header + files. + (parse_args): Change type of c from char to int. + +Sun Jun 14 14:26:28 1998 Nick Clifton + + * readelf.c (usage): Write to stdout, not stderr. + +Fri Jun 12 13:33:51 1998 Tom Tromey + + * po/Make-in (all-yes): Depend on .pot file if maintainer mode + enabled. + ($(PACKAGE).pot): Unconditionally depend on POTFILES. + +Fri Jun 12 16:06:15 1998 Michael Meissner + + * readelf.c (get_ppc_rel_type): New PowerPC support. + (dump_relocations): PowerPC uses RELA relocations. + (get_machine_name): Spell PowerPC correctly. + (get_file_type): Change unsigned short parameter to unsigned. + (get_machine_name): Ditto. + (get_machine_data): Return whether big endian or little endian. + (get_machine_flags): Interpret PowerPC, M32R, and MIPS flags. + (process_elf_header): Print endian-ess. Convert all numeric + formats to long or unsigned long. Print out machine specific flag + bits. + (process_section_headers): Increase name by 3 columns and decrease + type by the same so that .gcc_except_table fits in the space. + + * readelf.h: Include elf/ppc.h, elf/mips.h, and elf/m32r.h to get + machine specific flag bits. + +Thu Jun 11 17:54:26 1998 Nick Clifton + + * readelf.c: Remove extraneous #includes. Fix warnings produced + by -Wall when compiling under Linux. + + * Makefile.am (readelf_LDADD): Add $(LIBIBERTY). + +Thu Jun 11 18:30:20 1998 Ian Lance Taylor + + * stabs.c (struct stab_handle): Add self_crossref field. + (parse_stab_string): If a tag is a cross reference to itself, + don't define it in the tags list. + (parse_stab_type): Set info->self_crossref. + + * debug.c (struct debug_type_real_list): Define. + (debug_get_real_type): Add list parameter. Change all callers. + Check for circularity to avoid crashing when it occurs. + +Thu Jun 11 14:48:32 1998 Nick Clifton + + * readelf.c: New file: Display contents of ELF format file. + * readelf.h: New file: Header file for readelf.c + * Makefile.am: Add rules to build readelf. + * Makefile.in: Rebuilt. + * binutils.texi: Document readelf. + * NEWS: Mention inclusion of readelf into binutils. + * po/POTFILES.in; Rebuilt. + +Fri Jun 5 18:43:40 1998 Ian Lance Taylor + + * objcopy.c (setup_section): Adjust the section size if copy_byte + is >= 0. + (copy_section): Do not call bfd_set_section_size. + +Thu Jun 4 09:12:27 1998 Nick Clifton + + * objcopy.c (copy_usage): Add missing \n\ from help description. + +Wed Jun 3 19:31:33 1998 Ian Lance Taylor + + * Makefile.am (YACC): Correct bison -L option. + * Makefile.in: Rebuild. + + * binutils.texi, objdump.1: Document -p/--private-headers. + +Wed Jun 3 12:09:40 1998 Nick Clifton + + * objcopy.c: Add new command line options: --change-section-lma + and --change-section-vma. Rename old command line option + --adjust-section-vma to --change-section-address. Rename + --adjust-vma to --change-addresses and --adjust-start to + --change-start. Provide aliases to support the old versions of + these command line options. + + Change the names of macros and enum elements to upper case to + match the GNU coding standard. + + Replace calls to fprintf (stderr,...) with calls to fatal () or + non_fatal () as appropriate. + + * objcopy.1: Document command line option changes. + * binutils.texi: Document command line option changes. + + * bucomm.h: New exported funtion from bucomm.c: non_fatal(). + * bucomm.c (non_fatal): New exported function. Just like fatal() + except that it returns rather than calling xexit(). + + (bfd_check_format_matches): Call fatal() rather than bfd_fatal(). + + (check_matching_formats): Fix C formating. + + (parse_vma): Call fatal(). + +Mon Jun 1 18:26:40 1998 Ian Lance Taylor + + From Yuli Barcohen : + * debug.c (debug_type_samep): Avoid endless loops comparing + function and method parameter types. + +Fri May 22 14:02:42 1998 Ian Lance Taylor + + * dlltool.c (dump_iat): Comment out; not used. + (display): Rename from tell. Change all callers. + +Thu May 14 14:00:56 1998 Nick Clifton + + * dlltool.c: Add support for Thumb DLLs. Add support for + interworking between ARM and Thumb programs and DLLs. Tidy the + code. + + * binutils.texi: Document dlltool. + + * configure: Build dlltool for thumb-pe targets. + + * version.c (print_version): Include 1998 in copyright strings. + + * stabs.c (parse_stab): Support Win32 style directory separators. + +Sun May 10 22:34:44 1998 Jeffrey A Law (law@cygnus.com) + + * po/Make-in (install-info): New target. + +Fri May 8 10:33:13 1998 Nick Clifton + + * ar.c (usage): Extend information provided about command line + options. + +Wed May 6 15:28:51 1998 Klaus Kaempf + + * makefile.vms: Run dec c with /nodebug. Pass CC value when + calling make. + +Tue May 5 15:19:00 1998 Nick Clifton + + * configure: Build dlltool for thumb-pe target. + * configure.in: Build dlltool for thumb-pe target. + +Sun May 3 22:04:49 1998 Ian Lance Taylor + + * Makefile.am (EXTRA_PROGRAMS): Change $(SRCONV_PROG) to sysconf + sysdump coffdump to avoid extra $(EXEEXT). + * Makefile.in: Rebuild. + +Wed Apr 29 22:22:55 1998 Geoffrey Noer + + * configure.in: Stop appending EXEEXT to the end of + SRCONV_PROG (wrong because that variable may contain multiple + programs) + * Makefile.am: instead, add EXEEXTs to each SRCONV_PROG + program + * Makefile.in: regenerate + * configure: regenerate + +Tue Apr 28 19:14:34 1998 Tom Tromey + + * addr2line.c (main): Conditionally call setlocale. + * windres.c (main): Likewise. + * sysdump.c (main): Likewise. + * strings.c (main): Likewise. + * srconv.c (main): Likewise. + * size.c (main): Likewise. + * objdump.c (main): Likewise. + * objcopy.c (main): Likewise. + * nm.c (main): Likewise. + * nlmconv.c (main): Likewise. + * dlltool.c (main): Likewise. + * coffdump.c (main): Likewise. + * ar.c (main): Likewise. + * bucomm.h: Include if HAVE_LOCALE_H. + (LC_MESSAGES): Now can be defined even when ENABLE_NLS. + +Tue Apr 28 10:33:07 1998 Bill Moyer + + Add support for IMPORTS: + * defparse.y (impline): Add IMPORTS syntaxes. + * dlltool.c (ifunctype, iheadtype): New typedefs. + (import_list): New static variable. + (append_import): New static function. + (def_import): Add an entry to import_list. + (generate_idata_ofile): New static function. + (gen_exp_file): Call generate_idata_ofile. + * dlltool.h (def_import): Update declaration. + +Mon Apr 27 16:39:22 1998 Ian Lance Taylor + + * configure.in: Change version number to 2.9.4 + * configure: Rebuild. + +Wed Apr 22 16:00:35 1998 Tom Tromey + + * po/Make-in (MKINSTALLDIRS): Don't look in $(top_srcdir). + +Wed Apr 22 00:33:56 1998 Tom Tromey + + * Makefile.am (INCLUDES): Search intl dirs for headers; define + LOCALEDIR. + * addr2line.c (main): Call setlocale, bindtextdomain, textdomain. + * ar.c (main): Likewise. + * coffdump.c (main): Likewise. + * dlltool.c (main): Likewise. + * nlmconv.c (main): Likewise. + * nm.c (main): Likewise. + * objcopy.c (main): Likewise. + * objdump.c (main): Likewise. + * size.c (main): Likewise. + * srconv.c (main): Likewise. + * strings.c (main): Likewise. + * sysdump.c (main): Likewise. + * windres.c (main): Likewise. + +Tue Apr 21 22:13:08 1998 Tom Tromey + + * Many files: Added gettext invocations around user-visible + strings. + * bucomm.h: Added gettext-related includes and defines. + * acconfig.h (ENABLE_NLS, HAVE_CATGETS, HAVE_GETTEXT, HAVE_STPCPY, + HAVE_LC_MESSAGES): Define. + * configure.in: Call CY_GNU_GETTEXT. Create po/Makefile.in and + po/Makefile. Use AM_PROG_LEX. + * Makefile.am (SUBDIRS): New macro. + (POTFILES): Likewise. + (po/POTFILES.in): New target. + (LDADD): Added INTLLIBS. + (objdump_LDADD): Likewise. + (c__filt_LDADD): Likewise. + (ar_LDADD): Likewise. + (ranlib_LDADD): Likewise. + (dlltool_LDADD): Likewise. + (windres_LDADD): Likewise. + * po/Make-in, po/POTFILES.in, po/binutils.pot: New files. + +Tue Apr 21 16:07:18 1998 Stanislav Brabec + + * objcopy.c (preserve_dates): New file static variable. + (smart_rename): If preserve_dates, call set_times when copying. + (strip_main): Remove preserve_dates local variable. + (copy_main): Likewise. + +Tue Apr 7 15:41:15 1998 Ian Lance Taylor + + * Makefile.am (DISTSTUFF): Add defparse.h, defparse.c, rclex.c, + rcparse.h, and rcparse.c + * Makefile.in: Rebuild. + +Mon Apr 6 16:24:35 1998 Ian Lance Taylor + + * Makefile.am (PROGS): Move $(ADDR2LINE_PROG) to end, so that + Makefile.in doesn't have an empty continuation line. + (bin_PROGRAMS): Likewise. + * Makefile.in: Rebuild. + +Fri Apr 3 14:48:42 1998 Ian Lance Taylor + + * Makefile.am (DISTCLEANFILES): Add site.exp and site.bak. + (MOSTLYCLEANFILES): Add binutils.log, binutils.sum, and abcdefgh*. + (mostlyclean-local): New target. + * Makefile.in: Rebuild. + +Wed Apr 1 15:54:16 1998 Ian Lance Taylor + + From Zack Weinberg and H.J. Lu + : + * ar.c (usage): Mention S modifier. + (main): Add S modifier. + * ar.1, binutils.texi: Document S modifier. + +Wed Apr 1 13:11:23 1998 Andreas Schwab + + * binutils.texi: Use @itemx for a secondary item in a table. + +Tue Mar 31 18:44:13 1998 Ian Lance Taylor + + * dep-in.sed: Add rule to remove @OBJDIR@. + * Makefile.am (dep.sed): Substitute for @OBJDIR@. + * Makefile.in: Rebuild. + +Mon Mar 30 12:47:18 1998 Ian Lance Taylor + + * configure.in: Set version to 2.9.1. + * configure: Rebuild. + + * Branched binutils 2.9. + + * Makefile.am (DISTCLEANFILES): Remove defparse.h, arparse.h, + rcparse.h, and nlmheader.h. + * Makefile.in: Rebuild. + +Sat Mar 28 17:39:27 1998 Ian Lance Taylor + + * Makefile.am (MOSTLYCLEANFILES): Define. + * Makefile.in: Rebuild. + + Fix some gcc -Wall warnings: + * nlmconv.c (main): Add casts to avoid warnings. + (alpha_mangle_relocs): Likewise. + * objdump.c (dump_section_stabs): Likewise. + * size.c (print_sysv_format): Likewise. + * srcconv.c (wr_ob): Likewise. + * wrstabs.c (stab_modify_type): Likewise. + (stab_variable): Likewise. + * nlmconv.c (main): Initialize variables to avoid warnings. + * nm.c (sort_symbols_by_size): Likewise. + * objdump.c (disassemble_bytes): Likewise. + * wrstabs.c (stab_end_class_type): Likewise. + * coffgrok.c (do_sections_p2): Change j to unsigned int. + (do_lines): Change l to unsigned int. + * nlmheader.y (yylex): Change i to unsigned int. + * nm.c (print_symbol): Change j to long. + * size.c (lprint_number): Comment out. + * srconv.c (wr_ob): Change i to bfd_size_type. + * sysdump.c (unit_info_list): Comment out. + (object_body_list, program_structure, debug_list): Likewise. + * sysinfo.y (yyerror): Return value. + +Thu Mar 26 17:06:51 1998 Richard Henderson + + * defparse.y (explist): Allow epsilon. + Suggestion from Jonathan-Harris@psion.com. + +Thu Mar 26 16:59:09 1998 Richard Henderson + + * coffgrok.c (do_sections_p1): Use the section's lma instead of vma + for the benefit of prom loaders. + +Wed Mar 25 13:05:39 1998 Ian Lance Taylor + + Based on patch from H.J. Lu : + * Makefile.am (DISTSTUFF): New variable. + (diststuff): New target. + (DISTCLEANFILES): New variable. + * Makefile.in: Rebuild. + +Tue Mar 24 19:33:08 1998 Ian Lance Taylor + + * rclex.l: Accept { and } as synonyms for BEGIN and END. + +Fri Mar 20 19:18:08 1998 Ian Lance Taylor + + * aclocal.m4, configure: Rebuild with libtool 1.2. + +Tue Feb 24 13:07:50 1998 Doug Evans + + * objdump.c (disassemble_data): Delete "++place" after call to + find_symbol_for_address. Set disasm_info.symbols to array of + symbols at the current address. + +Wed Feb 18 23:39:46 1998 Richard Henderson + + * Makefile.am (install-exec-local): Install properly when ln + fails or tooldir == prefix. + +Tue Feb 17 18:40:55 1998 Richard Henderson + + * objcopy.c (compare_section_lma): Rename from _vma. + (copy_object): Gap fill based on LMA not VMA. + * binutils.texi: Update and clarify. + * objcopy.1: Likewise. + +Tue Feb 17 20:34:11 1998 Ian Lance Taylor + + * dlltool.c (gen_exp_file): Generate _imp__%s as well as __imp_%s, + for Microsoft compatibility. + (make_one_lib_file): Likewise. + + * dlltool.c (make_one_lib_file): Don't add 1 to hint. + +Fri Feb 13 16:37:44 1998 Ian Lance Taylor + + * Makefile.am (AUTOMAKE_OPTIONS): Define. + * configure, Makefile.in, aclocal.m4: Rebuild with automake 1.2e. + +Thu Feb 12 14:13:46 1998 Ian Lance Taylor + + * deflex.l: Accept '?' in symbol names, for VC++ mangled names. + From Mikey . + + * addr2line.c (usage): Update bug-gnu-utils address. + * ar.c (usage): Likewise. + * nlmconv.c (show_usage): Likewise. + * nm.c (usage): Likewise. + * objcopy.c (copy_usage): Likewise. + (strip_usage): Likewise. + * objdump.c (usage): Likewise. + * size.c (usage): Likewise. + * strings.c (usage): Likewise. + * windres.c (usage): Likewise. + * binutils.texi (Bug Reporting): Likewise. + +Sat Feb 7 15:36:24 1998 Ian Lance Taylor + + * configure, aclocal.m4: Rebuild with new libtool. + +Thu Feb 5 12:21:13 1998 Ian Lance Taylor + + * configure, Makefile.in, aclocal.m4: Rebuild with new libtool. + +Fri Jan 30 19:16:28 1998 Doug Evans + + * Makefile.am (CC_FOR_TARGET,nlmcomv.o): Change program_transform_name + to transform. + * Makefile.in: Regenerate. + +Thu Jan 29 16:24:04 1998 Mumit Khan + + * dlltool.c: Define exit status macros for _WIN32 but not + __CYGWIN32__. + (gen_lib_file): Check for exit status of unlink. + * resrc.c: Define popen and pclose if _WIN32 but not + __CYGWIN32__. + +Wed Jan 28 17:45:46 1998 Ian Lance Taylor + + * configure.in: Remove vfork check. + * nlmconv.c: Never include vfork.h. + * aclocal.m4, configure, Makefile.in, config.in: Rebuild. + +Wed Jan 28 17:43:02 1998 J.J. van der Heijden + + * objcopy.c (copy_archive): Only pass one argument to mkdir if + _WIN32 but not __CYGWIN32__. + (smart_rename): Add code for _WIN32 (not __CYGWIN32__), to cope + with different rename behaviour and lack of chown. + + * configure.in: Check for mingw32 when deciding whether to build + dlltool. + * dlltool.c: Never include vfork.h. + (run): Use pexecute rather than vfork. + (gen_lib_file): Check for errors from bfd_set_archive_head and + bfd_close. Close all the BFDs in the archive before deleting the + temporary files. + +Thu Jan 22 16:22:55 1998 Fred Fish + + * objdump.c (disassemble_bytes): Add flag INSN_HAS_RELOC to tell + disassembly function there is a reloc on this line. + +Wed Jan 14 15:29:43 1998 Richard Henderson + + * srconv.c (sh, h8300): Delete variables. + (addrsize, toolname, rnames): New variables. + (writeINT): Use addrsize. + (wr_un): Use toolname. + (wr_hd): Set up addrsize et al properly for h8300[hs]. + (walk_tree_symbol): Zero dsy. Use rnames. + (wr_un, wr_hd, wr_ob, wr_du): Use proper bfd access macros. + * sysdump.c (sh, h8300): Delete variables. + (addrsize): New variable. + (getINT): Use it. + (getone): Initialize it. + (getBITS): Range check on MAX. + +For older changes see ChangeLog-9197 + +Copyright (C) 1998-1999 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/support/sdbinutils/binutils/MAINTAINERS b/support/sdbinutils/binutils/MAINTAINERS new file mode 100644 index 0000000..3bb542d --- /dev/null +++ b/support/sdbinutils/binutils/MAINTAINERS @@ -0,0 +1,304 @@ + ========= Binutils Maintainers ========= + +This is the list of individuals responsible for maintenance and update +of the GNU Binary Utilities project. This includes the linker (ld), +the assembler (gas), the profiler (gprof), a whole suite of other +programs (binutils) and the libraries that they use (bfd and +opcodes). This project shares a common set of header files with the +GCC and GDB projects (include), so maintainership of those files is +shared amoungst the projects. + +The home page for binutils is: + + http://www.gnu.org/software/binutils/binutils.html + +and patches should be sent to: + + binutils@sourceware.org + +with "[Patch]" as part of the subject line. Note - patches to the +top level config.guess and config.sub scripts should be sent to: + + config-patches@gnu.org + +and not to the binutils lists. Patches to the other top level +configure files (configure, configure.ac, config-ml.in) should +be sent to the binutils lists, and copied to the gcc and gdb +lists as well (gcc-patches@gcc.gnu.org and +gdb-patches@sourceware.org). + +Patches to the libiberty sources should be sent to +gcc-patches@gcc.gnu.org. + + --------- Blanket Write Privs --------- + +The following people have permission to check patches into the +repository without obtaining approval first: + + Nick Clifton (head maintainer) + Ian Lance Taylor + Jeff Law + Jim Wilson + DJ Delorie + Alan Modra + Michael Meissner + Daniel Jacobowitz + Richard Sandiford + + --------- Maintainers --------- + +Maintainers are individuals who are responsible for, and have +permission to check in changes in, certain subsets of the code. Note +that maintainers still need approval to check in changes outside of +the immediate domain that they maintain. + +If there is no maintainer for a given domain then the responsibility +falls to the head maintainer (above). If there are several +maintainers for a given domain then responsibility falls to the first +maintainer. The first maintainer is free to devolve that +responsibility among the other maintainers. + + ALPHA Richard Henderson + AARCH64 Richard Earnshaw + AARCH64 Marcus Shawcroft + ARM Nick Clifton + ARM Richard Earnshaw + ARM Ramana Radhakrishnan + AVR Denis Chertykov + AVR Marek Michalkiewicz + BFIN Jie Zhang + BFIN Mike Frysinger + BUILD SYSTEM Daniel Jacobowitz + CR16 M R Swami Reddy + CRIS Hans-Peter Nilsson + CRX M R Swami Reddy + DLX Nikolaos Kavvadias + DWARF2 Jason Merrill + DWARF2 Jakub Jelinek + dwarf-mode.el Tom Tromey + EPIPHANY Joern Rennecke + FR30 Dave Brolley + FRV Dave Brolley + FRV Alexandre Oliva + GOLD Ian Lance Taylor + GOLD Cary Coutant + H8300 Prafulla Thakare + HPPA Dave Anglin + HPPA elf32 Alan Modra + HPPA elf64 Jeff Law [Basic maintainance only] + IA-64 Jim Wilson + IQ2000 Stan Cox + i860 Jason Eckhardt + ix86 H.J. Lu + ix86 PE Christopher Faylor + ix86 COFF DJ Delorie + ix86 PE/COFF Dave Korn + ix86 INTEL MODE Jan Beulich + LM32 Jon Beniston + M32R Doug Evans + M68HC11 M68HC12 Stephane Carrez + M68HC11 M68HC12 Sean Keys + M88k Mark Kettenis + MACH-O Tristan Gingold + MAXQ Inderpreet Singh + MEP Dave Brolley + METAG Markos Chandras + MICROBLAZE Michael Eager + MIPS Maciej W. Rozycki + MMIX Hans-Peter Nilsson + MN10300 Alexandre Oliva + Moxie Anthony Green + MSP430 Dmitry Diky + NDS32 Kuan-Lin Chen + NDS32 Wei-Cheng Wang + NetBSD support Matt Thomas + Nios II Sandra Loosemore + Nios II Andrew Jenner + OR1K Christian Svensson + OR1K Stefan Kristiansson + PPC Geoff Keating + PPC Alan Modra + PPC Peter Bergner + PPC vector ext Aldy Hernandez + RISC-V Palmer Dabbelt + RISC-V Andrew Waterman + RISC-V Jim Wilson + RL78 DJ Delorie + RX DJ Delorie + RX Nick Clifton + s390, s390x Martin Schwidefsky + s390, s390x Andreas Krebbel + SH Alexandre Oliva + SPARC David S. Miller + SPARC Jose E. Marchesi + SPU Alan Modra + TIC54X Timothy Wall + TIC6X Joseph Myers + TILE-Gx Walter Lee + TILEPro Walter Lee + VAX Matt Thomas + VAX Jan-Benedict Glaw + Visium Eric Botcazou + VMS Tristan Gingold + x86_64 Jan Hubicka + x86_64 Andreas Jaeger + x86_64 H.J. Lu + XCOFF Richard Sandiford + XGATE Sean Keys + Xtensa Sterling Augustine + z80 Arnold Metselaar + z8k Christian Groessler + + --------- Past Maintainers ------------- + +These folks have acted as maintainers in the past, but have now +moved on to other things. Our thanks for all their hard work +goes with them. + + Paul Brook + Eric Christopher + Mei Ligang + Mark Mitchell + Bernd Schmidt + Svein Seldal + + --------- CGEN Maintainers ------------- + +CGEN is a tool for building, amongst other things, assemblers, +disassemblers and simulators from a single description of a CPU. +It creates files in several of the binutils directories, but it +is mentioned here since there is a single group that maintains +CGEN and the files that it creates. + +If you have CGEN related problems you can send email to; + + cgen@sourceware.org + +The current CGEN maintainers are: + + Doug Evans, Frank Eigler + + --------- Write After Approval --------- + +Individuals with "write after approval" have the ability to check in +changes, but they must get approval for each change from someone in +one of the above lists (blanket write or maintainers). + +[It's a huge list, folks. You know who you are. If you have the + *ability* to do binutils checkins, you're in this group. Just + remember to get approval before checking anything in.] + + ------------- Obvious Fixes ------------- + +Fixes for obvious mistakes do not need approval, and can be checked in +right away, but the patch should still be sent to the binutils list. +The definition of obvious is a bit hazy, and if you are not sure, then +you should seek approval first. Obvious fixes include fixes for +spelling mistakes, blatantly incorrect code (where the correct code is +also blatantly obvious), and so on. Obvious fixes should always be +small, the larger they are, the more likely it is that they contain +some un-obvious side effect or consequence. + + --------- Branch Checkins --------- + +If a patch is approved for check in to the mainline sources, it can +also be checked into the current release branch. Normally however +only bug fixes should be applied to the branch. New features, new +ports, etc, should be restricted to the mainline. (Otherwise the +burden of maintaining the branch in sync with the mainline becomes too +great). If you are uncertain as to whether a patch is appropriate for +the branch, ask the branch maintainer. This is: + + (cf global maintainers) + + -------- Testsuites --------------- + +In general patches to any of the binutils testsuites should be +considered generic and sent to the binutils mailing list for +approval. Patches to target specific tests are the responsibility the +relevant port maintainer(s), and can be approved/checked in by them. +Other testsuite patches need the approval of a blanket-write-priveleges +person. + + -------- Configure patches ---------- + +Patches to the top level configure files (config.sub & config.guess) +are not the domain of the binutils project and they cannot be approved +by the binutils group. Instead they should be submitted to the config +maintainer at: + + config-patches@gnu.org + + --------- Creating Branches --------- + +Anyone with at least write-after-approval access may create a branch +to use for their own development purposes. In keeping with FSF +policies, all patches applied to such a branch must come from people +with appropriate copyright assignments on file. All legal +requirements that would apply to any other contribution apply equally +to contributions on a branch. + +Before creating the branch, you should select a name for the branch of +the form: + + binutils-- + +where "org" is the initials of your organization, or your own initials +if you are acting as an individual. For example, for a branch created +by The GNUDist Company, "tgc" would be an appropriate choice for +"org". It's up to each organization to select an appropriate choice +for "name"; some organizations may use more structure than others, so +"name" may contain additional hyphens. + +Suppose that The GNUDist Company was creating a branch to develop a +port of Binutils to the FullMonty processor. Then, an appropriate +choice of branch name would be: + + binutils-tgc-fm + +A date stamp is not required as part of the name field, but some +organizations like to have one. If you do include the date, you +should follow these rules: + +1. The date should be the date that the branch was created. + +2. The date should be numerical and in the form YYYYMMDD. + +For example: + + binutils-tgc-fm_20050101 + +would be appropriate if the branch was created on January 1st, 2005. + +Having selected the branch name, create the branch as follows: + +1. Check out binutils, so that you have a git checkout corresponding + to the initial state of your branch. + +2. Create a tag: + + git tag binutils---branchpoint + + That tag will allow you, and others, to easily determine what's + changed on the branch relative to the initial state. + +3. Create and push the branch: + + git checkout -b binutils---branch + git push origin HEAD + +4. Document the branch: + + Add a description of the branch to binutils/BRANCHES, and check + that file in. All branch descriptions should be added to the + HEAD revision of the file; it doesn't help to modify + binutils/BRANCHES on a branch! + +Please do not commit any patches to a branch you did not create +without the explicit permission of the person who created the branch. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/support/sdbinutils/binutils/Makefile b/support/sdbinutils/binutils/Makefile new file mode 100644 index 0000000..07f2a9d --- /dev/null +++ b/support/sdbinutils/binutils/Makefile @@ -0,0 +1,1520 @@ +# Makefile.in generated by automake 1.11.6 from Makefile.am. +# Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + +# +# Copyright (C) 2012-2018 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . +# + + + +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/binutils +pkgincludedir = $(includedir)/binutils +pkglibdir = $(libdir)/binutils +pkglibexecdir = $(libexecdir)/binutils +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = x86_64-pc-linux-gnu +host_triplet = x86_64-pc-linux-gnu +target_triplet = x86_64-pc-linux-gnu +bin_PROGRAMS = $(am__EXEEXT_8) \ + $(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_15) +noinst_PROGRAMS = $(am__EXEEXT_18) $(am__EXEEXT_21) +EXTRA_PROGRAMS = $(am__EXEEXT_1) srconv$(EXEEXT) sysdump$(EXEEXT) \ + coffdump$(EXEEXT) $(am__EXEEXT_2) $(am__EXEEXT_3) \ + $(am__EXEEXT_4) $(am__EXEEXT_5) +subdir = . +DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \ + $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(srcdir)/config.in \ + $(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in arparse.h \ + arparse.c arlex.c defparse.h defparse.c deflex.c nlmheader.h \ + nlmheader.c arparse.h arparse.c arlex.c mcparse.h mcparse.c \ + rcparse.h rcparse.c $(srcdir)/../depcomp $(srcdir)/../ylwrap +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \ + $(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/gettext-sister.m4 \ + $(top_srcdir)/../config/iconv.m4 \ + $(top_srcdir)/../config/largefile.m4 \ + $(top_srcdir)/../config/lcmessage.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/lib-ld.m4 \ + $(top_srcdir)/../config/lib-link.m4 \ + $(top_srcdir)/../config/lib-prefix.m4 \ + $(top_srcdir)/../config/nls.m4 \ + $(top_srcdir)/../config/override.m4 \ + $(top_srcdir)/../config/plugins.m4 \ + $(top_srcdir)/../config/po.m4 \ + $(top_srcdir)/../config/progtest.m4 \ + $(top_srcdir)/../config/zlib.m4 $(top_srcdir)/../libtool.m4 \ + $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ + $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ + $(top_srcdir)/../bfd/version.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = po/Makefile.in +CONFIG_CLEAN_VPATH_FILES = +am__EXEEXT_1 = nlmconv$(EXEEXT) +am__EXEEXT_2 = dlltool$(EXEEXT) +am__EXEEXT_3 = windres$(EXEEXT) +am__EXEEXT_4 = windmc$(EXEEXT) +am__EXEEXT_5 = dllwrap$(EXEEXT) +am__EXEEXT_6 = size$(EXEEXT) +am__EXEEXT_7 = objdump$(EXEEXT) +am__EXEEXT_8 = sdar$(EXEEXT) +am__EXEEXT_9 = strings$(EXEEXT) +am__EXEEXT_10 = sdranlib$(EXEEXT) +am__EXEEXT_11 = sdobjcopy$(EXEEXT) +am__EXEEXT_12 = addr2line$(EXEEXT) +am__EXEEXT_13 = readelf$(EXEEXT) +am__EXEEXT_14 = elfedit$(EXEEXT) +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" +am__EXEEXT_15 = sdnm$(EXEEXT) +am__EXEEXT_16 = strip-new$(EXEEXT) +am__EXEEXT_17 = cxxfilt$(EXEEXT) +am__EXEEXT_18 = $(am__EXEEXT_15) $(am__EXEEXT_16) $(am__EXEEXT_17) +am__EXEEXT_19 = bfdtest1$(EXEEXT) +am__EXEEXT_20 = bfdtest2$(EXEEXT) +am__EXEEXT_21 = $(am__EXEEXT_19) $(am__EXEEXT_20) +PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) +am__objects_1 = bucomm.$(OBJEXT) version.$(OBJEXT) filemode.$(OBJEXT) +am_addr2line_OBJECTS = addr2line.$(OBJEXT) $(am__objects_1) +addr2line_OBJECTS = $(am_addr2line_OBJECTS) +addr2line_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +am_ar_OBJECTS = arparse.$(OBJEXT) arlex.$(OBJEXT) ar.$(OBJEXT) \ + not-ranlib.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) \ + binemul.$(OBJEXT) emul_$(EMULATION).$(OBJEXT) $(am__objects_1) +ar_OBJECTS = $(am_ar_OBJECTS) +bfdtest1_SOURCES = bfdtest1.c +bfdtest1_OBJECTS = bfdtest1.$(OBJEXT) +bfdtest1_LDADD = $(LDADD) +bfdtest2_SOURCES = bfdtest2.c +bfdtest2_OBJECTS = bfdtest2.$(OBJEXT) +bfdtest2_LDADD = $(LDADD) +am_coffdump_OBJECTS = coffdump.$(OBJEXT) coffgrok.$(OBJEXT) \ + $(am__objects_1) +coffdump_OBJECTS = $(am_coffdump_OBJECTS) +coffdump_LDADD = $(LDADD) +am_cxxfilt_OBJECTS = cxxfilt.$(OBJEXT) $(am__objects_1) +cxxfilt_OBJECTS = $(am_cxxfilt_OBJECTS) +cxxfilt_LDADD = $(LDADD) +am_dlltool_OBJECTS = dlltool.$(OBJEXT) defparse.$(OBJEXT) \ + deflex.$(OBJEXT) $(am__objects_1) +dlltool_OBJECTS = $(am_dlltool_OBJECTS) +am_dllwrap_OBJECTS = dllwrap.$(OBJEXT) version.$(OBJEXT) +dllwrap_OBJECTS = $(am_dllwrap_OBJECTS) +am__objects_2 = elfcomm.$(OBJEXT) +am_elfedit_OBJECTS = elfedit.$(OBJEXT) version.$(OBJEXT) \ + $(am__objects_2) +elfedit_OBJECTS = $(am_elfedit_OBJECTS) +am_nlmconv_OBJECTS = nlmconv.$(OBJEXT) nlmheader.$(OBJEXT) \ + $(am__objects_1) +nlmconv_OBJECTS = $(am_nlmconv_OBJECTS) +nlmconv_LDADD = $(LDADD) +am_nm_new_OBJECTS = nm.$(OBJEXT) $(am__objects_1) +nm_new_OBJECTS = $(am_nm_new_OBJECTS) +nm_new_LDADD = $(LDADD) +am__objects_3 = rddbg.$(OBJEXT) debug.$(OBJEXT) stabs.$(OBJEXT) \ + ieee.$(OBJEXT) rdcoff.$(OBJEXT) +am__objects_4 = $(am__objects_3) wrstabs.$(OBJEXT) +am_objcopy_OBJECTS = objcopy.$(OBJEXT) not-strip.$(OBJEXT) \ + rename.$(OBJEXT) $(am__objects_4) $(am__objects_1) +objcopy_OBJECTS = $(am_objcopy_OBJECTS) +objcopy_LDADD = $(LDADD) +am_objdump_OBJECTS = objdump.$(OBJEXT) dwarf.$(OBJEXT) prdbg.$(OBJEXT) \ + $(am__objects_3) $(am__objects_1) $(am__objects_2) +objdump_OBJECTS = $(am_objdump_OBJECTS) +am_ranlib_OBJECTS = ar.$(OBJEXT) is-ranlib.$(OBJEXT) arparse.$(OBJEXT) \ + arlex.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) \ + binemul.$(OBJEXT) emul_$(EMULATION).$(OBJEXT) $(am__objects_1) +ranlib_OBJECTS = $(am_ranlib_OBJECTS) +am_readelf_OBJECTS = readelf.$(OBJEXT) version.$(OBJEXT) \ + unwind-ia64.$(OBJEXT) dwarf.$(OBJEXT) $(am__objects_2) +readelf_OBJECTS = $(am_readelf_OBJECTS) +am_size_OBJECTS = size.$(OBJEXT) $(am__objects_1) +size_OBJECTS = $(am_size_OBJECTS) +size_LDADD = $(LDADD) +am_srconv_OBJECTS = srconv.$(OBJEXT) coffgrok.$(OBJEXT) \ + $(am__objects_1) +srconv_OBJECTS = $(am_srconv_OBJECTS) +srconv_LDADD = $(LDADD) +am_strings_OBJECTS = strings.$(OBJEXT) $(am__objects_1) +strings_OBJECTS = $(am_strings_OBJECTS) +strings_LDADD = $(LDADD) +am_strip_new_OBJECTS = objcopy.$(OBJEXT) is-strip.$(OBJEXT) \ + rename.$(OBJEXT) $(am__objects_4) $(am__objects_1) +strip_new_OBJECTS = $(am_strip_new_OBJECTS) +strip_new_LDADD = $(LDADD) +am_sysdump_OBJECTS = sysdump.$(OBJEXT) $(am__objects_1) +sysdump_OBJECTS = $(am_sysdump_OBJECTS) +sysdump_LDADD = $(LDADD) +am_windmc_OBJECTS = windmc.$(OBJEXT) mcparse.$(OBJEXT) mclex.$(OBJEXT) \ + winduni.$(OBJEXT) $(am__objects_1) +windmc_OBJECTS = $(am_windmc_OBJECTS) +am_windres_OBJECTS = windres.$(OBJEXT) resrc.$(OBJEXT) \ + rescoff.$(OBJEXT) resbin.$(OBJEXT) rcparse.$(OBJEXT) \ + rclex.$(OBJEXT) winduni.$(OBJEXT) resres.$(OBJEXT) \ + $(am__objects_1) +windres_OBJECTS = $(am_windres_OBJECTS) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +SCRIPTS = $(bin_SCRIPTS) +DEFAULT_INCLUDES = -I. +depcomp = $(SHELL) $(top_srcdir)/../depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +am__skiplex = test -f $@ || +LEXCOMPILE = $(LEX) $(AM_LFLAGS) $(LFLAGS) +LTLEXCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(LEX) $(AM_LFLAGS) $(LFLAGS) +YLWRAP = $(top_srcdir)/../ylwrap +am__skipyacc = test -f $@ || +YACCCOMPILE = $(YACC) $(AM_YFLAGS) $(YFLAGS) +LTYACCCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(YACC) $(AM_YFLAGS) $(YFLAGS) +SOURCES = $(addr2line_SOURCES) $(ar_SOURCES) $(EXTRA_ar_SOURCES) \ + bfdtest1.c bfdtest2.c $(coffdump_SOURCES) $(cxxfilt_SOURCES) \ + $(dlltool_SOURCES) $(dllwrap_SOURCES) $(elfedit_SOURCES) \ + $(nlmconv_SOURCES) $(nm_new_SOURCES) $(objcopy_SOURCES) \ + $(objdump_SOURCES) $(EXTRA_objdump_SOURCES) $(ranlib_SOURCES) \ + $(readelf_SOURCES) $(size_SOURCES) $(srconv_SOURCES) \ + $(strings_SOURCES) $(strip_new_SOURCES) $(sysdump_SOURCES) \ + $(windmc_SOURCES) $(windres_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS +ETAGS = etags +CTAGS = ctags +DEJATOOL = $(PACKAGE) +RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir +DIST_SUBDIRS = $(SUBDIRS) +ACLOCAL = ${SHELL} /home/xavier/sdcc/support/sdbinutils/missing --run aclocal-1.11 +ALLOCA = +AMTAR = $${TAR-tar} +AR = ar +AUTOCONF = ${SHELL} /home/xavier/sdcc/support/sdbinutils/missing --run autoconf +AUTOHEADER = ${SHELL} /home/xavier/sdcc/support/sdbinutils/missing --run autoheader +AUTOMAKE = ${SHELL} /home/xavier/sdcc/support/sdbinutils/missing --run automake-1.11 +AWK = gawk +BUILD_DLLTOOL = +BUILD_DLLWRAP = +BUILD_INSTALL_MISC = +BUILD_MISC = +BUILD_NLMCONV = +BUILD_SRCONV = +BUILD_WINDMC = +BUILD_WINDRES = +CATALOGS = +CATOBJEXT = +CC = gcc +CCDEPMODE = depmode=gcc3 +CC_FOR_BUILD = gcc +CFLAGS = -g -O2 +CPP = gcc -E +CPPFLAGS = +CYGPATH_W = echo +DATADIRNAME = +DEFS = -DHAVE_CONFIG_H +DEMANGLER_NAME = c++filt +DEPDIR = .deps +DLLTOOL_DEFS = +DSYMUTIL = +DUMPBIN = +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = /bin/grep -E +EMULATION = vanilla +EMULATION_VECTOR = bin_vanilla_emulation +EXEEXT = +EXEEXT_FOR_BUILD = $(EXEEXT) +FGREP = /bin/grep -F +GENCAT = +GMSGFMT = /usr/bin/msgfmt +GREP = /bin/grep +HDEFINES = +INCINTL = +INSTALL = /usr/bin/install -c +INSTALL_DATA = /usr/bin/install -c -m 644 +INSTALL_PROGRAM = /usr/bin/install -c +INSTALL_SCRIPT = /usr/bin/install -c +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +INSTOBJEXT = +LD = ld -m elf_x86_64 +LDFLAGS = -static-libstdc++ -static-libgcc +LEX = `if [ -f ../flex/flex ]; then echo ../flex/flex; else echo flex; fi` +LEXLIB = -lfl +LEX_OUTPUT_ROOT = lex.yy +LIBICONV = +LIBINTL = +LIBINTL_DEP = +LIBOBJS = +LIBS = -ldl +LIBTOOL = $(SHELL) $(top_builddir)/libtool +LIPO = +LN_S = ln -s +LTLIBICONV = +LTLIBOBJS = +MAINT = # +MAKEINFO = makeinfo --split-size=5000000 +MKDIR_P = /bin/mkdir -p +MKINSTALLDIRS = $(top_builddir)/./../mkinstalldirs +MSGFMT = /usr/bin/msgfmt +MSGMERGE = /usr/bin/msgmerge +NLMCONV_DEFS = +NM = nm +NMEDIT = +NO_WERROR = +OBJDUMP = objdump +OBJDUMP_DEFS = -DOBJDUMP_PRIVATE_VECTORS="" + +# Extra object files for objdump +OBJDUMP_PRIVATE_OFILES = +OBJEXT = o +OTOOL = +OTOOL64 = +PACKAGE = binutils +PACKAGE_BUGREPORT = +PACKAGE_NAME = binutils +PACKAGE_STRING = binutils 2.30 +PACKAGE_TARNAME = binutils +PACKAGE_URL = +PACKAGE_VERSION = 2.30 +PATH_SEPARATOR = : +POSUB = +RANLIB = ranlib +SED = /bin/sed +SET_MAKE = +SHELL = /bin/bash +STRIP = strip +USE_NLS = yes +VERSION = 2.30 +WARN_CFLAGS = -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 +WARN_CFLAGS_FOR_BUILD = -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 +WARN_WRITE_STRINGS = -Wwrite-strings +XGETTEXT = /usr/bin/xgettext +YACC = `if [ -f ../bison/bison ]; then echo ../bison/bison -y -L$(srcdir)/../bison/; else echo bison -y; fi` +YFLAGS = -d +abs_builddir = /home/xavier/sdcc/support/sdbinutils/binutils +abs_srcdir = /home/xavier/sdcc/support/sdbinutils/binutils +abs_top_builddir = /home/xavier/sdcc/support/sdbinutils/binutils +abs_top_srcdir = /home/xavier/sdcc/support/sdbinutils/binutils +ac_ct_CC = +ac_ct_DUMPBIN = +am__include = include +am__leading_dot = . +am__quote = +am__tar = $${TAR-tar} chof - "$$tardir" +am__untar = $${TAR-tar} xf - +bindir = ${exec_prefix}/bin +build = x86_64-pc-linux-gnu +build_alias = x86_64-pc-linux-gnu +build_cpu = x86_64 +build_os = linux-gnu +build_vendor = pc +builddir = . +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host = x86_64-pc-linux-gnu +host_alias = x86_64-pc-linux-gnu +host_cpu = x86_64 +host_os = linux-gnu +host_vendor = pc +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = ${SHELL} /home/xavier/sdcc/support/sdbinutils/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = /bin/mkdir -p +oldincludedir = /usr/include +pdfdir = ${docdir} +prefix = /usr/local +program_transform_name = s,y,y, +psdir = ${docdir} +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = ${prefix}/etc +target = x86_64-pc-linux-gnu +target_alias = x86_64-pc-linux-gnu +target_cpu = x86_64 +target_os = linux-gnu +target_vendor = pc +top_build_prefix = +top_builddir = . +top_srcdir = . +zlibdir = +zlibinc = +AUTOMAKE_OPTIONS = dejagnu no-dist foreign +ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd +SUBDIRS = +tooldir = $(exec_prefix)/$(target_alias) + +# Automake 1.10+ disables lex and yacc output file regeneration if +# maintainer mode is disabled. Avoid this. +am__skiplex = +am__skipyacc = + +# This is where we get zlib from. zlibdir is -L../zlib and zlibinc is +# -I../zlib, unless we were configured with --with-system-zlib, in which +# case both are empty. +ZLIB = -lz +ZLIBINC = +AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC) +AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD) $(ZLIBINC) + +# these two are almost the same program +AR_PROG = sdar +RANLIB_PROG = sdranlib + +# objcopy and strip should be the same program +OBJCOPY_PROG = sdobjcopy +STRIP_PROG = strip-new +STRINGS_PROG = strings +READELF_PROG = readelf +ELFEDIT_PROG = elfedit + +# These should all be the same program too. +SIZE_PROG = size +NM_PROG = sdnm +OBJDUMP_PROG = objdump + +# This is the demangler, as a standalone program. +# Note: This one is used as the installed name too, unlike the above. +DEMANGLER_PROG = cxxfilt +ADDR2LINE_PROG = addr2line +NLMCONV_PROG = nlmconv +DLLTOOL_PROG = dlltool +WINDRES_PROG = windres +WINDMC_PROG = windmc +DLLWRAP_PROG = dllwrap +SRCONV_PROG = srconv$(EXEEXT) sysdump$(EXEEXT) coffdump$(EXEEXT) +bin_SCRIPTS = +EXTRA_SCRIPTS = embedspu +BFDTEST1_PROG = bfdtest1 +BFDTEST2_PROG = bfdtest2 +TEST_PROGS = $(BFDTEST1_PROG) $(BFDTEST2_PROG) +RENAMED_PROGS = $(NM_PROG) + +# Stuff that goes in tooldir/ if appropriate. +TOOL_PROGS = sdnm sdar sdranlib sdobjcopy +BASEDIR = $(srcdir)/.. +BFDDIR = $(BASEDIR)/bfd +INCDIR = $(BASEDIR)/include +AM_CPPFLAGS = -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) \ + \ + \ + -DLOCALEDIR="\"$(datadir)/locale\"" \ + -Dbin_dummy_emulation=$(EMULATION_VECTOR) + +HFILES = \ + arsup.h binemul.h bucomm.h budbg.h \ + coffgrok.h debug.h dlltool.h dwarf.h elfcomm.h nlmconv.h \ + objdump.h sysdep.h unwind-ia64.h windres.h winduni.h windint.h \ + windmc.h + +GENERATED_HFILES = arparse.h sysroff.h sysinfo.h defparse.h rcparse.h mcparse.h +BUILT_SOURCES = $(GENERATED_HFILES) +CFILES = \ + addr2line.c ar.c arsup.c bin2c.c binemul.c bucomm.c \ + coffdump.c coffgrok.c cxxfilt.c \ + dwarf.c debug.c dlltool.c dllwrap.c \ + elfcomm.c emul_aix.c emul_vanilla.c filemode.c \ + ieee.c is-ranlib.c is-strip.c maybe-ranlib.c maybe-strip.c \ + nlmconv.c nm.c not-ranlib.c not-strip.c \ + objcopy.c objdump.c prdbg.c \ + od-xcoff.c od-macho.c \ + rclex.c rdcoff.c rddbg.c readelf.c rename.c \ + resbin.c rescoff.c resrc.c resres.c \ + size.c srconv.c stabs.c strings.c sysdump.c \ + syslex_wrap.c unwind-ia64.c elfedit.c version.c \ + windres.c winduni.c wrstabs.c \ + windmc.c mclex.c + +GENERATED_CFILES = \ + arparse.c arlex.c sysroff.c sysinfo.c syslex.c \ + defparse.c deflex.c nlmheader.c rcparse.c mcparse.c + +DEBUG_SRCS = rddbg.c debug.c stabs.c ieee.c rdcoff.c +WRITE_DEBUG_SRCS = $(DEBUG_SRCS) wrstabs.c + +# Code shared by all the binutils. +BULIBS = bucomm.c version.c filemode.c + +# Code shared by the ELF related programs. +ELFLIBS = elfcomm.c +BFDLIB = ../bfd/libbfd.la +OPCODES = ../opcodes/libopcodes.la +LIBIBERTY = ../libiberty/libiberty.a +POTFILES = $(CFILES) $(DEBUG_SRCS) $(HFILES) +EXPECT = expect +RUNTEST = runtest +CC_FOR_TARGET = ` \ + if [ -f $$r/../gcc/xgcc ] ; then \ + if [ -f $$r/../newlib/Makefile ] ; then \ + echo $$r/../gcc/xgcc -B$$r/../gcc/ -idirafter $$r/../newlib/targ-include -idirafter $${srcroot}/../newlib/libc/include -nostdinc; \ + else \ + echo $$r/../gcc/xgcc -B$$r/../gcc/; \ + fi; \ + else \ + if [ "x86_64-pc-linux-gnu" = "x86_64-pc-linux-gnu" ] ; then \ + echo $(CC); \ + else \ + echo gcc | sed '$(transform)'; \ + fi; \ + fi` + + +# There's no global DEPENDENCIES. So, we must explicitly list everything +# which depends on libintl, since we don't know whether LIBINTL_DEP will be +# non-empty until configure time. Ugh! +size_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +objdump_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) $(OPCODES) $(OBJDUMP_PRIVATE_OFILES) +nm_new_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +ar_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +strings_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +strip_new_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +ranlib_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +cxxfilt_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +objcopy_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +nlmconv_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +srconv_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +sysdump_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +coffdump_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +dlltool_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +windres_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +windmc_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +addr2line_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +readelf_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) +elfedit_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) +dllwrap_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) +bfdtest1_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +bfdtest2_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) +size_SOURCES = size.c $(BULIBS) +objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) +strings_SOURCES = strings.c $(BULIBS) +readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c $(ELFLIBS) +readelf_LDADD = $(LIBINTL) $(LIBIBERTY) $(ZLIB) +elfedit_SOURCES = elfedit.c version.c $(ELFLIBS) +elfedit_LDADD = $(LIBINTL) $(LIBIBERTY) +strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) +nm_new_SOURCES = nm.c $(BULIBS) +objdump_SOURCES = objdump.c dwarf.c prdbg.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS) +EXTRA_objdump_SOURCES = od-xcoff.c +objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) +cxxfilt_SOURCES = cxxfilt.c $(BULIBS) +ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c binemul.c \ + emul_$(EMULATION).c $(BULIBS) + +EXTRA_ar_SOURCES = $(CFILES) +ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) +ranlib_SOURCES = ar.c is-ranlib.c arparse.y arlex.l arsup.c rename.c \ + binemul.c emul_$(EMULATION).c $(BULIBS) + +ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) +addr2line_SOURCES = addr2line.c $(BULIBS) +srconv_SOURCES = srconv.c coffgrok.c $(BULIBS) +dlltool_SOURCES = dlltool.c defparse.y deflex.l $(BULIBS) +dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) +coffdump_SOURCES = coffdump.c coffgrok.c $(BULIBS) +sysdump_SOURCES = sysdump.c $(BULIBS) +nlmconv_SOURCES = nlmconv.c nlmheader.y $(BULIBS) +windres_SOURCES = windres.c resrc.c rescoff.c resbin.c rcparse.y rclex.c \ + winduni.c resres.c $(BULIBS) + +windres_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) +windmc_SOURCES = windmc.c mcparse.y mclex.c \ + winduni.c $(BULIBS) + +windmc_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) +dllwrap_SOURCES = dllwrap.c version.c +dllwrap_LDADD = $(LIBIBERTY) $(LIBINTL) +EXTRA_DIST = arparse.c arparse.h arlex.c nlmheader.c sysinfo.c sysinfo.h \ + syslex.c deflex.c defparse.h defparse.c rcparse.h rcparse.c \ + mcparse.h mcparse.c embedspu.sh + + +# development.sh is used to determine -Werror default. +CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh +DISTCLEANFILES = sysroff.c sysroff.h site.exp site.bak embedspu +MOSTLYCLEANFILES = sysinfo$(EXEEXT_FOR_BUILD) bin2c$(EXEEXT_FOR_BUILD) \ + binutils.log binutils.sum abcdefgh* + +all: $(BUILT_SOURCES) config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .c .l .lo .o .obj .y +am--refresh: Makefile + @: +$(srcdir)/Makefile.in: # $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: # $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): # $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): + +config.h: stamp-h1 + @if test ! -f $@; then rm -f stamp-h1; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi + +stamp-h1: $(srcdir)/config.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.in: # $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +po/Makefile.in: $(top_builddir)/config.status $(top_srcdir)/po/Make-in + cd $(top_builddir) && $(SHELL) ./config.status $@ +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +addr2line$(EXEEXT): $(addr2line_OBJECTS) $(addr2line_DEPENDENCIES) $(EXTRA_addr2line_DEPENDENCIES) + @rm -f addr2line$(EXEEXT) + $(LINK) $(addr2line_OBJECTS) $(addr2line_LDADD) $(LIBS) +arparse.h: arparse.c + @if test ! -f $@; then rm -f arparse.c; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) arparse.c; else :; fi +sdar$(EXEEXT): $(ar_OBJECTS) $(ar_DEPENDENCIES) $(EXTRA_ar_DEPENDENCIES) + @rm -f ar$(EXEEXT) + $(LINK) $(ar_OBJECTS) $(ar_LDADD) $(LIBS) +bfdtest1$(EXEEXT): $(bfdtest1_OBJECTS) $(bfdtest1_DEPENDENCIES) $(EXTRA_bfdtest1_DEPENDENCIES) + @rm -f bfdtest1$(EXEEXT) + $(LINK) $(bfdtest1_OBJECTS) $(bfdtest1_LDADD) $(LIBS) +bfdtest2$(EXEEXT): $(bfdtest2_OBJECTS) $(bfdtest2_DEPENDENCIES) $(EXTRA_bfdtest2_DEPENDENCIES) + @rm -f bfdtest2$(EXEEXT) + $(LINK) $(bfdtest2_OBJECTS) $(bfdtest2_LDADD) $(LIBS) +coffdump$(EXEEXT): $(coffdump_OBJECTS) $(coffdump_DEPENDENCIES) $(EXTRA_coffdump_DEPENDENCIES) + @rm -f coffdump$(EXEEXT) + $(LINK) $(coffdump_OBJECTS) $(coffdump_LDADD) $(LIBS) +cxxfilt$(EXEEXT): $(cxxfilt_OBJECTS) $(cxxfilt_DEPENDENCIES) $(EXTRA_cxxfilt_DEPENDENCIES) + @rm -f cxxfilt$(EXEEXT) + $(LINK) $(cxxfilt_OBJECTS) $(cxxfilt_LDADD) $(LIBS) +defparse.h: defparse.c + @if test ! -f $@; then rm -f defparse.c; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) defparse.c; else :; fi +dlltool$(EXEEXT): $(dlltool_OBJECTS) $(dlltool_DEPENDENCIES) $(EXTRA_dlltool_DEPENDENCIES) + @rm -f dlltool$(EXEEXT) + $(LINK) $(dlltool_OBJECTS) $(dlltool_LDADD) $(LIBS) +dllwrap$(EXEEXT): $(dllwrap_OBJECTS) $(dllwrap_DEPENDENCIES) $(EXTRA_dllwrap_DEPENDENCIES) + @rm -f dllwrap$(EXEEXT) + $(LINK) $(dllwrap_OBJECTS) $(dllwrap_LDADD) $(LIBS) +elfedit$(EXEEXT): $(elfedit_OBJECTS) $(elfedit_DEPENDENCIES) $(EXTRA_elfedit_DEPENDENCIES) + @rm -f elfedit$(EXEEXT) + $(LINK) $(elfedit_OBJECTS) $(elfedit_LDADD) $(LIBS) +nlmheader.h: nlmheader.c + @if test ! -f $@; then rm -f nlmheader.c; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) nlmheader.c; else :; fi +nlmconv$(EXEEXT): $(nlmconv_OBJECTS) $(nlmconv_DEPENDENCIES) $(EXTRA_nlmconv_DEPENDENCIES) + @rm -f nlmconv$(EXEEXT) + $(LINK) $(nlmconv_OBJECTS) $(nlmconv_LDADD) $(LIBS) +sdnm$(EXEEXT): $(nm_new_OBJECTS) $(nm_new_DEPENDENCIES) $(EXTRA_nm_new_DEPENDENCIES) + @rm -f nm-new$(EXEEXT) + $(LINK) $(nm_new_OBJECTS) $(nm_new_LDADD) $(LIBS) +sdobjcopy$(EXEEXT): $(objcopy_OBJECTS) $(objcopy_DEPENDENCIES) $(EXTRA_objcopy_DEPENDENCIES) + @rm -f objcopy$(EXEEXT) + $(LINK) $(objcopy_OBJECTS) $(objcopy_LDADD) $(LIBS) +objdump$(EXEEXT): $(objdump_OBJECTS) $(objdump_DEPENDENCIES) $(EXTRA_objdump_DEPENDENCIES) + @rm -f objdump$(EXEEXT) + $(LINK) $(objdump_OBJECTS) $(objdump_LDADD) $(LIBS) +sdranlib$(EXEEXT): $(ranlib_OBJECTS) $(ranlib_DEPENDENCIES) $(EXTRA_ranlib_DEPENDENCIES) + @rm -f ranlib$(EXEEXT) + $(LINK) $(ranlib_OBJECTS) $(ranlib_LDADD) $(LIBS) +readelf$(EXEEXT): $(readelf_OBJECTS) $(readelf_DEPENDENCIES) $(EXTRA_readelf_DEPENDENCIES) + @rm -f readelf$(EXEEXT) + $(LINK) $(readelf_OBJECTS) $(readelf_LDADD) $(LIBS) +size$(EXEEXT): $(size_OBJECTS) $(size_DEPENDENCIES) $(EXTRA_size_DEPENDENCIES) + @rm -f size$(EXEEXT) + $(LINK) $(size_OBJECTS) $(size_LDADD) $(LIBS) +srconv$(EXEEXT): $(srconv_OBJECTS) $(srconv_DEPENDENCIES) $(EXTRA_srconv_DEPENDENCIES) + @rm -f srconv$(EXEEXT) + $(LINK) $(srconv_OBJECTS) $(srconv_LDADD) $(LIBS) +strings$(EXEEXT): $(strings_OBJECTS) $(strings_DEPENDENCIES) $(EXTRA_strings_DEPENDENCIES) + @rm -f strings$(EXEEXT) + $(LINK) $(strings_OBJECTS) $(strings_LDADD) $(LIBS) +strip-new$(EXEEXT): $(strip_new_OBJECTS) $(strip_new_DEPENDENCIES) $(EXTRA_strip_new_DEPENDENCIES) + @rm -f strip-new$(EXEEXT) + $(LINK) $(strip_new_OBJECTS) $(strip_new_LDADD) $(LIBS) +sysdump$(EXEEXT): $(sysdump_OBJECTS) $(sysdump_DEPENDENCIES) $(EXTRA_sysdump_DEPENDENCIES) + @rm -f sysdump$(EXEEXT) + $(LINK) $(sysdump_OBJECTS) $(sysdump_LDADD) $(LIBS) +mcparse.h: mcparse.c + @if test ! -f $@; then rm -f mcparse.c; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) mcparse.c; else :; fi +windmc$(EXEEXT): $(windmc_OBJECTS) $(windmc_DEPENDENCIES) $(EXTRA_windmc_DEPENDENCIES) + @rm -f windmc$(EXEEXT) + $(LINK) $(windmc_OBJECTS) $(windmc_LDADD) $(LIBS) +rcparse.h: rcparse.c + @if test ! -f $@; then rm -f rcparse.c; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) rcparse.c; else :; fi +windres$(EXEEXT): $(windres_OBJECTS) $(windres_DEPENDENCIES) $(EXTRA_windres_DEPENDENCIES) + @rm -f windres$(EXEEXT) + $(LINK) $(windres_OBJECTS) $(windres_LDADD) $(LIBS) +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +include ./$(DEPDIR)/addr2line.Po +include ./$(DEPDIR)/ar.Po +include ./$(DEPDIR)/arlex.Po +include ./$(DEPDIR)/arparse.Po +include ./$(DEPDIR)/arsup.Po +include ./$(DEPDIR)/bfdtest1.Po +include ./$(DEPDIR)/bfdtest2.Po +include ./$(DEPDIR)/bin2c.Po +include ./$(DEPDIR)/binemul.Po +include ./$(DEPDIR)/bucomm.Po +include ./$(DEPDIR)/coffdump.Po +include ./$(DEPDIR)/coffgrok.Po +include ./$(DEPDIR)/cxxfilt.Po +include ./$(DEPDIR)/debug.Po +include ./$(DEPDIR)/deflex.Po +include ./$(DEPDIR)/defparse.Po +include ./$(DEPDIR)/dlltool.Po +include ./$(DEPDIR)/dllwrap.Po +include ./$(DEPDIR)/dwarf.Po +include ./$(DEPDIR)/elfcomm.Po +include ./$(DEPDIR)/elfedit.Po +include ./$(DEPDIR)/emul_$(EMULATION).Po +include ./$(DEPDIR)/emul_aix.Po +include ./$(DEPDIR)/emul_vanilla.Po +include ./$(DEPDIR)/filemode.Po +include ./$(DEPDIR)/ieee.Po +include ./$(DEPDIR)/is-ranlib.Po +include ./$(DEPDIR)/is-strip.Po +include ./$(DEPDIR)/maybe-ranlib.Po +include ./$(DEPDIR)/maybe-strip.Po +include ./$(DEPDIR)/mclex.Po +include ./$(DEPDIR)/mcparse.Po +include ./$(DEPDIR)/nlmconv.Po +include ./$(DEPDIR)/nlmheader.Po +include ./$(DEPDIR)/nm.Po +include ./$(DEPDIR)/not-ranlib.Po +include ./$(DEPDIR)/not-strip.Po +include ./$(DEPDIR)/objcopy.Po +include ./$(DEPDIR)/objdump.Po +include ./$(DEPDIR)/od-macho.Po +include ./$(DEPDIR)/od-xcoff.Po +include ./$(DEPDIR)/prdbg.Po +include ./$(DEPDIR)/rclex.Po +include ./$(DEPDIR)/rcparse.Po +include ./$(DEPDIR)/rdcoff.Po +include ./$(DEPDIR)/rddbg.Po +include ./$(DEPDIR)/readelf.Po +include ./$(DEPDIR)/rename.Po +include ./$(DEPDIR)/resbin.Po +include ./$(DEPDIR)/rescoff.Po +include ./$(DEPDIR)/resrc.Po +include ./$(DEPDIR)/resres.Po +include ./$(DEPDIR)/size.Po +include ./$(DEPDIR)/srconv.Po +include ./$(DEPDIR)/stabs.Po +include ./$(DEPDIR)/strings.Po +include ./$(DEPDIR)/sysdump.Po +include ./$(DEPDIR)/syslex_wrap.Po +include ./$(DEPDIR)/unwind-ia64.Po +include ./$(DEPDIR)/version.Po +include ./$(DEPDIR)/windmc.Po +include ./$(DEPDIR)/windres.Po +include ./$(DEPDIR)/winduni.Po +include ./$(DEPDIR)/wrstabs.Po + +.c.o: + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c $< + +.c.obj: + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` + $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: + $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +# source='$<' object='$@' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(LTCOMPILE) -c -o $@ $< + +.l.c: + $(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE) + +.y.c: + $(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE) + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool config.lt + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) config.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) config.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG) + @echo 'Making a new site.exp file...' + @echo '## these variables are automatically generated by make ##' >site.tmp + @echo '# Do not edit here. If you wish to override these values' >>site.tmp + @echo '# edit the last section' >>site.tmp + @echo 'set srcdir "$(srcdir)"' >>site.tmp + @echo "set objdir `pwd`" >>site.tmp + @echo 'set build_alias "$(build_alias)"' >>site.tmp + @echo 'set build_triplet $(build_triplet)' >>site.tmp + @echo 'set host_alias "$(host_alias)"' >>site.tmp + @echo 'set host_triplet $(host_triplet)' >>site.tmp + @echo 'set target_alias "$(target_alias)"' >>site.tmp + @echo 'set target_triplet $(target_triplet)' >>site.tmp + @list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \ + echo "## Begin content included from file $$f. Do not modify. ##" \ + && cat `test -f "$$f" || echo '$(srcdir)/'`$$f \ + && echo "## End content included from file $$f. ##" \ + || exit 1; \ + done >> site.tmp + @echo "## End of auto-generated content; you can edit from here. ##" >> site.tmp + @if test -f site.exp; then \ + sed -e '1,/^## End of auto-generated content.*##/d' site.exp >> site.tmp; \ + fi + @-rm -f site.bak + @test ! -f site.exp || mv site.exp site.bak + @mv site.tmp site.exp + +distclean-DEJAGNU: + -rm -f site.exp site.bak + -l='$(DEJATOOL)'; for tool in $$l; do \ + rm -f $$tool.sum $$tool.log; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-recursive +all-am: Makefile $(PROGRAMS) $(SCRIPTS) config.h +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -rm -f arlex.c + -rm -f arparse.c + -rm -f arparse.h + -rm -f deflex.c + -rm -f defparse.c + -rm -f defparse.h + -rm -f mcparse.c + -rm -f mcparse.h + -rm -f nlmheader.c + -rm -f nlmheader.h + -rm -f rcparse.c + -rm -f rcparse.h + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-libtool \ + clean-noinstPROGRAMS mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-DEJAGNU distclean-compile \ + distclean-generic distclean-hdr distclean-libtool \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: install-binPROGRAMS install-binSCRIPTS + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: installcheck-local + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool mostlyclean-local + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \ + check-am ctags-recursive install install-am install-strip \ + tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am am--refresh check check-DEJAGNU check-am clean \ + clean-binPROGRAMS clean-generic clean-libtool \ + clean-noinstPROGRAMS ctags ctags-recursive distclean \ + distclean-DEJAGNU distclean-compile distclean-generic \ + distclean-hdr distclean-libtool distclean-tags dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-binSCRIPTS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-exec-local \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installcheck-local installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \ + pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-binSCRIPTS + +po/POTFILES.in: # Makefile + for f in $(POTFILES); do echo $$f; done | LC_ALL=C sort > tmp \ + && mv tmp $(srcdir)/po/POTFILES.in + +check-DEJAGNU: site.exp + srcdir=`cd $(srcdir) && pwd`; export srcdir; \ + r=`pwd`; export r; \ + LC_ALL=C; export LC_ALL; \ + EXPECT=$(EXPECT); export EXPECT; \ + runtest=$(RUNTEST); \ + if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ + CC="$(CC)" CC_FOR_BUILD="$(CC_FOR_BUILD)" \ + CC_FOR_TARGET="$(CC_FOR_TARGET)" CFLAGS_FOR_TARGET="$(CFLAGS)" \ + $$runtest --tool $(DEJATOOL) --srcdir $${srcdir}/testsuite \ + $(RUNTESTFLAGS); \ + else echo "WARNING: could not find \`runtest'" 1>&2; :;\ + fi + +installcheck-local: + /bin/sh $(srcdir)/sanity.sh $(bindir) + +objdump.o:objdump.c + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(OBJDUMP_DEFS) $(srcdir)/objdump.c + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='objdump.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c $(OBJDUMP_DEFS) $(srcdir)/objdump.c + +# The following is commented out for the conversion to automake. +# This rule creates a single binary that switches between ar and ranlib +# by looking at argv[0]. Use this kludge to save some disk space. +# However, you have to install things by hand. +# (That is after 'make install', replace the installed ranlib by a link to ar.) +# Alternatively, you can install ranlib.sh as ranlib. +# ar_with_ranlib: $(ADDL_DEPS) ar.o maybe-ranlib.o +# $(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $(AR_PROG) ar.o maybe-ranlib.o $(ADDL_LIBS) $(EXTRALIBS) +# -rm -f $(RANLIB_PROG) +# -ln $(AR_PROG) $(RANLIB_PROG) +# +# objcopy and strip in one binary that uses argv[0] to decide its action. +# +#objcopy_with_strip: $(ADDL_DEPS) objcopy.o maybe-strip.o +# $(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $(OBJCOPY_PROG) objcopy.o maybe-strip.o $(ADDL_LIBS) $(EXTRALIBS) +# -rm -f $(STRIP_PROG) +# -ln $(OBJCOPY_PROG) $(STRIP_PROG) + +sysroff.c: sysinfo$(EXEEXT_FOR_BUILD) sysroff.info + ./sysinfo$(EXEEXT_FOR_BUILD) -c <$(srcdir)/sysroff.info >sysroff.c + ./sysinfo$(EXEEXT_FOR_BUILD) -i <$(srcdir)/sysroff.info >>sysroff.c + ./sysinfo$(EXEEXT_FOR_BUILD) -g <$(srcdir)/sysroff.info >>sysroff.c + +sysroff.h: sysinfo$(EXEEXT_FOR_BUILD) sysroff.info + ./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h + +sysinfo$(EXEEXT_FOR_BUILD): sysinfo.o syslex_wrap.o + $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex_wrap.o + +syslex_wrap.o: syslex_wrap.c syslex.c sysinfo.h config.h + $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex_wrap.c + +sysinfo.o: sysinfo.c + if [ -r sysinfo.c ]; then \ + $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \ + else \ + $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \ + fi + +bin2c$(EXEEXT_FOR_BUILD): bin2c.c + $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c + +embedspu: embedspu.sh Makefile + awk '/^program_transform_name=/ {print "program_transform_name=\"$(program_transform_name)\""; next} {print}' < $< > $@ + chmod a+x $@ + +# We need these for parallel make. +sysinfo.h: sysinfo.c + +# Disable -Werror, if it has been enabled, since old versions of bison/ +# yacc will produce working code which contain compile time warnings. +arparse.o: arparse.c + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f arparse.c || echo $(srcdir)/`arparse.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='arparse.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `test -f arparse.c || echo $(srcdir)/`arparse.c $(NO_WERROR) + +arlex.o: arlex.c + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f arlex.c || echo $(srcdir)/`arlex.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='arlex.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `test -f arlex.c || echo $(srcdir)/`arlex.c $(NO_WERROR) + +sysroff.o: sysroff.c + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f sysroff.c || echo $(srcdir)/`sysroff.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='sysroff.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `test -f sysroff.c || echo $(srcdir)/`sysroff.c $(NO_WERROR) + +defparse.o: defparse.c + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f defparse.c || echo $(srcdir)/`defparse.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='defparse.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `test -f defparse.c || echo $(srcdir)/`defparse.c $(NO_WERROR) + +deflex.o: deflex.c + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f deflex.c || echo $(srcdir)/`deflex.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='deflex.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `test -f deflex.c || echo $(srcdir)/`deflex.c $(NO_WERROR) + +nlmheader.o: nlmheader.c + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f nlmheader.c || echo $(srcdir)/`nlmheader.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='nlmheader.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `test -f nlmheader.c || echo $(srcdir)/`nlmheader.c $(NO_WERROR) + +rcparse.o: rcparse.c + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f rcparse.c || echo $(srcdir)/`rcparse.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='rcparse.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `test -f rcparse.c || echo $(srcdir)/`rcparse.c $(NO_WERROR) + +mcparse.o: mcparse.c + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f mcparse.c || echo $(srcdir)/`mcparse.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='mcparse.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `test -f mcparse.c || echo $(srcdir)/`mcparse.c $(NO_WERROR) + +rclex.o: rclex.c + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(srcdir)/rclex.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='rclex.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c $(srcdir)/rclex.c $(NO_WERROR) + +mclex.o: mclex.c + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(srcdir)/mclex.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='mclex.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c $(srcdir)/mclex.c $(NO_WERROR) +srconv.o: sysroff.c + +dlltool.o: + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(DLLTOOL_DEFS) $(srcdir)/dlltool.c + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='dlltool.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c $(DLLTOOL_DEFS) $(srcdir)/dlltool.c + +rescoff.o: + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(DLLTOOL_DEFS) $(srcdir)/rescoff.c + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='rescoff.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c $(DLLTOOL_DEFS) $(srcdir)/rescoff.c +sysdump.o: sysroff.c + +# coff/sym.h and coff/ecoff.h won't be found by the automatic dependency +# scripts, since they are only included conditionally. +nlmconv.o: nlmconv.c + ldname=`echo ld | sed '$(transform)'`; \ + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ \ + -DLD_NAME="\"$${ldname}\"" $(srcdir)/nlmconv.c + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='nlmconv.c' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# ldname=`echo ld | sed '$(transform)'`; \ +# $(COMPILE) -c -DLD_NAME="\"$${ldname}\"" $(srcdir)/nlmconv.c + +diststuff: $(EXTRA_DIST) info +all: info +mostlyclean-local: + -rm -rf tmpdir + +.PHONY: install-exec-local + +install-exec-local: install-binPROGRAMS $(bin_PROGRAMS) $(noinst_PROGRAMS) + @list='$(RENAMED_PROGS)'; for p in $$list; do \ + if test -f $$p$(EXEEXT); then \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p$(EXEEXT) $(bindir)/`echo $$p|sed -e 's/-new//' -e 's/cxxfilt/$(DEMANGLER_NAME)/'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p$(EXEEXT) $(DESTDIR)$(bindir)/`echo $$p|sed -e 's/-new//' -e 's/cxxfilt/$(DEMANGLER_NAME)/'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + $(mkinstalldirs) $(DESTDIR)$(tooldir)/bin + for i in $(TOOL_PROGS); do \ + if [ -f $$i$(EXEEXT) ]; then \ + j=`echo $$i | sed -e 's/-new//'`; \ + k=`echo $$j | sed '$(transform)'`; \ + if [ "$(bindir)/$$k" != "$(tooldir)/bin/$$j" ]; then \ + rm -f $(DESTDIR)$(tooldir)/bin/$$j$(EXEEXT); \ + ln $(DESTDIR)$(bindir)/$$k$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$$j$(EXEEXT) >/dev/null 2>/dev/null \ + || $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$i$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$$j$(EXEEXT); \ + fi; \ + else true; \ + fi; \ + done + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/support/sdbinutils/binutils/Makefile.am b/support/sdbinutils/binutils/Makefile.am new file mode 100644 index 0000000..070a847 --- /dev/null +++ b/support/sdbinutils/binutils/Makefile.am @@ -0,0 +1,555 @@ +## Process this file with automake to generate Makefile.in +# +# Copyright (C) 2012-2018 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . +# + +AUTOMAKE_OPTIONS = dejagnu no-dist foreign +ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd + +SUBDIRS = + +tooldir = $(exec_prefix)/$(target_alias) + +## These aren't set by automake, because they appear in +## bfd/acinclude.m4, which is included by binutils/acinclude.m4, and +## thus is not seen by automake. +CC_FOR_BUILD = @CC_FOR_BUILD@ +EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@ + +YACC = `if [ -f ../bison/bison ]; then echo ../bison/bison -y -L$(srcdir)/../bison/; else echo @YACC@; fi` +YFLAGS = -d +LEX = `if [ -f ../flex/flex ]; then echo ../flex/flex; else echo @LEX@; fi` +LEXLIB = @LEXLIB@ + +# Automake 1.10+ disables lex and yacc output file regeneration if +# maintainer mode is disabled. Avoid this. +am__skiplex = +am__skipyacc = + +# This is where we get zlib from. zlibdir is -L../zlib and zlibinc is +# -I../zlib, unless we were configured with --with-system-zlib, in which +# case both are empty. +ZLIB = @zlibdir@ -lz +ZLIBINC = @zlibinc@ + +WARN_CFLAGS = @WARN_CFLAGS@ +WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@ +NO_WERROR = @NO_WERROR@ +AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC) +AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD) $(ZLIBINC) +LIBICONV = @LIBICONV@ + +# these two are almost the same program +AR_PROG=sdar +RANLIB_PROG=sdranlib + +# objcopy and strip should be the same program +OBJCOPY_PROG=sdobjcopy +STRIP_PROG=strip-new + +STRINGS_PROG=strings + +READELF_PROG=readelf + +ELFEDIT_PROG=elfedit + +# These should all be the same program too. +SIZE_PROG=size +NM_PROG=sdnm +#OBJDUMP_PROG=objdump + +# This is the demangler, as a standalone program. +# Note: This one is used as the installed name too, unlike the above. +DEMANGLER_PROG=cxxfilt + +ADDR2LINE_PROG=addr2line + +NLMCONV_PROG=nlmconv +DLLTOOL_PROG=dlltool +WINDRES_PROG=windres +WINDMC_PROG=windmc +DLLWRAP_PROG=dllwrap + +SRCONV_PROG=srconv$(EXEEXT) sysdump$(EXEEXT) coffdump$(EXEEXT) + +bin_PROGRAMS = $(AR_PROG) $(RANLIB_PROG) $(OBJCOPY_PROG) + +bin_SCRIPTS = @BUILD_INSTALL_MISC@ +EXTRA_SCRIPTS = embedspu + +## Test programs. +BFDTEST1_PROG = bfdtest1 +BFDTEST2_PROG = bfdtest2 + +TEST_PROGS = $(BFDTEST1_PROG) $(BFDTEST2_PROG) + +## We need a special rule to install the programs which are built with +## -new, and to rename cxxfilt to c++filt. +RENAMED_PROGS = $(NM_PROG) +noinst_PROGRAMS = $(RENAMED_PROGS) $(TEST_PROGS) @BUILD_MISC@ + +EXTRA_PROGRAMS = + +# Stuff that goes in tooldir/ if appropriate. +TOOL_PROGS = sdnm sdar sdranlib sdobjcopy + +BASEDIR = $(srcdir)/.. +BFDDIR = $(BASEDIR)/bfd +INCDIR = $(BASEDIR)/include + +AM_CPPFLAGS = -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) \ + @HDEFINES@ \ + @INCINTL@ \ + -DLOCALEDIR="\"$(datadir)/locale\"" \ + -Dbin_dummy_emulation=$(EMULATION_VECTOR) + +HFILES = \ + arsup.h binemul.h bucomm.h budbg.h \ + coffgrok.h debug.h dlltool.h dwarf.h elfcomm.h nlmconv.h \ + objdump.h sysdep.h unwind-ia64.h windres.h winduni.h windint.h \ + windmc.h + +GENERATED_HFILES = arparse.h sysroff.h sysinfo.h defparse.h rcparse.h mcparse.h +BUILT_SOURCES = $(GENERATED_HFILES) + +CFILES = \ + addr2line.c ar.c arsup.c bin2c.c binemul.c bucomm.c \ + coffdump.c coffgrok.c cxxfilt.c \ + dwarf.c debug.c dlltool.c dllwrap.c \ + elfcomm.c emul_aix.c emul_vanilla.c filemode.c \ + ieee.c is-ranlib.c is-strip.c maybe-ranlib.c maybe-strip.c \ + nlmconv.c nm.c not-ranlib.c not-strip.c \ + objcopy.c objdump.c prdbg.c \ + od-xcoff.c od-macho.c \ + rclex.c rdcoff.c rddbg.c readelf.c rename.c \ + resbin.c rescoff.c resrc.c resres.c \ + size.c srconv.c stabs.c strings.c sysdump.c \ + syslex_wrap.c unwind-ia64.c elfedit.c version.c \ + windres.c winduni.c wrstabs.c \ + windmc.c mclex.c + +GENERATED_CFILES = \ + arparse.c arlex.c sysroff.c sysinfo.c syslex.c \ + defparse.c deflex.c nlmheader.c rcparse.c mcparse.c + +DEBUG_SRCS = rddbg.c debug.c stabs.c ieee.c rdcoff.c +WRITE_DEBUG_SRCS = $(DEBUG_SRCS) wrstabs.c + +# Extra object files for objdump +OBJDUMP_PRIVATE_OFILES = @OBJDUMP_PRIVATE_OFILES@ + +# Code shared by all the binutils. +BULIBS = bucomm.c version.c filemode.c + +# Code shared by the ELF related programs. +ELFLIBS = elfcomm.c + +BFDLIB = ../bfd/libbfd.la + +OPCODES = ../opcodes/libopcodes.la + +LIBIBERTY = ../libiberty/libiberty.a + +POTFILES = $(CFILES) $(DEBUG_SRCS) $(HFILES) +po/POTFILES.in: @MAINT@ Makefile + for f in $(POTFILES); do echo $$f; done | LC_ALL=C sort > tmp \ + && mv tmp $(srcdir)/po/POTFILES.in + +EXPECT = expect +RUNTEST = runtest + +CC_FOR_TARGET = ` \ + if [ -f $$r/../gcc/xgcc ] ; then \ + if [ -f $$r/../newlib/Makefile ] ; then \ + echo $$r/../gcc/xgcc -B$$r/../gcc/ -idirafter $$r/../newlib/targ-include -idirafter $${srcroot}/../newlib/libc/include -nostdinc; \ + else \ + echo $$r/../gcc/xgcc -B$$r/../gcc/; \ + fi; \ + else \ + if [ "@host@" = "@target@" ] ; then \ + echo $(CC); \ + else \ + echo gcc | sed '$(transform)'; \ + fi; \ + fi` + +check-DEJAGNU: site.exp + srcdir=`cd $(srcdir) && pwd`; export srcdir; \ + r=`pwd`; export r; \ + LC_ALL=C; export LC_ALL; \ + EXPECT=$(EXPECT); export EXPECT; \ + runtest=$(RUNTEST); \ + if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ + CC="$(CC)" CC_FOR_BUILD="$(CC_FOR_BUILD)" \ + CC_FOR_TARGET="$(CC_FOR_TARGET)" CFLAGS_FOR_TARGET="$(CFLAGS)" \ + $$runtest --tool $(DEJATOOL) --srcdir $${srcdir}/testsuite \ + $(RUNTESTFLAGS); \ + else echo "WARNING: could not find \`runtest'" 1>&2; :;\ + fi + +installcheck-local: + /bin/sh $(srcdir)/sanity.sh $(bindir) + +# There's no global DEPENDENCIES. So, we must explicitly list everything +# which depends on libintl, since we don't know whether LIBINTL_DEP will be +# non-empty until configure time. Ugh! +size_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +objdump_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) $(OPCODES) $(OBJDUMP_PRIVATE_OFILES) +nm_new_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +ar_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +strings_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +strip_new_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +ranlib_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +cxxfilt_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +objcopy_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +nlmconv_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +srconv_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +sysdump_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +coffdump_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +dlltool_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +windres_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +windmc_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +addr2line_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +readelf_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) +elfedit_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) +dllwrap_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) +bfdtest1_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +bfdtest2_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) + +LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) + +size_SOURCES = size.c $(BULIBS) + +objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) + +strings_SOURCES = strings.c $(BULIBS) + +readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c $(ELFLIBS) +readelf_LDADD = $(LIBINTL) $(LIBIBERTY) $(ZLIB) + +elfedit_SOURCES = elfedit.c version.c $(ELFLIBS) +elfedit_LDADD = $(LIBINTL) $(LIBIBERTY) + +strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) + +nm_new_SOURCES = nm.c $(BULIBS) + +objdump_SOURCES = objdump.c dwarf.c prdbg.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS) +EXTRA_objdump_SOURCES = od-xcoff.c +objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) + +objdump.@OBJEXT@:objdump.c +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(OBJDUMP_DEFS) $(srcdir)/objdump.c + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='objdump.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c $(OBJDUMP_DEFS) $(srcdir)/objdump.c +endif + +cxxfilt_SOURCES = cxxfilt.c $(BULIBS) + +ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c binemul.c \ + emul_$(EMULATION).c $(BULIBS) +EXTRA_ar_SOURCES = $(CFILES) +ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) + +ranlib_SOURCES = ar.c is-ranlib.c arparse.y arlex.l arsup.c rename.c \ + binemul.c emul_$(EMULATION).c $(BULIBS) +ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) + +addr2line_SOURCES = addr2line.c $(BULIBS) + +# The following is commented out for the conversion to automake. +# This rule creates a single binary that switches between ar and ranlib +# by looking at argv[0]. Use this kludge to save some disk space. +# However, you have to install things by hand. +# (That is after 'make install', replace the installed ranlib by a link to ar.) +# Alternatively, you can install ranlib.sh as ranlib. +# ar_with_ranlib: $(ADDL_DEPS) ar.o maybe-ranlib.o +# $(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $(AR_PROG) ar.o maybe-ranlib.o $(ADDL_LIBS) $(EXTRALIBS) +# -rm -f $(RANLIB_PROG) +# -ln $(AR_PROG) $(RANLIB_PROG) +# +# objcopy and strip in one binary that uses argv[0] to decide its action. +# +#objcopy_with_strip: $(ADDL_DEPS) objcopy.o maybe-strip.o +# $(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $(OBJCOPY_PROG) objcopy.o maybe-strip.o $(ADDL_LIBS) $(EXTRALIBS) +# -rm -f $(STRIP_PROG) +# -ln $(OBJCOPY_PROG) $(STRIP_PROG) + +sysroff.c: sysinfo$(EXEEXT_FOR_BUILD) sysroff.info + ./sysinfo$(EXEEXT_FOR_BUILD) -c <$(srcdir)/sysroff.info >sysroff.c + ./sysinfo$(EXEEXT_FOR_BUILD) -i <$(srcdir)/sysroff.info >>sysroff.c + ./sysinfo$(EXEEXT_FOR_BUILD) -g <$(srcdir)/sysroff.info >>sysroff.c + +sysroff.h: sysinfo$(EXEEXT_FOR_BUILD) sysroff.info + ./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h + +sysinfo$(EXEEXT_FOR_BUILD): sysinfo.@OBJEXT@ syslex_wrap.@OBJEXT@ + $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.@OBJEXT@ syslex_wrap.@OBJEXT@ + +syslex_wrap.@OBJEXT@: syslex_wrap.c syslex.c sysinfo.h config.h + $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex_wrap.c + +sysinfo.@OBJEXT@: sysinfo.c + if [ -r sysinfo.c ]; then \ + $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \ + else \ + $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \ + fi + +bin2c$(EXEEXT_FOR_BUILD): bin2c.c + $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c + +embedspu: embedspu.sh Makefile + awk '/^program_transform_name=/ {print "program_transform_name=\"$(program_transform_name)\""; next} {print}' < $< > $@ + chmod a+x $@ + +# We need these for parallel make. +sysinfo.h: sysinfo.c + +# Disable -Werror, if it has been enabled, since old versions of bison/ +# yacc will produce working code which contain compile time warnings. +arparse.@OBJEXT@: arparse.c +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f arparse.c || echo $(srcdir)/`arparse.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='arparse.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c `test -f arparse.c || echo $(srcdir)/`arparse.c $(NO_WERROR) +endif + +arlex.@OBJEXT@: arlex.c +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f arlex.c || echo $(srcdir)/`arlex.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='arlex.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c `test -f arlex.c || echo $(srcdir)/`arlex.c $(NO_WERROR) +endif + +sysroff.@OBJEXT@: sysroff.c +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f sysroff.c || echo $(srcdir)/`sysroff.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='sysroff.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c `test -f sysroff.c || echo $(srcdir)/`sysroff.c $(NO_WERROR) +endif + +defparse.@OBJEXT@: defparse.c +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f defparse.c || echo $(srcdir)/`defparse.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='defparse.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c `test -f defparse.c || echo $(srcdir)/`defparse.c $(NO_WERROR) +endif + +deflex.@OBJEXT@: deflex.c +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f deflex.c || echo $(srcdir)/`deflex.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='deflex.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c `test -f deflex.c || echo $(srcdir)/`deflex.c $(NO_WERROR) +endif + +nlmheader.@OBJEXT@: nlmheader.c +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f nlmheader.c || echo $(srcdir)/`nlmheader.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='nlmheader.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c `test -f nlmheader.c || echo $(srcdir)/`nlmheader.c $(NO_WERROR) +endif + +rcparse.@OBJEXT@: rcparse.c +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f rcparse.c || echo $(srcdir)/`rcparse.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='rcparse.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c `test -f rcparse.c || echo $(srcdir)/`rcparse.c $(NO_WERROR) +endif + +mcparse.@OBJEXT@: mcparse.c +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f mcparse.c || echo $(srcdir)/`mcparse.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='mcparse.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c `test -f mcparse.c || echo $(srcdir)/`mcparse.c $(NO_WERROR) +endif + +rclex.@OBJEXT@: rclex.c +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(srcdir)/rclex.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='rclex.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c $(srcdir)/rclex.c $(NO_WERROR) +endif + +mclex.@OBJEXT@: mclex.c +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(srcdir)/mclex.c $(NO_WERROR) + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='mclex.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c $(srcdir)/mclex.c $(NO_WERROR) +endif + +srconv_SOURCES = srconv.c coffgrok.c $(BULIBS) +srconv.@OBJEXT@: sysroff.c + +dlltool_SOURCES = dlltool.c defparse.y deflex.l $(BULIBS) +dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) + +dlltool.@OBJEXT@: +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(DLLTOOL_DEFS) $(srcdir)/dlltool.c + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='dlltool.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c $(DLLTOOL_DEFS) $(srcdir)/dlltool.c +endif + +rescoff.@OBJEXT@: +if am__fastdepCC + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(DLLTOOL_DEFS) $(srcdir)/rescoff.c + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='rescoff.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + $(COMPILE) -c $(DLLTOOL_DEFS) $(srcdir)/rescoff.c +endif + +coffdump_SOURCES = coffdump.c coffgrok.c $(BULIBS) + +sysdump_SOURCES = sysdump.c $(BULIBS) +sysdump.@OBJEXT@: sysroff.c + +# coff/sym.h and coff/ecoff.h won't be found by the automatic dependency +# scripts, since they are only included conditionally. +nlmconv.@OBJEXT@: nlmconv.c +if am__fastdepCC + ldname=`echo ld | sed '$(transform)'`; \ + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ \ + -DLD_NAME="\"$${ldname}\"" @NLMCONV_DEFS@ $(srcdir)/nlmconv.c + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +else +if AMDEP + source='nlmconv.c' object='$@' libtool=no @AMDEPBACKSLASH@ + DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +endif + ldname=`echo ld | sed '$(transform)'`; \ + $(COMPILE) -c -DLD_NAME="\"$${ldname}\"" @NLMCONV_DEFS@ $(srcdir)/nlmconv.c +endif + +nlmconv_SOURCES = nlmconv.c nlmheader.y $(BULIBS) + +windres_SOURCES = windres.c resrc.c rescoff.c resbin.c rcparse.y rclex.c \ + winduni.c resres.c $(BULIBS) +windres_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) + +windmc_SOURCES = windmc.c mcparse.y mclex.c \ + winduni.c $(BULIBS) +windmc_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) + +dllwrap_SOURCES = dllwrap.c version.c +dllwrap_LDADD = $(LIBIBERTY) $(LIBINTL) + + +EXTRA_DIST = arparse.c arparse.h arlex.c nlmheader.c sysinfo.c sysinfo.h \ + syslex.c deflex.c defparse.h defparse.c rcparse.h rcparse.c \ + mcparse.h mcparse.c embedspu.sh + +diststuff: $(EXTRA_DIST) info +all: info + +# development.sh is used to determine -Werror default. +CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh + +DISTCLEANFILES = sysroff.c sysroff.h site.exp site.bak embedspu + +MOSTLYCLEANFILES = sysinfo$(EXEEXT_FOR_BUILD) bin2c$(EXEEXT_FOR_BUILD) \ + binutils.log binutils.sum abcdefgh* +mostlyclean-local: + -rm -rf tmpdir + +.PHONY: install-exec-local + +install-exec-local: install-binPROGRAMS $(bin_PROGRAMS) $(noinst_PROGRAMS) + @list='$(RENAMED_PROGS)'; for p in $$list; do \ + if test -f $$p$(EXEEXT); then \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p$(EXEEXT) $(bindir)/`echo $$p|sed -e 's/-new//' -e 's/cxxfilt/$(DEMANGLER_NAME)/'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p$(EXEEXT) $(DESTDIR)$(bindir)/`echo $$p|sed -e 's/-new//' -e 's/cxxfilt/$(DEMANGLER_NAME)/'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + $(mkinstalldirs) $(DESTDIR)$(tooldir)/bin + for i in $(TOOL_PROGS); do \ + if [ -f $$i$(EXEEXT) ]; then \ + j=`echo $$i | sed -e 's/-new//'`; \ + k=`echo $$j | sed '$(transform)'`; \ + if [ "$(bindir)/$$k" != "$(tooldir)/bin/$$j" ]; then \ + rm -f $(DESTDIR)$(tooldir)/bin/$$j$(EXEEXT); \ + ln $(DESTDIR)$(bindir)/$$k$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$$j$(EXEEXT) >/dev/null 2>/dev/null \ + || $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$i$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$$j$(EXEEXT); \ + fi; \ + else true; \ + fi; \ + done diff --git a/support/sdbinutils/binutils/Makefile.in b/support/sdbinutils/binutils/Makefile.in new file mode 100644 index 0000000..f427d86 --- /dev/null +++ b/support/sdbinutils/binutils/Makefile.in @@ -0,0 +1,1520 @@ +# Makefile.in generated by automake 1.11.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# +# Copyright (C) 2012-2018 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . +# + + +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +bin_PROGRAMS = $(am__EXEEXT_8) \ + $(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_15) +noinst_PROGRAMS = $(am__EXEEXT_18) $(am__EXEEXT_21) @BUILD_MISC@ +EXTRA_PROGRAMS = $(am__EXEEXT_1) srconv$(EXEEXT) sysdump$(EXEEXT) \ + coffdump$(EXEEXT) $(am__EXEEXT_2) $(am__EXEEXT_3) \ + $(am__EXEEXT_4) $(am__EXEEXT_5) +subdir = . +DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \ + $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(srcdir)/config.in \ + $(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in arparse.h \ + arparse.c arlex.c defparse.h defparse.c deflex.c nlmheader.h \ + nlmheader.c arparse.h arparse.c arlex.c mcparse.h mcparse.c \ + rcparse.h rcparse.c $(srcdir)/../depcomp $(srcdir)/../ylwrap +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \ + $(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/gettext-sister.m4 \ + $(top_srcdir)/../config/iconv.m4 \ + $(top_srcdir)/../config/largefile.m4 \ + $(top_srcdir)/../config/lcmessage.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/lib-ld.m4 \ + $(top_srcdir)/../config/lib-link.m4 \ + $(top_srcdir)/../config/lib-prefix.m4 \ + $(top_srcdir)/../config/nls.m4 \ + $(top_srcdir)/../config/override.m4 \ + $(top_srcdir)/../config/plugins.m4 \ + $(top_srcdir)/../config/po.m4 \ + $(top_srcdir)/../config/progtest.m4 \ + $(top_srcdir)/../config/zlib.m4 $(top_srcdir)/../libtool.m4 \ + $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ + $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ + $(top_srcdir)/../bfd/version.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = po/Makefile.in +CONFIG_CLEAN_VPATH_FILES = +am__EXEEXT_1 = nlmconv$(EXEEXT) +am__EXEEXT_2 = dlltool$(EXEEXT) +am__EXEEXT_3 = windres$(EXEEXT) +am__EXEEXT_4 = windmc$(EXEEXT) +am__EXEEXT_5 = dllwrap$(EXEEXT) +am__EXEEXT_6 = size$(EXEEXT) +am__EXEEXT_7 = objdump$(EXEEXT) +am__EXEEXT_8 = sdar$(EXEEXT) +am__EXEEXT_9 = strings$(EXEEXT) +am__EXEEXT_10 = sdranlib$(EXEEXT) +am__EXEEXT_11 = sdobjcopy$(EXEEXT) +am__EXEEXT_12 = addr2line$(EXEEXT) +am__EXEEXT_13 = readelf$(EXEEXT) +am__EXEEXT_14 = elfedit$(EXEEXT) +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" +am__EXEEXT_15 = sdnm$(EXEEXT) +am__EXEEXT_16 = strip-new$(EXEEXT) +am__EXEEXT_17 = cxxfilt$(EXEEXT) +am__EXEEXT_18 = $(am__EXEEXT_15) $(am__EXEEXT_16) $(am__EXEEXT_17) +am__EXEEXT_19 = bfdtest1$(EXEEXT) +am__EXEEXT_20 = bfdtest2$(EXEEXT) +am__EXEEXT_21 = $(am__EXEEXT_19) $(am__EXEEXT_20) +PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) +am__objects_1 = bucomm.$(OBJEXT) version.$(OBJEXT) filemode.$(OBJEXT) +am_addr2line_OBJECTS = addr2line.$(OBJEXT) $(am__objects_1) +addr2line_OBJECTS = $(am_addr2line_OBJECTS) +addr2line_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +am_ar_OBJECTS = arparse.$(OBJEXT) arlex.$(OBJEXT) ar.$(OBJEXT) \ + not-ranlib.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) \ + binemul.$(OBJEXT) emul_$(EMULATION).$(OBJEXT) $(am__objects_1) +ar_OBJECTS = $(am_ar_OBJECTS) +bfdtest1_SOURCES = bfdtest1.c +bfdtest1_OBJECTS = bfdtest1.$(OBJEXT) +bfdtest1_LDADD = $(LDADD) +bfdtest2_SOURCES = bfdtest2.c +bfdtest2_OBJECTS = bfdtest2.$(OBJEXT) +bfdtest2_LDADD = $(LDADD) +am_coffdump_OBJECTS = coffdump.$(OBJEXT) coffgrok.$(OBJEXT) \ + $(am__objects_1) +coffdump_OBJECTS = $(am_coffdump_OBJECTS) +coffdump_LDADD = $(LDADD) +am_cxxfilt_OBJECTS = cxxfilt.$(OBJEXT) $(am__objects_1) +cxxfilt_OBJECTS = $(am_cxxfilt_OBJECTS) +cxxfilt_LDADD = $(LDADD) +am_dlltool_OBJECTS = dlltool.$(OBJEXT) defparse.$(OBJEXT) \ + deflex.$(OBJEXT) $(am__objects_1) +dlltool_OBJECTS = $(am_dlltool_OBJECTS) +am_dllwrap_OBJECTS = dllwrap.$(OBJEXT) version.$(OBJEXT) +dllwrap_OBJECTS = $(am_dllwrap_OBJECTS) +am__objects_2 = elfcomm.$(OBJEXT) +am_elfedit_OBJECTS = elfedit.$(OBJEXT) version.$(OBJEXT) \ + $(am__objects_2) +elfedit_OBJECTS = $(am_elfedit_OBJECTS) +am_nlmconv_OBJECTS = nlmconv.$(OBJEXT) nlmheader.$(OBJEXT) \ + $(am__objects_1) +nlmconv_OBJECTS = $(am_nlmconv_OBJECTS) +nlmconv_LDADD = $(LDADD) +am_nm_new_OBJECTS = nm.$(OBJEXT) $(am__objects_1) +nm_new_OBJECTS = $(am_nm_new_OBJECTS) +nm_new_LDADD = $(LDADD) +am__objects_3 = rddbg.$(OBJEXT) debug.$(OBJEXT) stabs.$(OBJEXT) \ + ieee.$(OBJEXT) rdcoff.$(OBJEXT) +am__objects_4 = $(am__objects_3) wrstabs.$(OBJEXT) +am_objcopy_OBJECTS = objcopy.$(OBJEXT) not-strip.$(OBJEXT) \ + rename.$(OBJEXT) $(am__objects_4) $(am__objects_1) +objcopy_OBJECTS = $(am_objcopy_OBJECTS) +objcopy_LDADD = $(LDADD) +am_objdump_OBJECTS = objdump.$(OBJEXT) dwarf.$(OBJEXT) prdbg.$(OBJEXT) \ + $(am__objects_3) $(am__objects_1) $(am__objects_2) +objdump_OBJECTS = $(am_objdump_OBJECTS) +am_ranlib_OBJECTS = ar.$(OBJEXT) is-ranlib.$(OBJEXT) arparse.$(OBJEXT) \ + arlex.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) \ + binemul.$(OBJEXT) emul_$(EMULATION).$(OBJEXT) $(am__objects_1) +ranlib_OBJECTS = $(am_ranlib_OBJECTS) +am_readelf_OBJECTS = readelf.$(OBJEXT) version.$(OBJEXT) \ + unwind-ia64.$(OBJEXT) dwarf.$(OBJEXT) $(am__objects_2) +readelf_OBJECTS = $(am_readelf_OBJECTS) +am_size_OBJECTS = size.$(OBJEXT) $(am__objects_1) +size_OBJECTS = $(am_size_OBJECTS) +size_LDADD = $(LDADD) +am_srconv_OBJECTS = srconv.$(OBJEXT) coffgrok.$(OBJEXT) \ + $(am__objects_1) +srconv_OBJECTS = $(am_srconv_OBJECTS) +srconv_LDADD = $(LDADD) +am_strings_OBJECTS = strings.$(OBJEXT) $(am__objects_1) +strings_OBJECTS = $(am_strings_OBJECTS) +strings_LDADD = $(LDADD) +am_strip_new_OBJECTS = objcopy.$(OBJEXT) is-strip.$(OBJEXT) \ + rename.$(OBJEXT) $(am__objects_4) $(am__objects_1) +strip_new_OBJECTS = $(am_strip_new_OBJECTS) +strip_new_LDADD = $(LDADD) +am_sysdump_OBJECTS = sysdump.$(OBJEXT) $(am__objects_1) +sysdump_OBJECTS = $(am_sysdump_OBJECTS) +sysdump_LDADD = $(LDADD) +am_windmc_OBJECTS = windmc.$(OBJEXT) mcparse.$(OBJEXT) mclex.$(OBJEXT) \ + winduni.$(OBJEXT) $(am__objects_1) +windmc_OBJECTS = $(am_windmc_OBJECTS) +am_windres_OBJECTS = windres.$(OBJEXT) resrc.$(OBJEXT) \ + rescoff.$(OBJEXT) resbin.$(OBJEXT) rcparse.$(OBJEXT) \ + rclex.$(OBJEXT) winduni.$(OBJEXT) resres.$(OBJEXT) \ + $(am__objects_1) +windres_OBJECTS = $(am_windres_OBJECTS) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +SCRIPTS = $(bin_SCRIPTS) +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/../depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +@MAINTAINER_MODE_FALSE@am__skiplex = test -f $@ || +LEXCOMPILE = $(LEX) $(AM_LFLAGS) $(LFLAGS) +LTLEXCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(LEX) $(AM_LFLAGS) $(LFLAGS) +YLWRAP = $(top_srcdir)/../ylwrap +@MAINTAINER_MODE_FALSE@am__skipyacc = test -f $@ || +YACCCOMPILE = $(YACC) $(AM_YFLAGS) $(YFLAGS) +LTYACCCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(YACC) $(AM_YFLAGS) $(YFLAGS) +SOURCES = $(addr2line_SOURCES) $(ar_SOURCES) $(EXTRA_ar_SOURCES) \ + bfdtest1.c bfdtest2.c $(coffdump_SOURCES) $(cxxfilt_SOURCES) \ + $(dlltool_SOURCES) $(dllwrap_SOURCES) $(elfedit_SOURCES) \ + $(nlmconv_SOURCES) $(nm_new_SOURCES) $(objcopy_SOURCES) \ + $(objdump_SOURCES) $(EXTRA_objdump_SOURCES) $(ranlib_SOURCES) \ + $(readelf_SOURCES) $(size_SOURCES) $(srconv_SOURCES) \ + $(strings_SOURCES) $(strip_new_SOURCES) $(sysdump_SOURCES) \ + $(windmc_SOURCES) $(windres_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS +ETAGS = etags +CTAGS = ctags +DEJATOOL = $(PACKAGE) +RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir +DIST_SUBDIRS = $(SUBDIRS) +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_DLLTOOL = @BUILD_DLLTOOL@ +BUILD_DLLWRAP = @BUILD_DLLWRAP@ +BUILD_INSTALL_MISC = @BUILD_INSTALL_MISC@ +BUILD_MISC = @BUILD_MISC@ +BUILD_NLMCONV = @BUILD_NLMCONV@ +BUILD_SRCONV = @BUILD_SRCONV@ +BUILD_WINDMC = @BUILD_WINDMC@ +BUILD_WINDRES = @BUILD_WINDRES@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CC_FOR_BUILD = @CC_FOR_BUILD@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DEFS = @DEFS@ +DEMANGLER_NAME = @DEMANGLER_NAME@ +DEPDIR = @DEPDIR@ +DLLTOOL_DEFS = @DLLTOOL_DEFS@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EMULATION = @EMULATION@ +EMULATION_VECTOR = @EMULATION_VECTOR@ +EXEEXT = @EXEEXT@ +EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@ +FGREP = @FGREP@ +GENCAT = @GENCAT@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +HDEFINES = @HDEFINES@ +INCINTL = @INCINTL@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = `if [ -f ../flex/flex ]; then echo ../flex/flex; else echo @LEX@; fi` +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBINTL_DEP = @LIBINTL_DEP@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NLMCONV_DEFS = @NLMCONV_DEFS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NO_WERROR = @NO_WERROR@ +OBJDUMP = @OBJDUMP@ +OBJDUMP_DEFS = @OBJDUMP_DEFS@ + +# Extra object files for objdump +OBJDUMP_PRIVATE_OFILES = @OBJDUMP_PRIVATE_OFILES@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@ +WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@ +XGETTEXT = @XGETTEXT@ +YACC = `if [ -f ../bison/bison ]; then echo ../bison/bison -y -L$(srcdir)/../bison/; else echo @YACC@; fi` +YFLAGS = -d +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +zlibdir = @zlibdir@ +zlibinc = @zlibinc@ +AUTOMAKE_OPTIONS = dejagnu no-dist foreign +ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd +SUBDIRS = +tooldir = $(exec_prefix)/$(target_alias) + +# Automake 1.10+ disables lex and yacc output file regeneration if +# maintainer mode is disabled. Avoid this. +am__skiplex = +am__skipyacc = + +# This is where we get zlib from. zlibdir is -L../zlib and zlibinc is +# -I../zlib, unless we were configured with --with-system-zlib, in which +# case both are empty. +ZLIB = @zlibdir@ -lz +ZLIBINC = @zlibinc@ +AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC) +AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD) $(ZLIBINC) + +# these two are almost the same program +AR_PROG = sdar +RANLIB_PROG = sdranlib + +# objcopy and strip should be the same program +OBJCOPY_PROG = sdobjcopy +STRIP_PROG = strip-new +STRINGS_PROG = strings +READELF_PROG = readelf +ELFEDIT_PROG = elfedit + +# These should all be the same program too. +SIZE_PROG = size +NM_PROG = sdnm +OBJDUMP_PROG = objdump + +# This is the demangler, as a standalone program. +# Note: This one is used as the installed name too, unlike the above. +DEMANGLER_PROG = cxxfilt +ADDR2LINE_PROG = addr2line +NLMCONV_PROG = nlmconv +DLLTOOL_PROG = dlltool +WINDRES_PROG = windres +WINDMC_PROG = windmc +DLLWRAP_PROG = dllwrap +SRCONV_PROG = srconv$(EXEEXT) sysdump$(EXEEXT) coffdump$(EXEEXT) +bin_SCRIPTS = @BUILD_INSTALL_MISC@ +EXTRA_SCRIPTS = embedspu +BFDTEST1_PROG = bfdtest1 +BFDTEST2_PROG = bfdtest2 +TEST_PROGS = $(BFDTEST1_PROG) $(BFDTEST2_PROG) +RENAMED_PROGS = $(NM_PROG) + +# Stuff that goes in tooldir/ if appropriate. +TOOL_PROGS = sdnm sdar sdranlib sdobjcopy +BASEDIR = $(srcdir)/.. +BFDDIR = $(BASEDIR)/bfd +INCDIR = $(BASEDIR)/include +AM_CPPFLAGS = -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) \ + @HDEFINES@ \ + @INCINTL@ \ + -DLOCALEDIR="\"$(datadir)/locale\"" \ + -Dbin_dummy_emulation=$(EMULATION_VECTOR) + +HFILES = \ + arsup.h binemul.h bucomm.h budbg.h \ + coffgrok.h debug.h dlltool.h dwarf.h elfcomm.h nlmconv.h \ + objdump.h sysdep.h unwind-ia64.h windres.h winduni.h windint.h \ + windmc.h + +GENERATED_HFILES = arparse.h sysroff.h sysinfo.h defparse.h rcparse.h mcparse.h +BUILT_SOURCES = $(GENERATED_HFILES) +CFILES = \ + addr2line.c ar.c arsup.c bin2c.c binemul.c bucomm.c \ + coffdump.c coffgrok.c cxxfilt.c \ + dwarf.c debug.c dlltool.c dllwrap.c \ + elfcomm.c emul_aix.c emul_vanilla.c filemode.c \ + ieee.c is-ranlib.c is-strip.c maybe-ranlib.c maybe-strip.c \ + nlmconv.c nm.c not-ranlib.c not-strip.c \ + objcopy.c objdump.c prdbg.c \ + od-xcoff.c od-macho.c \ + rclex.c rdcoff.c rddbg.c readelf.c rename.c \ + resbin.c rescoff.c resrc.c resres.c \ + size.c srconv.c stabs.c strings.c sysdump.c \ + syslex_wrap.c unwind-ia64.c elfedit.c version.c \ + windres.c winduni.c wrstabs.c \ + windmc.c mclex.c + +GENERATED_CFILES = \ + arparse.c arlex.c sysroff.c sysinfo.c syslex.c \ + defparse.c deflex.c nlmheader.c rcparse.c mcparse.c + +DEBUG_SRCS = rddbg.c debug.c stabs.c ieee.c rdcoff.c +WRITE_DEBUG_SRCS = $(DEBUG_SRCS) wrstabs.c + +# Code shared by all the binutils. +BULIBS = bucomm.c version.c filemode.c + +# Code shared by the ELF related programs. +ELFLIBS = elfcomm.c +BFDLIB = ../bfd/libbfd.la +OPCODES = ../opcodes/libopcodes.la +LIBIBERTY = ../libiberty/libiberty.a +POTFILES = $(CFILES) $(DEBUG_SRCS) $(HFILES) +EXPECT = expect +RUNTEST = runtest +CC_FOR_TARGET = ` \ + if [ -f $$r/../gcc/xgcc ] ; then \ + if [ -f $$r/../newlib/Makefile ] ; then \ + echo $$r/../gcc/xgcc -B$$r/../gcc/ -idirafter $$r/../newlib/targ-include -idirafter $${srcroot}/../newlib/libc/include -nostdinc; \ + else \ + echo $$r/../gcc/xgcc -B$$r/../gcc/; \ + fi; \ + else \ + if [ "@host@" = "@target@" ] ; then \ + echo $(CC); \ + else \ + echo gcc | sed '$(transform)'; \ + fi; \ + fi` + + +# There's no global DEPENDENCIES. So, we must explicitly list everything +# which depends on libintl, since we don't know whether LIBINTL_DEP will be +# non-empty until configure time. Ugh! +size_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +objdump_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) $(OPCODES) $(OBJDUMP_PRIVATE_OFILES) +nm_new_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +ar_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +strings_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +strip_new_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +ranlib_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +cxxfilt_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +objcopy_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +nlmconv_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +srconv_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +sysdump_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +coffdump_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +dlltool_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +windres_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +windmc_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +addr2line_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +readelf_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) +elfedit_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) +dllwrap_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) +bfdtest1_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +bfdtest2_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) +LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) +size_SOURCES = size.c $(BULIBS) +objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) +strings_SOURCES = strings.c $(BULIBS) +readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c $(ELFLIBS) +readelf_LDADD = $(LIBINTL) $(LIBIBERTY) $(ZLIB) +elfedit_SOURCES = elfedit.c version.c $(ELFLIBS) +elfedit_LDADD = $(LIBINTL) $(LIBIBERTY) +strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) +nm_new_SOURCES = nm.c $(BULIBS) +objdump_SOURCES = objdump.c dwarf.c prdbg.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS) +EXTRA_objdump_SOURCES = od-xcoff.c +objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) +cxxfilt_SOURCES = cxxfilt.c $(BULIBS) +ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c binemul.c \ + emul_$(EMULATION).c $(BULIBS) + +EXTRA_ar_SOURCES = $(CFILES) +ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) +ranlib_SOURCES = ar.c is-ranlib.c arparse.y arlex.l arsup.c rename.c \ + binemul.c emul_$(EMULATION).c $(BULIBS) + +ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) +addr2line_SOURCES = addr2line.c $(BULIBS) +srconv_SOURCES = srconv.c coffgrok.c $(BULIBS) +dlltool_SOURCES = dlltool.c defparse.y deflex.l $(BULIBS) +dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) +coffdump_SOURCES = coffdump.c coffgrok.c $(BULIBS) +sysdump_SOURCES = sysdump.c $(BULIBS) +nlmconv_SOURCES = nlmconv.c nlmheader.y $(BULIBS) +windres_SOURCES = windres.c resrc.c rescoff.c resbin.c rcparse.y rclex.c \ + winduni.c resres.c $(BULIBS) + +windres_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) +windmc_SOURCES = windmc.c mcparse.y mclex.c \ + winduni.c $(BULIBS) + +windmc_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) +dllwrap_SOURCES = dllwrap.c version.c +dllwrap_LDADD = $(LIBIBERTY) $(LIBINTL) +EXTRA_DIST = arparse.c arparse.h arlex.c nlmheader.c sysinfo.c sysinfo.h \ + syslex.c deflex.c defparse.h defparse.c rcparse.h rcparse.c \ + mcparse.h mcparse.c embedspu.sh + + +# development.sh is used to determine -Werror default. +CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh +DISTCLEANFILES = sysroff.c sysroff.h site.exp site.bak embedspu +MOSTLYCLEANFILES = sysinfo$(EXEEXT_FOR_BUILD) bin2c$(EXEEXT_FOR_BUILD) \ + binutils.log binutils.sum abcdefgh* + +all: $(BUILT_SOURCES) config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .c .l .lo .o .obj .y +am--refresh: Makefile + @: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): + +config.h: stamp-h1 + @if test ! -f $@; then rm -f stamp-h1; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi + +stamp-h1: $(srcdir)/config.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +po/Makefile.in: $(top_builddir)/config.status $(top_srcdir)/po/Make-in + cd $(top_builddir) && $(SHELL) ./config.status $@ +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +addr2line$(EXEEXT): $(addr2line_OBJECTS) $(addr2line_DEPENDENCIES) $(EXTRA_addr2line_DEPENDENCIES) + @rm -f addr2line$(EXEEXT) + $(LINK) $(addr2line_OBJECTS) $(addr2line_LDADD) $(LIBS) +arparse.h: arparse.c + @if test ! -f $@; then rm -f arparse.c; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) arparse.c; else :; fi +sdar$(EXEEXT): $(ar_OBJECTS) $(ar_DEPENDENCIES) $(EXTRA_ar_DEPENDENCIES) + @rm -f ar$(EXEEXT) + $(LINK) $(ar_OBJECTS) $(ar_LDADD) $(LIBS) +bfdtest1$(EXEEXT): $(bfdtest1_OBJECTS) $(bfdtest1_DEPENDENCIES) $(EXTRA_bfdtest1_DEPENDENCIES) + @rm -f bfdtest1$(EXEEXT) + $(LINK) $(bfdtest1_OBJECTS) $(bfdtest1_LDADD) $(LIBS) +bfdtest2$(EXEEXT): $(bfdtest2_OBJECTS) $(bfdtest2_DEPENDENCIES) $(EXTRA_bfdtest2_DEPENDENCIES) + @rm -f bfdtest2$(EXEEXT) + $(LINK) $(bfdtest2_OBJECTS) $(bfdtest2_LDADD) $(LIBS) +coffdump$(EXEEXT): $(coffdump_OBJECTS) $(coffdump_DEPENDENCIES) $(EXTRA_coffdump_DEPENDENCIES) + @rm -f coffdump$(EXEEXT) + $(LINK) $(coffdump_OBJECTS) $(coffdump_LDADD) $(LIBS) +cxxfilt$(EXEEXT): $(cxxfilt_OBJECTS) $(cxxfilt_DEPENDENCIES) $(EXTRA_cxxfilt_DEPENDENCIES) + @rm -f cxxfilt$(EXEEXT) + $(LINK) $(cxxfilt_OBJECTS) $(cxxfilt_LDADD) $(LIBS) +defparse.h: defparse.c + @if test ! -f $@; then rm -f defparse.c; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) defparse.c; else :; fi +dlltool$(EXEEXT): $(dlltool_OBJECTS) $(dlltool_DEPENDENCIES) $(EXTRA_dlltool_DEPENDENCIES) + @rm -f dlltool$(EXEEXT) + $(LINK) $(dlltool_OBJECTS) $(dlltool_LDADD) $(LIBS) +dllwrap$(EXEEXT): $(dllwrap_OBJECTS) $(dllwrap_DEPENDENCIES) $(EXTRA_dllwrap_DEPENDENCIES) + @rm -f dllwrap$(EXEEXT) + $(LINK) $(dllwrap_OBJECTS) $(dllwrap_LDADD) $(LIBS) +elfedit$(EXEEXT): $(elfedit_OBJECTS) $(elfedit_DEPENDENCIES) $(EXTRA_elfedit_DEPENDENCIES) + @rm -f elfedit$(EXEEXT) + $(LINK) $(elfedit_OBJECTS) $(elfedit_LDADD) $(LIBS) +nlmheader.h: nlmheader.c + @if test ! -f $@; then rm -f nlmheader.c; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) nlmheader.c; else :; fi +nlmconv$(EXEEXT): $(nlmconv_OBJECTS) $(nlmconv_DEPENDENCIES) $(EXTRA_nlmconv_DEPENDENCIES) + @rm -f nlmconv$(EXEEXT) + $(LINK) $(nlmconv_OBJECTS) $(nlmconv_LDADD) $(LIBS) +sdnm$(EXEEXT): $(nm_new_OBJECTS) $(nm_new_DEPENDENCIES) $(EXTRA_nm_new_DEPENDENCIES) + @rm -f nm-new$(EXEEXT) + $(LINK) $(nm_new_OBJECTS) $(nm_new_LDADD) $(LIBS) +sdobjcopy$(EXEEXT): $(objcopy_OBJECTS) $(objcopy_DEPENDENCIES) $(EXTRA_objcopy_DEPENDENCIES) + @rm -f objcopy$(EXEEXT) + $(LINK) $(objcopy_OBJECTS) $(objcopy_LDADD) $(LIBS) +objdump$(EXEEXT): $(objdump_OBJECTS) $(objdump_DEPENDENCIES) $(EXTRA_objdump_DEPENDENCIES) + @rm -f objdump$(EXEEXT) + $(LINK) $(objdump_OBJECTS) $(objdump_LDADD) $(LIBS) +sdranlib$(EXEEXT): $(ranlib_OBJECTS) $(ranlib_DEPENDENCIES) $(EXTRA_ranlib_DEPENDENCIES) + @rm -f ranlib$(EXEEXT) + $(LINK) $(ranlib_OBJECTS) $(ranlib_LDADD) $(LIBS) +readelf$(EXEEXT): $(readelf_OBJECTS) $(readelf_DEPENDENCIES) $(EXTRA_readelf_DEPENDENCIES) + @rm -f readelf$(EXEEXT) + $(LINK) $(readelf_OBJECTS) $(readelf_LDADD) $(LIBS) +size$(EXEEXT): $(size_OBJECTS) $(size_DEPENDENCIES) $(EXTRA_size_DEPENDENCIES) + @rm -f size$(EXEEXT) + $(LINK) $(size_OBJECTS) $(size_LDADD) $(LIBS) +srconv$(EXEEXT): $(srconv_OBJECTS) $(srconv_DEPENDENCIES) $(EXTRA_srconv_DEPENDENCIES) + @rm -f srconv$(EXEEXT) + $(LINK) $(srconv_OBJECTS) $(srconv_LDADD) $(LIBS) +strings$(EXEEXT): $(strings_OBJECTS) $(strings_DEPENDENCIES) $(EXTRA_strings_DEPENDENCIES) + @rm -f strings$(EXEEXT) + $(LINK) $(strings_OBJECTS) $(strings_LDADD) $(LIBS) +strip-new$(EXEEXT): $(strip_new_OBJECTS) $(strip_new_DEPENDENCIES) $(EXTRA_strip_new_DEPENDENCIES) + @rm -f strip-new$(EXEEXT) + $(LINK) $(strip_new_OBJECTS) $(strip_new_LDADD) $(LIBS) +sysdump$(EXEEXT): $(sysdump_OBJECTS) $(sysdump_DEPENDENCIES) $(EXTRA_sysdump_DEPENDENCIES) + @rm -f sysdump$(EXEEXT) + $(LINK) $(sysdump_OBJECTS) $(sysdump_LDADD) $(LIBS) +mcparse.h: mcparse.c + @if test ! -f $@; then rm -f mcparse.c; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) mcparse.c; else :; fi +windmc$(EXEEXT): $(windmc_OBJECTS) $(windmc_DEPENDENCIES) $(EXTRA_windmc_DEPENDENCIES) + @rm -f windmc$(EXEEXT) + $(LINK) $(windmc_OBJECTS) $(windmc_LDADD) $(LIBS) +rcparse.h: rcparse.c + @if test ! -f $@; then rm -f rcparse.c; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) rcparse.c; else :; fi +windres$(EXEEXT): $(windres_OBJECTS) $(windres_DEPENDENCIES) $(EXTRA_windres_DEPENDENCIES) + @rm -f windres$(EXEEXT) + $(LINK) $(windres_OBJECTS) $(windres_LDADD) $(LIBS) +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/addr2line.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ar.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arlex.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arparse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arsup.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bfdtest1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bfdtest2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bin2c.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/binemul.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bucomm.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coffdump.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coffgrok.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cxxfilt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/deflex.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/defparse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlltool.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dllwrap.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfcomm.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfedit.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emul_$(EMULATION).Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emul_aix.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emul_vanilla.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filemode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ieee.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is-ranlib.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is-strip.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/maybe-ranlib.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/maybe-strip.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mclex.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mcparse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nlmconv.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nlmheader.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/not-ranlib.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/not-strip.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/objcopy.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/objdump.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/od-macho.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/od-xcoff.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prdbg.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rclex.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rcparse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rdcoff.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rddbg.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readelf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rename.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resbin.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rescoff.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resrc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resres.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/size.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/srconv.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stabs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strings.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysdump.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syslex_wrap.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unwind-ia64.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/windmc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/windres.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/winduni.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wrstabs.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +.l.c: + $(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE) + +.y.c: + $(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE) + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool config.lt + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) config.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) config.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG) + @echo 'Making a new site.exp file...' + @echo '## these variables are automatically generated by make ##' >site.tmp + @echo '# Do not edit here. If you wish to override these values' >>site.tmp + @echo '# edit the last section' >>site.tmp + @echo 'set srcdir "$(srcdir)"' >>site.tmp + @echo "set objdir `pwd`" >>site.tmp + @echo 'set build_alias "$(build_alias)"' >>site.tmp + @echo 'set build_triplet $(build_triplet)' >>site.tmp + @echo 'set host_alias "$(host_alias)"' >>site.tmp + @echo 'set host_triplet $(host_triplet)' >>site.tmp + @echo 'set target_alias "$(target_alias)"' >>site.tmp + @echo 'set target_triplet $(target_triplet)' >>site.tmp + @list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \ + echo "## Begin content included from file $$f. Do not modify. ##" \ + && cat `test -f "$$f" || echo '$(srcdir)/'`$$f \ + && echo "## End content included from file $$f. ##" \ + || exit 1; \ + done >> site.tmp + @echo "## End of auto-generated content; you can edit from here. ##" >> site.tmp + @if test -f site.exp; then \ + sed -e '1,/^## End of auto-generated content.*##/d' site.exp >> site.tmp; \ + fi + @-rm -f site.bak + @test ! -f site.exp || mv site.exp site.bak + @mv site.tmp site.exp + +distclean-DEJAGNU: + -rm -f site.exp site.bak + -l='$(DEJATOOL)'; for tool in $$l; do \ + rm -f $$tool.sum $$tool.log; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-recursive +all-am: Makefile $(PROGRAMS) $(SCRIPTS) config.h +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -rm -f arlex.c + -rm -f arparse.c + -rm -f arparse.h + -rm -f deflex.c + -rm -f defparse.c + -rm -f defparse.h + -rm -f mcparse.c + -rm -f mcparse.h + -rm -f nlmheader.c + -rm -f nlmheader.h + -rm -f rcparse.c + -rm -f rcparse.h + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-libtool \ + clean-noinstPROGRAMS mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-DEJAGNU distclean-compile \ + distclean-generic distclean-hdr distclean-libtool \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: install-binPROGRAMS install-binSCRIPTS + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: installcheck-local + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool mostlyclean-local + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \ + check-am ctags-recursive install install-am install-strip \ + tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am am--refresh check check-DEJAGNU check-am clean \ + clean-binPROGRAMS clean-generic clean-libtool \ + clean-noinstPROGRAMS ctags ctags-recursive distclean \ + distclean-DEJAGNU distclean-compile distclean-generic \ + distclean-hdr distclean-libtool distclean-tags dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-binSCRIPTS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-exec-local \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installcheck-local installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \ + pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-binSCRIPTS + +po/POTFILES.in: @MAINT@ Makefile + for f in $(POTFILES); do echo $$f; done | LC_ALL=C sort > tmp \ + && mv tmp $(srcdir)/po/POTFILES.in + +check-DEJAGNU: site.exp + srcdir=`cd $(srcdir) && pwd`; export srcdir; \ + r=`pwd`; export r; \ + LC_ALL=C; export LC_ALL; \ + EXPECT=$(EXPECT); export EXPECT; \ + runtest=$(RUNTEST); \ + if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ + CC="$(CC)" CC_FOR_BUILD="$(CC_FOR_BUILD)" \ + CC_FOR_TARGET="$(CC_FOR_TARGET)" CFLAGS_FOR_TARGET="$(CFLAGS)" \ + $$runtest --tool $(DEJATOOL) --srcdir $${srcdir}/testsuite \ + $(RUNTESTFLAGS); \ + else echo "WARNING: could not find \`runtest'" 1>&2; :;\ + fi + +installcheck-local: + /bin/sh $(srcdir)/sanity.sh $(bindir) + +objdump.@OBJEXT@:objdump.c +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(OBJDUMP_DEFS) $(srcdir)/objdump.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='objdump.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $(OBJDUMP_DEFS) $(srcdir)/objdump.c + +# The following is commented out for the conversion to automake. +# This rule creates a single binary that switches between ar and ranlib +# by looking at argv[0]. Use this kludge to save some disk space. +# However, you have to install things by hand. +# (That is after 'make install', replace the installed ranlib by a link to ar.) +# Alternatively, you can install ranlib.sh as ranlib. +# ar_with_ranlib: $(ADDL_DEPS) ar.o maybe-ranlib.o +# $(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $(AR_PROG) ar.o maybe-ranlib.o $(ADDL_LIBS) $(EXTRALIBS) +# -rm -f $(RANLIB_PROG) +# -ln $(AR_PROG) $(RANLIB_PROG) +# +# objcopy and strip in one binary that uses argv[0] to decide its action. +# +#objcopy_with_strip: $(ADDL_DEPS) objcopy.o maybe-strip.o +# $(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $(OBJCOPY_PROG) objcopy.o maybe-strip.o $(ADDL_LIBS) $(EXTRALIBS) +# -rm -f $(STRIP_PROG) +# -ln $(OBJCOPY_PROG) $(STRIP_PROG) + +sysroff.c: sysinfo$(EXEEXT_FOR_BUILD) sysroff.info + ./sysinfo$(EXEEXT_FOR_BUILD) -c <$(srcdir)/sysroff.info >sysroff.c + ./sysinfo$(EXEEXT_FOR_BUILD) -i <$(srcdir)/sysroff.info >>sysroff.c + ./sysinfo$(EXEEXT_FOR_BUILD) -g <$(srcdir)/sysroff.info >>sysroff.c + +sysroff.h: sysinfo$(EXEEXT_FOR_BUILD) sysroff.info + ./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h + +sysinfo$(EXEEXT_FOR_BUILD): sysinfo.@OBJEXT@ syslex_wrap.@OBJEXT@ + $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.@OBJEXT@ syslex_wrap.@OBJEXT@ + +syslex_wrap.@OBJEXT@: syslex_wrap.c syslex.c sysinfo.h config.h + $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex_wrap.c + +sysinfo.@OBJEXT@: sysinfo.c + if [ -r sysinfo.c ]; then \ + $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \ + else \ + $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \ + fi + +bin2c$(EXEEXT_FOR_BUILD): bin2c.c + $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c + +embedspu: embedspu.sh Makefile + awk '/^program_transform_name=/ {print "program_transform_name=\"$(program_transform_name)\""; next} {print}' < $< > $@ + chmod a+x $@ + +# We need these for parallel make. +sysinfo.h: sysinfo.c + +# Disable -Werror, if it has been enabled, since old versions of bison/ +# yacc will produce working code which contain compile time warnings. +arparse.@OBJEXT@: arparse.c +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f arparse.c || echo $(srcdir)/`arparse.c $(NO_WERROR) +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='arparse.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f arparse.c || echo $(srcdir)/`arparse.c $(NO_WERROR) + +arlex.@OBJEXT@: arlex.c +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f arlex.c || echo $(srcdir)/`arlex.c $(NO_WERROR) +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='arlex.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f arlex.c || echo $(srcdir)/`arlex.c $(NO_WERROR) + +sysroff.@OBJEXT@: sysroff.c +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f sysroff.c || echo $(srcdir)/`sysroff.c $(NO_WERROR) +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sysroff.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f sysroff.c || echo $(srcdir)/`sysroff.c $(NO_WERROR) + +defparse.@OBJEXT@: defparse.c +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f defparse.c || echo $(srcdir)/`defparse.c $(NO_WERROR) +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='defparse.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f defparse.c || echo $(srcdir)/`defparse.c $(NO_WERROR) + +deflex.@OBJEXT@: deflex.c +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f deflex.c || echo $(srcdir)/`deflex.c $(NO_WERROR) +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='deflex.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f deflex.c || echo $(srcdir)/`deflex.c $(NO_WERROR) + +nlmheader.@OBJEXT@: nlmheader.c +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f nlmheader.c || echo $(srcdir)/`nlmheader.c $(NO_WERROR) +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nlmheader.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f nlmheader.c || echo $(srcdir)/`nlmheader.c $(NO_WERROR) + +rcparse.@OBJEXT@: rcparse.c +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f rcparse.c || echo $(srcdir)/`rcparse.c $(NO_WERROR) +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rcparse.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f rcparse.c || echo $(srcdir)/`rcparse.c $(NO_WERROR) + +mcparse.@OBJEXT@: mcparse.c +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f mcparse.c || echo $(srcdir)/`mcparse.c $(NO_WERROR) +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mcparse.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f mcparse.c || echo $(srcdir)/`mcparse.c $(NO_WERROR) + +rclex.@OBJEXT@: rclex.c +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(srcdir)/rclex.c $(NO_WERROR) +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rclex.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $(srcdir)/rclex.c $(NO_WERROR) + +mclex.@OBJEXT@: mclex.c +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(srcdir)/mclex.c $(NO_WERROR) +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mclex.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $(srcdir)/mclex.c $(NO_WERROR) +srconv.@OBJEXT@: sysroff.c + +dlltool.@OBJEXT@: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(DLLTOOL_DEFS) $(srcdir)/dlltool.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dlltool.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $(DLLTOOL_DEFS) $(srcdir)/dlltool.c + +rescoff.@OBJEXT@: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(DLLTOOL_DEFS) $(srcdir)/rescoff.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rescoff.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $(DLLTOOL_DEFS) $(srcdir)/rescoff.c +sysdump.@OBJEXT@: sysroff.c + +# coff/sym.h and coff/ecoff.h won't be found by the automatic dependency +# scripts, since they are only included conditionally. +nlmconv.@OBJEXT@: nlmconv.c +@am__fastdepCC_TRUE@ ldname=`echo ld | sed '$(transform)'`; \ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ \ +@am__fastdepCC_TRUE@ -DLD_NAME="\"$${ldname}\"" @NLMCONV_DEFS@ $(srcdir)/nlmconv.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nlmconv.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ ldname=`echo ld | sed '$(transform)'`; \ +@am__fastdepCC_FALSE@ $(COMPILE) -c -DLD_NAME="\"$${ldname}\"" @NLMCONV_DEFS@ $(srcdir)/nlmconv.c + +diststuff: $(EXTRA_DIST) info +all: info +mostlyclean-local: + -rm -rf tmpdir + +.PHONY: install-exec-local + +install-exec-local: install-binPROGRAMS $(bin_PROGRAMS) $(noinst_PROGRAMS) + @list='$(RENAMED_PROGS)'; for p in $$list; do \ + if test -f $$p$(EXEEXT); then \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p$(EXEEXT) $(bindir)/`echo $$p|sed -e 's/-new//' -e 's/cxxfilt/$(DEMANGLER_NAME)/'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p$(EXEEXT) $(DESTDIR)$(bindir)/`echo $$p|sed -e 's/-new//' -e 's/cxxfilt/$(DEMANGLER_NAME)/'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + $(mkinstalldirs) $(DESTDIR)$(tooldir)/bin + for i in $(TOOL_PROGS); do \ + if [ -f $$i$(EXEEXT) ]; then \ + j=`echo $$i | sed -e 's/-new//'`; \ + k=`echo $$j | sed '$(transform)'`; \ + if [ "$(bindir)/$$k" != "$(tooldir)/bin/$$j" ]; then \ + rm -f $(DESTDIR)$(tooldir)/bin/$$j$(EXEEXT); \ + ln $(DESTDIR)$(bindir)/$$k$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$$j$(EXEEXT) >/dev/null 2>/dev/null \ + || $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$i$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$$j$(EXEEXT); \ + fi; \ + else true; \ + fi; \ + done + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/support/sdbinutils/binutils/NEWS b/support/sdbinutils/binutils/NEWS new file mode 100644 index 0000000..c0fa05f --- /dev/null +++ b/support/sdbinutils/binutils/NEWS @@ -0,0 +1,606 @@ +-*- text -*- + +Changes in 2.30: + +* Add --debug-dump=links option to readelf and --dwarf=links option to objdump + which displays the contents of any .gnu_debuglink or .gnu_debugaltlink + sections. + + Add a --debug-dump=follow-links option to readelf and a --dwarf=follow-links + option to objdump which causes indirect links into separate debug info files + to be followed when dumping other DWARF sections. + +Changes in 2.29: + +* The MIPS port now supports microMIPS eXtended Physical Addressing (XPA) + instructions for assembly and disassembly. + +* The MIPS port now supports the microMIPS Release 5 ISA for assembly and + disassembly. + +* The MIPS port now supports the Imagination interAptiv MR2 processor, + which implements the MIPS32r3 ISA, the MIPS16e2 ASE as well as a couple + of implementation-specific regular MIPS and MIPS16e2 ASE instructions. + +* The SPARC port now supports the SPARC M8 processor, which implements the + Oracle SPARC Architecture 2017. + +* The MIPS port now supports the MIPS16e2 ASE for assembly and disassembly. + +* Add support for ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX. + +* Add support for the wasm32 ELF conversion of the WebAssembly file format. + +* Add --inlines option to objdump, which extends the --line-numbers option + so that inlined functions will display their nesting information. + +* Add --merge-notes options to objcopy to reduce the size of notes in + a binary file by merging and deleting redundant notes. + +* Add support for locating separate debug info files using the build-id + method, where the separate file has a name based upon the build-id of + the original file. + +Changes in 2.28: + +* This version of binutils fixes a problem with PowerPC VLE 16A and 16D + relocations which were functionally swapped, for example, + R_PPC_VLE_HA16A performed like R_PPC_VLE_HA16D while R_PPC_VLE_HA16D + performed like R_PPC_VLE_HA16A. This could have been fixed by + renumbering relocations, which would keep object files created by an + older version of gas compatible with a newer ld. However, that would + require an ABI update, affecting other assemblers and linkers that + create and process the relocations correctly. It is recommended that + all VLE object files be recompiled, but ld can modify the relocations + if --vle-reloc-fixup is passed to ld. If the new ld command line + option is not used, ld will ld warn on finding relocations inconsistent + with the instructions being relocated. + +* The nm program has a new command line option (--with-version-strings) + which will display a symbol's version information, if any, after the + symbol's name. + +* The ARC port of objdump now accepts a -M option to specify the extra + instruction class(es) that should be disassembled. + +* The --remove-section option for objcopy and strip now accepts section + patterns starting with an exclamation point to indicate a non-matching + section. A non-matching section is removed from the set of sections + matched by an earlier --remove-section pattern. + +* The --only-section option for objcopy now accepts section patterns + starting with an exclamation point to indicate a non-matching section. + A non-matching section is removed from the set of sections matched by + an earlier --only-section pattern. + +* New --remove-relocations=SECTIONPATTERN option for objcopy and strip. + This option can be used to remove sections containing relocations. + The SECTIONPATTERN is the section to which the relocations apply, not + the relocation section itself. + +Changes in 2.27: + +* Add a configure option, --enable-64-bit-archive, to force use of a + 64-bit format when creating an archive symbol index. + +* Add --elf-stt-common= option to objcopy for ELF targets to control + whether to convert common symbols to the STT_COMMON type. + +Changes in 2.26: + +* Add option to objcopy to insert new symbols into a file: + --add-symbol =[
:][,] + +* Add support for the ARC EM/HS, and ARC600/700 architectures. + +* Extend objcopy --compress-debug-sections option to support + --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi] for ELF + targets. + +* Add --update-section option to objcopy. + +* Add --output-separator option to strings. + +Changes in 2.25: + +* Add --data option to strings to only print strings in loadable, initialized + data sections. Change the default behaviour to be --all, but add a new + configure time option of --disable-default-strings-all to restore the old + default behaviour. + +* Add --include-all-whitespace to strings. + +* Add --dump-section option to objcopy. + +* Add support for the Andes NDS32. + +Changes in 2.24: + +* Objcopy now supports wildcard characters in command line options that take + section names. + +* Add support for Altera Nios II. + +Changes in 2.23: + +* Add support for the VLE extension to the PowerPC architecture. + +* Add support for x64 Windows target of the delayed-load-library. + +* Add support for the Renesas RL78 architecture. + +Changes in 2.22: + +* Add support for displaying the contents of .debug.macro sections. + +* Add --preprocessor-arg option to windres to specify additional options + passed to preprocessor. + +* Add --dwarf-start and --dwarf-end to readelf and objdump. These are used by + the new Emacs mode, see dwarf-mode.el. + +* Add support for the Tilera TILEPro and TILE-Gx architectures. + +changes in 2.21: + +* Add --interleave-width option to objcopy to allowing copying a range of + bytes from the input to the output with the --interleave option. + +* Add support for the TMS320C6000 (TI C6X) processor family. + +* Readelf can now display ARM unwind tables (.ARM.exidx / .ARM.extab) using + the -u / --unwind option. + +* Add --dyn-syms to readelf to dump dynamic symbol table. + +* A new tool - elfedit - has been added to directly manipulate ELF format + binaries. + +* Add to dlltool .def file feature of aliasing PE internal symbol name by + '== ' option. + +* Add a new command line option -a / --addresses to addr2line to display the + address before function name or source filename. + +* Add a new command line option -p / --pretty-print to addr2line to have + a more human readable output. + +* The hppa/som targets can now be compiled on any host. + +Changes in 2.20: + +* Add support for delay importing to dlltool. Use the --output-delaylib + switch to create a delay-import library. The resulting app will load the dll + as soon as the first function is called. It will link to __delayLoadHelper2() + from the static delayimp library, which will import LoadLibraryA and + GetProcAddress from kernel32. + +* Add a new command line option, --insn-width=WIDTH, to objdump to specify + number of bytes to be displayed on a single line when disassembling + instructions. + +* Readelf can now display the relocated contents of a section as a sequence + of bytes via the --relocated-dump= command line option. + +* The gprof program has been given a new command line option: + --external-symbols-table= which reads in symbols from a specified + file. + +* The plugin target has been added to bfd. It can load the same shared objects + used by gold and uses them to provide basic support for new file formats. + +* The verilog memory hex dump file format is now supported as an output format + for objcopy. + +* Add --file-alignment, --heap, --image-base, --section-alignment, + --stack and --subsystem command line options to objcopy, which will + set PE optional header. + +* Option --dwarf/-W of objdump is now as flexible as readelf --debug-dump/-w. + +* --as-needed now links in a dynamic library if it satisfies undefined + symbols in regular objects, or in other dynamic libraries. In the + latter case the library is not linked if it is found in a DT_NEEDED + entry of one of the libraries already linked. + +* Added --prefix=PREFIX and --prefix-strip=LEVEL switches to objdump to + add absolute paths for -S. + +* Add new option --use-nul-prefixed-import-tables to dlltool to allow fall- + back to old import table generation with null element prefix. + +* Added --identify-strict switch to cause --identify to + report an error when the import library is associated with + multiple DLLs. + +* Added --identify option to dlltool, which determines the + name of the DLL associated with the specified . + +* Support for PowerPC booke64 instructions has been removed. The assembler no + longer accepts -mbooke32 or -mbooke64 and the disassembler no longer accepts + -Mbooke32 or -Mbooke64. Instead, -mbooke and -Mbooke should be used. + +Changes in 2.19: + +* Added -wL switch to dump decoded contents of .debug_line. + +* Added support for "thin" archives which contain pathnames pointing to + object files rather than the files themselves and which contain a + flattened symbol index for all objects, and archives, which have been + added to the archive. + +* Added -F switch to objdump to include file offsets in the disassembly. + +* Added -c switch to readelf to allow string dumps of archive symbol index. + +* Support for SSE5 has been added to the i386 port. + +* Added -p switch to readelf to allow string dumps of sections. + +Changes in 2.18: + +* Resolved 37 coding problems in bfd including static array overruns, null + pointer dereferences and use of a malloc buffer after it has been freed, as + revealed by static analysis donated by Coverity, Inc. (http://scan.coverity.com). + +* The binutils sources are now released under version 3 of the GNU General + Public License. + +* A new tool "windmc" has been added for some targets. This is a message + compiler which attempts to be compatible with the MS version. + +* Add codepage support to the windres tool. It now supports many new + resource types (e.g. MANIFEST, TOOLBAR, etc). The output generation + for binary files is done now via bfd itself. The endianess problems + for different hosts are solved. Dumps of .res files can now be + re-compiled by windres without lossing resources or compilation errors. + Some problems on dialog resource translations are corrected. + +* Add --extract-symbol command line option to objcopy, which will + strip everything out of an ordinary object file or executable except + for its symbol table. Files containing just symbols can be useful + to some OSes. + +Changes in 2.17: + +* Add "-x NAME" to readelf in addition to "-x NUMBER". + +* Add -i and -t switches to cxxfilt. -i disables the display of implementation + specific extra demangling information (if any) and -t disables the demangling + of types. + +* Add support for the "@" syntax to the command lines of all tools, so + that extra switches can be read from . + +* Add "-W/--dwarf" to objdump to display the contents of the DWARF + debug sections. + +* Add "-t/--section-details" to readelf to display section details. + "-N/--full-section-name" is deprecated. + +* powerpc-linux ld now supports a variant form of PLT and GOT for the security + conscious. This form will automatically be chosen when ld detects that all + code in regular object files was generated by gcc -msecure-plt. The old PLT + and GOT may be forced by a new ld option, --bss-plt. + +* Add "-i/--inlines" to addr2line to print enclosing scope information + for inlined function chains, back to first non-inlined function. + +* Add "-N/--full-section-name" to readelf to display full section name. + +* Add "-M entry:" switch to objdump to specify a function entry address + when disassembling VAX binaries. + +* Add "--globalize-symbol " and "--globalize-symbols " switches + to objcopy to convert local symbols into global symbols. + +* gprof now allows input files to have histogram records for + several memory ranges, provided those ranges are disjoint. + +Changes in 2.16: + +* Add "-g/--section-groups" to readelf to display section groups. + +* objcopy recognizes two new options --strip-unneeded-symbol and + --strip-unneeded-symbols, namely for use together with the wildcard + matching the original --strip-symbol/--strip-symbols provided, but + retaining any symbols matching but needed by relocations. + +* readelf can now display address ranges from .debug_range sections. This + happens automatically when a DW_AT_range attribute is encountered. The + command line switch --debug-dump=Ranges (or -wR) can also be used to display + the contents of the .debug_range section. + +* nm and objdump now have a switch "--special-syms" to enable the displaying of + symbols which the target considers to be special. By default these symbols + are no longer displayed. Currently the only special symbols are the Mapping + symbols used by the ARM port to mark transitions between text and data and + between ARM and THUMB code. + +* dlltool has a switch "--ext-prefix-alias " to generate additional + import and export symbols with prepended to them. + +Changes in 2.15: + +* objcopy for MIPS targets now accepts "-M no-aliases" as an option to the + disassembler to print the "raw" mips instruction mnemonic instead of some + pseudo instruction name. I.E. print "daddu" or "or" instead of "move", + "sll" instead of "nop", etc. + +* objcopy and strip can now take wildcard patterns in symbol names specified on + the command line provided that the --wildcard switch is used to enable them. + +* readelf can now parse archives. + +* objdump now accepts --debugging-tags to print the debug information in a + format compatible with ctags tool. + +* objcopy and strip now accept --only-keep-debug to create a file containing + those sections that would be stripped out by --strip-debug. The idea is that + this can be used in conjunction with the --add-gnu-debuglink switch to create + a two part program distribution - one a stripped executable and the other the + debugging info. + +* objcopy now accepts --add-gnu-debuglink= to insert a .gnu_debuglink + section into a (presumably stripped) executable. This allows the debug + information for the file to be held in a separate file. + +* BFD marks the sections .comment and .note as 'n' in the BSD/POSIX + single-character representation. This can be checked by running nm + with the -a switch. + +Changes in 2.14: + +* Added --info switch to objcopy and strip. + +* Support for Vitesse IQ2000 added by Red Hat. + +* Added 'S' encoding to strings to allow the display of 8-bit characters. + +* Added --prefix-symbols=, --prefix-sections= and + --prefix-alloc-sections= to objcopy. + +* readelf can handle the extensions to the DWARF2 spec used by the Unified + Parallel C compiler. + +* BFD no longer declares a "boolean" type, to avoid clashes with other + headers that declare the same. Users of BFD should replace boolean, + false and true, with int, 0 and 1, or define their own boolean type. + +* Support for IP2K added by Denis Chertykov. + +Changes in 2.13: + +* Support for the Fujitsu FRV architecture added by Red Hat. Models for FR400 + and FR500 included. + +Changes in version 2.12: + +* Support for Don Knuth's MMIX, by Hans-Peter Nilsson. + +* size: Add --totals to display summary of sizes (Berkeley format only). + +* readelf: Add --wide option to not break section header or segment listing + lines to fit into 80 columns. + +* strings: Add --encoding to display wide character strings. By Markus Kuhn. + +* objcopy: Add --rename-section to change section names. + +* readelf: Support added for DWARF 2.1 extensions. Support added for + displaying the contents of .debug.macinfo sections. + +* New command line switches added to objcopy to allow symbols to be kept as + global symbols, and also to specify files containing lists of such symbols. + by Honda Hiroki. + +* Support for OpenRISC by Johan Rydberg. + +* New command line switch to objcopy --alt-machine-code which creates a binary + with an alternate machine code if one is defined in the architecture + description. Only supported for ELF targets. By Alexandre Oliva. + +* New command line switch to objcopy -B (or --binary-architecture) which sets + the architecture of the output file to the given argument. This option only + makes sense, if the input target is binary. Otherwise it is ignored. + By Stefan Geuken. + +* Support for PDP-11 by Lars Brinkhoff. + +Changes in binutils 2.11: + +* Add support for ARM v5t and v5te architectures and Intel's XScale ARM + extenstions. + +* Add --srec-len and --srec-forceS3 command line switch to objcopy. + By Luciano Gemme. + +* Support for the MIPS32, by Anders Norlander. + +* Support for the i860, by Jason Eckhardt. + +* Support for CRIS (Axis Communications ETRAX series). + +Changes in binutils 2.10: + +* Support for 64-bit ELF on HPPA. + +* New command line switch to objdump --file-start-context which shows the + entire file contents up to the source line first encountered for a given + file. + +* New command line switch to objdump -M (or --disassembler-options) which takes + a parameter which can then be interpreted on a per-target basis by the + disassembler. Used by ARM targets to select register name sets, ISA, APCS or + raw verions. + +* objdump support for -mi386:intel which causes disassembly to be displayed + with intel syntax. + +* New program: readelf. This displays the contents of ELF format files, + regardless of target machine. + +* objcopy now takes --change-section-lma, --change-section-vma, and + --change-section-address options. The old --adjust-section-vma option is + equivalent to --change-section-address. The other --adjust-* options are now + renamed to --change-*, although --adjust-* continues to work. + +* objcopy has a --redefine-sym option that lets you rename symbols. + +* objcopy now takes a -j/--only-section option to copy only the specified + sections. + +* dlltool now supports the IMPORTS command. + +* dlltool now takes --export-all-symbols, --no-export-all-symbols, + --exclude-symbols, and --no-default-excludes options. + +Changes in binutils 2.9: + +* Added windres program, which can be used to manipulate resources in WIN32 + files as used on Windows 95 and Windows NT. + +* The objcopy --gap-fill and --pad-to options operate on the LMA rather than + the VMA of the sections. + +* Added S modifier to ar to not build a symbol table. + +Changes in binutils 2.8: + +* The objdump disassembly format has been changed, and hopefully improved. Use + the new --prefix-addresses option to get the old format. There are also new + --disassemble-zeroes and --no-show-raw-insn options which affect disassembler + output. + +* Formats may now be specified as configuration triplets. For example, + objdump -b i386-pc-linux. The triplets are not passed through config.sub, + so they must be in canonical form. + +* Added new addr2line program. This uses the debugging information to convert + an address into a file name and line number within a program. + +* Added --change-leading-char argument to objcopy. + +* Added --weaken argument to objcopy. + +* objdump --dynamic-reloc now works on ELF executables and shared libraries. + +* Added --adjust-vma option to objdump. + +* Added -C/--demangle option to objdump. + +* Added -p/--preserve-dates option to strip and objcopy. + +Changes in binutils 2.7: + +* Added --enable-shared and --enable-commonbfdlib options to configure. + +* Added --debugging argument to objdump and objcopy. + +* Added --defined-only argument to nm. + +* Added --remove-leading-char argument to objcopy. + +* The objdump --line-numbers option is now meaningful with --reloc. + +* Added --line-numbers option to nm. + +* Added --endian/-EB/-EL option to objdump. + +* Added support for Alpha OpenVMS/AXP. + +Changes in binutils 2.6: + +* Added -N/--strip-symbol and -K/--keep-symbol arguments to strip and objcopy. + +* Added several arguments to objcopy to provide some control over how the new + file is laid out in memory. Also added binary output format to BFD to permit + generating plain binary files. + +* Added --start-address and --stop-address options to objdump. + +* ar and ranlib now work on AIX. The tools are now built by default on AIX. + +Changes in binutils 2.5: + +* Changed objdump -dr to dump the relocs interspersed with the assembly + listing, for a more useful listing of relocatable files. + +* Changed objdump -d/--disassemble to only disassemble SEC_CODE sections. + Added -D/--disassemble-all option to disassemble all sections. + +* Added --size-sort option to nm. + +* strip and objcopy should now be able to handle dynamically linked ELF + executables. + +Changes in binutils 2.4: + +* Support for HP-PA (by Jeff Law), i386 Mach (by David Mackenzie), RS/6000 and + PowerPC (except ar and ranlib; by Ian Taylor). + +* Support for Irix 5. + +* Programs `strip' and `objcopy' will not attempt to write dynamically linked + ELF output files, since BFD currently can't create them properly. + +Changes in binutils 2.3: + +* A new --stabs argument has been added to objdump to dump stabs sections in + ELF and COFF files. + +* A new program, nlmconv, has been added. It can convert object files into + Novell NetWare Loadable Modules. + +* The strings program has been added. + +Changes in binutils 2.2: + +* The 'copy' program has been renamed to 'objcopy', for consistency with + 'objdump', and because 'copy' might more plausibly be used as a synonym for + 'cp'. + +* The new stand-alone program c++filt is a filter that converts encoded + (mangled) C++ assembly-level identifiers to user-level names. (Note: This + may get moved to the gcc distribution.) + +* nm -o on an archive now prefixes each line with the archive name, matching + the output from BSD nm. + +* ar (and ld) can now read (but not write) BSD4.4-style archives. + +* New support for H8500, Z8000, and the Hitach SH. + +* Dis-assembler interface changed to allow sharing with gdb. + +* There is new Elf code, but it is not yet ready for general use. + +* There is the beginnings of a test suite. + +Changes in binutils 2.1: + +* There is now support for writing ECOFF files, so ld and the other utilities + should work on Risc/Ultrix and Irix. Please let us know how well this works. + +* ar now automatically creates a symbol table (a __.SYMDEF member, in the BSD + version), if there are any object files in the archive. So running ranlib is + now redundant (unless the non-standard q command is used). This is required + for Posix.2 conformance. + +* The archive-reading code now reads both BSD-style and SYSV-style archives + independently of the selected target format. This is to encourage people to + switch to SYSV-format, which has a number of advantages. + +* The strip and copy programs now have options to remove debug-symbols only + and/or local symbols only. They now also support long options. + + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Local variables: +fill-column: 79 +End: diff --git a/support/sdbinutils/binutils/README b/support/sdbinutils/binutils/README new file mode 100644 index 0000000..d88f04d --- /dev/null +++ b/support/sdbinutils/binutils/README @@ -0,0 +1,299 @@ + README for BINUTILS + +These are the GNU binutils. These are utilities of use when dealing +with binary files, either object files or executables. These tools +consist of the linker (ld), the assembler (gas), and the profiler +(gprof) each of which have their own sub-directory named after them. +There is also a collection of other binary tools, including the +disassembler (objdump) in this directory. These tools make use of a +pair of libraries (bfd and opcodes) and a common set of header files +(include). + +There are README and NEWS files in most of the program sub-directories +which give more information about those specific programs. + + +Copyright Notices +================= + +Copyright years on binutils source files may be listed using range +notation, e.g., 1991-2012, indicating that every year in the range, +inclusive, is a copyrightable year that could otherwise be listed +individually. + + +Unpacking and Installation -- quick overview +============================================ + +When you unpack the binutils archive file, you will get a directory +called something like `binutils-XXX', where XXX is the number of the +release. (Probably 2.13 or higher). This directory contains +various files and sub-directories. Most of the files in the top +directory are for information and for configuration. The actual +source code is in sub-directories. + +To build binutils, you can just do: + + cd binutils-XXX + ./configure [options] + make + make install # copies the programs files into /usr/local/bin + # by default. + +This will configure and build all the libraries as well as the +assembler, the binutils, and the linker. + +If you have GNU make, we recommend building in a different directory: + + mkdir objdir + cd objdir + ../binutils-XXX/configure [options] + make + make install + +This relies on the VPATH feature of GNU make. + +By default, the binutils will be configured to support the system on +which they are built. When doing cross development, use the --target +configure option to specify a different target, eg: + + ./configure --target=foo-elf + +The --enable-targets option adds support for more binary file formats +besides the default. List them as the argument to --enable-targets, +separated by commas. For example: + + ./configure --enable-targets=sun3,rs6000-aix,decstation + +The name 'all' compiles in support for all valid BFD targets: + + ./configure --enable-targets=all + +On 32-bit hosts though, this support will be restricted to 32-bit +target unless the --enable-64-bit-bfd option is also used: + + ./configure --enable-64-bit-bfd --enable-targets=all + +You can also specify the --enable-shared option when you run +configure. This will build the BFD and opcodes libraries as shared +libraries. You can use arguments with the --enable-shared option to +indicate that only certain libraries should be built shared; for +example, --enable-shared=bfd. The only potential shared libraries in +a binutils release are bfd and opcodes. + +The binutils will be linked against the shared libraries. The build +step will attempt to place the correct library in the run-time search +path for the binaries. However, in some cases, after you install the +binaries, you may have to set an environment variable, normally +LD_LIBRARY_PATH, so that the system can find the installed libbfd +shared library. + +On hosts that support shared system libraries the binutils will be +linked against them. If you have static versions of the system +libraries installed as well and you wish to create static binaries +instead then use the LDFLAGS environment variable, like this: + + ../binutils-XXX/configure LDFLAGS="--static" [more options] + +Note: the two dashes are important. The binutils make use of the +libtool script which has a special interpretation of "-static" when it +is in the LDFLAGS environment variable. + +To build under openVMS/AXP, see the file makefile.vms in the top level +directory. + + +Native Language Support +======================= + +By default Native Language Support will be enabled for binutils. On +some systems however this support is not present and can lead to error +messages such as "undefined reference to `libintl_gettext'" when +building there tools. If that happens the NLS support can be disabled +by adding the --disable-nls switch to the configure line like this: + + ../binutils-XXX/configure --disable-nls + + +If you don't have ar +==================== + +If your system does not already have an 'ar' program, the normal +binutils build process will not work. In this case, run configure as +usual. Before running make, run this script: + +#!/bin/sh +MAKE_PROG="${MAKE-make}" +MAKE="${MAKE_PROG} AR=true LINK=true" +export MAKE +${MAKE} $* all-libiberty +${MAKE} $* all-intl +${MAKE} $* all-bfd +cd binutils +MAKE="${MAKE_PROG}" +export MAKE +${MAKE} $* ar_DEPENDENCIES= ar_LDADD='../bfd/*.o ../libiberty/*.o `if test -f ../intl/gettext.o; then echo '../intl/*.o'; fi`' ar + +This script will build an ar program in binutils/ar. Move binutils/ar +into a directory on your PATH. After doing this, you can run make as +usual to build the complete binutils distribution. You do not need +the ranlib program in order to build the distribution. + +Porting +======= + +Binutils-2.13 supports many different architectures, but there +are many more not supported, including some that were supported +by earlier versions. We are hoping for volunteers to improve this +situation. + +The major effort in porting binutils to a new host and/or target +architecture involves the BFD library. There is some documentation +in ../bfd/doc. The file ../gdb/doc/gdbint.texinfo (distributed +with gdb-5.x) may also be of help. + +Reporting bugs +============== + +Send bug reports and patches to: + + bug-binutils@gnu.org. + +Please include the following in bug reports: + +- A description of exactly what went wrong, and exactly what should have + happened instead. + +- The configuration name(s) given to the "configure" script. The + "config.status" file should have this information. This is assuming + you built binutils yourself. If you didn't build binutils youself, + then we need information regarding your machine and operating system, + and it may be more appropriate to report bugs to wherever you obtained + binutils. + +- The options given to the tool (gas, objcopy, ld etc.) at run time. + +- The actual input file that caused the problem. + +Always mention the version number you are running; this is printed by +running any of the binutils with the --version option. We appreciate +reports about bugs, but we do not promise to fix them, particularly so +when the bug report is against an old version. If you are able, please +consider building the latest tools from git to check that your bug has +not already been fixed. + +When reporting problems about gas and ld, it's useful to provide a +testcase that triggers the problem. In the case of a gas problem, we +want input files to gas and command line switches used. The inputs to +gas are _NOT_ .c or .i files, but rather .s files. If your original +source was a C program, you can generate the .s file and see the command +line options by passing -v -save-temps to gcc in addition to all the +usual options you use. The reason we don't want C files is that we +might not have a C compiler around for the target you use. While it +might be possible to build a compiler, that takes considerable time and +disk space, and we might not end up with exactly the same compiler you +use. + +In the case of a ld problem, the input files are .o, .a and .so files, +and possibly a linker script specified with -T. Again, when using gcc +to link, you can see these files by adding options to the gcc command +line. Use -v -save-temps -Wl,-t, except that on targets that use gcc's +collect2, you would add -v -save-temps -Wl,-t,-debug. The -t option +tells ld to print all files and libraries used, so that, for example, +you can associate -lc on the ld command line with the actual libc used. +Note that your simple two line C program to trigger a problem typically +expands into several megabytes of objects by the time you include +libraries. + +It is antisocial to post megabyte sized attachments to mailing lists, so +please put large testcases somewhere on an ftp or web site so that only +interested developers need to download them, or offer to email them on +request. Better still, try to reduce the testcase, for example, try to +develop a ld testcase that doesn't use system libraries. However, +please be sure it is a complete testcase and that it really does +demonstrate the problem. Also, don't bother paring it down if that will +cause large delays in filing the bug report. + +If you expect to be contributing a large number of test cases, it would +be helpful if you would look at the test suite included in the release +(based on the Deja Gnu testing framework, available from the usual ftp +sites) and write test cases to fit into that framework. This is +certainly not required. + +VMS +=== + +This section was written by Klaus K"ampf . It +describes how to build and install the binutils on openVMS (Alpha and +Vax). (The BFD library only supports reading Vax object files.) + +Compiling the release: + +To compile the gnu binary utilities and the gnu assembler, you'll +need DEC C or GNU C for openVMS/Alpha. You'll need *both* compilers +on openVMS/Vax. + +Compiling with either DEC C or GNU C works on openVMS/Alpha only. Some +of the opcodes and binutils files trap a bug in the DEC C optimizer, +so these files must be compiled with /noopt. + +Compiling on openVMS/Vax is a bit complicated, as the bfd library traps +a bug in GNU C and the gnu assembler a bug in (my version of) DEC C. + +I never tried compiling with VAX C. + + +You further need GNU Make Version 3.76 or later. This is available +at ftp.progis.de or any GNU archive site. The makefiles assume that +gmake starts gnu make as a foreign command. + +If you're compiling with DEC C or VAX C, you must run + + $ @setup + +before starting gnu-make. This isn't needed with GNU C. + +On the Alpha you can choose the compiler by editing the toplevel +makefile.vms. Either select CC=cc (for DEC C) or CC=gcc (for GNU C) + + +Installing the release + +Provided that your directory setup conforms to the GNU on openVMS +standard, you already have a concealed device named 'GNU_ROOT'. +In this case, a simple + + $ gmake install + +suffices to copy all programs and libraries to the proper directories. + +Define the programs as foreign commands by adding these lines to your +login.com: + + $ gas :== $GNU_ROOT:[bin]as.exe + $ size :== $GNU_ROOT:[bin]size.exe + $ nm :== $GNU_ROOT:[bin]nm.exe + $ objdump :== $GNU_ROOT:[bin]objdump.exe + $ strings :== $GNU_ROOT:[bin]strings.exe + +If you have a different directory setup, copy the binary utilities +([.binutils]size.exe, [.binutils]nm.exe, [.binutils]objdump.exe, +and [.binutils]strings.exe) and the gnu assembler and preprocessor +([.gas]as.exe and [.gas]gasp.exe]) to a directory of your choice +and define all programs as foreign commands. + + +If you're satisfied with the compilation, you may want to remove +unneeded objects and libraries: + + $ gmake clean + + +If you have any problems or questions about the binutils on VMS, feel +free to mail me at kkaempf@rmi.de. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/support/sdbinutils/binutils/README-how-to-make-a-release b/support/sdbinutils/binutils/README-how-to-make-a-release new file mode 100644 index 0000000..4e6d1e7 --- /dev/null +++ b/support/sdbinutils/binutils/README-how-to-make-a-release @@ -0,0 +1,211 @@ + README for MAKING BINUTILS RELEASES + +This is a collection of notes on how to perform a binutils release. A +lot of this information can also be found in the maintain.texi file in +the gnulib project: + + https://www.gnu.org/software/gnulib/ + +It is useful to have a cloned copy of the sources of this project as +it also contains an upload script used to install tarballs on the GNU +FTP server. + +Make sure that you have upload authority on sourceware and fencepost. +Beware - this is an involved process and can take weeks to complete. +See the maintain.texi file for details on how to obtain these +permissions. + +------------------------------------------------- +How to perform a release. +------------------------------------------------- + + 1. Send an email out warning contributors about the forthcoming + branch. Set a date for the branch (weekends are better because + they are less busy). + + 2. Update the libiberty and config directories and the top level + configure files. + + 3. When branch day arrives add markers for the upcoming release to + gas, ld, gold and binutils NEWS files. + [make-prelease.sh command i] + [make-prelease.sh command C] + Likewise for all of the ChangeLog files. + Add a note of the name of the new branch to binutils/BRANCHES. + Commit these changes. + [make-prerelease.sh command C] + + 4. Create the release branch using: + + git tag -a binutils-2_30-branch [eg for the 2.30 branch...] + git push --tags origin binutils-2_30-branch + + 5. Update bfd/configure and bfd/configure.ac on HEAD to indicate + snapshot of the following release. + + 6. Rename the current HEAD version entry in Bugzilla, and create a + new one. E.g. rename "2.30 (HEAD)" to 2.30, and create "2.31 + (HEAD)". Go to "Edit products" from the bottom toolbar, click on + "binutils", then on "Edit versions". If you don't have + permissions to do this, either ask Daniel Berlin to fix your + account or ask Daniel Jacobowitz to do it. + + 7. Regenerate various files on both branch and HEAD by configuring + with --enable-maintainer-mode. No need to check in changes to + the autoconf/automake/etc files, but be sure the .pot files are + up to date. + + 8. Create an initial prerelease: + + a. Bump the version on the branch, and check this in. + + b. Create a source tarball: + + git clean -f -d -x + CFLAGS="-O -g0" ./src-release.sh -b binutils + rm -rf $release_dir/proto-toplev + rm $release_dir/binutils-$version + rm $release_dir/binutils-$version.tar + mv $release_dir/binutils-$version.tar.lzip .. + + c. Build a test target using this tarball. + + d. Upload the prerelease snapshot to the FTP: + + scp ../binutils-$version.tar.bz2 sourceware.org:~ftp/pub/binutils/snapshots + ssh sourceware.org md5sum \~ftp/pub/binutils/snapshots/binutils-$version.tar.bz2 + md5sum ../binutils-$version.tar.bz2 + + 9. Send it to the Translation Project: + + http://translationproject.org/html/maintainers.html + + Sending mail for one of the POT files is sufficient. + + 10. Announce the availability of the snapshot and the branch on the + binutils mailing list. Set a date for when the release will + actually happen. Nag maintainers to fix any testsuite failures + for their architectures... + +xxx -- fill in stuff here -- xxx + +------------------------------------------------- +How to perform a point release. +------------------------------------------------- + +A point release is easier than a normal release since a lot of the +work has already been done. The branch has been created, the +translations updated and the documentation uploaded. So the procedure +looks like this: + + 0. Decide that a point release is necessary. + + Usually this only happens when a sufficient number of serious + bugs have been found and fixed since the previous release, and a + new official release is not imminent. + + 1. Tell the community that a point release is happening. Ask + maintainers to ensure that their ports are up to date on the + release branch. Ask the community if there are any bug fixes + which are missing from the branch. Allow some time for the + responses to this step. + + 2. Make sure that the branch sources build, test and install + correctly. + + 2.5 Prepare a list of the bugs which have been fixed. This + will be needed for step 8. + + 3. In the branch sources: + + a. Update the minor release number in bfd/version.m4. + b. Edit bfd/development.sh and set "development=false". + c. Regenerate the configure files. + d. Commit the updates along with a "this-is-the-2.XX.X-release" + note in all of the changelogs. + e. Tag the branch with the new release number: + + git tag -a binutils-2_XX_X + [optional: add "-u XXXXX" to sign with a gpg key] + git push origin binutils-2_XX_X + + f. Check that your file creation mask will create the + correct file permissions. Eg: + + umask 022 + + g. Create the release tarballs: + ./src-release -b -g -l -x binutils + + h. Check that the files in the tarballs have the correct + permissions. + + i. Edit bfd/development.sh and set "development=true". + j. Commit this change into the git repository. + k. Clean up the source tree. (Use "git status" to find new + files, and remove them). + + FIXME: The tarballs will contain spurious autom4te.cache + directories which could be removed to reduce their size. + + 4. [If paranoid - upload the tarballs to one of the FTP servers and + ask people to test it before going on to step 5]. + + 5. Upload the tarballs to ftp.gnu.org. + + gnupload --to ftp.gnu.org:binutils binutils-X.XX.X.tar.* + + The gnupload script is in the gnulib/build-aux directory. + + 6. Upload the tarballs to sourceware.org: + + sftp sourceware.org + cd /ftp/pub/binutils/releases + put binutils-X.XX.X.tar.* + chmod 644 binutils-X.XX.X.tar.* + quit + + FIXME: Should the signatures (created by the gnupload script in + step 5) be uploaded as well ? + + 7. Update web pages. For sourceware.org: + + * Log on to sourceware.org + * Go /www/htdocs/binutils + * Edit index.html + + For the www.gnu.org site you have to email webmasters@gnu.org + and ask them to make the change(s). + + 8. Send an emails to the binutils list, info-gnu@gnu.org and + David Edelsohn announcing the new release. + (The email to Davis is so that he can update the GNU Toolchain + social media). Something like this: +------------------------------------------------------------------------ +Hi Everyone, + + We are pleased to announce that version 2.XX.X of the Binutils project + sources have been released and are now available for download at: + + https://ftp.gnu.org/gnu/binutils + https://sourceware.org/pub/binutils/releases/ + + This is a point release over the previous 2.XX version, containing bug + fixes but no new features. + + Our thanks go out to all of the binutils contributors, past and + present, for helping to make this release possible. + + Here is a list of the bugs that have been fixed: + xx + xx + xx + xx +-------------------------------------------------------------------------- + + +Copyright (C) 2017-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/support/sdbinutils/binutils/aclocal.m4 b/support/sdbinutils/binutils/aclocal.m4 new file mode 100644 index 0000000..8b8d20e --- /dev/null +++ b/support/sdbinutils/binutils/aclocal.m4 @@ -0,0 +1,1034 @@ +# generated automatically by aclocal 1.11.6 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, +# Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.64],, +[m4_warning([this file was generated for autoconf 2.64. +You have another version of autoconf. It may work, but is not guaranteed to. +If you have problems, you may need to regenerate the build system entirely. +To do so, use the procedure documented by the package, typically `autoreconf'.])]) + +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software +# Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 1 + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.11' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.11.6], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) + +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.11.6])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 1 + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 9 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, +# 2010, 2011 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 12 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + am__universal=false + m4_case([$1], [CC], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac], + [CXX], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac]) + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +AC_SUBST([am__nodep])dnl +_AM_SUBST_NOTMAKE([am__nodep])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +#serial 5 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[{ + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 16 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.62])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl +]) +_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl +dnl The `parallel-tests' driver may need to know about EXEEXT, so add the +dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro +dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_CONFIG_COMMANDS_PRE(dnl +[m4_provide_if([_AM_COMPILER_EXEEXT], + [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl +]) + +dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further +dnl mangled by Autoconf and run in a shell conditional statement. +m4_define([_AC_COMPILER_EXEEXT], +m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, +# Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 1 + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi +AC_SUBST(install_sh)]) + +# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_PROG_LEX +# ----------- +# Autoconf leaves LEX=: if lex or flex can't be found. Change that to a +# "missing" invocation, for better error output. +AC_DEFUN([AM_PROG_LEX], +[AC_PREREQ(2.50)dnl +AC_REQUIRE([AM_MISSING_HAS_RUN])dnl +AC_REQUIRE([AC_PROG_LEX])dnl +if test "$LEX" = :; then + LEX=${am_missing_run}flex +fi]) + +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- +# From Jim Meyering + +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008, +# 2011 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_MAINTAINER_MODE([DEFAULT-MODE]) +# ---------------------------------- +# Control maintainer-specific portions of Makefiles. +# Default is to disable them, unless `enable' is passed literally. +# For symmetry, `disable' may be passed as well. Anyway, the user +# can override the default with the --enable/--disable switch. +AC_DEFUN([AM_MAINTAINER_MODE], +[m4_case(m4_default([$1], [disable]), + [enable], [m4_define([am_maintainer_other], [disable])], + [disable], [m4_define([am_maintainer_other], [enable])], + [m4_define([am_maintainer_other], [enable]) + m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) +AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) + dnl maintainer-mode's default is 'disable' unless 'enable' is passed + AC_ARG_ENABLE([maintainer-mode], +[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST([MAINT])dnl +] +) + +AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from `make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 6 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, +# Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 1 + +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software +# Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# -------------------- +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ------------------------ +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[[\\\"\#\$\&\'\`$am_lf]]*) + AC_MSG_ERROR([unsafe absolute working directory name]);; +esac +case $srcdir in + *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) + AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; +esac + +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 1 + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# AM_SUBST_NOTMAKE(VARIABLE) +# -------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AC_SUBST([AMTAR], ['$${TAR-tar}']) +m4_if([$1], [v7], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + +m4_include([../bfd/acinclude.m4]) +m4_include([../bfd/warning.m4]) +m4_include([../config/acx.m4]) +m4_include([../config/depstand.m4]) +m4_include([../config/gettext-sister.m4]) +m4_include([../config/iconv.m4]) +m4_include([../config/largefile.m4]) +m4_include([../config/lcmessage.m4]) +m4_include([../config/lead-dot.m4]) +m4_include([../config/lib-ld.m4]) +m4_include([../config/lib-link.m4]) +m4_include([../config/lib-prefix.m4]) +m4_include([../config/nls.m4]) +m4_include([../config/override.m4]) +m4_include([../config/plugins.m4]) +m4_include([../config/po.m4]) +m4_include([../config/progtest.m4]) +m4_include([../config/zlib.m4]) +m4_include([../libtool.m4]) +m4_include([../ltoptions.m4]) +m4_include([../ltsugar.m4]) +m4_include([../ltversion.m4]) +m4_include([../lt~obsolete.m4]) diff --git a/support/sdbinutils/binutils/addr2line.c b/support/sdbinutils/binutils/addr2line.c new file mode 100644 index 0000000..64454f5 --- /dev/null +++ b/support/sdbinutils/binutils/addr2line.c @@ -0,0 +1,510 @@ +/* addr2line.c -- convert addresses to line number and function name + Copyright (C) 1997-2018 Free Software Foundation, Inc. + Contributed by Ulrich Lauther + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + + +/* Derived from objdump.c and nm.c by Ulrich.Lauther@mchp.siemens.de + + Usage: + addr2line [options] addr addr ... + or + addr2line [options] + + both forms write results to stdout, the second form reads addresses + to be converted from stdin. */ + +#include "sysdep.h" +#include "bfd.h" +#include "getopt.h" +#include "libiberty.h" +#include "demangle.h" +#include "bucomm.h" +#include "elf-bfd.h" + +static bfd_boolean unwind_inlines; /* -i, unwind inlined functions. */ +static bfd_boolean with_addresses; /* -a, show addresses. */ +static bfd_boolean with_functions; /* -f, show function names. */ +static bfd_boolean do_demangle; /* -C, demangle names. */ +static bfd_boolean pretty_print; /* -p, print on one line. */ +static bfd_boolean base_names; /* -s, strip directory names. */ + +static int naddr; /* Number of addresses to process. */ +static char **addr; /* Hex addresses to process. */ + +static asymbol **syms; /* Symbol table. */ + +static struct option long_options[] = +{ + {"addresses", no_argument, NULL, 'a'}, + {"basenames", no_argument, NULL, 's'}, + {"demangle", optional_argument, NULL, 'C'}, + {"exe", required_argument, NULL, 'e'}, + {"functions", no_argument, NULL, 'f'}, + {"inlines", no_argument, NULL, 'i'}, + {"pretty-print", no_argument, NULL, 'p'}, + {"section", required_argument, NULL, 'j'}, + {"target", required_argument, NULL, 'b'}, + {"help", no_argument, NULL, 'H'}, + {"version", no_argument, NULL, 'V'}, + {0, no_argument, 0, 0} +}; + +static void usage (FILE *, int); +static void slurp_symtab (bfd *); +static void find_address_in_section (bfd *, asection *, void *); +static void find_offset_in_section (bfd *, asection *); +static void translate_addresses (bfd *, asection *); + +/* Print a usage message to STREAM and exit with STATUS. */ + +static void +usage (FILE *stream, int status) +{ + fprintf (stream, _("Usage: %s [option(s)] [addr(s)]\n"), program_name); + fprintf (stream, _(" Convert addresses into line number/file name pairs.\n")); + fprintf (stream, _(" If no addresses are specified on the command line, they will be read from stdin\n")); + fprintf (stream, _(" The options are:\n\ + @ Read options from \n\ + -a --addresses Show addresses\n\ + -b --target= Set the binary file format\n\ + -e --exe= Set the input file name (default is a.out)\n\ + -i --inlines Unwind inlined functions\n\ + -j --section= Read section-relative offsets instead of addresses\n\ + -p --pretty-print Make the output easier to read for humans\n\ + -s --basenames Strip directory names\n\ + -f --functions Show function names\n\ + -C --demangle[=style] Demangle function names\n\ + -h --help Display this information\n\ + -v --version Display the program's version\n\ +\n")); + + list_supported_targets (program_name, stream); + if (REPORT_BUGS_TO[0] && status == 0) + fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); + exit (status); +} + +/* Read in the symbol table. */ + +static void +slurp_symtab (bfd *abfd) +{ + long storage; + long symcount; + bfd_boolean dynamic = FALSE; + + if ((bfd_get_file_flags (abfd) & HAS_SYMS) == 0) + return; + + storage = bfd_get_symtab_upper_bound (abfd); + if (storage == 0) + { + storage = bfd_get_dynamic_symtab_upper_bound (abfd); + dynamic = TRUE; + } + if (storage < 0) + bfd_fatal (bfd_get_filename (abfd)); + + syms = (asymbol **) xmalloc (storage); + if (dynamic) + symcount = bfd_canonicalize_dynamic_symtab (abfd, syms); + else + symcount = bfd_canonicalize_symtab (abfd, syms); + if (symcount < 0) + bfd_fatal (bfd_get_filename (abfd)); + + /* If there are no symbols left after canonicalization and + we have not tried the dynamic symbols then give them a go. */ + if (symcount == 0 + && ! dynamic + && (storage = bfd_get_dynamic_symtab_upper_bound (abfd)) > 0) + { + free (syms); + syms = xmalloc (storage); + symcount = bfd_canonicalize_dynamic_symtab (abfd, syms); + } + + /* PR 17512: file: 2a1d3b5b. + Do not pretend that we have some symbols when we don't. */ + if (symcount <= 0) + { + free (syms); + syms = NULL; + } +} + +/* These global variables are used to pass information between + translate_addresses and find_address_in_section. */ + +static bfd_vma pc; +static const char *filename; +static const char *functionname; +static unsigned int line; +static unsigned int discriminator; +static bfd_boolean found; + +/* Look for an address in a section. This is called via + bfd_map_over_sections. */ + +static void +find_address_in_section (bfd *abfd, asection *section, + void *data ATTRIBUTE_UNUSED) +{ + bfd_vma vma; + bfd_size_type size; + + if (found) + return; + + if ((bfd_get_section_flags (abfd, section) & SEC_ALLOC) == 0) + return; + + vma = bfd_get_section_vma (abfd, section); + if (pc < vma) + return; + + size = bfd_get_section_size (section); + if (pc >= vma + size) + return; + + found = bfd_find_nearest_line_discriminator (abfd, section, syms, pc - vma, + &filename, &functionname, + &line, &discriminator); +} + +/* Look for an offset in a section. This is directly called. */ + +static void +find_offset_in_section (bfd *abfd, asection *section) +{ + bfd_size_type size; + + if (found) + return; + + if ((bfd_get_section_flags (abfd, section) & SEC_ALLOC) == 0) + return; + + size = bfd_get_section_size (section); + if (pc >= size) + return; + + found = bfd_find_nearest_line_discriminator (abfd, section, syms, pc, + &filename, &functionname, + &line, &discriminator); +} + +/* Read hexadecimal addresses from stdin, translate into + file_name:line_number and optionally function name. */ + +static void +translate_addresses (bfd *abfd, asection *section) +{ + int read_stdin = (naddr == 0); + + for (;;) + { + if (read_stdin) + { + char addr_hex[100]; + + if (fgets (addr_hex, sizeof addr_hex, stdin) == NULL) + break; + pc = bfd_scan_vma (addr_hex, NULL, 16); + } + else + { + if (naddr <= 0) + break; + --naddr; + pc = bfd_scan_vma (*addr++, NULL, 16); + } + + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) + { + const struct elf_backend_data *bed = get_elf_backend_data (abfd); + bfd_vma sign = (bfd_vma) 1 << (bed->s->arch_size - 1); + + pc &= (sign << 1) - 1; + if (bed->sign_extend_vma) + pc = (pc ^ sign) - sign; + } + + if (with_addresses) + { + printf ("0x"); + bfd_printf_vma (abfd, pc); + + if (pretty_print) + printf (": "); + else + printf ("\n"); + } + + found = FALSE; + if (section) + find_offset_in_section (abfd, section); + else + bfd_map_over_sections (abfd, find_address_in_section, NULL); + + if (! found) + { + if (with_functions) + { + if (pretty_print) + printf ("?? "); + else + printf ("??\n"); + } + printf ("??:0\n"); + } + else + { + while (1) + { + if (with_functions) + { + const char *name; + char *alloc = NULL; + + name = functionname; + if (name == NULL || *name == '\0') + name = "??"; + else if (do_demangle) + { + alloc = bfd_demangle (abfd, name, DMGL_ANSI | DMGL_PARAMS); + if (alloc != NULL) + name = alloc; + } + + printf ("%s", name); + if (pretty_print) + /* Note for translators: This printf is used to join the + function name just printed above to the line number/ + file name pair that is about to be printed below. Eg: + + foo at 123:bar.c */ + printf (_(" at ")); + else + printf ("\n"); + + if (alloc != NULL) + free (alloc); + } + + if (base_names && filename != NULL) + { + char *h; + + h = strrchr (filename, '/'); + if (h != NULL) + filename = h + 1; + } + + printf ("%s:", filename ? filename : "??"); + if (line != 0) + { + if (discriminator != 0) + printf ("%u (discriminator %u)\n", line, discriminator); + else + printf ("%u\n", line); + } + else + printf ("?\n"); + if (!unwind_inlines) + found = FALSE; + else + found = bfd_find_inliner_info (abfd, &filename, &functionname, + &line); + if (! found) + break; + if (pretty_print) + /* Note for translators: This printf is used to join the + line number/file name pair that has just been printed with + the line number/file name pair that is going to be printed + by the next iteration of the while loop. Eg: + + 123:bar.c (inlined by) 456:main.c */ + printf (_(" (inlined by) ")); + } + } + + /* fflush() is essential for using this command as a server + child process that reads addresses from a pipe and responds + with line number information, processing one address at a + time. */ + fflush (stdout); + } +} + +/* Process a file. Returns an exit value for main(). */ + +static int +process_file (const char *file_name, const char *section_name, + const char *target) +{ + bfd *abfd; + asection *section; + char **matching; + + if (get_file_size (file_name) < 1) + return 1; + + abfd = bfd_openr (file_name, target); + if (abfd == NULL) + bfd_fatal (file_name); + + /* Decompress sections. */ + abfd->flags |= BFD_DECOMPRESS; + + if (bfd_check_format (abfd, bfd_archive)) + fatal (_("%s: cannot get addresses from archive"), file_name); + + if (! bfd_check_format_matches (abfd, bfd_object, &matching)) + { + bfd_nonfatal (bfd_get_filename (abfd)); + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (matching); + free (matching); + } + xexit (1); + } + + if (section_name != NULL) + { + section = bfd_get_section_by_name (abfd, section_name); + if (section == NULL) + fatal (_("%s: cannot find section %s"), file_name, section_name); + } + else + section = NULL; + + slurp_symtab (abfd); + + translate_addresses (abfd, section); + + if (syms != NULL) + { + free (syms); + syms = NULL; + } + + bfd_close (abfd); + + return 0; +} + +int +main (int argc, char **argv) +{ + const char *file_name; + const char *section_name; + char *target; + int c; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + program_name = *argv; + xmalloc_set_program_name (program_name); + bfd_set_error_program_name (program_name); + + expandargv (&argc, &argv); + + bfd_init (); + set_default_bfd_target (); + + file_name = NULL; + section_name = NULL; + target = NULL; + while ((c = getopt_long (argc, argv, "ab:Ce:sfHhij:pVv", long_options, (int *) 0)) + != EOF) + { + switch (c) + { + case 0: + break; /* We've been given a long option. */ + case 'a': + with_addresses = TRUE; + break; + case 'b': + target = optarg; + break; + case 'C': + do_demangle = TRUE; + if (optarg != NULL) + { + enum demangling_styles style; + + style = cplus_demangle_name_to_style (optarg); + if (style == unknown_demangling) + fatal (_("unknown demangling style `%s'"), + optarg); + + cplus_demangle_set_style (style); + } + break; + case 'e': + file_name = optarg; + break; + case 's': + base_names = TRUE; + break; + case 'f': + with_functions = TRUE; + break; + case 'p': + pretty_print = TRUE; + break; + case 'v': + case 'V': + print_version ("addr2line"); + break; + case 'h': + case 'H': + usage (stdout, 0); + break; + case 'i': + unwind_inlines = TRUE; + break; + case 'j': + section_name = optarg; + break; + default: + usage (stderr, 1); + break; + } + } + + if (file_name == NULL) + file_name = "a.out"; + + addr = argv + optind; + naddr = argc - optind; + + return process_file (file_name, section_name, target); +} diff --git a/support/sdbinutils/binutils/ar.c b/support/sdbinutils/binutils/ar.c new file mode 100644 index 0000000..66a81e7 --- /dev/null +++ b/support/sdbinutils/binutils/ar.c @@ -0,0 +1,1507 @@ +/* ar.c - Archive modify and extract. + Copyright (C) 1991-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +/* + Bugs: GNU ar used to check file against filesystem in quick_update and + replace operations (would check mtime). Doesn't warn when name truncated. + No way to specify pos_end. Error messages should be more consistent. */ + +#include "sysdep.h" +#include "bfd.h" +#include "libiberty.h" +#include "progress.h" +#include "getopt.h" +#include "aout/ar.h" +#include "bucomm.h" +#include "arsup.h" +#include "filenames.h" +#include "binemul.h" +#include "plugin-api.h" +#include "plugin.h" + +#ifdef __GO32___ +#define EXT_NAME_LEN 3 /* Bufflen of addition to name if it's MS-DOS. */ +#else +#define EXT_NAME_LEN 6 /* Ditto for *NIX. */ +#endif + +/* Static declarations. */ + +static void mri_emul (void); +static const char *normalize (const char *, bfd *); +static void remove_output (void); +static void map_over_members (bfd *, void (*)(bfd *), char **, int); +static void print_contents (bfd * member); +static void delete_members (bfd *, char **files_to_delete); + +static void move_members (bfd *, char **files_to_move); +static void replace_members + (bfd *, char **files_to_replace, bfd_boolean quick); +static void print_descr (bfd * abfd); +static void write_archive (bfd *); +static int ranlib_only (const char *archname); +static int ranlib_touch (const char *archname); +static void usage (int); + +/** Globals and flags. */ + +static int mri_mode; + +/* This flag distinguishes between ar and ranlib: + 1 means this is 'ranlib'; 0 means this is 'ar'. + -1 means if we should use argv[0] to decide. */ +extern int is_ranlib; + +/* Nonzero means don't warn about creating the archive file if necessary. */ +int silent_create = 0; + +/* Nonzero means describe each action performed. */ +int verbose = 0; + +/* Nonzero means preserve dates of members when extracting them. */ +int preserve_dates = 0; + +/* Nonzero means don't replace existing members whose dates are more recent + than the corresponding files. */ +int newer_only = 0; + +/* Controls the writing of an archive symbol table (in BSD: a __.SYMDEF + member). -1 means we've been explicitly asked to not write a symbol table; + +1 means we've been explicitly asked to write it; + 0 is the default. + Traditionally, the default in BSD has been to not write the table. + However, for POSIX.2 compliance the default is now to write a symbol table + if any of the members are object files. */ +int write_armap = 0; + +/* Operate in deterministic mode: write zero for timestamps, uids, + and gids for archive members and the archive symbol table, and write + consistent file modes. */ +int deterministic = -1; /* Determinism indeterminate. */ + +/* Nonzero means it's the name of an existing member; position new or moved + files with respect to this one. */ +char *posname = NULL; + +/* Sez how to use `posname': pos_before means position before that member. + pos_after means position after that member. pos_end means always at end. + pos_default means default appropriately. For the latter two, `posname' + should also be zero. */ +enum pos + { + pos_default, pos_before, pos_after, pos_end + } postype = pos_default; + +enum operations + { + none = 0, del, replace, print_table, + print_files, extract, move, quick_append + } operation = none; + +static bfd ** +get_pos_bfd (bfd **, enum pos, const char *); + +/* For extract/delete only. If COUNTED_NAME_MODE is TRUE, we only + extract the COUNTED_NAME_COUNTER instance of that name. */ +static bfd_boolean counted_name_mode = 0; +static int counted_name_counter = 0; + +/* Whether to truncate names of files stored in the archive. */ +static bfd_boolean ar_truncate = FALSE; + +/* Whether to use a full file name match when searching an archive. + This is convenient for archives created by the Microsoft lib + program. */ +static bfd_boolean full_pathname = FALSE; + +/* Whether to create a "thin" archive (symbol index only -- no files). */ +static bfd_boolean make_thin_archive = FALSE; + +static int show_version = 0; + +static int show_help = 0; + +#if BFD_SUPPORTS_PLUGINS +static const char *plugin_target = "plugin"; +#else +static const char *plugin_target = NULL; +#endif + +static const char *target = NULL; + +#define OPTION_PLUGIN 201 +#define OPTION_TARGET 202 + +static struct option long_options[] = +{ + {"help", no_argument, &show_help, 1}, + {"plugin", required_argument, NULL, OPTION_PLUGIN}, + {"target", required_argument, NULL, OPTION_TARGET}, + {"version", no_argument, &show_version, 1}, + {NULL, no_argument, NULL, 0} +}; + +int interactive = 0; + +static void +mri_emul (void) +{ + interactive = isatty (fileno (stdin)); + yyparse (); +} + +/* If COUNT is 0, then FUNCTION is called once on each entry. If nonzero, + COUNT is the length of the FILES chain; FUNCTION is called on each entry + whose name matches one in FILES. */ + +static void +map_over_members (bfd *arch, void (*function)(bfd *), char **files, int count) +{ + bfd *head; + int match_count; + + if (count == 0) + { + for (head = arch->archive_next; head; head = head->archive_next) + { + PROGRESS (1); + function (head); + } + return; + } + + /* This may appear to be a baroque way of accomplishing what we want. + However we have to iterate over the filenames in order to notice where + a filename is requested but does not exist in the archive. Ditto + mapping over each file each time -- we want to hack multiple + references. */ + + for (head = arch->archive_next; head; head = head->archive_next) + head->archive_pass = 0; + + for (; count > 0; files++, count--) + { + bfd_boolean found = FALSE; + + match_count = 0; + for (head = arch->archive_next; head; head = head->archive_next) + { + const char * filename; + + PROGRESS (1); + /* PR binutils/15796: Once an archive element has been matched + do not match it again. If the user provides multiple same-named + parameters on the command line their intent is to match multiple + same-named entries in the archive, not the same entry multiple + times. */ + if (head->archive_pass) + continue; + + filename = head->filename; + if (filename == NULL) + { + /* Some archive formats don't get the filenames filled in + until the elements are opened. */ + struct stat buf; + bfd_stat_arch_elt (head, &buf); + } + else if (bfd_is_thin_archive (arch)) + { + /* Thin archives store full pathnames. Need to normalize. */ + filename = normalize (filename, arch); + } + + if (filename != NULL + && !FILENAME_CMP (normalize (*files, arch), filename)) + { + ++match_count; + if (counted_name_mode + && match_count != counted_name_counter) + { + /* Counting, and didn't match on count; go on to the + next one. */ + continue; + } + + found = TRUE; + function (head); + head->archive_pass = 1; + /* PR binutils/15796: Once a file has been matched, do not + match any more same-named files in the archive. If the + user does want to match multiple same-name files in an + archive they should provide multiple same-name parameters + to the ar command. */ + break; + } + } + + if (!found) + /* xgettext:c-format */ + fprintf (stderr, _("no entry %s in archive\n"), *files); + } +} + +bfd_boolean operation_alters_arch = FALSE; + +static void +usage (int help) +{ + FILE *s; + +#if BFD_SUPPORTS_PLUGINS + /* xgettext:c-format */ + const char *command_line + = _("Usage: %s [emulation options] [-]{dmpqrstx}[abcDfilMNoPsSTuvV]" + " [--plugin ] [member-name] [count] archive-file file...\n"); + +#else + /* xgettext:c-format */ + const char *command_line + = _("Usage: %s [emulation options] [-]{dmpqrstx}[abcDfilMNoPsSTuvV]" + " [member-name] [count] archive-file file...\n"); +#endif + s = help ? stdout : stderr; + + fprintf (s, command_line, program_name); + + /* xgettext:c-format */ + fprintf (s, _(" %s -M [ - read options from \n")); + fprintf (s, _(" --target=BFDNAME - specify the target object format as BFDNAME\n")); +#if BFD_SUPPORTS_PLUGINS + fprintf (s, _(" optional:\n")); + fprintf (s, _(" --plugin

- load the specified plugin\n")); +#endif + + ar_emul_usage (s); + + list_supported_targets (program_name, s); + + if (REPORT_BUGS_TO[0] && help) + fprintf (s, _("Report bugs to %s\n"), REPORT_BUGS_TO); + + xexit (help ? 0 : 1); +} + +static void +ranlib_usage (int help) +{ + FILE *s; + + s = help ? stdout : stderr; + + /* xgettext:c-format */ + fprintf (s, _("Usage: %s [options] archive\n"), program_name); + fprintf (s, _(" Generate an index to speed access to archives\n")); + fprintf (s, _(" The options are:\n\ + @ Read options from \n")); +#if BFD_SUPPORTS_PLUGINS + fprintf (s, _("\ + --plugin Load the specified plugin\n")); +#endif + if (DEFAULT_AR_DETERMINISTIC) + fprintf (s, _("\ + -D Use zero for symbol map timestamp (default)\n\ + -U Use an actual symbol map timestamp\n")); + else + fprintf (s, _("\ + -D Use zero for symbol map timestamp\n\ + -U Use actual symbol map timestamp (default)\n")); + fprintf (s, _("\ + -t Update the archive's symbol map timestamp\n\ + -h --help Print this help message\n\ + -v --version Print version information\n")); + + list_supported_targets (program_name, s); + + if (REPORT_BUGS_TO[0] && help) + fprintf (s, _("Report bugs to %s\n"), REPORT_BUGS_TO); + + xexit (help ? 0 : 1); +} + +/* Normalize a file name specified on the command line into a file + name which we will use in an archive. */ + +static const char * +normalize (const char *file, bfd *abfd) +{ + const char *filename; + + if (full_pathname) + return file; + + filename = lbasename (file); + + if (ar_truncate + && abfd != NULL + && strlen (filename) > abfd->xvec->ar_max_namelen) + { + char *s; + + /* Space leak. */ + s = (char *) xmalloc (abfd->xvec->ar_max_namelen + 1); + memcpy (s, filename, abfd->xvec->ar_max_namelen); + s[abfd->xvec->ar_max_namelen] = '\0'; + filename = s; + } + + return filename; +} + +/* Remove any output file. This is only called via xatexit. */ + +static const char *output_filename = NULL; +static FILE *output_file = NULL; +static bfd *output_bfd = NULL; + +static void +remove_output (void) +{ + if (output_filename != NULL) + { + if (output_bfd != NULL) + bfd_cache_close (output_bfd); + if (output_file != NULL) + fclose (output_file); + unlink_if_ordinary (output_filename); + } +} + +static char ** +decode_options (int argc, char **argv) +{ + int c; + + /* Convert old-style tar call by exploding option element and rearranging + options accordingly. */ + + if (argc > 1 && argv[1][0] != '-') + { + int new_argc; /* argc value for rearranged arguments */ + char **new_argv; /* argv value for rearranged arguments */ + char *const *in; /* cursor into original argv */ + char **out; /* cursor into rearranged argv */ + const char *letter; /* cursor into old option letters */ + char buffer[3]; /* constructed option buffer */ + + /* Initialize a constructed option. */ + + buffer[0] = '-'; + buffer[2] = '\0'; + + /* Allocate a new argument array, and copy program name in it. */ + + new_argc = argc - 1 + strlen (argv[1]); + new_argv = xmalloc ((new_argc + 1) * sizeof (*argv)); + in = argv; + out = new_argv; + *out++ = *in++; + + /* Copy each old letter option as a separate option. */ + + for (letter = *in++; *letter; letter++) + { + buffer[1] = *letter; + *out++ = xstrdup (buffer); + } + + /* Copy all remaining options. */ + + while (in < argv + argc) + *out++ = *in++; + *out = NULL; + + /* Replace the old option list by the new one. */ + + argc = new_argc; + argv = new_argv; + } + + while ((c = getopt_long (argc, argv, "hdmpqrtxlcoVsSuvabiMNfPTDU", + long_options, NULL)) != EOF) + { + switch (c) + { + case 'd': + case 'm': + case 'p': + case 'q': + case 'r': + case 't': + case 'x': + if (operation != none) + fatal (_("two different operation options specified")); + break; + } + + switch (c) + { + case 'h': + show_help = 1; + break; + case 'd': + operation = del; + operation_alters_arch = TRUE; + break; + case 'm': + operation = move; + operation_alters_arch = TRUE; + break; + case 'p': + operation = print_files; + break; + case 'q': + operation = quick_append; + operation_alters_arch = TRUE; + break; + case 'r': + operation = replace; + operation_alters_arch = TRUE; + break; + case 't': + operation = print_table; + break; + case 'x': + operation = extract; + break; + case 'l': + break; + case 'c': + silent_create = 1; + break; + case 'o': + preserve_dates = 1; + break; + case 'V': + show_version = TRUE; + break; + case 's': + write_armap = 1; + break; + case 'S': + write_armap = -1; + break; + case 'u': + newer_only = 1; + break; + case 'v': + verbose = 1; + break; + case 'a': + postype = pos_after; + break; + case 'b': + postype = pos_before; + break; + case 'i': + postype = pos_before; + break; + case 'M': + mri_mode = 1; + break; + case 'N': + counted_name_mode = TRUE; + break; + case 'f': + ar_truncate = TRUE; + break; + case 'P': + full_pathname = TRUE; + break; + case 'T': + make_thin_archive = TRUE; + break; + case 'D': + deterministic = TRUE; + break; + case 'U': + deterministic = FALSE; + break; + case OPTION_PLUGIN: +#if BFD_SUPPORTS_PLUGINS + bfd_plugin_set_plugin (optarg); +#else + fprintf (stderr, _("sorry - this program has been built without plugin support\n")); + xexit (1); +#endif + break; + case OPTION_TARGET: + target = optarg; + break; + case 0: /* A long option that just sets a flag. */ + break; + default: + usage (0); + } + } + + return &argv[optind]; +} + +/* If neither -D nor -U was specified explicitly, + then use the configured default. */ +static void +default_deterministic (void) +{ + if (deterministic < 0) + deterministic = DEFAULT_AR_DETERMINISTIC; +} + +static void +ranlib_main (int argc, char **argv) +{ + int arg_index, status = 0; + bfd_boolean touch = FALSE; + int c; + + while ((c = getopt_long (argc, argv, "DhHUvVt", long_options, NULL)) != EOF) + { + switch (c) + { + case 'D': + deterministic = TRUE; + break; + case 'U': + deterministic = FALSE; + break; + case 'h': + case 'H': + show_help = 1; + break; + case 't': + touch = TRUE; + break; + case 'v': + case 'V': + show_version = 1; + break; + + /* PR binutils/13493: Support plugins. */ + case OPTION_PLUGIN: +#if BFD_SUPPORTS_PLUGINS + bfd_plugin_set_plugin (optarg); +#else + fprintf (stderr, _("sorry - this program has been built without plugin support\n")); + xexit (1); +#endif + break; + } + } + + if (argc < 2) + ranlib_usage (0); + + if (show_help) + ranlib_usage (1); + + if (show_version) + print_version ("ranlib"); + + default_deterministic (); + + arg_index = optind; + + while (arg_index < argc) + { + if (! touch) + status |= ranlib_only (argv[arg_index]); + else + status |= ranlib_touch (argv[arg_index]); + ++arg_index; + } + + xexit (status); +} + +int main (int, char **); + +int +main (int argc, char **argv) +{ + int arg_index; + char **files; + int file_count; + char *inarch_filename; + int i; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + program_name = argv[0]; + xmalloc_set_program_name (program_name); + bfd_set_error_program_name (program_name); +#if BFD_SUPPORTS_PLUGINS + bfd_plugin_set_program_name (program_name); +#endif + + expandargv (&argc, &argv); + + if (is_ranlib < 0) + { + const char *temp = lbasename (program_name); + + if (strlen (temp) >= 6 + && FILENAME_CMP (temp + strlen (temp) - 6, "ranlib") == 0) + is_ranlib = 1; + else + is_ranlib = 0; + } + + START_PROGRESS (program_name, 0); + + bfd_init (); + set_default_bfd_target (); + + xatexit (remove_output); + + for (i = 1; i < argc; i++) + if (! ar_emul_parse_arg (argv[i])) + break; + argv += (i - 1); + argc -= (i - 1); + + if (is_ranlib) + ranlib_main (argc, argv); + + if (argc < 2) + usage (0); + + argv = decode_options (argc, argv); + + if (show_help) + usage (1); + + if (show_version) + print_version ("ar"); + + arg_index = 0; + + if (mri_mode) + { + default_deterministic (); + mri_emul (); + } + else + { + bfd *arch; + + /* Fail if no files are specified on the command line. + (But not for MRI mode which allows for reading arguments + and filenames from stdin). */ + if (argv[arg_index] == NULL) + usage (0); + + /* We don't use do_quick_append any more. Too many systems + expect ar to always rebuild the symbol table even when q is + used. */ + + /* We can't write an armap when using ar q, so just do ar r + instead. */ + if (operation == quick_append && write_armap) + operation = replace; + + if ((operation == none || operation == print_table) + && write_armap == 1) + xexit (ranlib_only (argv[arg_index])); + + if (operation == none) + fatal (_("no operation specified")); + + if (newer_only && operation != replace) + fatal (_("`u' is only meaningful with the `r' option.")); + + if (newer_only && deterministic > 0) + fatal (_("`u' is not meaningful with the `D' option.")); + + if (newer_only && deterministic < 0 && DEFAULT_AR_DETERMINISTIC) + non_fatal (_("\ +`u' modifier ignored since `D' is the default (see `U')")); + + default_deterministic (); + + if (postype != pos_default) + { + posname = argv[arg_index++]; + if (posname == NULL) + fatal (_("missing position arg.")); + } + + if (counted_name_mode) + { + if (operation != extract && operation != del) + fatal (_("`N' is only meaningful with the `x' and `d' options.")); + if (argv[arg_index] == NULL) + fatal (_("`N' missing value.")); + counted_name_counter = atoi (argv[arg_index++]); + if (counted_name_counter <= 0) + fatal (_("Value for `N' must be positive.")); + } + + inarch_filename = argv[arg_index++]; + if (inarch_filename == NULL) + usage (0); + + for (file_count = 0; argv[arg_index + file_count] != NULL; file_count++) + continue; + + files = (file_count > 0) ? argv + arg_index : NULL; + + arch = open_inarch (inarch_filename, + files == NULL ? (char *) NULL : files[0]); + + if (operation == extract && bfd_is_thin_archive (arch)) + fatal (_("`x' cannot be used on thin archives.")); + + switch (operation) + { + case print_table: + map_over_members (arch, print_descr, files, file_count); + break; + + case print_files: + map_over_members (arch, print_contents, files, file_count); + break; + + case extract: + map_over_members (arch, extract_file, files, file_count); + break; + + case del: + if (files != NULL) + delete_members (arch, files); + else + output_filename = NULL; + break; + + case move: + /* PR 12558: Creating and moving at the same time does + not make sense. Just create the archive instead. */ + if (! silent_create) + { + if (files != NULL) + move_members (arch, files); + else + output_filename = NULL; + break; + } + /* Fall through. */ + + case replace: + case quick_append: + if (files != NULL || write_armap > 0) + replace_members (arch, files, operation == quick_append); + else + output_filename = NULL; + break; + + /* Shouldn't happen! */ + default: + /* xgettext:c-format */ + fatal (_("internal error -- this option not implemented")); + } + } + + END_PROGRESS (program_name); + + xexit (0); + return 0; +} + +bfd * +open_inarch (const char *archive_filename, const char *file) +{ + bfd **last_one; + bfd *next_one; + struct stat sbuf; + bfd *arch; + char **matching; + + bfd_set_error (bfd_error_no_error); + + if (target == NULL) + target = plugin_target; + + if (stat (archive_filename, &sbuf) != 0) + { +#if !defined(__GO32__) || defined(__DJGPP__) + + /* FIXME: I don't understand why this fragment was ifndef'ed + away for __GO32__; perhaps it was in the days of DJGPP v1.x. + stat() works just fine in v2.x, so I think this should be + removed. For now, I enable it for DJGPP v2. -- EZ. */ + + /* KLUDGE ALERT! Temporary fix until I figger why + stat() is wrong ... think it's buried in GO32's IDT - Jax */ + if (errno != ENOENT) + bfd_fatal (archive_filename); +#endif + + if (!operation_alters_arch) + { + fprintf (stderr, "%s: ", program_name); + perror (archive_filename); + maybequit (); + return NULL; + } + + /* If the target isn't set, try to figure out the target to use + for the archive from the first object on the list. */ + if (target == NULL && file != NULL) + { + bfd *obj; + + obj = bfd_openr (file, target); + if (obj != NULL) + { + if (bfd_check_format (obj, bfd_object)) + target = bfd_get_target (obj); + (void) bfd_close (obj); + } + } + + /* Create an empty archive. */ + arch = bfd_openw (archive_filename, target); + if (arch == NULL + || ! bfd_set_format (arch, bfd_archive) + || ! bfd_close (arch)) + bfd_fatal (archive_filename); + else if (!silent_create) + non_fatal (_("creating %s"), archive_filename); + + /* If we die creating a new archive, don't leave it around. */ + output_filename = archive_filename; + } + + arch = bfd_openr (archive_filename, target); + if (arch == NULL) + { + bloser: + bfd_fatal (archive_filename); + } + + if (! bfd_check_format_matches (arch, bfd_archive, &matching)) + { + bfd_nonfatal (archive_filename); + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (matching); + free (matching); + } + xexit (1); + } + + if ((operation == replace || operation == quick_append) + && bfd_openr_next_archived_file (arch, NULL) != NULL) + { + /* PR 15140: Catch attempts to convert a normal + archive into a thin archive or vice versa. */ + if (make_thin_archive && ! bfd_is_thin_archive (arch)) + { + fatal (_("Cannot convert existing library %s to thin format"), + bfd_get_filename (arch)); + goto bloser; + } + else if (! make_thin_archive && bfd_is_thin_archive (arch)) + { + fatal (_("Cannot convert existing thin library %s to normal format"), + bfd_get_filename (arch)); + goto bloser; + } + } + + last_one = &(arch->archive_next); + /* Read all the contents right away, regardless. */ + for (next_one = bfd_openr_next_archived_file (arch, NULL); + next_one; + next_one = bfd_openr_next_archived_file (arch, next_one)) + { + PROGRESS (1); + *last_one = next_one; + last_one = &next_one->archive_next; + } + *last_one = (bfd *) NULL; + if (bfd_get_error () != bfd_error_no_more_archived_files) + goto bloser; + return arch; +} + +static void +print_contents (bfd *abfd) +{ + bfd_size_type ncopied = 0; + bfd_size_type size; + char *cbuf = (char *) xmalloc (BUFSIZE); + struct stat buf; + + if (bfd_stat_arch_elt (abfd, &buf) != 0) + /* xgettext:c-format */ + fatal (_("internal stat error on %s"), bfd_get_filename (abfd)); + + if (verbose) + printf ("\n<%s>\n\n", bfd_get_filename (abfd)); + + bfd_seek (abfd, (file_ptr) 0, SEEK_SET); + + size = buf.st_size; + while (ncopied < size) + { + bfd_size_type nread; + bfd_size_type tocopy = size - ncopied; + + if (tocopy > BUFSIZE) + tocopy = BUFSIZE; + + nread = bfd_bread (cbuf, tocopy, abfd); + if (nread != tocopy) + /* xgettext:c-format */ + fatal (_("%s is not a valid archive"), + bfd_get_filename (abfd->my_archive)); + + /* fwrite in mingw32 may return int instead of bfd_size_type. Cast the + return value to bfd_size_type to avoid comparison between signed and + unsigned values. */ + if ((bfd_size_type) fwrite (cbuf, 1, nread, stdout) != nread) + fatal ("stdout: %s", strerror (errno)); + ncopied += tocopy; + } + free (cbuf); +} + +/* Extract a member of the archive into its own file. + + We defer opening the new file until after we have read a BUFSIZ chunk of the + old one, since we know we have just read the archive header for the old + one. Since most members are shorter than BUFSIZ, this means we will read + the old header, read the old data, write a new inode for the new file, and + write the new data, and be done. This 'optimization' is what comes from + sitting next to a bare disk and hearing it every time it seeks. -- Gnu + Gilmore */ + +void +extract_file (bfd *abfd) +{ + FILE *ostream; + char *cbuf = (char *) xmalloc (BUFSIZE); + bfd_size_type nread, tocopy; + bfd_size_type ncopied = 0; + bfd_size_type size; + struct stat buf; + + /* PR binutils/17533: Do not allow directory traversal + outside of the current directory tree. */ + if (! is_valid_archive_path (bfd_get_filename (abfd))) + { + non_fatal (_("illegal pathname found in archive member: %s"), + bfd_get_filename (abfd)); + free (cbuf); + return; + } + + if (bfd_stat_arch_elt (abfd, &buf) != 0) + /* xgettext:c-format */ + fatal (_("internal stat error on %s"), bfd_get_filename (abfd)); + size = buf.st_size; + + if (verbose) + printf ("x - %s\n", bfd_get_filename (abfd)); + + bfd_seek (abfd, (file_ptr) 0, SEEK_SET); + + ostream = NULL; + if (size == 0) + { + /* Seems like an abstraction violation, eh? Well it's OK! */ + output_filename = bfd_get_filename (abfd); + + ostream = fopen (bfd_get_filename (abfd), FOPEN_WB); + if (ostream == NULL) + { + perror (bfd_get_filename (abfd)); + xexit (1); + } + + output_file = ostream; + } + else + while (ncopied < size) + { + tocopy = size - ncopied; + if (tocopy > BUFSIZE) + tocopy = BUFSIZE; + + nread = bfd_bread (cbuf, tocopy, abfd); + if (nread != tocopy) + /* xgettext:c-format */ + fatal (_("%s is not a valid archive"), + bfd_get_filename (abfd->my_archive)); + + /* See comment above; this saves disk arm motion */ + if (ostream == NULL) + { + /* Seems like an abstraction violation, eh? Well it's OK! */ + output_filename = bfd_get_filename (abfd); + + ostream = fopen (bfd_get_filename (abfd), FOPEN_WB); + if (ostream == NULL) + { + perror (bfd_get_filename (abfd)); + xexit (1); + } + + output_file = ostream; + } + + /* fwrite in mingw32 may return int instead of bfd_size_type. Cast + the return value to bfd_size_type to avoid comparison between + signed and unsigned values. */ + if ((bfd_size_type) fwrite (cbuf, 1, nread, ostream) != nread) + fatal ("%s: %s", output_filename, strerror (errno)); + ncopied += tocopy; + } + + if (ostream != NULL) + fclose (ostream); + + output_file = NULL; + output_filename = NULL; + + chmod (bfd_get_filename (abfd), buf.st_mode); + + if (preserve_dates) + { + /* Set access time to modification time. Only st_mtime is + initialized by bfd_stat_arch_elt. */ + buf.st_atime = buf.st_mtime; + set_times (bfd_get_filename (abfd), &buf); + } + + free (cbuf); +} + +static void +write_archive (bfd *iarch) +{ + bfd *obfd; + char *old_name, *new_name; + bfd *contents_head = iarch->archive_next; + + old_name = (char *) xmalloc (strlen (bfd_get_filename (iarch)) + 1); + strcpy (old_name, bfd_get_filename (iarch)); + new_name = make_tempname (old_name); + + if (new_name == NULL) + bfd_fatal (_("could not create temporary file whilst writing archive")); + + output_filename = new_name; + + obfd = bfd_openw (new_name, bfd_get_target (iarch)); + + if (obfd == NULL) + bfd_fatal (old_name); + + output_bfd = obfd; + + bfd_set_format (obfd, bfd_archive); + + /* Request writing the archive symbol table unless we've + been explicitly requested not to. */ + obfd->has_armap = write_armap >= 0; + + if (ar_truncate) + { + /* This should really use bfd_set_file_flags, but that rejects + archives. */ + obfd->flags |= BFD_TRADITIONAL_FORMAT; + } + + if (deterministic) + obfd->flags |= BFD_DETERMINISTIC_OUTPUT; + + if (make_thin_archive || bfd_is_thin_archive (iarch)) + bfd_is_thin_archive (obfd) = 1; + + if (!bfd_set_archive_head (obfd, contents_head)) + bfd_fatal (old_name); + + if (!bfd_close (obfd)) + bfd_fatal (old_name); + + output_bfd = NULL; + output_filename = NULL; + + /* We don't care if this fails; we might be creating the archive. */ + bfd_close (iarch); + + if (smart_rename (new_name, old_name, 0) != 0) + xexit (1); + free (old_name); + free (new_name); +} + +/* Return a pointer to the pointer to the entry which should be rplacd'd + into when altering. DEFAULT_POS should be how to interpret pos_default, + and should be a pos value. */ + +static bfd ** +get_pos_bfd (bfd **contents, enum pos default_pos, const char *default_posname) +{ + bfd **after_bfd = contents; + enum pos realpos; + const char *realposname; + + if (postype == pos_default) + { + realpos = default_pos; + realposname = default_posname; + } + else + { + realpos = postype; + realposname = posname; + } + + if (realpos == pos_end) + { + while (*after_bfd) + after_bfd = &((*after_bfd)->archive_next); + } + else + { + for (; *after_bfd; after_bfd = &(*after_bfd)->archive_next) + if (FILENAME_CMP ((*after_bfd)->filename, realposname) == 0) + { + if (realpos == pos_after) + after_bfd = &(*after_bfd)->archive_next; + break; + } + } + return after_bfd; +} + +static void +delete_members (bfd *arch, char **files_to_delete) +{ + bfd **current_ptr_ptr; + bfd_boolean found; + bfd_boolean something_changed = FALSE; + int match_count; + + for (; *files_to_delete != NULL; ++files_to_delete) + { + /* In a.out systems, the armap is optional. It's also called + __.SYMDEF. So if the user asked to delete it, we should remember + that fact. This isn't quite right for COFF systems (where + __.SYMDEF might be regular member), but it's very unlikely + to be a problem. FIXME */ + + if (!strcmp (*files_to_delete, "__.SYMDEF")) + { + arch->has_armap = FALSE; + write_armap = -1; + continue; + } + + found = FALSE; + match_count = 0; + current_ptr_ptr = &(arch->archive_next); + while (*current_ptr_ptr) + { + if (FILENAME_CMP (normalize (*files_to_delete, arch), + (*current_ptr_ptr)->filename) == 0) + { + ++match_count; + if (counted_name_mode + && match_count != counted_name_counter) + { + /* Counting, and didn't match on count; go on to the + next one. */ + } + else + { + found = TRUE; + something_changed = TRUE; + if (verbose) + printf ("d - %s\n", + *files_to_delete); + *current_ptr_ptr = ((*current_ptr_ptr)->archive_next); + goto next_file; + } + } + + current_ptr_ptr = &((*current_ptr_ptr)->archive_next); + } + + if (verbose && !found) + { + /* xgettext:c-format */ + printf (_("No member named `%s'\n"), *files_to_delete); + } + next_file: + ; + } + + if (something_changed) + write_archive (arch); + else + output_filename = NULL; +} + + +/* Reposition existing members within an archive */ + +static void +move_members (bfd *arch, char **files_to_move) +{ + bfd **after_bfd; /* New entries go after this one */ + bfd **current_ptr_ptr; /* cdr pointer into contents */ + + for (; *files_to_move; ++files_to_move) + { + current_ptr_ptr = &(arch->archive_next); + while (*current_ptr_ptr) + { + bfd *current_ptr = *current_ptr_ptr; + if (FILENAME_CMP (normalize (*files_to_move, arch), + current_ptr->filename) == 0) + { + /* Move this file to the end of the list - first cut from + where it is. */ + bfd *link_bfd; + *current_ptr_ptr = current_ptr->archive_next; + + /* Now glue to end */ + after_bfd = get_pos_bfd (&arch->archive_next, pos_end, NULL); + link_bfd = *after_bfd; + *after_bfd = current_ptr; + current_ptr->archive_next = link_bfd; + + if (verbose) + printf ("m - %s\n", *files_to_move); + + goto next_file; + } + + current_ptr_ptr = &((*current_ptr_ptr)->archive_next); + } + /* xgettext:c-format */ + fatal (_("no entry %s in archive %s!"), *files_to_move, arch->filename); + + next_file:; + } + + write_archive (arch); +} + +/* Ought to default to replacing in place, but this is existing practice! */ + +static void +replace_members (bfd *arch, char **files_to_move, bfd_boolean quick) +{ + bfd_boolean changed = FALSE; + bfd **after_bfd; /* New entries go after this one. */ + bfd *current; + bfd **current_ptr; + + while (files_to_move && *files_to_move) + { + if (! quick) + { + current_ptr = &arch->archive_next; + while (*current_ptr) + { + current = *current_ptr; + + /* For compatibility with existing ar programs, we + permit the same file to be added multiple times. */ + if (FILENAME_CMP (normalize (*files_to_move, arch), + normalize (current->filename, arch)) == 0 + && current->arelt_data != NULL) + { + if (newer_only) + { + struct stat fsbuf, asbuf; + + if (stat (*files_to_move, &fsbuf) != 0) + { + if (errno != ENOENT) + bfd_fatal (*files_to_move); + goto next_file; + } + if (bfd_stat_arch_elt (current, &asbuf) != 0) + /* xgettext:c-format */ + fatal (_("internal stat error on %s"), + current->filename); + + if (fsbuf.st_mtime <= asbuf.st_mtime) + goto next_file; + } + + after_bfd = get_pos_bfd (&arch->archive_next, pos_after, + current->filename); + if (ar_emul_replace (after_bfd, *files_to_move, + target, verbose)) + { + /* Snip out this entry from the chain. */ + *current_ptr = (*current_ptr)->archive_next; + changed = TRUE; + } + + goto next_file; + } + current_ptr = &(current->archive_next); + } + } + + /* Add to the end of the archive. */ + after_bfd = get_pos_bfd (&arch->archive_next, pos_end, NULL); + + if (ar_emul_append (after_bfd, *files_to_move, target, + verbose, make_thin_archive)) + changed = TRUE; + + next_file:; + + files_to_move++; + } + + if (changed) + write_archive (arch); + else + output_filename = NULL; +} + +static int +ranlib_only (const char *archname) +{ + bfd *arch; + + if (get_file_size (archname) < 1) + return 1; + write_armap = 1; + arch = open_inarch (archname, (char *) NULL); + if (arch == NULL) + xexit (1); + write_archive (arch); + return 0; +} + +/* Update the timestamp of the symbol map of an archive. */ + +static int +ranlib_touch (const char *archname) +{ +#ifdef __GO32__ + /* I don't think updating works on go32. */ + ranlib_only (archname); +#else + int f; + bfd *arch; + char **matching; + + if (get_file_size (archname) < 1) + return 1; + f = open (archname, O_RDWR | O_BINARY, 0); + if (f < 0) + { + bfd_set_error (bfd_error_system_call); + bfd_fatal (archname); + } + + arch = bfd_fdopenr (archname, (const char *) NULL, f); + if (arch == NULL) + bfd_fatal (archname); + if (! bfd_check_format_matches (arch, bfd_archive, &matching)) + { + bfd_nonfatal (archname); + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (matching); + free (matching); + } + xexit (1); + } + + if (! bfd_has_map (arch)) + /* xgettext:c-format */ + fatal (_("%s: no archive map to update"), archname); + + if (deterministic) + arch->flags |= BFD_DETERMINISTIC_OUTPUT; + + bfd_update_armap_timestamp (arch); + + if (! bfd_close (arch)) + bfd_fatal (archname); +#endif + return 0; +} + +/* Things which are interesting to map over all or some of the files: */ + +static void +print_descr (bfd *abfd) +{ + print_arelt_descr (stdout, abfd, verbose); +} diff --git a/support/sdbinutils/binutils/arlex.c b/support/sdbinutils/binutils/arlex.c new file mode 100644 index 0000000..fe70d9e --- /dev/null +++ b/support/sdbinutils/binutils/arlex.c @@ -0,0 +1,2042 @@ + +#line 3 "arlex.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern int yyleng; + +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = NULL; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); + +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); + +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define yywrap() (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +FILE *yyin = NULL, *yyout = NULL; + +typedef int yy_state_type; + +extern int yylineno; +int yylineno = 1; + +extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; +#define YY_NUM_RULES 40 +#define YY_END_OF_BUFFER 41 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[177] = + { 0, + 0, 0, 41, 40, 39, 38, 35, 32, 33, 36, + 40, 34, 37, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 36, 31, 37, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 7, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 22, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + + 35, 35, 35, 10, 11, 12, 35, 15, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 25, 26, 27, + 35, 30, 35, 35, 35, 3, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 18, 35, 35, 35, 35, + 35, 35, 35, 1, 2, 4, 5, 35, 35, 35, + 35, 35, 16, 17, 19, 20, 35, 35, 35, 35, + 35, 35, 8, 9, 13, 14, 35, 23, 24, 28, + 29, 35, 35, 6, 21, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 1, 1, 4, 1, 1, 1, 5, + 6, 7, 8, 9, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 10, 1, + 1, 1, 1, 1, 11, 12, 13, 14, 15, 16, + 4, 17, 18, 4, 4, 19, 20, 21, 22, 23, + 4, 24, 25, 26, 27, 28, 4, 29, 30, 4, + 1, 4, 1, 1, 4, 1, 31, 32, 33, 34, + + 35, 36, 4, 37, 38, 4, 4, 39, 40, 41, + 42, 43, 4, 44, 45, 46, 47, 48, 4, 49, + 50, 4, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static const YY_CHAR yy_meta[51] = + { 0, + 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 + } ; + +static const flex_int16_t yy_base[180] = + { 0, + 0, 0, 193, 194, 194, 194, 0, 194, 194, 0, + 190, 194, 0, 177, 32, 37, 32, 163, 174, 170, + 164, 171, 174, 169, 149, 15, 22, 17, 135, 146, + 142, 136, 143, 146, 141, 0, 0, 194, 0, 161, + 159, 158, 153, 147, 156, 143, 149, 148, 141, 150, + 141, 135, 138, 127, 125, 124, 119, 113, 122, 109, + 115, 114, 107, 116, 107, 101, 104, 43, 136, 135, + 130, 129, 0, 119, 123, 118, 114, 118, 119, 122, + 124, 25, 104, 103, 98, 97, 0, 87, 91, 86, + 82, 86, 87, 90, 92, 105, 100, 97, 94, 93, + + 105, 106, 102, 0, 0, 0, 104, 0, 92, 75, + 70, 67, 64, 63, 75, 76, 72, 0, 0, 0, + 74, 0, 62, 91, 88, 0, 86, 85, 73, 85, + 79, 83, 70, 62, 59, 0, 57, 56, 44, 56, + 50, 54, 41, 0, 0, 0, 0, 63, 58, 59, + 67, 66, 0, 0, 0, 0, 38, 33, 34, 42, + 41, 51, 0, 0, 0, 0, 30, 0, 0, 0, + 0, 43, 21, 0, 0, 194, 65, 66, 69 + } ; + +static const flex_int16_t yy_def[180] = + { 0, + 176, 1, 176, 176, 176, 176, 177, 176, 176, 178, + 176, 176, 179, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 178, 176, 179, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 0, 176, 176, 176 + } ; + +static const flex_int16_t yy_nxt[245] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 7, 15, 16, 17, 18, 19, 7, 20, 7, + 7, 21, 7, 22, 23, 7, 7, 24, 7, 7, + 25, 7, 26, 27, 28, 29, 30, 7, 31, 7, + 7, 32, 7, 33, 34, 7, 7, 35, 7, 7, + 41, 43, 45, 55, 44, 42, 57, 59, 56, 58, + 46, 96, 97, 110, 111, 60, 37, 36, 37, 39, + 175, 39, 174, 173, 172, 171, 170, 169, 168, 167, + 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, + 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, + + 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, + 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, + 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, + 116, 115, 114, 113, 112, 109, 108, 107, 106, 105, + 104, 103, 102, 101, 100, 99, 98, 95, 94, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, + 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, + 62, 61, 54, 53, 52, 51, 50, 49, 48, 47, + 40, 38, 176, 3, 176, 176, 176, 176, 176, 176, + + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176 + } ; + +static const flex_int16_t yy_chk[245] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 15, 16, 17, 26, 16, 15, 27, 28, 26, 27, + 17, 68, 68, 82, 82, 28, 178, 177, 178, 179, + 173, 179, 172, 167, 162, 161, 160, 159, 158, 157, + 152, 151, 150, 149, 148, 143, 142, 141, 140, 139, + 138, 137, 135, 134, 133, 132, 131, 130, 129, 128, + + 127, 125, 124, 123, 121, 117, 116, 115, 114, 113, + 112, 111, 110, 109, 107, 103, 102, 101, 100, 99, + 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, + 88, 86, 85, 84, 83, 81, 80, 79, 78, 77, + 76, 75, 74, 72, 71, 70, 69, 67, 66, 65, + 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, + 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, + 44, 43, 42, 41, 40, 35, 34, 33, 32, 31, + 30, 29, 25, 24, 23, 22, 21, 20, 19, 18, + 14, 11, 3, 176, 176, 176, 176, 176, 176, 176, + + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int yy_flex_debug; +int yy_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "arlex.l" +#define YY_NO_INPUT 1 +#line 4 "arlex.l" +/* arlex.l - Strange script language lexer */ + +/* Copyright (C) 1992-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + + +/* Contributed by Steve Chamberlain . */ + +#define DONTDECLARE_MALLOC +#include "ansidecl.h" +#include "libiberty.h" +#include "arparse.h" + +#ifndef YY_NO_UNPUT +#define YY_NO_UNPUT +#endif + +extern int yylex (void); + +int linenumber; +#line 592 "arlex.c" +#line 593 "arlex.c" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals ( void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( void ); + +int yyget_debug ( void ); + +void yyset_debug ( int debug_flag ); + +YY_EXTRA_TYPE yyget_extra ( void ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined ); + +FILE *yyget_in ( void ); + +void yyset_in ( FILE * _in_str ); + +FILE *yyget_out ( void ); + +void yyset_out ( FILE * _out_str ); + + int yyget_leng ( void ); + +char *yyget_text ( void ); + +int yyget_lineno ( void ); + +void yyset_lineno ( int _line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( void ); +#else +extern int yywrap ( void ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * ); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( void ); +#else +static int input ( void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + int n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex (void); + +#define YY_DECL int yylex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + { +#line 45 "arlex.l" + + +#line 811 "arlex.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 177 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 194 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 47 "arlex.l" +{ return ADDLIB; } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 48 "arlex.l" +{ return ADDMOD; } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 49 "arlex.l" +{ return CLEAR; } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 50 "arlex.l" +{ return CREATE; } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 51 "arlex.l" +{ return DELETE; } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 52 "arlex.l" +{ return DIRECTORY; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 53 "arlex.l" +{ return END; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 54 "arlex.l" +{ return EXTRACT; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 55 "arlex.l" +{ return FULLDIR; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 56 "arlex.l" +{ return HELP; } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 57 "arlex.l" +{ return LIST; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 58 "arlex.l" +{ return OPEN; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 59 "arlex.l" +{ return REPLACE; } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 60 "arlex.l" +{ return VERBOSE; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 61 "arlex.l" +{ return SAVE; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 62 "arlex.l" +{ return ADDLIB; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 63 "arlex.l" +{ return ADDMOD; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 64 "arlex.l" +{ return CLEAR; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 65 "arlex.l" +{ return CREATE; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 66 "arlex.l" +{ return DELETE; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 67 "arlex.l" +{ return DIRECTORY; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 68 "arlex.l" +{ return END; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 69 "arlex.l" +{ return EXTRACT; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 70 "arlex.l" +{ return FULLDIR; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 71 "arlex.l" +{ return HELP; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 72 "arlex.l" +{ return LIST; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 73 "arlex.l" +{ return OPEN; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 74 "arlex.l" +{ return REPLACE; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 75 "arlex.l" +{ return VERBOSE; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 76 "arlex.l" +{ return SAVE; } + YY_BREAK +case 31: +/* rule 31 can match eol */ +YY_RULE_SETUP +#line 77 "arlex.l" +{ linenumber ++; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 78 "arlex.l" +{ return '('; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 79 "arlex.l" +{ return ')'; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 80 "arlex.l" +{ return ','; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 81 "arlex.l" +{ + yylval.name = xstrdup (yytext); + return FILENAME; + } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 85 "arlex.l" +{ } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 86 "arlex.l" +{ } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 87 "arlex.l" +{ } + YY_BREAK +case 39: +/* rule 39 can match eol */ +YY_RULE_SETUP +#line 88 "arlex.l" +{ linenumber ++; return NEWLINE; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 90 "arlex.l" +ECHO; + YY_BREAK +#line 1073 "arlex.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + yy_state_type yy_current_state; + char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 177 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + int yy_is_jam; + char *yy_cp = (yy_c_buf_p); + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 177 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 176); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yy_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf ); + + yyfree( (void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr ) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg ) +{ + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int yyget_lineno (void) +{ + + return yylineno; +} + +/** Get the input stream. + * + */ +FILE *yyget_in (void) +{ + return yyin; +} + +/** Get the output stream. + * + */ +FILE *yyget_out (void) +{ + return yyout; +} + +/** Get the length of the current token. + * + */ +int yyget_leng (void) +{ + return yyleng; +} + +/** Get the current token. + * + */ + +char *yyget_text (void) +{ + return yytext; +} + +/** Set the current line number. + * @param _line_number line number + * + */ +void yyset_lineno (int _line_number ) +{ + + yylineno = _line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str ) +{ + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str ) +{ + yyout = _out_str ; +} + +int yyget_debug (void) +{ + return yy_flex_debug; +} + +void yyset_debug (int _bdebug ) +{ + yy_flex_debug = _bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = NULL; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = NULL; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } + + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n ) +{ + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s ) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 90 "arlex.l" + + diff --git a/support/sdbinutils/binutils/arlex.l b/support/sdbinutils/binutils/arlex.l new file mode 100644 index 0000000..f778f63 --- /dev/null +++ b/support/sdbinutils/binutils/arlex.l @@ -0,0 +1,90 @@ +%option noinput nounput noyywrap + +%{ +/* arlex.l - Strange script language lexer */ + +/* Copyright (C) 1992-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + + +/* Contributed by Steve Chamberlain . */ + +#define DONTDECLARE_MALLOC +#include "ansidecl.h" +#include "libiberty.h" +#include "arparse.h" + +#ifndef YY_NO_UNPUT +#define YY_NO_UNPUT +#endif + +extern int yylex (void); + +int linenumber; +%} + +%a 10000 +%o 25000 + +%% + +"ADDLIB" { return ADDLIB; } +"ADDMOD" { return ADDMOD; } +"CLEAR" { return CLEAR; } +"CREATE" { return CREATE; } +"DELETE" { return DELETE; } +"DIRECTORY" { return DIRECTORY; } +"END" { return END; } +"EXTRACT" { return EXTRACT; } +"FULLDIR" { return FULLDIR; } +"HELP" { return HELP; } +"LIST" { return LIST; } +"OPEN" { return OPEN; } +"REPLACE" { return REPLACE; } +"VERBOSE" { return VERBOSE; } +"SAVE" { return SAVE; } +"addlib" { return ADDLIB; } +"addmod" { return ADDMOD; } +"clear" { return CLEAR; } +"create" { return CREATE; } +"delete" { return DELETE; } +"directory" { return DIRECTORY; } +"end" { return END; } +"extract" { return EXTRACT; } +"fulldir" { return FULLDIR; } +"help" { return HELP; } +"list" { return LIST; } +"open" { return OPEN; } +"replace" { return REPLACE; } +"verbose" { return VERBOSE; } +"save" { return SAVE; } +"+\n" { linenumber ++; } +"(" { return '('; } +")" { return ')'; } +"," { return ','; } +[A-Za-z0-9/\\$:.\-\_]+ { + yylval.name = xstrdup (yytext); + return FILENAME; + } +"*".* { } +";".* { } +" " { } +"\n" { linenumber ++; return NEWLINE; } + +%% diff --git a/support/sdbinutils/binutils/arparse.c b/support/sdbinutils/binutils/arparse.c new file mode 100644 index 0000000..1facc88 --- /dev/null +++ b/support/sdbinutils/binutils/arparse.c @@ -0,0 +1,1689 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "3.0.4" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* Copy the first part of user declarations. */ +#line 1 "arparse.y" /* yacc.c:339 */ + +/* arparse.y - Strange script language parser */ + +/* Copyright (C) 1992-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + + +/* Contributed by Steve Chamberlain + sac@cygnus.com + +*/ +#define DONTDECLARE_MALLOC +#include "sysdep.h" +#include "bfd.h" +#include "arsup.h" +extern int verbose; +extern int yylex (void); +static int yyerror (const char *); + +#line 102 "arparse.c" /* yacc.c:339 */ + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* In a future release of Bison, this section will be replaced + by #include "y.tab.h". */ +#ifndef YY_YY_ARPARSE_H_INCLUDED +# define YY_YY_ARPARSE_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + NEWLINE = 258, + VERBOSE = 259, + FILENAME = 260, + ADDLIB = 261, + LIST = 262, + ADDMOD = 263, + CLEAR = 264, + CREATE = 265, + DELETE = 266, + DIRECTORY = 267, + END = 268, + EXTRACT = 269, + FULLDIR = 270, + HELP = 271, + QUIT = 272, + REPLACE = 273, + SAVE = 274, + OPEN = 275 + }; +#endif +/* Tokens. */ +#define NEWLINE 258 +#define VERBOSE 259 +#define FILENAME 260 +#define ADDLIB 261 +#define LIST 262 +#define ADDMOD 263 +#define CLEAR 264 +#define CREATE 265 +#define DELETE 266 +#define DIRECTORY 267 +#define END 268 +#define EXTRACT 269 +#define FULLDIR 270 +#define HELP 271 +#define QUIT 272 +#define REPLACE 273 +#define SAVE 274 +#define OPEN 275 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 37 "arparse.y" /* yacc.c:355 */ + + char *name; +struct list *list ; + + +#line 188 "arparse.c" /* yacc.c:355 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_ARPARSE_H_INCLUDED */ + +/* Copy the second part of user declarations. */ + +#line 205 "arparse.c" /* yacc.c:358 */ + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 34 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 24 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 22 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 42 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 53 + +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 275 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 21, 22, 2, 2, 23, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20 +}; + +#if YYDEBUG + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 68, 68, 68, 72, 73, 77, 81, 82, 83, + 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, + 94, 95, 96, 101, 106, 111, 116, 120, 125, 130, + 137, 142, 148, 152, 159, 161, 165, 168, 172, 178, + 183, 184, 189 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || 0 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NEWLINE", "VERBOSE", "FILENAME", + "ADDLIB", "LIST", "ADDMOD", "CLEAR", "CREATE", "DELETE", "DIRECTORY", + "END", "EXTRACT", "FULLDIR", "HELP", "QUIT", "REPLACE", "SAVE", "OPEN", + "'('", "')'", "','", "$accept", "start", "$@1", "session", + "command_line", "command", "extract_command", "replace_command", + "clear_command", "delete_command", "addmod_command", "list_command", + "save_command", "open_command", "create_command", "addlib_command", + "directory_command", "optional_filename", "modulelist", "modulename", + "optcomma", "verbose_command", YY_NULLPTR +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 40, 41, 44 +}; +# endif + +#define YYPACT_NINF -14 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-14))) + +#define YYTABLE_NINF -42 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int8 yypact[] = +{ + -14, 1, -14, -14, 5, -14, -14, -14, 2, -14, + -14, -14, 21, -14, 22, -14, -14, -14, -14, 23, + -14, 26, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, 10, -3, -14, -3, 10, -3, + -3, -14, -14, -14, -14, -14, 27, 28, -1, -14, + -14, -14, -14 +}; + + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 0, 5, 1, 0, 20, 42, 21, 0, 28, + 39, 25, 0, 39, 0, 19, 39, 39, 29, 0, + 4, 0, 15, 16, 12, 17, 13, 18, 14, 7, + 8, 11, 10, 9, 37, 27, 31, 26, 37, 23, + 24, 30, 6, 39, 32, 40, 0, 35, 41, 38, + 34, 33, 36 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -4, -13, + -14, -14 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 1, 2, 4, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 51, 44, 35, + 46, 33 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int8 yytable[] = +{ + 37, 3, -41, 39, 40, -3, 5, 34, -22, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 45, 52, 45, 17, 18, 19, 36, 38, 41, 42, + 48, 43, 49, 50, 47 +}; + +static const yytype_uint8 yycheck[] = +{ + 13, 0, 5, 16, 17, 0, 1, 5, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 23, 22, 23, 18, 19, 20, 5, 5, 5, 3, + 43, 21, 5, 5, 38 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 25, 26, 0, 27, 1, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 18, 19, 20, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 45, 5, 43, 5, 43, 5, 43, + 43, 5, 3, 21, 42, 23, 44, 42, 43, 5, + 5, 41, 22 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 24, 26, 25, 27, 27, 28, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 41, 42, 42, 43, 43, + 44, 44, 45 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 2, 2, 0, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 2, 2, 1, 2, 2, 1, 1, + 2, 2, 3, 4, 1, 0, 3, 0, 3, 0, + 1, 0, 1 +}; + + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +{ + unsigned long int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +yystrlen (const char *yystr) +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +yystpcpy (char *yydest, const char *yysrc) +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +{ + YYUSE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 68 "arparse.y" /* yacc.c:1646 */ + { prompt(); } +#line 1318 "arparse.c" /* yacc.c:1646 */ + break; + + case 6: +#line 77 "arparse.y" /* yacc.c:1646 */ + { prompt(); } +#line 1324 "arparse.c" /* yacc.c:1646 */ + break; + + case 19: +#line 93 "arparse.y" /* yacc.c:1646 */ + { ar_end(); return 0; } +#line 1330 "arparse.c" /* yacc.c:1646 */ + break; + + case 21: +#line 95 "arparse.y" /* yacc.c:1646 */ + { yyerror("foo"); } +#line 1336 "arparse.c" /* yacc.c:1646 */ + break; + + case 23: +#line 102 "arparse.y" /* yacc.c:1646 */ + { ar_extract((yyvsp[0].list)); } +#line 1342 "arparse.c" /* yacc.c:1646 */ + break; + + case 24: +#line 107 "arparse.y" /* yacc.c:1646 */ + { ar_replace((yyvsp[0].list)); } +#line 1348 "arparse.c" /* yacc.c:1646 */ + break; + + case 25: +#line 112 "arparse.y" /* yacc.c:1646 */ + { ar_clear(); } +#line 1354 "arparse.c" /* yacc.c:1646 */ + break; + + case 26: +#line 117 "arparse.y" /* yacc.c:1646 */ + { ar_delete((yyvsp[0].list)); } +#line 1360 "arparse.c" /* yacc.c:1646 */ + break; + + case 27: +#line 121 "arparse.y" /* yacc.c:1646 */ + { ar_addmod((yyvsp[0].list)); } +#line 1366 "arparse.c" /* yacc.c:1646 */ + break; + + case 28: +#line 126 "arparse.y" /* yacc.c:1646 */ + { ar_list(); } +#line 1372 "arparse.c" /* yacc.c:1646 */ + break; + + case 29: +#line 131 "arparse.y" /* yacc.c:1646 */ + { ar_save(); } +#line 1378 "arparse.c" /* yacc.c:1646 */ + break; + + case 30: +#line 138 "arparse.y" /* yacc.c:1646 */ + { ar_open((yyvsp[0].name),0); } +#line 1384 "arparse.c" /* yacc.c:1646 */ + break; + + case 31: +#line 143 "arparse.y" /* yacc.c:1646 */ + { ar_open((yyvsp[0].name),1); } +#line 1390 "arparse.c" /* yacc.c:1646 */ + break; + + case 32: +#line 149 "arparse.y" /* yacc.c:1646 */ + { ar_addlib((yyvsp[-1].name),(yyvsp[0].list)); } +#line 1396 "arparse.c" /* yacc.c:1646 */ + break; + + case 33: +#line 153 "arparse.y" /* yacc.c:1646 */ + { ar_directory((yyvsp[-2].name), (yyvsp[-1].list), (yyvsp[0].name)); } +#line 1402 "arparse.c" /* yacc.c:1646 */ + break; + + case 34: +#line 160 "arparse.y" /* yacc.c:1646 */ + { (yyval.name) = (yyvsp[0].name); } +#line 1408 "arparse.c" /* yacc.c:1646 */ + break; + + case 35: +#line 161 "arparse.y" /* yacc.c:1646 */ + { (yyval.name) = 0; } +#line 1414 "arparse.c" /* yacc.c:1646 */ + break; + + case 36: +#line 166 "arparse.y" /* yacc.c:1646 */ + { (yyval.list) = (yyvsp[-1].list); } +#line 1420 "arparse.c" /* yacc.c:1646 */ + break; + + case 37: +#line 168 "arparse.y" /* yacc.c:1646 */ + { (yyval.list) = 0; } +#line 1426 "arparse.c" /* yacc.c:1646 */ + break; + + case 38: +#line 173 "arparse.y" /* yacc.c:1646 */ + { struct list *n = (struct list *) malloc(sizeof(struct list)); + n->next = (yyvsp[-2].list); + n->name = (yyvsp[0].name); + (yyval.list) = n; + } +#line 1436 "arparse.c" /* yacc.c:1646 */ + break; + + case 39: +#line 178 "arparse.y" /* yacc.c:1646 */ + { (yyval.list) = 0; } +#line 1442 "arparse.c" /* yacc.c:1646 */ + break; + + case 42: +#line 190 "arparse.y" /* yacc.c:1646 */ + { verbose = !verbose; } +#line 1448 "arparse.c" /* yacc.c:1646 */ + break; + + +#line 1452 "arparse.c" /* yacc.c:1646 */ + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} +#line 194 "arparse.y" /* yacc.c:1906 */ + + +static int +yyerror (const char *x ATTRIBUTE_UNUSED) +{ + extern int linenumber; + + printf (_("Syntax error in archive script, line %d\n"), linenumber + 1); + return 0; +} diff --git a/support/sdbinutils/binutils/arparse.h b/support/sdbinutils/binutils/arparse.h new file mode 100644 index 0000000..0014ee6 --- /dev/null +++ b/support/sdbinutils/binutils/arparse.h @@ -0,0 +1,112 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef YY_YY_ARPARSE_H_INCLUDED +# define YY_YY_ARPARSE_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + NEWLINE = 258, + VERBOSE = 259, + FILENAME = 260, + ADDLIB = 261, + LIST = 262, + ADDMOD = 263, + CLEAR = 264, + CREATE = 265, + DELETE = 266, + DIRECTORY = 267, + END = 268, + EXTRACT = 269, + FULLDIR = 270, + HELP = 271, + QUIT = 272, + REPLACE = 273, + SAVE = 274, + OPEN = 275 + }; +#endif +/* Tokens. */ +#define NEWLINE 258 +#define VERBOSE 259 +#define FILENAME 260 +#define ADDLIB 261 +#define LIST 262 +#define ADDMOD 263 +#define CLEAR 264 +#define CREATE 265 +#define DELETE 266 +#define DIRECTORY 267 +#define END 268 +#define EXTRACT 269 +#define FULLDIR 270 +#define HELP 271 +#define QUIT 272 +#define REPLACE 273 +#define SAVE 274 +#define OPEN 275 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 37 "arparse.y" /* yacc.c:1909 */ + + char *name; +struct list *list ; + + +#line 100 "arparse.h" /* yacc.c:1909 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_ARPARSE_H_INCLUDED */ diff --git a/support/sdbinutils/binutils/arparse.y b/support/sdbinutils/binutils/arparse.y new file mode 100644 index 0000000..217c13a --- /dev/null +++ b/support/sdbinutils/binutils/arparse.y @@ -0,0 +1,203 @@ +%{ +/* arparse.y - Strange script language parser */ + +/* Copyright (C) 1992-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + + +/* Contributed by Steve Chamberlain + sac@cygnus.com + +*/ +#define DONTDECLARE_MALLOC +#include "sysdep.h" +#include "bfd.h" +#include "arsup.h" +extern int verbose; +extern int yylex (void); +static int yyerror (const char *); +%} + +%union { + char *name; +struct list *list ; + +}; + +%token NEWLINE +%token VERBOSE +%token FILENAME +%token ADDLIB +%token LIST +%token ADDMOD +%token CLEAR +%token CREATE +%token DELETE +%token DIRECTORY +%token END +%token EXTRACT +%token FULLDIR +%token HELP +%token QUIT +%token REPLACE +%token SAVE +%token OPEN + +%type modulelist +%type modulename +%type optional_filename +%% + +start: + { prompt(); } session + ; + +session: + session command_line + | + ; + +command_line: + command NEWLINE { prompt(); } + ; + +command: + open_command + | create_command + | verbose_command + | directory_command + | addlib_command + | clear_command + | addmod_command + | save_command + | extract_command + | replace_command + | delete_command + | list_command + | END { ar_end(); return 0; } + | error + | FILENAME { yyerror("foo"); } + | + ; + + +extract_command: + EXTRACT modulename + { ar_extract($2); } + ; + +replace_command: + REPLACE modulename + { ar_replace($2); } + ; + +clear_command: + CLEAR + { ar_clear(); } + ; + +delete_command: + DELETE modulename + { ar_delete($2); } + ; +addmod_command: + ADDMOD modulename + { ar_addmod($2); } + ; + +list_command: + LIST + { ar_list(); } + ; + +save_command: + SAVE + { ar_save(); } + ; + + + +open_command: + OPEN FILENAME + { ar_open($2,0); } + ; + +create_command: + CREATE FILENAME + { ar_open($2,1); } + ; + + +addlib_command: + ADDLIB FILENAME modulelist + { ar_addlib($2,$3); } + ; +directory_command: + DIRECTORY FILENAME modulelist optional_filename + { ar_directory($2, $3, $4); } + ; + + + +optional_filename: + FILENAME + { $$ = $1; } + | { $$ = 0; } + ; + +modulelist: + '(' modulename ')' + { $$ = $2; } + | + { $$ = 0; } + ; + +modulename: + modulename optcomma FILENAME + { struct list *n = (struct list *) malloc(sizeof(struct list)); + n->next = $1; + n->name = $3; + $$ = n; + } + | { $$ = 0; } + ; + + +optcomma: + ',' + | + ; + + +verbose_command: + VERBOSE + { verbose = !verbose; } + ; + + +%% + +static int +yyerror (const char *x ATTRIBUTE_UNUSED) +{ + extern int linenumber; + + printf (_("Syntax error in archive script, line %d\n"), linenumber + 1); + return 0; +} diff --git a/support/sdbinutils/binutils/arsup.c b/support/sdbinutils/binutils/arsup.c new file mode 100644 index 0000000..ee2bb9b --- /dev/null +++ b/support/sdbinutils/binutils/arsup.c @@ -0,0 +1,489 @@ +/* arsup.c - Archive support for MRI compatibility + Copyright (C) 1992-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + + +/* Contributed by Steve Chamberlain + sac@cygnus.com + + This file looks after requests from arparse.y, to provide the MRI + style librarian command syntax + 1 word LIST. */ + +#include "sysdep.h" +#include "bfd.h" +#include "libiberty.h" +#include "filenames.h" +#include "bucomm.h" +#include "arsup.h" + +static void map_over_list + (bfd *, void (*function) (bfd *, bfd *), struct list *); +static void ar_directory_doer (bfd *, bfd *); +static void ar_addlib_doer (bfd *, bfd *); + +extern int verbose; +extern int deterministic; + +static bfd *obfd; +static char *real_name; +static FILE *outfile; + +static void +map_over_list (bfd *arch, void (*function) (bfd *, bfd *), struct list *list) +{ + bfd *head; + + if (list == NULL) + { + bfd *next; + + head = arch->archive_next; + while (head != NULL) + { + next = head->archive_next; + function (head, (bfd *) NULL); + head = next; + } + } + else + { + struct list *ptr; + + /* This may appear to be a baroque way of accomplishing what we + want. however we have to iterate over the filenames in order + to notice where a filename is requested but does not exist in + the archive. Ditto mapping over each file each time -- we + want to hack multiple references. */ + for (ptr = list; ptr; ptr = ptr->next) + { + bfd_boolean found = FALSE; + bfd *prev = arch; + + for (head = arch->archive_next; head; head = head->archive_next) + { + if (head->filename != NULL + && FILENAME_CMP (ptr->name, head->filename) == 0) + { + found = TRUE; + function (head, prev); + } + prev = head; + } + if (! found) + fprintf (stderr, _("No entry %s in archive.\n"), ptr->name); + } + } +} + + + +static void +ar_directory_doer (bfd *abfd, bfd *ignore ATTRIBUTE_UNUSED) +{ + print_arelt_descr(outfile, abfd, verbose); +} + +void +ar_directory (char *ar_name, struct list *list, char *output) +{ + bfd *arch; + + arch = open_inarch (ar_name, (char *) NULL); + if (output) + { + outfile = fopen(output,"w"); + if (outfile == 0) + { + outfile = stdout; + fprintf (stderr,_("Can't open file %s\n"), output); + output = 0; + } + } + else + outfile = stdout; + + map_over_list (arch, ar_directory_doer, list); + + bfd_close (arch); + + if (output) + fclose (outfile); +} + +void +prompt (void) +{ + extern int interactive; + + if (interactive) + { + printf ("AR >"); + fflush (stdout); + } +} + +void +maybequit (void) +{ + if (! interactive) + xexit (9); +} + + +void +ar_open (char *name, int t) +{ + char *tname = (char *) xmalloc (strlen (name) + 10); + const char *bname = lbasename (name); + real_name = name; + + /* Prepend tmp- to the beginning, to avoid file-name clashes after + truncation on filesystems with limited namespaces (DOS). */ + sprintf (tname, "%.*stmp-%s", (int) (bname - name), name, bname); + obfd = bfd_openw (tname, NULL); + + if (!obfd) + { + fprintf (stderr, + _("%s: Can't open output archive %s\n"), + program_name, tname); + + maybequit (); + } + else + { + if (!t) + { + bfd **ptr; + bfd *element; + bfd *ibfd; + + ibfd = bfd_openr (name, NULL); + + if (!ibfd) + { + fprintf (stderr,_("%s: Can't open input archive %s\n"), + program_name, name); + maybequit (); + return; + } + + if (!bfd_check_format(ibfd, bfd_archive)) + { + fprintf (stderr, + _("%s: file %s is not an archive\n"), + program_name, name); + maybequit (); + return; + } + + ptr = &(obfd->archive_head); + element = bfd_openr_next_archived_file (ibfd, NULL); + + while (element) + { + *ptr = element; + ptr = &element->archive_next; + element = bfd_openr_next_archived_file (ibfd, element); + } + } + + bfd_set_format (obfd, bfd_archive); + + obfd->has_armap = 1; + obfd->is_thin_archive = 0; + } +} + +static void +ar_addlib_doer (bfd *abfd, bfd *prev) +{ + /* Add this module to the output bfd. */ + if (prev != NULL) + prev->archive_next = abfd->archive_next; + + abfd->archive_next = obfd->archive_head; + obfd->archive_head = abfd; +} + +void +ar_addlib (char *name, struct list *list) +{ + if (obfd == NULL) + { + fprintf (stderr, _("%s: no output archive specified yet\n"), program_name); + maybequit (); + } + else + { + bfd *arch; + + arch = open_inarch (name, (char *) NULL); + if (arch != NULL) + map_over_list (arch, ar_addlib_doer, list); + + /* Don't close the bfd, since it will make the elements disappear. */ + } +} + +void +ar_addmod (struct list *list) +{ + if (!obfd) + { + fprintf (stderr, _("%s: no open output archive\n"), program_name); + maybequit (); + } + else + { + while (list) + { + bfd *abfd; + +#if BFD_SUPPORTS_PLUGINS + abfd = bfd_openr (list->name, "plugin"); +#else + abfd = bfd_openr (list->name, NULL); +#endif + if (!abfd) + { + fprintf (stderr, _("%s: can't open file %s\n"), + program_name, list->name); + maybequit (); + } + else + { + abfd->archive_next = obfd->archive_head; + obfd->archive_head = abfd; + } + list = list->next; + } + } +} + + +void +ar_clear (void) +{ + if (obfd) + obfd->archive_head = 0; +} + +void +ar_delete (struct list *list) +{ + if (!obfd) + { + fprintf (stderr, _("%s: no open output archive\n"), program_name); + maybequit (); + } + else + { + while (list) + { + /* Find this name in the archive. */ + bfd *member = obfd->archive_head; + bfd **prev = &(obfd->archive_head); + int found = 0; + + while (member) + { + if (FILENAME_CMP(member->filename, list->name) == 0) + { + *prev = member->archive_next; + found = 1; + } + else + prev = &(member->archive_next); + + member = member->archive_next; + } + + if (!found) + { + fprintf (stderr, _("%s: can't find module file %s\n"), + program_name, list->name); + maybequit (); + } + + list = list->next; + } + } +} + +void +ar_save (void) +{ + if (!obfd) + { + fprintf (stderr, _("%s: no open output archive\n"), program_name); + maybequit (); + } + else + { + char *ofilename = xstrdup (bfd_get_filename (obfd)); + + if (deterministic > 0) + obfd->flags |= BFD_DETERMINISTIC_OUTPUT; + + bfd_close (obfd); + + smart_rename (ofilename, real_name, 0); + obfd = 0; + free (ofilename); + } +} + +void +ar_replace (struct list *list) +{ + if (!obfd) + { + fprintf (stderr, _("%s: no open output archive\n"), program_name); + maybequit (); + } + else + { + while (list) + { + /* Find this name in the archive. */ + bfd *member = obfd->archive_head; + bfd **prev = &(obfd->archive_head); + int found = 0; + + while (member) + { + if (FILENAME_CMP (member->filename, list->name) == 0) + { + /* Found the one to replace. */ + bfd *abfd = bfd_openr (list->name, NULL); + + if (!abfd) + { + fprintf (stderr, _("%s: can't open file %s\n"), + program_name, list->name); + maybequit (); + } + else + { + *prev = abfd; + abfd->archive_next = member->archive_next; + found = 1; + } + } + else + { + prev = &(member->archive_next); + } + member = member->archive_next; + } + + if (!found) + { + bfd *abfd = bfd_openr (list->name, NULL); + + fprintf (stderr,_("%s: can't find module file %s\n"), + program_name, list->name); + if (!abfd) + { + fprintf (stderr, _("%s: can't open file %s\n"), + program_name, list->name); + maybequit (); + } + else + *prev = abfd; + } + + list = list->next; + } + } +} + +/* And I added this one. */ +void +ar_list (void) +{ + if (!obfd) + { + fprintf (stderr, _("%s: no open output archive\n"), program_name); + maybequit (); + } + else + { + bfd *abfd; + + outfile = stdout; + verbose =1 ; + printf (_("Current open archive is %s\n"), bfd_get_filename (obfd)); + + for (abfd = obfd->archive_head; + abfd != (bfd *)NULL; + abfd = abfd->archive_next) + ar_directory_doer (abfd, (bfd *) NULL); + } +} + +void +ar_end (void) +{ + if (obfd) + { + bfd_cache_close (obfd); + unlink (bfd_get_filename (obfd)); + } +} + +void +ar_extract (struct list *list) +{ + if (!obfd) + { + fprintf (stderr, _("%s: no open archive\n"), program_name); + maybequit (); + } + else + { + while (list) + { + /* Find this name in the archive. */ + bfd *member = obfd->archive_head; + int found = 0; + + while (member && !found) + { + if (FILENAME_CMP (member->filename, list->name) == 0) + { + extract_file (member); + found = 1; + } + + member = member->archive_next; + } + + if (!found) + { + bfd_openr (list->name, NULL); + fprintf (stderr, _("%s: can't find module file %s\n"), + program_name, list->name); + } + + list = list->next; + } + } +} diff --git a/support/sdbinutils/binutils/arsup.h b/support/sdbinutils/binutils/arsup.h new file mode 100644 index 0000000..ab6e58c --- /dev/null +++ b/support/sdbinutils/binutils/arsup.h @@ -0,0 +1,62 @@ +/* arsup.h - archive support header file + Copyright (C) 1992-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +struct list { + char *name; + struct list *next; +}; + +void maybequit (void); + +void prompt (void); + +void ar_clear (void); + +void ar_replace (struct list *); + +void ar_delete (struct list *); + +void ar_save (void); + +void ar_list (void); + +void ar_open (char *, int); + +void ar_directory (char *, struct list *, char *); + +void ar_addmod (struct list *); + +void ar_addlib (char *, struct list *); + +void ar_end (void); + +void ar_extract (struct list *); + +bfd *open_inarch (const char *archive_filename, const char *); + +extern int yylex (void); + +int yyparse (void); + +/* Functions from ar.c */ + +void extract_file (bfd * abfd); + +extern int interactive; diff --git a/support/sdbinutils/binutils/bfdtest1.c b/support/sdbinutils/binutils/bfdtest1.c new file mode 100644 index 0000000..93ba51b --- /dev/null +++ b/support/sdbinutils/binutils/bfdtest1.c @@ -0,0 +1,70 @@ +/* A program to test BFD. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + + This file is part of the GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "sysdep.h" +#include "bfd.h" + +static void +die (const char *s) +{ + printf ("oops: %s\n", s); + exit (1); +} + +int +main (int argc, char **argv) +{ + bfd *archive; + bfd *last, *next; + + if (argc != 2) + die ("usage: bfdtest1 "); + + archive = bfd_openr (argv[1], NULL); + if (archive == NULL) + die ("no such archive"); + + if (!bfd_check_format (archive, bfd_archive)) + { + bfd_close (archive); + die ("bfd_check_format"); + } + + for (last = bfd_openr_next_archived_file (archive, NULL); + last; + last = next) + { + next = bfd_openr_next_archived_file (archive, last); + bfd_close (last); + } + + for (last = bfd_openr_next_archived_file (archive, NULL); + last; + last = next) + { + next = bfd_openr_next_archived_file (archive, last); + bfd_close (last); + } + + if (!bfd_close (archive)) + die ("bfd_close"); + + return 0; +} diff --git a/support/sdbinutils/binutils/bfdtest2.c b/support/sdbinutils/binutils/bfdtest2.c new file mode 100644 index 0000000..0886d6e --- /dev/null +++ b/support/sdbinutils/binutils/bfdtest2.c @@ -0,0 +1,106 @@ +/* A program to test BFD. + Copyright (C) 2012-2018 Free Software Foundation, Inc. + + This file is part of the GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "sysdep.h" +#include "bfd.h" + +static void +die (const char *s) +{ + printf ("oops: %s\n", s); + exit (1); +} + +static void * +iovec_open (struct bfd *nbfd ATTRIBUTE_UNUSED, void *open_closure) +{ + return open_closure; +} + +static file_ptr iovec_read (struct bfd *nbfd ATTRIBUTE_UNUSED, + void *stream, void *buf, file_ptr nbytes, + file_ptr offset) +{ + FILE* file = (FILE*) stream; + + if (fseek(file, offset, SEEK_SET) != 0) + die ("fseek error"); + + return fread (buf, 1, nbytes, file); +} + +static int +iovec_stat (struct bfd *abfd ATTRIBUTE_UNUSED, + void *stream, struct stat *sb) +{ + return fstat (fileno ((FILE*) stream), sb); +} + +static bfd_boolean +check_format_any (struct bfd *abfd, bfd_format format) +{ + char** targets = NULL; + + if (bfd_check_format_matches (abfd, format, &targets)) + return TRUE; + + if (targets) + { + bfd_find_target (targets[0], abfd); + + return bfd_check_format (abfd, format); + } + + return FALSE; +} + +int +main (int argc, const char** argv) +{ + FILE* file; + bfd *abfd, *mbfd; + + if (argc < 2) + die ("Usage: test archivefile"); + + file = fopen(argv[1], "rb"); + if (!file) + die ("file not found"); + + abfd = bfd_openr_iovec (argv[1], 0, iovec_open, file, + iovec_read, NULL, iovec_stat); + if (!abfd) + die ("error opening file"); + + if (!check_format_any (abfd, bfd_archive)) + die ("not an archive"); + + mbfd = bfd_openr_next_archived_file (abfd, 0); + if (!mbfd) + die ("error opening archive member"); + + if (!bfd_close (mbfd)) + die ("error closing archive member"); + + if (!bfd_close (abfd)) + die ("error closing archive"); + + return 0; +} diff --git a/support/sdbinutils/binutils/bin2c.c b/support/sdbinutils/binutils/bin2c.c new file mode 100644 index 0000000..37b570a --- /dev/null +++ b/support/sdbinutils/binutils/bin2c.c @@ -0,0 +1,66 @@ +/* bin2c.c -- dump binary file in hex format + Copyright (C) 2007-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include +#include +#include "binary-io.h" + +int +main (int argc, char *argv[]) +{ + int c; + int i; + + if (argc != 1) + { + int ishelp = 0; + FILE *stream; + + if (argc == 2 && argv[1][0] == '-') + { + const char *opt = &argv[1][1]; + if (*opt == '-') + ++opt; + ishelp = *opt == 'h' || *opt == 'H'; + } + + stream = ishelp ? stdout : stderr; + fprintf (stream, "Usage: %s < input_file > output_file\n", argv[0]); + fprintf (stream, "Prints bytes from stdin in hex format.\n"); + exit (!ishelp); + } + + SET_BINARY (fileno (stdin)); + + i = 0; + while ((c = getc (stdin)) != EOF) + { + printf ("0x%02x,", c); + if (++i == 16) + { + printf ("\n"); + i = 0; + } + } + if (i != 0) + printf ("\n"); + + exit (0); +} diff --git a/support/sdbinutils/binutils/binemul.c b/support/sdbinutils/binutils/binemul.c new file mode 100644 index 0000000..e0dd94c --- /dev/null +++ b/support/sdbinutils/binutils/binemul.c @@ -0,0 +1,148 @@ +/* Binutils emulation layer. + Copyright (C) 2002-2018 Free Software Foundation, Inc. + Written by Tom Rix, Red Hat Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "binemul.h" + +extern bin_emulation_xfer_type bin_dummy_emulation; + +void +ar_emul_usage (FILE *fp) +{ + if (bin_dummy_emulation.ar_usage) + bin_dummy_emulation.ar_usage (fp); +} + +void +ar_emul_default_usage (FILE *fp) +{ + AR_EMUL_USAGE_PRINT_OPTION_HEADER (fp); + /* xgettext:c-format */ + fprintf (fp, _(" No emulation specific options\n")); +} + +bfd_boolean +ar_emul_append (bfd **after_bfd, char *file_name, const char *target, + bfd_boolean verbose, bfd_boolean flatten) +{ + if (bin_dummy_emulation.ar_append) + return bin_dummy_emulation.ar_append (after_bfd, file_name, target, + verbose, flatten); + + return FALSE; +} + +static bfd_boolean +any_ok (bfd *new_bfd ATTRIBUTE_UNUSED) +{ + return TRUE; +} + +bfd_boolean +do_ar_emul_append (bfd **after_bfd, bfd *new_bfd, + bfd_boolean verbose, bfd_boolean flatten, + bfd_boolean (*check) (bfd *)) +{ + /* When flattening, add the members of an archive instead of the + archive itself. */ + if (flatten && bfd_check_format (new_bfd, bfd_archive)) + { + bfd *elt; + bfd_boolean added = FALSE; + + for (elt = bfd_openr_next_archived_file (new_bfd, NULL); + elt; + elt = bfd_openr_next_archived_file (new_bfd, elt)) + { + if (do_ar_emul_append (after_bfd, elt, verbose, TRUE, check)) + { + added = TRUE; + after_bfd = &((*after_bfd)->archive_next); + } + } + + return added; + } + + if (!check (new_bfd)) + return FALSE; + + AR_EMUL_APPEND_PRINT_VERBOSE (verbose, new_bfd->filename); + + new_bfd->archive_next = *after_bfd; + *after_bfd = new_bfd; + + return TRUE; +} + +bfd_boolean +ar_emul_default_append (bfd **after_bfd, char *file_name, + const char *target, bfd_boolean verbose, + bfd_boolean flatten) +{ + bfd *new_bfd; + + new_bfd = bfd_openr (file_name, target); + AR_EMUL_ELEMENT_CHECK (new_bfd, file_name); + return do_ar_emul_append (after_bfd, new_bfd, verbose, flatten, any_ok); +} + +bfd_boolean +ar_emul_replace (bfd **after_bfd, char *file_name, const char *target, + bfd_boolean verbose) +{ + if (bin_dummy_emulation.ar_replace) + return bin_dummy_emulation.ar_replace (after_bfd, file_name, + target, verbose); + + return FALSE; +} + +bfd_boolean +ar_emul_default_replace (bfd **after_bfd, char *file_name, + const char *target, bfd_boolean verbose) +{ + bfd *new_bfd; + + new_bfd = bfd_openr (file_name, target); + AR_EMUL_ELEMENT_CHECK (new_bfd, file_name); + + AR_EMUL_REPLACE_PRINT_VERBOSE (verbose, file_name); + + new_bfd->archive_next = *after_bfd; + *after_bfd = new_bfd; + + return TRUE; +} + +bfd_boolean +ar_emul_parse_arg (char *arg) +{ + if (bin_dummy_emulation.ar_parse_arg) + return bin_dummy_emulation.ar_parse_arg (arg); + + return FALSE; +} + +bfd_boolean +ar_emul_default_parse_arg (char *arg ATTRIBUTE_UNUSED) +{ + return FALSE; +} diff --git a/support/sdbinutils/binutils/binemul.h b/support/sdbinutils/binutils/binemul.h new file mode 100644 index 0000000..d45f22c --- /dev/null +++ b/support/sdbinutils/binutils/binemul.h @@ -0,0 +1,71 @@ +/* Binutils emulation layer. + Copyright (C) 2002-2018 Free Software Foundation, Inc. + Written by Tom Rix, Red Hat Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#ifndef BINEMUL_H +#define BINEMUL_H + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" + +extern void ar_emul_usage (FILE *); +extern void ar_emul_default_usage (FILE *); +extern bfd_boolean ar_emul_append (bfd **, char *, const char *, + bfd_boolean, bfd_boolean); +extern bfd_boolean ar_emul_default_append (bfd **, char *, const char *, + bfd_boolean, bfd_boolean); +extern bfd_boolean do_ar_emul_append (bfd **, bfd *, + bfd_boolean, bfd_boolean, + bfd_boolean (*)(bfd *)); +extern bfd_boolean ar_emul_replace (bfd **, char *, const char *, + bfd_boolean); +extern bfd_boolean ar_emul_default_replace (bfd **, char *, + const char *, bfd_boolean); +extern bfd_boolean ar_emul_parse_arg (char *); +extern bfd_boolean ar_emul_default_parse_arg (char *); + +/* Macros for common output. */ + +#define AR_EMUL_USAGE_PRINT_OPTION_HEADER(fp) \ + /* xgettext:c-format */ \ + fprintf (fp, _(" emulation options: \n")) + +#define AR_EMUL_ELEMENT_CHECK(abfd, file_name) \ + do { if ((abfd) == NULL) bfd_fatal (file_name); } while (0) + +#define AR_EMUL_APPEND_PRINT_VERBOSE(verbose, file_name) \ + do { if (verbose) printf ("a - %s\n", file_name); } while (0) + +#define AR_EMUL_REPLACE_PRINT_VERBOSE(verbose, file_name) \ + do { if (verbose) printf ("r - %s\n", file_name); } while (0) + +typedef struct bin_emulation_xfer_struct +{ + /* Print out the extra options. */ + void (* ar_usage) (FILE *fp); + bfd_boolean (* ar_append) (bfd **, char *, const char *, bfd_boolean, + bfd_boolean); + bfd_boolean (* ar_replace) (bfd **, char *, const char *, bfd_boolean); + bfd_boolean (* ar_parse_arg) (char *); +} +bin_emulation_xfer_type; + +#endif diff --git a/support/sdbinutils/binutils/bucomm.c b/support/sdbinutils/binutils/bucomm.c new file mode 100644 index 0000000..d3a8d2d --- /dev/null +++ b/support/sdbinutils/binutils/bucomm.c @@ -0,0 +1,667 @@ +/* bucomm.c -- Bin Utils COMmon code. + Copyright (C) 1991-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* We might put this in a library someday so it could be dynamically + loaded, but for now it's not necessary. */ + +#include "sysdep.h" +#include "bfd.h" +#include "libiberty.h" +#include "filenames.h" + +#include /* ctime, maybe time_t */ +#include +#include "bucomm.h" + +#ifndef HAVE_TIME_T_IN_TIME_H +#ifndef HAVE_TIME_T_IN_TYPES_H +typedef long time_t; +#endif +#endif + +/* Error reporting. */ + +char *program_name; + +void +bfd_nonfatal (const char *string) +{ + const char *errmsg; + + errmsg = bfd_errmsg (bfd_get_error ()); + fflush (stdout); + if (string) + fprintf (stderr, "%s: %s: %s\n", program_name, string, errmsg); + else + fprintf (stderr, "%s: %s\n", program_name, errmsg); +} + +/* Issue a non fatal error message. FILENAME, or if NULL then BFD, + are used to indicate the problematic file. SECTION, if non NULL, + is used to provide a section name. If FORMAT is non-null, then it + is used to print additional information via vfprintf. Finally the + bfd error message is printed. In summary, error messages are of + one of the following forms: + + PROGRAM:file: bfd-error-message + PROGRAM:file[section]: bfd-error-message + PROGRAM:file: printf-message: bfd-error-message + PROGRAM:file[section]: printf-message: bfd-error-message. */ + +void +bfd_nonfatal_message (const char *filename, + const bfd *abfd, + const asection *section, + const char *format, ...) +{ + const char *errmsg; + const char *section_name; + va_list args; + + errmsg = bfd_errmsg (bfd_get_error ()); + fflush (stdout); + section_name = NULL; + va_start (args, format); + fprintf (stderr, "%s", program_name); + + if (abfd) + { + if (!filename) + filename = bfd_get_archive_filename (abfd); + if (section) + section_name = bfd_get_section_name (abfd, section); + } + if (section_name) + fprintf (stderr, ":%s[%s]", filename, section_name); + else + fprintf (stderr, ":%s", filename); + + if (format) + { + fprintf (stderr, ": "); + vfprintf (stderr, format, args); + } + fprintf (stderr, ": %s\n", errmsg); + va_end (args); +} + +void +bfd_fatal (const char *string) +{ + bfd_nonfatal (string); + xexit (1); +} + +void +report (const char * format, va_list args) +{ + fflush (stdout); + fprintf (stderr, "%s: ", program_name); + vfprintf (stderr, format, args); + putc ('\n', stderr); +} + +void +fatal (const char *format, ...) +{ + va_list args; + + va_start (args, format); + + report (format, args); + va_end (args); + xexit (1); +} + +void +non_fatal (const char *format, ...) +{ + va_list args; + + va_start (args, format); + + report (format, args); + va_end (args); +} + +/* Set the default BFD target based on the configured target. Doing + this permits the binutils to be configured for a particular target, + and linked against a shared BFD library which was configured for a + different target. */ + +void +set_default_bfd_target (void) +{ + /* The macro TARGET is defined by Makefile. */ + const char *target = TARGET; + + if (! bfd_set_default_target (target)) + fatal (_("can't set BFD default target to `%s': %s"), + target, bfd_errmsg (bfd_get_error ())); +} + +/* After a FALSE return from bfd_check_format_matches with + bfd_get_error () == bfd_error_file_ambiguously_recognized, print + the possible matching targets. */ + +void +list_matching_formats (char **p) +{ + fflush (stdout); + fprintf (stderr, _("%s: Matching formats:"), program_name); + while (*p) + fprintf (stderr, " %s", *p++); + fputc ('\n', stderr); +} + +/* List the supported targets. */ + +void +list_supported_targets (const char *name, FILE *f) +{ + int t; + const char **targ_names; + + if (name == NULL) + fprintf (f, _("Supported targets:")); + else + fprintf (f, _("%s: supported targets:"), name); + + targ_names = bfd_target_list (); + for (t = 0; targ_names[t] != NULL; t++) + fprintf (f, " %s", targ_names[t]); + fprintf (f, "\n"); + free (targ_names); +} + +/* List the supported architectures. */ + +void +list_supported_architectures (const char *name, FILE *f) +{ + const char ** arch; + const char ** arches; + + if (name == NULL) + fprintf (f, _("Supported architectures:")); + else + fprintf (f, _("%s: supported architectures:"), name); + + for (arch = arches = bfd_arch_list (); *arch; arch++) + fprintf (f, " %s", *arch); + fprintf (f, "\n"); + free (arches); +} + +static const char * +endian_string (enum bfd_endian endian) +{ + switch (endian) + { + case BFD_ENDIAN_BIG: return _("big endian"); + case BFD_ENDIAN_LITTLE: return _("little endian"); + default: return _("endianness unknown"); + } +} + +/* Data passed to do_display_target and other target iterators. */ + +struct display_target { + /* Temp file. */ + char *filename; + /* Return status. */ + int error; + /* Number of targets. */ + int count; + /* Size of info in bytes. */ + size_t alloc; + /* Per-target info. */ + struct { + /* Target name. */ + const char *name; + /* Non-zero if target/arch combination supported. */ + unsigned char arch[bfd_arch_last - bfd_arch_obscure - 1]; + } *info; +}; + +/* List the targets that BFD is configured to support, each followed + by its endianness and the architectures it supports. Also build + info about target/archs. */ + +static int +do_display_target (const bfd_target *targ, void *data) +{ + struct display_target *param = (struct display_target *) data; + bfd *abfd; + size_t amt; + + param->count += 1; + amt = param->count * sizeof (*param->info); + if (param->alloc < amt) + { + size_t size = ((param->count < 64 ? 64 : param->count) + * sizeof (*param->info) * 2); + param->info = xrealloc (param->info, size); + memset ((char *) param->info + param->alloc, 0, size - param->alloc); + param->alloc = size; + } + param->info[param->count - 1].name = targ->name; + + printf (_("%s\n (header %s, data %s)\n"), targ->name, + endian_string (targ->header_byteorder), + endian_string (targ->byteorder)); + + abfd = bfd_openw (param->filename, targ->name); + if (abfd == NULL) + { + bfd_nonfatal (param->filename); + param->error = 1; + } + else if (!bfd_set_format (abfd, bfd_object)) + { + if (bfd_get_error () != bfd_error_invalid_operation) + { + bfd_nonfatal (targ->name); + param->error = 1; + } + } + else + { + enum bfd_architecture a; + + for (a = bfd_arch_obscure + 1; a < bfd_arch_last; a++) + if (bfd_set_arch_mach (abfd, a, 0)) + { + printf (" %s\n", bfd_printable_arch_mach (a, 0)); + param->info[param->count - 1].arch[a - bfd_arch_obscure - 1] = 1; + } + } + if (abfd != NULL) + bfd_close_all_done (abfd); + + return param->error; +} + +static void +display_target_list (struct display_target *arg) +{ + arg->filename = make_temp_file (NULL); + arg->error = 0; + arg->count = 0; + arg->alloc = 0; + arg->info = NULL; + + bfd_iterate_over_targets (do_display_target, arg); + + unlink (arg->filename); + free (arg->filename); +} + +/* Calculate how many targets we can print across the page. */ + +static int +do_info_size (int targ, int width, const struct display_target *arg) +{ + while (targ < arg->count) + { + width -= strlen (arg->info[targ].name) + 1; + if (width < 0) + return targ; + ++targ; + } + return targ; +} + +/* Print header of target names. */ + +static void +do_info_header (int targ, int stop_targ, const struct display_target *arg) +{ + while (targ != stop_targ) + printf ("%s ", arg->info[targ++].name); +} + +/* Print a table row. */ + +static void +do_info_row (int targ, int stop_targ, enum bfd_architecture a, + const struct display_target *arg) +{ + while (targ != stop_targ) + { + if (arg->info[targ].arch[a - bfd_arch_obscure - 1]) + fputs (arg->info[targ].name, stdout); + else + { + int l = strlen (arg->info[targ].name); + while (l--) + putchar ('-'); + } + ++targ; + if (targ != stop_targ) + putchar (' '); + } +} + +/* Print tables of all the target-architecture combinations that + BFD has been configured to support. */ + +static void +display_target_tables (const struct display_target *arg) +{ + const char *columns; + int width, start_targ, stop_targ; + enum bfd_architecture arch; + int longest_arch = 0; + + for (arch = bfd_arch_obscure + 1; arch < bfd_arch_last; arch++) + { + const char *s = bfd_printable_arch_mach (arch, 0); + int len = strlen (s); + if (len > longest_arch) + longest_arch = len; + } + + width = 0; + columns = getenv ("COLUMNS"); + if (columns != NULL) + width = atoi (columns); + if (width == 0) + width = 80; + + for (start_targ = 0; start_targ < arg->count; start_targ = stop_targ) + { + stop_targ = do_info_size (start_targ, width - longest_arch - 1, arg); + + printf ("\n%*s", longest_arch + 1, " "); + do_info_header (start_targ, stop_targ, arg); + putchar ('\n'); + + for (arch = bfd_arch_obscure + 1; arch < bfd_arch_last; arch++) + { + if (strcmp (bfd_printable_arch_mach (arch, 0), "UNKNOWN!") != 0) + { + printf ("%*s ", longest_arch, + bfd_printable_arch_mach (arch, 0)); + + do_info_row (start_targ, stop_targ, arch, arg); + putchar ('\n'); + } + } + } +} + +int +display_info (void) +{ + struct display_target arg; + + printf (_("BFD header file version %s\n"), BFD_VERSION_STRING); + + display_target_list (&arg); + if (!arg.error) + display_target_tables (&arg); + + return arg.error; +} + +/* Display the archive header for an element as if it were an ls -l listing: + + Mode User\tGroup\tSize\tDate Name */ + +void +print_arelt_descr (FILE *file, bfd *abfd, bfd_boolean verbose) +{ + struct stat buf; + + if (verbose) + { + if (bfd_stat_arch_elt (abfd, &buf) == 0) + { + char modebuf[11]; + char timebuf[40]; + time_t when = buf.st_mtime; + const char *ctime_result = (const char *) ctime (&when); + bfd_size_type size; + + /* PR binutils/17605: Check for corrupt time values. */ + if (ctime_result == NULL) + sprintf (timebuf, _("

*/ +}; + +static const unsigned char mcore_le_jtab[] = +{ + 0x02, 0x71, /* lrw r1,2 */ + 0x01, 0x81, /* ld.w r1,(r1,0) */ + 0xC1, 0x00, /* jmp r1 */ + 0x00, 0x12, /* nop */ + 0x00, 0x00, 0x00, 0x00 /*
*/ +}; + +/* This is the glue sequence for PowerPC PE. There is a + tocrel16-tocdefn reloc against the first instruction. + We also need a IMGLUE reloc against the glue function + to restore the toc saved by the third instruction in + the glue. */ +static const unsigned char ppc_jtab[] = +{ + 0x00, 0x00, 0x62, 0x81, /* lwz r11,0(r2) */ + /* Reloc TOCREL16 __imp_xxx */ + 0x00, 0x00, 0x8B, 0x81, /* lwz r12,0(r11) */ + 0x04, 0x00, 0x41, 0x90, /* stw r2,4(r1) */ + 0xA6, 0x03, 0x89, 0x7D, /* mtctr r12 */ + 0x04, 0x00, 0x4B, 0x80, /* lwz r2,4(r11) */ + 0x20, 0x04, 0x80, 0x4E /* bctr */ +}; + +#ifdef DLLTOOL_PPC +/* The glue instruction, picks up the toc from the stw in + the above code: "lwz r2,4(r1)". */ +static bfd_vma ppc_glue_insn = 0x80410004; +#endif + +static const char i386_trampoline[] = + "\tpushl %%ecx\n" + "\tpushl %%edx\n" + "\tpushl %%eax\n" + "\tpushl $__DELAY_IMPORT_DESCRIPTOR_%s\n" + "\tcall ___delayLoadHelper2@8\n" + "\tpopl %%edx\n" + "\tpopl %%ecx\n" + "\tjmp *%%eax\n"; + +static const char i386_x64_trampoline[] = + "\tpushq %%rcx\n" + "\tpushq %%rdx\n" + "\tpushq %%r8\n" + "\tpushq %%r9\n" + "\tsubq $40, %%rsp\n" + "\tmovq %%rax, %%rdx\n" + "\tleaq __DELAY_IMPORT_DESCRIPTOR_%s(%%rip), %%rcx\n" + "\tcall __delayLoadHelper2\n" + "\taddq $40, %%rsp\n" + "\tpopq %%r9\n" + "\tpopq %%r8\n" + "\tpopq %%rdx\n" + "\tpopq %%rcx\n" + "\tjmp *%%rax\n"; + +struct mac +{ + const char *type; + const char *how_byte; + const char *how_short; + const char *how_long; + const char *how_asciz; + const char *how_comment; + const char *how_jump; + const char *how_global; + const char *how_space; + const char *how_align_short; + const char *how_align_long; + const char *how_default_as_switches; + const char *how_bfd_target; + enum bfd_architecture how_bfd_arch; + const unsigned char *how_jtab; + int how_jtab_size; /* Size of the jtab entry. */ + int how_jtab_roff; /* Offset into it for the ind 32 reloc into idata 5. */ + const unsigned char *how_dljtab; + int how_dljtab_size; /* Size of the dljtab entry. */ + int how_dljtab_roff1; /* Offset for the ind 32 reloc into idata 5. */ + int how_dljtab_roff2; /* Offset for the ind 32 reloc into idata 5. */ + int how_dljtab_roff3; /* Offset for the ind 32 reloc into idata 5. */ + const char *trampoline; +}; + +static const struct mac +mtable[] = +{ + { +#define MARM 0 + "arm", ".byte", ".short", ".long", ".asciz", "@", + "ldr\tip,[pc]\n\tldr\tpc,[ip]\n\t.long", + ".global", ".space", ".align\t2",".align\t4", "-mapcs-32", + "pe-arm-little", bfd_arch_arm, + arm_jtab, sizeof (arm_jtab), 8, + 0, 0, 0, 0, 0, 0 + } + , + { +#define M386 1 + "i386", ".byte", ".short", ".long", ".asciz", "#", + "jmp *", ".global", ".space", ".align\t2",".align\t4", "", + "pe-i386",bfd_arch_i386, + i386_jtab, sizeof (i386_jtab), 2, + i386_dljtab, sizeof (i386_dljtab), 2, 7, 12, i386_trampoline + } + , + { +#define MPPC 2 + "ppc", ".byte", ".short", ".long", ".asciz", "#", + "jmp *", ".global", ".space", ".align\t2",".align\t4", "", + "pe-powerpcle",bfd_arch_powerpc, + ppc_jtab, sizeof (ppc_jtab), 0, + 0, 0, 0, 0, 0, 0 + } + , + { +#define MTHUMB 3 + "thumb", ".byte", ".short", ".long", ".asciz", "@", + "push\t{r6}\n\tldr\tr6, [pc, #8]\n\tldr\tr6, [r6]\n\tmov\tip, r6\n\tpop\t{r6}\n\tbx\tip", + ".global", ".space", ".align\t2",".align\t4", "-mthumb-interwork", + "pe-arm-little", bfd_arch_arm, + thumb_jtab, sizeof (thumb_jtab), 12, + 0, 0, 0, 0, 0, 0 + } + , +#define MARM_INTERWORK 4 + { + "arm_interwork", ".byte", ".short", ".long", ".asciz", "@", + "ldr\tip,[pc]\n\tldr\tip,[ip]\n\tbx\tip\n\t.long", + ".global", ".space", ".align\t2",".align\t4", "-mthumb-interwork", + "pe-arm-little", bfd_arch_arm, + arm_interwork_jtab, sizeof (arm_interwork_jtab), 12, + 0, 0, 0, 0, 0, 0 + } + , + { +#define MMCORE_BE 5 + "mcore-be", ".byte", ".short", ".long", ".asciz", "//", + "lrw r1,[1f]\n\tld.w r1,(r1,0)\n\tjmp r1\n\tnop\n1:.long", + ".global", ".space", ".align\t2",".align\t4", "", + "pe-mcore-big", bfd_arch_mcore, + mcore_be_jtab, sizeof (mcore_be_jtab), 8, + 0, 0, 0, 0, 0, 0 + } + , + { +#define MMCORE_LE 6 + "mcore-le", ".byte", ".short", ".long", ".asciz", "//", + "lrw r1,[1f]\n\tld.w r1,(r1,0)\n\tjmp r1\n\tnop\n1:.long", + ".global", ".space", ".align\t2",".align\t4", "-EL", + "pe-mcore-little", bfd_arch_mcore, + mcore_le_jtab, sizeof (mcore_le_jtab), 8, + 0, 0, 0, 0, 0, 0 + } + , + { +#define MMCORE_ELF 7 + "mcore-elf-be", ".byte", ".short", ".long", ".asciz", "//", + "lrw r1,[1f]\n\tld.w r1,(r1,0)\n\tjmp r1\n\tnop\n1:.long", + ".global", ".space", ".align\t2",".align\t4", "", + "elf32-mcore-big", bfd_arch_mcore, + mcore_be_jtab, sizeof (mcore_be_jtab), 8, + 0, 0, 0, 0, 0, 0 + } + , + { +#define MMCORE_ELF_LE 8 + "mcore-elf-le", ".byte", ".short", ".long", ".asciz", "//", + "lrw r1,[1f]\n\tld.w r1,(r1,0)\n\tjmp r1\n\tnop\n1:.long", + ".global", ".space", ".align\t2",".align\t4", "-EL", + "elf32-mcore-little", bfd_arch_mcore, + mcore_le_jtab, sizeof (mcore_le_jtab), 8, + 0, 0, 0, 0, 0, 0 + } + , + { +#define MARM_EPOC 9 + "arm-epoc", ".byte", ".short", ".long", ".asciz", "@", + "ldr\tip,[pc]\n\tldr\tpc,[ip]\n\t.long", + ".global", ".space", ".align\t2",".align\t4", "", + "epoc-pe-arm-little", bfd_arch_arm, + arm_jtab, sizeof (arm_jtab), 8, + 0, 0, 0, 0, 0, 0 + } + , + { +#define MARM_WINCE 10 + "arm-wince", ".byte", ".short", ".long", ".asciz", "@", + "ldr\tip,[pc]\n\tldr\tpc,[ip]\n\t.long", + ".global", ".space", ".align\t2",".align\t4", "-mapcs-32", + "pe-arm-wince-little", bfd_arch_arm, + arm_jtab, sizeof (arm_jtab), 8, + 0, 0, 0, 0, 0, 0 + } + , + { +#define MX86 11 + "i386:x86-64", ".byte", ".short", ".long", ".asciz", "#", + "jmp *", ".global", ".space", ".align\t2",".align\t4", "", + "pe-x86-64",bfd_arch_i386, + i386_jtab, sizeof (i386_jtab), 2, + i386_x64_dljtab, sizeof (i386_x64_dljtab), 2, 9, 14, i386_x64_trampoline + } + , + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +}; + +typedef struct dlist +{ + char *text; + struct dlist *next; +} +dlist_type; + +typedef struct export +{ + const char *name; + const char *internal_name; + const char *import_name; + const char *its_name; + int ordinal; + int constant; + int noname; /* Don't put name in image file. */ + int private; /* Don't put reference in import lib. */ + int data; + int forward; /* Number of forward label, 0 means no forward. */ + struct export *next; +} +export_type; + +/* A list of symbols which we should not export. */ + +struct string_list +{ + struct string_list *next; + char *string; +}; + +static struct string_list *excludes; + +static const char *rvaafter (int); +static const char *rvabefore (int); +static const char *asm_prefix (int, const char *); +static void process_def_file (const char *); +static void new_directive (char *); +static void append_import (const char *, const char *, int, const char *); +static void run (const char *, char *); +static void scan_drectve_symbols (bfd *); +static void scan_filtered_symbols (bfd *, void *, long, unsigned int); +static void add_excludes (const char *); +static bfd_boolean match_exclude (const char *); +static void set_default_excludes (void); +static long filter_symbols (bfd *, void *, long, unsigned int); +static void scan_all_symbols (bfd *); +static void scan_open_obj_file (bfd *); +static void scan_obj_file (const char *); +static void dump_def_info (FILE *); +static int sfunc (const void *, const void *); +static void flush_page (FILE *, bfd_vma *, bfd_vma, int); +static void gen_def_file (void); +static void generate_idata_ofile (FILE *); +static void assemble_file (const char *, const char *); +static void gen_exp_file (void); +static const char *xlate (const char *); +static char *make_label (const char *, const char *); +static char *make_imp_label (const char *, const char *); +static bfd *make_one_lib_file (export_type *, int, int); +static bfd *make_head (void); +static bfd *make_tail (void); +static bfd *make_delay_head (void); +static void gen_lib_file (int); +static void dll_name_list_append (dll_name_list_type *, bfd_byte *); +static int dll_name_list_count (dll_name_list_type *); +static void dll_name_list_print (dll_name_list_type *); +static void dll_name_list_free_contents (dll_name_list_node_type *); +static void dll_name_list_free (dll_name_list_type *); +static dll_name_list_type * dll_name_list_create (void); +static void identify_dll_for_implib (void); +static void identify_search_archive + (bfd *, void (*) (bfd *, bfd *, void *), void *); +static void identify_search_member (bfd *, bfd *, void *); +static bfd_boolean identify_process_section_p (asection *, bfd_boolean); +static void identify_search_section (bfd *, asection *, void *); +static void identify_member_contains_symname (bfd *, bfd *, void *); + +static int pfunc (const void *, const void *); +static int nfunc (const void *, const void *); +static void remove_null_names (export_type **); +static void process_duplicates (export_type **); +static void fill_ordinals (export_type **); +static void mangle_defs (void); +static void usage (FILE *, int); +static void inform (const char *, ...) ATTRIBUTE_PRINTF_1; +static void set_dll_name_from_def (const char *name, char is_dll); + +static char * +prefix_encode (char *start, unsigned code) +{ + static char alpha[26] = "abcdefghijklmnopqrstuvwxyz"; + static char buf[32]; + char *p; + strcpy (buf, start); + p = strchr (buf, '\0'); + do + *p++ = alpha[code % sizeof (alpha)]; + while ((code /= sizeof (alpha)) != 0); + *p = '\0'; + return buf; +} + +static char * +dlltmp (char **buf, const char *fmt) +{ + if (!*buf) + { + *buf = malloc (strlen (tmp_prefix) + 64); + sprintf (*buf, fmt, tmp_prefix); + } + return *buf; +} + +static void +inform (const char * message, ...) +{ + va_list args; + + va_start (args, message); + + if (!verbose) + return; + + report (message, args); + + va_end (args); +} + +static const char * +rvaafter (int mach) +{ + switch (mach) + { + case MARM: + case M386: + case MX86: + case MPPC: + case MTHUMB: + case MARM_INTERWORK: + case MMCORE_BE: + case MMCORE_LE: + case MMCORE_ELF: + case MMCORE_ELF_LE: + case MARM_EPOC: + case MARM_WINCE: + break; + default: + /* xgettext:c-format */ + fatal (_("Internal error: Unknown machine type: %d"), mach); + break; + } + return ""; +} + +static const char * +rvabefore (int mach) +{ + switch (mach) + { + case MARM: + case M386: + case MX86: + case MPPC: + case MTHUMB: + case MARM_INTERWORK: + case MMCORE_BE: + case MMCORE_LE: + case MMCORE_ELF: + case MMCORE_ELF_LE: + case MARM_EPOC: + case MARM_WINCE: + return ".rva\t"; + default: + /* xgettext:c-format */ + fatal (_("Internal error: Unknown machine type: %d"), mach); + break; + } + return ""; +} + +static const char * +asm_prefix (int mach, const char *name) +{ + switch (mach) + { + case MARM: + case MPPC: + case MTHUMB: + case MARM_INTERWORK: + case MMCORE_BE: + case MMCORE_LE: + case MMCORE_ELF: + case MMCORE_ELF_LE: + case MARM_EPOC: + case MARM_WINCE: + break; + case M386: + case MX86: + /* Symbol names starting with ? do not have a leading underscore. */ + if ((name && *name == '?') || leading_underscore == 0) + break; + else + return "_"; + default: + /* xgettext:c-format */ + fatal (_("Internal error: Unknown machine type: %d"), mach); + break; + } + return ""; +} + +#define ASM_BYTE mtable[machine].how_byte +#define ASM_SHORT mtable[machine].how_short +#define ASM_LONG mtable[machine].how_long +#define ASM_TEXT mtable[machine].how_asciz +#define ASM_C mtable[machine].how_comment +#define ASM_JUMP mtable[machine].how_jump +#define ASM_GLOBAL mtable[machine].how_global +#define ASM_SPACE mtable[machine].how_space +#define ASM_ALIGN_SHORT mtable[machine].how_align_short +#define ASM_RVA_BEFORE rvabefore (machine) +#define ASM_RVA_AFTER rvaafter (machine) +#define ASM_PREFIX(NAME) asm_prefix (machine, (NAME)) +#define ASM_ALIGN_LONG mtable[machine].how_align_long +#define HOW_BFD_READ_TARGET 0 /* Always default. */ +#define HOW_BFD_WRITE_TARGET mtable[machine].how_bfd_target +#define HOW_BFD_ARCH mtable[machine].how_bfd_arch +#define HOW_JTAB (delay ? mtable[machine].how_dljtab \ + : mtable[machine].how_jtab) +#define HOW_JTAB_SIZE (delay ? mtable[machine].how_dljtab_size \ + : mtable[machine].how_jtab_size) +#define HOW_JTAB_ROFF (delay ? mtable[machine].how_dljtab_roff1 \ + : mtable[machine].how_jtab_roff) +#define HOW_JTAB_ROFF2 (delay ? mtable[machine].how_dljtab_roff2 : 0) +#define HOW_JTAB_ROFF3 (delay ? mtable[machine].how_dljtab_roff3 : 0) +#define ASM_SWITCHES mtable[machine].how_default_as_switches + +static char **oav; + +static void +process_def_file (const char *name) +{ + FILE *f = fopen (name, FOPEN_RT); + + if (!f) + /* xgettext:c-format */ + fatal (_("Can't open def file: %s"), name); + + yyin = f; + + /* xgettext:c-format */ + inform (_("Processing def file: %s"), name); + + yyparse (); + + inform (_("Processed def file")); +} + +/**********************************************************************/ + +/* Communications with the parser. */ + +static int d_nfuncs; /* Number of functions exported. */ +static int d_named_nfuncs; /* Number of named functions exported. */ +static int d_low_ord; /* Lowest ordinal index. */ +static int d_high_ord; /* Highest ordinal index. */ +static export_type *d_exports; /* List of exported functions. */ +static export_type **d_exports_lexically; /* Vector of exported functions in alpha order. */ +static dlist_type *d_list; /* Descriptions. */ +static dlist_type *a_list; /* Stuff to go in directives. */ +static int d_nforwards = 0; /* Number of forwarded exports. */ + +static int d_is_dll; +static int d_is_exe; + +int +yyerror (const char * err ATTRIBUTE_UNUSED) +{ + /* xgettext:c-format */ + non_fatal (_("Syntax error in def file %s:%d"), def_file, linenumber); + + return 0; +} + +void +def_exports (const char *name, const char *internal_name, int ordinal, + int noname, int constant, int data, int private, + const char *its_name) +{ + struct export *p = (struct export *) xmalloc (sizeof (*p)); + + p->name = name; + p->internal_name = internal_name ? internal_name : name; + p->its_name = its_name; + p->import_name = name; + p->ordinal = ordinal; + p->constant = constant; + p->noname = noname; + p->private = private; + p->data = data; + p->next = d_exports; + d_exports = p; + d_nfuncs++; + + if ((internal_name != NULL) + && (strchr (internal_name, '.') != NULL)) + p->forward = ++d_nforwards; + else + p->forward = 0; /* no forward */ +} + +static void +set_dll_name_from_def (const char *name, char is_dll) +{ + const char *image_basename = lbasename (name); + if (image_basename != name) + non_fatal (_("%s: Path components stripped from image name, '%s'."), + def_file, name); + /* Append the default suffix, if none specified. */ + if (strchr (image_basename, '.') == 0) + { + const char * suffix = is_dll ? ".dll" : ".exe"; + + dll_name = xmalloc (strlen (image_basename) + strlen (suffix) + 1); + sprintf (dll_name, "%s%s", image_basename, suffix); + } + else + dll_name = xstrdup (image_basename); +} + +void +def_name (const char *name, int base) +{ + /* xgettext:c-format */ + inform (_("NAME: %s base: %x"), name, base); + + if (d_is_dll) + non_fatal (_("Can't have LIBRARY and NAME")); + + if (dll_name_set_by_exp_name && name && *name != 0) + { + dll_name = NULL; + dll_name_set_by_exp_name = 0; + } + /* If --dllname not provided, use the one in the DEF file. + FIXME: Is this appropriate for executables? */ + if (!dll_name) + set_dll_name_from_def (name, 0); + d_is_exe = 1; +} + +void +def_library (const char *name, int base) +{ + /* xgettext:c-format */ + inform (_("LIBRARY: %s base: %x"), name, base); + + if (d_is_exe) + non_fatal (_("Can't have LIBRARY and NAME")); + + if (dll_name_set_by_exp_name && name && *name != 0) + { + dll_name = NULL; + dll_name_set_by_exp_name = 0; + } + + /* If --dllname not provided, use the one in the DEF file. */ + if (!dll_name) + set_dll_name_from_def (name, 1); + d_is_dll = 1; +} + +void +def_description (const char *desc) +{ + dlist_type *d = (dlist_type *) xmalloc (sizeof (dlist_type)); + d->text = xstrdup (desc); + d->next = d_list; + d_list = d; +} + +static void +new_directive (char *dir) +{ + dlist_type *d = (dlist_type *) xmalloc (sizeof (dlist_type)); + d->text = xstrdup (dir); + d->next = a_list; + a_list = d; +} + +void +def_heapsize (int reserve, int commit) +{ + char b[200]; + if (commit > 0) + sprintf (b, "-heap 0x%x,0x%x ", reserve, commit); + else + sprintf (b, "-heap 0x%x ", reserve); + new_directive (xstrdup (b)); +} + +void +def_stacksize (int reserve, int commit) +{ + char b[200]; + if (commit > 0) + sprintf (b, "-stack 0x%x,0x%x ", reserve, commit); + else + sprintf (b, "-stack 0x%x ", reserve); + new_directive (xstrdup (b)); +} + +/* append_import simply adds the given import definition to the global + import_list. It is used by def_import. */ + +static void +append_import (const char *symbol_name, const char *dllname, int func_ordinal, + const char *its_name) +{ + iheadtype **pq; + iheadtype *q; + + for (pq = &import_list; *pq != NULL; pq = &(*pq)->next) + { + if (strcmp ((*pq)->dllname, dllname) == 0) + { + q = *pq; + q->functail->next = xmalloc (sizeof (ifunctype)); + q->functail = q->functail->next; + q->functail->ord = func_ordinal; + q->functail->name = xstrdup (symbol_name); + q->functail->its_name = (its_name ? xstrdup (its_name) : NULL); + q->functail->next = NULL; + q->nfuncs++; + return; + } + } + + q = xmalloc (sizeof (iheadtype)); + q->dllname = xstrdup (dllname); + q->nfuncs = 1; + q->funchead = xmalloc (sizeof (ifunctype)); + q->functail = q->funchead; + q->next = NULL; + q->functail->name = xstrdup (symbol_name); + q->functail->its_name = (its_name ? xstrdup (its_name) : NULL); + q->functail->ord = func_ordinal; + q->functail->next = NULL; + + *pq = q; +} + +/* def_import is called from within defparse.y when an IMPORT + declaration is encountered. Depending on the form of the + declaration, the module name may or may not need ".dll" to be + appended to it, the name of the function may be stored in internal + or entry, and there may or may not be an ordinal value associated + with it. */ + +/* A note regarding the parse modes: + In defparse.y we have to accept import declarations which follow + any one of the following forms: + = . + = . + . + . + Furthermore, the dll's name may or may not end with ".dll", which + complicates the parsing a little. Normally the dll's name is + passed to def_import() in the "module" parameter, but when it ends + with ".dll" it gets passed in "module" sans ".dll" and that needs + to be reappended. + + def_import gets five parameters: + APP_NAME - the name of the function in the application, if + present, or NULL if not present. + MODULE - the name of the dll, possibly sans extension (ie, '.dll'). + DLLEXT - the extension of the dll, if present, NULL if not present. + ENTRY - the name of the function in the dll, if present, or NULL. + ORD_VAL - the numerical tag of the function in the dll, if present, + or NULL. Exactly one of or must be + present (i.e., not NULL). */ + +void +def_import (const char *app_name, const char *module, const char *dllext, + const char *entry, int ord_val, const char *its_name) +{ + const char *application_name; + char *buf = NULL; + + if (entry != NULL) + application_name = entry; + else + { + if (app_name != NULL) + application_name = app_name; + else + application_name = ""; + } + + if (dllext != NULL) + module = buf = concat (module, ".", dllext, NULL); + + append_import (application_name, module, ord_val, its_name); + + if (buf) + free (buf); +} + +void +def_version (int major, int minor) +{ + printf (_("VERSION %d.%d\n"), major, minor); +} + +void +def_section (const char *name, int attr) +{ + char buf[200]; + char atts[5]; + char *d = atts; + if (attr & 1) + *d++ = 'R'; + + if (attr & 2) + *d++ = 'W'; + if (attr & 4) + *d++ = 'X'; + if (attr & 8) + *d++ = 'S'; + *d++ = 0; + sprintf (buf, "-attr %s %s", name, atts); + new_directive (xstrdup (buf)); +} + +void +def_code (int attr) +{ + + def_section ("CODE", attr); +} + +void +def_data (int attr) +{ + def_section ("DATA", attr); +} + +/**********************************************************************/ + +static void +run (const char *what, char *args) +{ + char *s; + int pid, wait_status; + int i; + const char **argv; + char *errmsg_fmt, *errmsg_arg; + char *temp_base = choose_temp_base (); + + inform (_("run: %s %s"), what, args); + + /* Count the args */ + i = 0; + for (s = args; *s; s++) + if (*s == ' ') + i++; + i++; + argv = xmalloc (sizeof (char *) * (i + 3)); + i = 0; + argv[i++] = what; + s = args; + while (1) + { + while (*s == ' ') + ++s; + argv[i++] = s; + while (*s != ' ' && *s != 0) + s++; + if (*s == 0) + break; + *s++ = 0; + } + argv[i++] = NULL; + + pid = pexecute (argv[0], (char * const *) argv, program_name, temp_base, + &errmsg_fmt, &errmsg_arg, PEXECUTE_ONE | PEXECUTE_SEARCH); + free(argv); + + if (pid == -1) + { + inform ("%s", strerror (errno)); + + fatal (errmsg_fmt, errmsg_arg); + } + + pid = pwait (pid, & wait_status, 0); + + if (pid == -1) + { + /* xgettext:c-format */ + fatal (_("wait: %s"), strerror (errno)); + } + else if (WIFSIGNALED (wait_status)) + { + /* xgettext:c-format */ + fatal (_("subprocess got fatal signal %d"), WTERMSIG (wait_status)); + } + else if (WIFEXITED (wait_status)) + { + if (WEXITSTATUS (wait_status) != 0) + /* xgettext:c-format */ + non_fatal (_("%s exited with status %d"), + what, WEXITSTATUS (wait_status)); + } + else + abort (); +} + +/* Look for a list of symbols to export in the .drectve section of + ABFD. Pass each one to def_exports. */ + +static void +scan_drectve_symbols (bfd *abfd) +{ + asection * s; + int size; + char * buf; + char * p; + char * e; + + /* Look for .drectve's */ + s = bfd_get_section_by_name (abfd, DRECTVE_SECTION_NAME); + + if (s == NULL) + return; + + size = bfd_get_section_size (s); + buf = xmalloc (size); + + bfd_get_section_contents (abfd, s, buf, 0, size); + + /* xgettext:c-format */ + inform (_("Sucking in info from %s section in %s"), + DRECTVE_SECTION_NAME, bfd_get_filename (abfd)); + + /* Search for -export: strings. The exported symbols can optionally + have type tags (eg., -export:foo,data), so handle those as well. + Currently only data tag is supported. */ + p = buf; + e = buf + size; + while (p < e) + { + if (p[0] == '-' + && CONST_STRNEQ (p, "-export:")) + { + char * name; + char * c; + flagword flags = BSF_FUNCTION; + + p += 8; + /* Do we have a quoted export? */ + if (*p == '"') + { + p++; + name = p; + while (p < e && *p != '"') + ++p; + } + else + { + name = p; + while (p < e && *p != ',' && *p != ' ' && *p != '-') + p++; + } + c = xmalloc (p - name + 1); + memcpy (c, name, p - name); + c[p - name] = 0; + /* Advance over trailing quote. */ + if (p < e && *p == '"') + ++p; + if (p < e && *p == ',') /* found type tag. */ + { + char *tag_start = ++p; + while (p < e && *p != ' ' && *p != '-') + p++; + if (CONST_STRNEQ (tag_start, "data")) + flags &= ~BSF_FUNCTION; + } + + /* FIXME: The 5th arg is for the `constant' field. + What should it be? Not that it matters since it's not + currently useful. */ + def_exports (c, 0, -1, 0, 0, ! (flags & BSF_FUNCTION), 0, NULL); + + if (add_stdcall_alias && strchr (c, '@')) + { + int lead_at = (*c == '@') ; + char *exported_name = xstrdup (c + lead_at); + char *atsym = strchr (exported_name, '@'); + *atsym = '\0'; + /* Note: stdcall alias symbols can never be data. */ + def_exports (exported_name, xstrdup (c), -1, 0, 0, 0, 0, NULL); + } + } + else + p++; + } + free (buf); +} + +/* Look through the symbols in MINISYMS, and add each one to list of + symbols to export. */ + +static void +scan_filtered_symbols (bfd *abfd, void *minisyms, long symcount, + unsigned int size) +{ + asymbol *store; + bfd_byte *from, *fromend; + + store = bfd_make_empty_symbol (abfd); + if (store == NULL) + bfd_fatal (bfd_get_filename (abfd)); + + from = (bfd_byte *) minisyms; + fromend = from + symcount * size; + for (; from < fromend; from += size) + { + asymbol *sym; + const char *symbol_name; + + sym = bfd_minisymbol_to_symbol (abfd, FALSE, from, store); + if (sym == NULL) + bfd_fatal (bfd_get_filename (abfd)); + + symbol_name = bfd_asymbol_name (sym); + if (bfd_get_symbol_leading_char (abfd) == symbol_name[0]) + ++symbol_name; + + def_exports (xstrdup (symbol_name) , 0, -1, 0, 0, + ! (sym->flags & BSF_FUNCTION), 0, NULL); + + if (add_stdcall_alias && strchr (symbol_name, '@')) + { + int lead_at = (*symbol_name == '@'); + char *exported_name = xstrdup (symbol_name + lead_at); + char *atsym = strchr (exported_name, '@'); + *atsym = '\0'; + /* Note: stdcall alias symbols can never be data. */ + def_exports (exported_name, xstrdup (symbol_name), -1, 0, 0, 0, 0, NULL); + } + } +} + +/* Add a list of symbols to exclude. */ + +static void +add_excludes (const char *new_excludes) +{ + char *local_copy; + char *exclude_string; + + local_copy = xstrdup (new_excludes); + + exclude_string = strtok (local_copy, ",:"); + for (; exclude_string; exclude_string = strtok (NULL, ",:")) + { + struct string_list *new_exclude; + + new_exclude = ((struct string_list *) + xmalloc (sizeof (struct string_list))); + new_exclude->string = (char *) xmalloc (strlen (exclude_string) + 2); + /* Don't add a leading underscore for fastcall symbols. */ + if (*exclude_string == '@') + sprintf (new_exclude->string, "%s", exclude_string); + else + sprintf (new_exclude->string, "%s%s", (!leading_underscore ? "" : "_"), + exclude_string); + new_exclude->next = excludes; + excludes = new_exclude; + + /* xgettext:c-format */ + inform (_("Excluding symbol: %s"), exclude_string); + } + + free (local_copy); +} + +/* See if STRING is on the list of symbols to exclude. */ + +static bfd_boolean +match_exclude (const char *string) +{ + struct string_list *excl_item; + + for (excl_item = excludes; excl_item; excl_item = excl_item->next) + if (strcmp (string, excl_item->string) == 0) + return TRUE; + return FALSE; +} + +/* Add the default list of symbols to exclude. */ + +static void +set_default_excludes (void) +{ + add_excludes (default_excludes); +} + +/* Choose which symbols to export. */ + +static long +filter_symbols (bfd *abfd, void *minisyms, long symcount, unsigned int size) +{ + bfd_byte *from, *fromend, *to; + asymbol *store; + + store = bfd_make_empty_symbol (abfd); + if (store == NULL) + bfd_fatal (bfd_get_filename (abfd)); + + from = (bfd_byte *) minisyms; + fromend = from + symcount * size; + to = (bfd_byte *) minisyms; + + for (; from < fromend; from += size) + { + int keep = 0; + asymbol *sym; + + sym = bfd_minisymbol_to_symbol (abfd, FALSE, (const void *) from, store); + if (sym == NULL) + bfd_fatal (bfd_get_filename (abfd)); + + /* Check for external and defined only symbols. */ + keep = (((sym->flags & BSF_GLOBAL) != 0 + || (sym->flags & BSF_WEAK) != 0 + || bfd_is_com_section (sym->section)) + && ! bfd_is_und_section (sym->section)); + + keep = keep && ! match_exclude (sym->name); + + if (keep) + { + memcpy (to, from, size); + to += size; + } + } + + return (to - (bfd_byte *) minisyms) / size; +} + +/* Export all symbols in ABFD, except for ones we were told not to + export. */ + +static void +scan_all_symbols (bfd *abfd) +{ + long symcount; + void *minisyms; + unsigned int size; + + /* Ignore bfds with an import descriptor table. We assume that any + such BFD contains symbols which are exported from another DLL, + and we don't want to reexport them from here. */ + if (bfd_get_section_by_name (abfd, ".idata$4")) + return; + + if (! (bfd_get_file_flags (abfd) & HAS_SYMS)) + { + /* xgettext:c-format */ + non_fatal (_("%s: no symbols"), bfd_get_filename (abfd)); + return; + } + + symcount = bfd_read_minisymbols (abfd, FALSE, &minisyms, &size); + if (symcount < 0) + bfd_fatal (bfd_get_filename (abfd)); + + if (symcount == 0) + { + /* xgettext:c-format */ + non_fatal (_("%s: no symbols"), bfd_get_filename (abfd)); + return; + } + + /* Discard the symbols we don't want to export. It's OK to do this + in place; we'll free the storage anyway. */ + + symcount = filter_symbols (abfd, minisyms, symcount, size); + scan_filtered_symbols (abfd, minisyms, symcount, size); + + free (minisyms); +} + +/* Look at the object file to decide which symbols to export. */ + +static void +scan_open_obj_file (bfd *abfd) +{ + if (export_all_symbols) + scan_all_symbols (abfd); + else + scan_drectve_symbols (abfd); + + /* FIXME: we ought to read in and block out the base relocations. */ + + /* xgettext:c-format */ + inform (_("Done reading %s"), bfd_get_filename (abfd)); +} + +static void +scan_obj_file (const char *filename) +{ + bfd * f = bfd_openr (filename, 0); + + if (!f) + /* xgettext:c-format */ + fatal (_("Unable to open object file: %s: %s"), filename, bfd_get_errmsg ()); + + /* xgettext:c-format */ + inform (_("Scanning object file %s"), filename); + + if (bfd_check_format (f, bfd_archive)) + { + bfd *arfile = bfd_openr_next_archived_file (f, 0); + while (arfile) + { + bfd *next; + if (bfd_check_format (arfile, bfd_object)) + scan_open_obj_file (arfile); + next = bfd_openr_next_archived_file (f, arfile); + bfd_close (arfile); + /* PR 17512: file: 58715298. */ + if (next == arfile) + break; + arfile = next; + } + +#ifdef DLLTOOL_MCORE_ELF + if (mcore_elf_out_file) + inform (_("Cannot produce mcore-elf dll from archive file: %s"), filename); +#endif + } + else if (bfd_check_format (f, bfd_object)) + { + scan_open_obj_file (f); + +#ifdef DLLTOOL_MCORE_ELF + if (mcore_elf_out_file) + mcore_elf_cache_filename (filename); +#endif + } + + bfd_close (f); +} + + + +static void +dump_def_info (FILE *f) +{ + int i; + export_type *exp; + fprintf (f, "%s ", ASM_C); + for (i = 0; oav[i]; i++) + fprintf (f, "%s ", oav[i]); + fprintf (f, "\n"); + for (i = 0, exp = d_exports; exp; i++, exp = exp->next) + { + fprintf (f, "%s %d = %s %s @ %d %s%s%s%s%s%s\n", + ASM_C, + i, + exp->name, + exp->internal_name, + exp->ordinal, + exp->noname ? "NONAME " : "", + exp->private ? "PRIVATE " : "", + exp->constant ? "CONSTANT" : "", + exp->data ? "DATA" : "", + exp->its_name ? " ==" : "", + exp->its_name ? exp->its_name : ""); + } +} + +/* Generate the .exp file. */ + +static int +sfunc (const void *a, const void *b) +{ + if (*(const bfd_vma *) a == *(const bfd_vma *) b) + return 0; + + return ((*(const bfd_vma *) a > *(const bfd_vma *) b) ? 1 : -1); +} + +static void +flush_page (FILE *f, bfd_vma *need, bfd_vma page_addr, int on_page) +{ + int i; + + /* Flush this page. */ + fprintf (f, "\t%s\t0x%08x\t%s Starting RVA for chunk\n", + ASM_LONG, + (int) page_addr, + ASM_C); + fprintf (f, "\t%s\t0x%x\t%s Size of block\n", + ASM_LONG, + (on_page * 2) + (on_page & 1) * 2 + 8, + ASM_C); + + for (i = 0; i < on_page; i++) + { + bfd_vma needed = need[i]; + + if (needed) + { + if (!create_for_pep) + { + /* Relocation via HIGHLOW. */ + needed = ((needed - page_addr) | 0x3000) & 0xffff; + } + else + { + /* Relocation via DIR64. */ + needed = ((needed - page_addr) | 0xa000) & 0xffff; + } + } + + fprintf (f, "\t%s\t0x%lx\n", ASM_SHORT, (long) needed); + } + + /* And padding */ + if (on_page & 1) + fprintf (f, "\t%s\t0x%x\n", ASM_SHORT, 0 | 0x0000); +} + +static void +gen_def_file (void) +{ + int i; + export_type *exp; + + inform (_("Adding exports to output file")); + + fprintf (output_def, ";"); + for (i = 0; oav[i]; i++) + fprintf (output_def, " %s", oav[i]); + + fprintf (output_def, "\nEXPORTS\n"); + + for (i = 0, exp = d_exports; exp; i++, exp = exp->next) + { + char *quote = strchr (exp->name, '.') ? "\"" : ""; + char *res = cplus_demangle (exp->internal_name, DMGL_ANSI | DMGL_PARAMS); + + if (res) + { + fprintf (output_def,";\t%s\n", res); + free (res); + } + + if (strcmp (exp->name, exp->internal_name) == 0) + { + fprintf (output_def, "\t%s%s%s @ %d%s%s%s%s%s\n", + quote, + exp->name, + quote, + exp->ordinal, + exp->noname ? " NONAME" : "", + exp->private ? "PRIVATE " : "", + exp->data ? " DATA" : "", + exp->its_name ? " ==" : "", + exp->its_name ? exp->its_name : ""); + } + else + { + char * quote1 = strchr (exp->internal_name, '.') ? "\"" : ""; + /* char *alias = */ + fprintf (output_def, "\t%s%s%s = %s%s%s @ %d%s%s%s%s%s\n", + quote, + exp->name, + quote, + quote1, + exp->internal_name, + quote1, + exp->ordinal, + exp->noname ? " NONAME" : "", + exp->private ? "PRIVATE " : "", + exp->data ? " DATA" : "", + exp->its_name ? " ==" : "", + exp->its_name ? exp->its_name : ""); + } + } + + inform (_("Added exports to output file")); +} + +/* generate_idata_ofile generates the portable assembly source code + for the idata sections. It appends the source code to the end of + the file. */ + +static void +generate_idata_ofile (FILE *filvar) +{ + iheadtype *headptr; + ifunctype *funcptr; + int headindex; + int funcindex; + int nheads; + + if (import_list == NULL) + return; + + fprintf (filvar, "%s Import data sections\n", ASM_C); + fprintf (filvar, "\n\t.section\t.idata$2\n"); + fprintf (filvar, "\t%s\tdoi_idata\n", ASM_GLOBAL); + fprintf (filvar, "doi_idata:\n"); + + nheads = 0; + for (headptr = import_list; headptr != NULL; headptr = headptr->next) + { + fprintf (filvar, "\t%slistone%d%s\t%s %s\n", + ASM_RVA_BEFORE, nheads, ASM_RVA_AFTER, + ASM_C, headptr->dllname); + fprintf (filvar, "\t%s\t0\n", ASM_LONG); + fprintf (filvar, "\t%s\t0\n", ASM_LONG); + fprintf (filvar, "\t%sdllname%d%s\n", + ASM_RVA_BEFORE, nheads, ASM_RVA_AFTER); + fprintf (filvar, "\t%slisttwo%d%s\n\n", + ASM_RVA_BEFORE, nheads, ASM_RVA_AFTER); + nheads++; + } + + fprintf (filvar, "\t%s\t0\n", ASM_LONG); /* NULL record at */ + fprintf (filvar, "\t%s\t0\n", ASM_LONG); /* end of idata$2 */ + fprintf (filvar, "\t%s\t0\n", ASM_LONG); /* section */ + fprintf (filvar, "\t%s\t0\n", ASM_LONG); + fprintf (filvar, "\t%s\t0\n", ASM_LONG); + + fprintf (filvar, "\n\t.section\t.idata$4\n"); + headindex = 0; + for (headptr = import_list; headptr != NULL; headptr = headptr->next) + { + fprintf (filvar, "listone%d:\n", headindex); + for (funcindex = 0; funcindex < headptr->nfuncs; funcindex++) + { + if (create_for_pep) + fprintf (filvar, "\t%sfuncptr%d_%d%s\n%s\t0\n", + ASM_RVA_BEFORE, headindex, funcindex, ASM_RVA_AFTER, + ASM_LONG); + else + fprintf (filvar, "\t%sfuncptr%d_%d%s\n", + ASM_RVA_BEFORE, headindex, funcindex, ASM_RVA_AFTER); + } + if (create_for_pep) + fprintf (filvar, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + else + fprintf (filvar, "\t%s\t0\n", ASM_LONG); /* NULL terminating list. */ + headindex++; + } + + fprintf (filvar, "\n\t.section\t.idata$5\n"); + headindex = 0; + for (headptr = import_list; headptr != NULL; headptr = headptr->next) + { + fprintf (filvar, "listtwo%d:\n", headindex); + for (funcindex = 0; funcindex < headptr->nfuncs; funcindex++) + { + if (create_for_pep) + fprintf (filvar, "\t%sfuncptr%d_%d%s\n%s\t0\n", + ASM_RVA_BEFORE, headindex, funcindex, ASM_RVA_AFTER, + ASM_LONG); + else + fprintf (filvar, "\t%sfuncptr%d_%d%s\n", + ASM_RVA_BEFORE, headindex, funcindex, ASM_RVA_AFTER); + } + if (create_for_pep) + fprintf (filvar, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + else + fprintf (filvar, "\t%s\t0\n", ASM_LONG); /* NULL terminating list. */ + headindex++; + } + + fprintf (filvar, "\n\t.section\t.idata$6\n"); + headindex = 0; + for (headptr = import_list; headptr != NULL; headptr = headptr->next) + { + funcindex = 0; + for (funcptr = headptr->funchead; funcptr != NULL; + funcptr = funcptr->next) + { + fprintf (filvar,"funcptr%d_%d:\n", headindex, funcindex); + fprintf (filvar,"\t%s\t%d\n", ASM_SHORT, + ((funcptr->ord) & 0xFFFF)); + fprintf (filvar,"\t%s\t\"%s\"\n", ASM_TEXT, + (funcptr->its_name ? funcptr->its_name : funcptr->name)); + fprintf (filvar,"\t%s\t0\n", ASM_BYTE); + funcindex++; + } + headindex++; + } + + fprintf (filvar, "\n\t.section\t.idata$7\n"); + headindex = 0; + for (headptr = import_list; headptr != NULL; headptr = headptr->next) + { + fprintf (filvar,"dllname%d:\n", headindex); + fprintf (filvar,"\t%s\t\"%s\"\n", ASM_TEXT, headptr->dllname); + fprintf (filvar,"\t%s\t0\n", ASM_BYTE); + headindex++; + } +} + +/* Assemble the specified file. */ +static void +assemble_file (const char * source, const char * dest) +{ + char * cmd; + + cmd = xmalloc (strlen (ASM_SWITCHES) + strlen (as_flags) + + strlen (source) + strlen (dest) + 50); + + sprintf (cmd, "%s %s -o %s %s", ASM_SWITCHES, as_flags, dest, source); + + run (as_name, cmd); + free (cmd); +} + +static const char * temp_file_to_remove[5]; +#define TEMP_EXPORT_FILE 0 +#define TEMP_HEAD_FILE 1 +#define TEMP_TAIL_FILE 2 +#define TEMP_HEAD_O_FILE 3 +#define TEMP_TAIL_O_FILE 4 + +static void +unlink_temp_files (void) +{ + unsigned i; + + if (dontdeltemps > 0) + return; + + for (i = 0; i < ARRAY_SIZE (temp_file_to_remove); i++) + { + if (temp_file_to_remove[i]) + { + unlink (temp_file_to_remove[i]); + temp_file_to_remove[i] = NULL; + } + } +} + +static void +gen_exp_file (void) +{ + FILE *f; + int i; + export_type *exp; + dlist_type *dl; + + /* xgettext:c-format */ + inform (_("Generating export file: %s"), exp_name); + + f = fopen (TMP_ASM, FOPEN_WT); + if (!f) + /* xgettext:c-format */ + fatal (_("Unable to open temporary assembler file: %s"), TMP_ASM); + + temp_file_to_remove[TEMP_EXPORT_FILE] = TMP_ASM; + + /* xgettext:c-format */ + inform (_("Opened temporary file: %s"), TMP_ASM); + + dump_def_info (f); + + if (d_exports) + { + fprintf (f, "\t.section .edata\n\n"); + fprintf (f, "\t%s 0 %s Allways 0\n", ASM_LONG, ASM_C); + fprintf (f, "\t%s 0x%lx %s Time and date\n", ASM_LONG, + (unsigned long) time(0), ASM_C); + fprintf (f, "\t%s 0 %s Major and Minor version\n", ASM_LONG, ASM_C); + fprintf (f, "\t%sname%s %s Ptr to name of dll\n", ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C); + fprintf (f, "\t%s %d %s Starting ordinal of exports\n", ASM_LONG, d_low_ord, ASM_C); + + + fprintf (f, "\t%s %d %s Number of functions\n", ASM_LONG, d_high_ord - d_low_ord + 1, ASM_C); + fprintf(f,"\t%s named funcs %d, low ord %d, high ord %d\n", + ASM_C, + d_named_nfuncs, d_low_ord, d_high_ord); + fprintf (f, "\t%s %d %s Number of names\n", ASM_LONG, + show_allnames ? d_high_ord - d_low_ord + 1 : d_named_nfuncs, ASM_C); + fprintf (f, "\t%safuncs%s %s Address of functions\n", ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C); + + fprintf (f, "\t%sanames%s %s Address of Name Pointer Table\n", + ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C); + + fprintf (f, "\t%sanords%s %s Address of ordinals\n", ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C); + + fprintf (f, "name: %s \"%s\"\n", ASM_TEXT, dll_name); + + + fprintf(f,"%s Export address Table\n", ASM_C); + fprintf(f,"\t%s\n", ASM_ALIGN_LONG); + fprintf (f, "afuncs:\n"); + i = d_low_ord; + + for (exp = d_exports; exp; exp = exp->next) + { + if (exp->ordinal != i) + { + while (i < exp->ordinal) + { + fprintf(f,"\t%s\t0\n", ASM_LONG); + i++; + } + } + + if (exp->forward == 0) + { + if (exp->internal_name[0] == '@') + fprintf (f, "\t%s%s%s\t%s %d\n", ASM_RVA_BEFORE, + exp->internal_name, ASM_RVA_AFTER, ASM_C, exp->ordinal); + else + fprintf (f, "\t%s%s%s%s\t%s %d\n", ASM_RVA_BEFORE, + ASM_PREFIX (exp->internal_name), + exp->internal_name, ASM_RVA_AFTER, ASM_C, exp->ordinal); + } + else + fprintf (f, "\t%sf%d%s\t%s %d\n", ASM_RVA_BEFORE, + exp->forward, ASM_RVA_AFTER, ASM_C, exp->ordinal); + i++; + } + + fprintf (f,"%s Export Name Pointer Table\n", ASM_C); + fprintf (f, "anames:\n"); + + for (i = 0; (exp = d_exports_lexically[i]); i++) + { + if (!exp->noname || show_allnames) + fprintf (f, "\t%sn%d%s\n", + ASM_RVA_BEFORE, exp->ordinal, ASM_RVA_AFTER); + } + + fprintf (f,"%s Export Ordinal Table\n", ASM_C); + fprintf (f, "anords:\n"); + for (i = 0; (exp = d_exports_lexically[i]); i++) + { + if (!exp->noname || show_allnames) + fprintf (f, "\t%s %d\n", ASM_SHORT, exp->ordinal - d_low_ord); + } + + fprintf(f,"%s Export Name Table\n", ASM_C); + for (i = 0; (exp = d_exports_lexically[i]); i++) + { + if (!exp->noname || show_allnames) + fprintf (f, "n%d: %s \"%s\"\n", + exp->ordinal, ASM_TEXT, + (exp->its_name ? exp->its_name : xlate (exp->name))); + if (exp->forward != 0) + fprintf (f, "f%d: %s \"%s\"\n", + exp->forward, ASM_TEXT, exp->internal_name); + } + + if (a_list) + { + fprintf (f, "\t.section %s\n", DRECTVE_SECTION_NAME); + for (dl = a_list; dl; dl = dl->next) + { + fprintf (f, "\t%s\t\"%s\"\n", ASM_TEXT, dl->text); + } + } + + if (d_list) + { + fprintf (f, "\t.section .rdata\n"); + for (dl = d_list; dl; dl = dl->next) + { + char *p; + int l; + + /* We don't output as ascii because there can + be quote characters in the string. */ + l = 0; + for (p = dl->text; *p; p++) + { + if (l == 0) + fprintf (f, "\t%s\t", ASM_BYTE); + else + fprintf (f, ","); + fprintf (f, "%d", *p); + if (p[1] == 0) + { + fprintf (f, ",0\n"); + break; + } + if (++l == 10) + { + fprintf (f, "\n"); + l = 0; + } + } + } + } + } + + /* Add to the output file a way of getting to the exported names + without using the import library. */ + if (add_indirect) + { + fprintf (f, "\t.section\t.rdata\n"); + for (i = 0, exp = d_exports; exp; i++, exp = exp->next) + if (!exp->noname || show_allnames) + { + /* We use a single underscore for MS compatibility, and a + double underscore for backward compatibility with old + cygwin releases. */ + if (create_compat_implib) + fprintf (f, "\t%s\t__imp_%s\n", ASM_GLOBAL, exp->name); + fprintf (f, "\t%s\t_imp_%s%s\n", ASM_GLOBAL, + (!leading_underscore ? "" : "_"), exp->name); + if (create_compat_implib) + fprintf (f, "__imp_%s:\n", exp->name); + fprintf (f, "_imp_%s%s:\n", (!leading_underscore ? "" : "_"), exp->name); + fprintf (f, "\t%s\t%s\n", ASM_LONG, exp->name); + } + } + + /* Dump the reloc section if a base file is provided. */ + if (base_file) + { + bfd_vma addr; + bfd_vma need[COFF_PAGE_SIZE]; + bfd_vma page_addr; + bfd_size_type numbytes; + int num_entries; + bfd_vma *copy; + int j; + int on_page; + fprintf (f, "\t.section\t.init\n"); + fprintf (f, "lab:\n"); + + fseek (base_file, 0, SEEK_END); + numbytes = ftell (base_file); + fseek (base_file, 0, SEEK_SET); + copy = xmalloc (numbytes); + if (fread (copy, 1, numbytes, base_file) < numbytes) + fatal (_("failed to read the number of entries from base file")); + num_entries = numbytes / sizeof (bfd_vma); + + + fprintf (f, "\t.section\t.reloc\n"); + if (num_entries) + { + int src; + int dst = 0; + bfd_vma last = (bfd_vma) -1; + qsort (copy, num_entries, sizeof (bfd_vma), sfunc); + /* Delete duplicates */ + for (src = 0; src < num_entries; src++) + { + if (last != copy[src]) + last = copy[dst++] = copy[src]; + } + num_entries = dst; + addr = copy[0]; + page_addr = addr & PAGE_MASK; /* work out the page addr */ + on_page = 0; + for (j = 0; j < num_entries; j++) + { + addr = copy[j]; + if ((addr & PAGE_MASK) != page_addr) + { + flush_page (f, need, page_addr, on_page); + on_page = 0; + page_addr = addr & PAGE_MASK; + } + need[on_page++] = addr; + } + flush_page (f, need, page_addr, on_page); + +/* fprintf (f, "\t%s\t0,0\t%s End\n", ASM_LONG, ASM_C);*/ + } + } + + generate_idata_ofile (f); + + fclose (f); + + /* Assemble the file. */ + assemble_file (TMP_ASM, exp_name); + + if (dontdeltemps == 0) + { + temp_file_to_remove[TEMP_EXPORT_FILE] = NULL; + unlink (TMP_ASM); + } + + inform (_("Generated exports file")); +} + +static const char * +xlate (const char *name) +{ + int lead_at = (*name == '@'); + int is_stdcall = (!lead_at && strchr (name, '@') != NULL); + + if (!lead_at && (add_underscore + || (add_stdcall_underscore && is_stdcall))) + { + char *copy = xmalloc (strlen (name) + 2); + + copy[0] = '_'; + strcpy (copy + 1, name); + name = copy; + } + + if (killat) + { + char *p; + + name += lead_at; + /* PR 9766: Look for the last @ sign in the name. */ + p = strrchr (name, '@'); + if (p && ISDIGIT (p[1])) + *p = 0; + } + return name; +} + +typedef struct +{ + int id; + const char *name; + int flags; + int align; + asection *sec; + asymbol *sym; + asymbol **sympp; + int size; + unsigned char *data; +} sinfo; + +#define INIT_SEC_DATA(id, name, flags, align) \ + { id, name, flags, align, NULL, NULL, NULL, 0, NULL } + +#ifndef DLLTOOL_PPC + +#define TEXT 0 +#define DATA 1 +#define BSS 2 +#define IDATA7 3 +#define IDATA5 4 +#define IDATA4 5 +#define IDATA6 6 + +#define NSECS 7 + +#define TEXT_SEC_FLAGS \ + (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY | SEC_HAS_CONTENTS) +#define DATA_SEC_FLAGS (SEC_ALLOC | SEC_LOAD | SEC_DATA) +#define BSS_SEC_FLAGS SEC_ALLOC + +static sinfo secdata[NSECS] = +{ + INIT_SEC_DATA (TEXT, ".text", TEXT_SEC_FLAGS, 2), + INIT_SEC_DATA (DATA, ".data", DATA_SEC_FLAGS, 2), + INIT_SEC_DATA (BSS, ".bss", BSS_SEC_FLAGS, 2), + INIT_SEC_DATA (IDATA7, ".idata$7", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (IDATA5, ".idata$5", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (IDATA4, ".idata$4", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (IDATA6, ".idata$6", SEC_HAS_CONTENTS, 1) +}; + +#else + +/* Sections numbered to make the order the same as other PowerPC NT + compilers. This also keeps funny alignment thingies from happening. */ +#define TEXT 0 +#define PDATA 1 +#define RDATA 2 +#define IDATA5 3 +#define IDATA4 4 +#define IDATA6 5 +#define IDATA7 6 +#define DATA 7 +#define BSS 8 + +#define NSECS 9 + +static sinfo secdata[NSECS] = +{ + INIT_SEC_DATA (TEXT, ".text", SEC_CODE | SEC_HAS_CONTENTS, 3), + INIT_SEC_DATA (PDATA, ".pdata", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (RDATA, ".reldata", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (IDATA5, ".idata$5", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (IDATA4, ".idata$4", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (IDATA6, ".idata$6", SEC_HAS_CONTENTS, 1), + INIT_SEC_DATA (IDATA7, ".idata$7", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (DATA, ".data", SEC_DATA, 2), + INIT_SEC_DATA (BSS, ".bss", 0, 2) +}; + +#endif + +/* This is what we're trying to make. We generate the imp symbols with + both single and double underscores, for compatibility. + + .text + .global _GetFileVersionInfoSizeW@8 + .global __imp_GetFileVersionInfoSizeW@8 +_GetFileVersionInfoSizeW@8: + jmp * __imp_GetFileVersionInfoSizeW@8 + .section .idata$7 # To force loading of head + .long __version_a_head +# Import Address Table + .section .idata$5 +__imp_GetFileVersionInfoSizeW@8: + .rva ID2 + +# Import Lookup Table + .section .idata$4 + .rva ID2 +# Hint/Name table + .section .idata$6 +ID2: .short 2 + .asciz "GetFileVersionInfoSizeW" + + + For the PowerPC, here's the variation on the above scheme: + +# Rather than a simple "jmp *", the code to get to the dll function +# looks like: + .text + lwz r11,[tocv]__imp_function_name(r2) +# RELOC: 00000000 TOCREL16,TOCDEFN __imp_function_name + lwz r12,0(r11) + stw r2,4(r1) + mtctr r12 + lwz r2,4(r11) + bctr */ + +static char * +make_label (const char *prefix, const char *name) +{ + int len = strlen (ASM_PREFIX (name)) + strlen (prefix) + strlen (name); + char *copy = xmalloc (len + 1); + + strcpy (copy, ASM_PREFIX (name)); + strcat (copy, prefix); + strcat (copy, name); + return copy; +} + +static char * +make_imp_label (const char *prefix, const char *name) +{ + int len; + char *copy; + + if (name[0] == '@') + { + len = strlen (prefix) + strlen (name); + copy = xmalloc (len + 1); + strcpy (copy, prefix); + strcat (copy, name); + } + else + { + len = strlen (ASM_PREFIX (name)) + strlen (prefix) + strlen (name); + copy = xmalloc (len + 1); + strcpy (copy, prefix); + strcat (copy, ASM_PREFIX (name)); + strcat (copy, name); + } + return copy; +} + +static bfd * +make_one_lib_file (export_type *exp, int i, int delay) +{ + bfd * abfd; + asymbol * exp_label; + asymbol * iname = 0; + asymbol * iname2; + asymbol * iname_lab; + asymbol ** iname_lab_pp; + asymbol ** iname_pp; +#ifdef DLLTOOL_PPC + asymbol ** fn_pp; + asymbol ** toc_pp; +#define EXTRA 2 +#endif +#ifndef EXTRA +#define EXTRA 0 +#endif + asymbol * ptrs[NSECS + 4 + EXTRA + 1]; + flagword applicable; + char * outname = xmalloc (strlen (TMP_STUB) + 10); + int oidx = 0; + + + sprintf (outname, "%s%05d.o", TMP_STUB, i); + + abfd = bfd_openw (outname, HOW_BFD_WRITE_TARGET); + + if (!abfd) + /* xgettext:c-format */ + fatal (_("bfd_open failed open stub file: %s: %s"), + outname, bfd_get_errmsg ()); + + /* xgettext:c-format */ + inform (_("Creating stub file: %s"), outname); + + bfd_set_format (abfd, bfd_object); + bfd_set_arch_mach (abfd, HOW_BFD_ARCH, 0); + +#ifdef DLLTOOL_ARM + if (machine == MARM_INTERWORK || machine == MTHUMB) + bfd_set_private_flags (abfd, F_INTERWORK); +#endif + + applicable = bfd_applicable_section_flags (abfd); + + /* First make symbols for the sections. */ + for (i = 0; i < NSECS; i++) + { + sinfo *si = secdata + i; + + if (si->id != i) + abort (); + si->sec = bfd_make_section_old_way (abfd, si->name); + bfd_set_section_flags (abfd, + si->sec, + si->flags & applicable); + + bfd_set_section_alignment(abfd, si->sec, si->align); + si->sec->output_section = si->sec; + si->sym = bfd_make_empty_symbol(abfd); + si->sym->name = si->sec->name; + si->sym->section = si->sec; + si->sym->flags = BSF_LOCAL; + si->sym->value = 0; + ptrs[oidx] = si->sym; + si->sympp = ptrs + oidx; + si->size = 0; + si->data = NULL; + + oidx++; + } + + if (! exp->data) + { + exp_label = bfd_make_empty_symbol (abfd); + exp_label->name = make_imp_label ("", exp->name); + + /* On PowerPC, the function name points to a descriptor in + the rdata section, the first element of which is a + pointer to the code (..function_name), and the second + points to the .toc. */ +#ifdef DLLTOOL_PPC + if (machine == MPPC) + exp_label->section = secdata[RDATA].sec; + else +#endif + exp_label->section = secdata[TEXT].sec; + + exp_label->flags = BSF_GLOBAL; + exp_label->value = 0; + +#ifdef DLLTOOL_ARM + if (machine == MTHUMB) + bfd_coff_set_symbol_class (abfd, exp_label, C_THUMBEXTFUNC); +#endif + ptrs[oidx++] = exp_label; + } + + /* Generate imp symbols with one underscore for Microsoft + compatibility, and with two underscores for backward + compatibility with old versions of cygwin. */ + if (create_compat_implib) + { + iname = bfd_make_empty_symbol (abfd); + iname->name = make_imp_label ("___imp", exp->name); + iname->section = secdata[IDATA5].sec; + iname->flags = BSF_GLOBAL; + iname->value = 0; + } + + iname2 = bfd_make_empty_symbol (abfd); + iname2->name = make_imp_label ("__imp_", exp->name); + iname2->section = secdata[IDATA5].sec; + iname2->flags = BSF_GLOBAL; + iname2->value = 0; + + iname_lab = bfd_make_empty_symbol (abfd); + + iname_lab->name = head_label; + iname_lab->section = bfd_und_section_ptr; + iname_lab->flags = 0; + iname_lab->value = 0; + + iname_pp = ptrs + oidx; + if (create_compat_implib) + ptrs[oidx++] = iname; + ptrs[oidx++] = iname2; + + iname_lab_pp = ptrs + oidx; + ptrs[oidx++] = iname_lab; + +#ifdef DLLTOOL_PPC + /* The symbol referring to the code (.text). */ + { + asymbol *function_name; + + function_name = bfd_make_empty_symbol(abfd); + function_name->name = make_label ("..", exp->name); + function_name->section = secdata[TEXT].sec; + function_name->flags = BSF_GLOBAL; + function_name->value = 0; + + fn_pp = ptrs + oidx; + ptrs[oidx++] = function_name; + } + + /* The .toc symbol. */ + { + asymbol *toc_symbol; + + toc_symbol = bfd_make_empty_symbol (abfd); + toc_symbol->name = make_label (".", "toc"); + toc_symbol->section = bfd_und_section_ptr; + toc_symbol->flags = BSF_GLOBAL; + toc_symbol->value = 0; + + toc_pp = ptrs + oidx; + ptrs[oidx++] = toc_symbol; + } +#endif + + ptrs[oidx] = 0; + + for (i = 0; i < NSECS; i++) + { + sinfo *si = secdata + i; + asection *sec = si->sec; + arelent *rel, *rel2 = 0, *rel3 = 0; + arelent **rpp; + + switch (i) + { + case TEXT: + if (! exp->data) + { + si->size = HOW_JTAB_SIZE; + si->data = xmalloc (HOW_JTAB_SIZE); + memcpy (si->data, HOW_JTAB, HOW_JTAB_SIZE); + + /* Add the reloc into idata$5. */ + rel = xmalloc (sizeof (arelent)); + + rpp = xmalloc (sizeof (arelent *) * (delay ? 4 : 2)); + rpp[0] = rel; + rpp[1] = 0; + + rel->address = HOW_JTAB_ROFF; + rel->addend = 0; + + if (delay) + { + rel2 = xmalloc (sizeof (arelent)); + rpp[1] = rel2; + rel2->address = HOW_JTAB_ROFF2; + rel2->addend = 0; + rel3 = xmalloc (sizeof (arelent)); + rpp[2] = rel3; + rel3->address = HOW_JTAB_ROFF3; + rel3->addend = 0; + rpp[3] = 0; + } + + if (machine == MPPC) + { + rel->howto = bfd_reloc_type_lookup (abfd, + BFD_RELOC_16_GOTOFF); + rel->sym_ptr_ptr = iname_pp; + } + else if (machine == MX86) + { + rel->howto = bfd_reloc_type_lookup (abfd, + BFD_RELOC_32_PCREL); + rel->sym_ptr_ptr = iname_pp; + } + else + { + rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32); + rel->sym_ptr_ptr = secdata[IDATA5].sympp; + } + + if (delay) + { + if (machine == MX86) + rel2->howto = bfd_reloc_type_lookup (abfd, + BFD_RELOC_32_PCREL); + else + rel2->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32); + rel2->sym_ptr_ptr = rel->sym_ptr_ptr; + rel3->howto = bfd_reloc_type_lookup (abfd, + BFD_RELOC_32_PCREL); + rel3->sym_ptr_ptr = iname_lab_pp; + } + + sec->orelocation = rpp; + sec->reloc_count = delay ? 3 : 1; + } + break; + + case IDATA5: + if (delay) + { + si->size = create_for_pep ? 8 : 4; + si->data = xmalloc (si->size); + sec->reloc_count = 1; + memset (si->data, 0, si->size); + /* Point after jmp [__imp_...] instruction. */ + si->data[0] = 6; + rel = xmalloc (sizeof (arelent)); + rpp = xmalloc (sizeof (arelent *) * 2); + rpp[0] = rel; + rpp[1] = 0; + rel->address = 0; + rel->addend = 0; + if (create_for_pep) + rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_64); + else + rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32); + rel->sym_ptr_ptr = secdata[TEXT].sympp; + sec->orelocation = rpp; + break; + } + /* Fall through. */ + + case IDATA4: + /* An idata$4 or idata$5 is one word long, and has an + rva to idata$6. */ + + if (create_for_pep) + { + si->data = xmalloc (8); + si->size = 8; + if (exp->noname) + { + si->data[0] = exp->ordinal ; + si->data[1] = exp->ordinal >> 8; + si->data[2] = exp->ordinal >> 16; + si->data[3] = exp->ordinal >> 24; + si->data[4] = 0; + si->data[5] = 0; + si->data[6] = 0; + si->data[7] = 0x80; + } + else + { + sec->reloc_count = 1; + memset (si->data, 0, si->size); + rel = xmalloc (sizeof (arelent)); + rpp = xmalloc (sizeof (arelent *) * 2); + rpp[0] = rel; + rpp[1] = 0; + rel->address = 0; + rel->addend = 0; + rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_RVA); + rel->sym_ptr_ptr = secdata[IDATA6].sympp; + sec->orelocation = rpp; + } + } + else + { + si->data = xmalloc (4); + si->size = 4; + + if (exp->noname) + { + si->data[0] = exp->ordinal ; + si->data[1] = exp->ordinal >> 8; + si->data[2] = exp->ordinal >> 16; + si->data[3] = 0x80; + } + else + { + sec->reloc_count = 1; + memset (si->data, 0, si->size); + rel = xmalloc (sizeof (arelent)); + rpp = xmalloc (sizeof (arelent *) * 2); + rpp[0] = rel; + rpp[1] = 0; + rel->address = 0; + rel->addend = 0; + rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_RVA); + rel->sym_ptr_ptr = secdata[IDATA6].sympp; + sec->orelocation = rpp; + } + } + break; + + case IDATA6: + if (!exp->noname) + { + int idx = exp->ordinal; + + if (exp->its_name) + si->size = strlen (exp->its_name) + 3; + else + si->size = strlen (xlate (exp->import_name)) + 3; + si->data = xmalloc (si->size); + memset (si->data, 0, si->size); + si->data[0] = idx & 0xff; + si->data[1] = idx >> 8; + if (exp->its_name) + strcpy ((char *) si->data + 2, exp->its_name); + else + strcpy ((char *) si->data + 2, xlate (exp->import_name)); + } + break; + case IDATA7: + if (delay) + break; + si->size = 4; + si->data = xmalloc (4); + memset (si->data, 0, si->size); + rel = xmalloc (sizeof (arelent)); + rpp = xmalloc (sizeof (arelent *) * 2); + rpp[0] = rel; + rel->address = 0; + rel->addend = 0; + rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_RVA); + rel->sym_ptr_ptr = iname_lab_pp; + sec->orelocation = rpp; + sec->reloc_count = 1; + break; + +#ifdef DLLTOOL_PPC + case PDATA: + { + /* The .pdata section is 5 words long. + Think of it as: + struct + { + bfd_vma BeginAddress, [0x00] + EndAddress, [0x04] + ExceptionHandler, [0x08] + HandlerData, [0x0c] + PrologEndAddress; [0x10] + }; */ + + /* So this pdata section setups up this as a glue linkage to + a dll routine. There are a number of house keeping things + we need to do: + + 1. In the name of glue trickery, the ADDR32 relocs for 0, + 4, and 0x10 are set to point to the same place: + "..function_name". + 2. There is one more reloc needed in the pdata section. + The actual glue instruction to restore the toc on + return is saved as the offset in an IMGLUE reloc. + So we need a total of four relocs for this section. + + 3. Lastly, the HandlerData field is set to 0x03, to indicate + that this is a glue routine. */ + arelent *imglue, *ba_rel, *ea_rel, *pea_rel; + + /* Alignment must be set to 2**2 or you get extra stuff. */ + bfd_set_section_alignment(abfd, sec, 2); + + si->size = 4 * 5; + si->data = xmalloc (si->size); + memset (si->data, 0, si->size); + rpp = xmalloc (sizeof (arelent *) * 5); + rpp[0] = imglue = xmalloc (sizeof (arelent)); + rpp[1] = ba_rel = xmalloc (sizeof (arelent)); + rpp[2] = ea_rel = xmalloc (sizeof (arelent)); + rpp[3] = pea_rel = xmalloc (sizeof (arelent)); + rpp[4] = 0; + + /* Stick the toc reload instruction in the glue reloc. */ + bfd_put_32(abfd, ppc_glue_insn, (char *) &imglue->address); + + imglue->addend = 0; + imglue->howto = bfd_reloc_type_lookup (abfd, + BFD_RELOC_32_GOTOFF); + imglue->sym_ptr_ptr = fn_pp; + + ba_rel->address = 0; + ba_rel->addend = 0; + ba_rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32); + ba_rel->sym_ptr_ptr = fn_pp; + + bfd_put_32 (abfd, 0x18, si->data + 0x04); + ea_rel->address = 4; + ea_rel->addend = 0; + ea_rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32); + ea_rel->sym_ptr_ptr = fn_pp; + + /* Mark it as glue. */ + bfd_put_32 (abfd, 0x03, si->data + 0x0c); + + /* Mark the prolog end address. */ + bfd_put_32 (abfd, 0x0D, si->data + 0x10); + pea_rel->address = 0x10; + pea_rel->addend = 0; + pea_rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32); + pea_rel->sym_ptr_ptr = fn_pp; + + sec->orelocation = rpp; + sec->reloc_count = 4; + break; + } + case RDATA: + /* Each external function in a PowerPC PE file has a two word + descriptor consisting of: + 1. The address of the code. + 2. The address of the appropriate .toc + We use relocs to build this. */ + si->size = 8; + si->data = xmalloc (8); + memset (si->data, 0, si->size); + + rpp = xmalloc (sizeof (arelent *) * 3); + rpp[0] = rel = xmalloc (sizeof (arelent)); + rpp[1] = xmalloc (sizeof (arelent)); + rpp[2] = 0; + + rel->address = 0; + rel->addend = 0; + rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32); + rel->sym_ptr_ptr = fn_pp; + + rel = rpp[1]; + + rel->address = 4; + rel->addend = 0; + rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32); + rel->sym_ptr_ptr = toc_pp; + + sec->orelocation = rpp; + sec->reloc_count = 2; + break; +#endif /* DLLTOOL_PPC */ + } + } + + { + bfd_vma vma = 0; + /* Size up all the sections. */ + for (i = 0; i < NSECS; i++) + { + sinfo *si = secdata + i; + + bfd_set_section_size (abfd, si->sec, si->size); + bfd_set_section_vma (abfd, si->sec, vma); + } + } + /* Write them out. */ + for (i = 0; i < NSECS; i++) + { + sinfo *si = secdata + i; + + if (i == IDATA5 && no_idata5) + continue; + + if (i == IDATA4 && no_idata4) + continue; + + bfd_set_section_contents (abfd, si->sec, + si->data, 0, + si->size); + } + + bfd_set_symtab (abfd, ptrs, oidx); + bfd_close (abfd); + abfd = bfd_openr (outname, HOW_BFD_READ_TARGET); + if (!abfd) + /* xgettext:c-format */ + fatal (_("bfd_open failed reopen stub file: %s: %s"), + outname, bfd_get_errmsg ()); + + return abfd; +} + +static bfd * +make_head (void) +{ + FILE *f = fopen (TMP_HEAD_S, FOPEN_WT); + bfd *abfd; + + if (f == NULL) + { + fatal (_("failed to open temporary head file: %s"), TMP_HEAD_S); + return NULL; + } + + temp_file_to_remove[TEMP_HEAD_FILE] = TMP_HEAD_S; + + fprintf (f, "%s IMAGE_IMPORT_DESCRIPTOR\n", ASM_C); + fprintf (f, "\t.section\t.idata$2\n"); + + fprintf (f,"\t%s\t%s\n", ASM_GLOBAL, head_label); + + fprintf (f, "%s:\n", head_label); + + fprintf (f, "\t%shname%s\t%sPtr to image import by name list\n", + ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C); + + fprintf (f, "\t%sthis should be the timestamp, but NT sometimes\n", ASM_C); + fprintf (f, "\t%sdoesn't load DLLs when this is set.\n", ASM_C); + fprintf (f, "\t%s\t0\t%s loaded time\n", ASM_LONG, ASM_C); + fprintf (f, "\t%s\t0\t%s Forwarder chain\n", ASM_LONG, ASM_C); + fprintf (f, "\t%s__%s_iname%s\t%s imported dll's name\n", + ASM_RVA_BEFORE, + imp_name_lab, + ASM_RVA_AFTER, + ASM_C); + fprintf (f, "\t%sfthunk%s\t%s pointer to firstthunk\n", + ASM_RVA_BEFORE, + ASM_RVA_AFTER, ASM_C); + + fprintf (f, "%sStuff for compatibility\n", ASM_C); + + if (!no_idata5) + { + fprintf (f, "\t.section\t.idata$5\n"); + if (use_nul_prefixed_import_tables) + { + if (create_for_pep) + fprintf (f,"\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + else + fprintf (f,"\t%s\t0\n", ASM_LONG); + } + fprintf (f, "fthunk:\n"); + } + + if (!no_idata4) + { + fprintf (f, "\t.section\t.idata$4\n"); + if (use_nul_prefixed_import_tables) + { + if (create_for_pep) + fprintf (f,"\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + else + fprintf (f,"\t%s\t0\n", ASM_LONG); + } + fprintf (f, "hname:\n"); + } + + fclose (f); + + assemble_file (TMP_HEAD_S, TMP_HEAD_O); + + abfd = bfd_openr (TMP_HEAD_O, HOW_BFD_READ_TARGET); + if (abfd == NULL) + /* xgettext:c-format */ + fatal (_("failed to open temporary head file: %s: %s"), + TMP_HEAD_O, bfd_get_errmsg ()); + + temp_file_to_remove[TEMP_HEAD_O_FILE] = TMP_HEAD_O; + return abfd; +} + +bfd * +make_delay_head (void) +{ + FILE *f = fopen (TMP_HEAD_S, FOPEN_WT); + bfd *abfd; + + if (f == NULL) + { + fatal (_("failed to open temporary head file: %s"), TMP_HEAD_S); + return NULL; + } + + temp_file_to_remove[TEMP_HEAD_FILE] = TMP_HEAD_S; + + /* Output the __tailMerge__xxx function */ + fprintf (f, "%s Import trampoline\n", ASM_C); + fprintf (f, "\t.section\t.text\n"); + fprintf(f,"\t%s\t%s\n", ASM_GLOBAL, head_label); + fprintf (f, "%s:\n", head_label); + fprintf (f, mtable[machine].trampoline, imp_name_lab); + + /* Output the delay import descriptor */ + fprintf (f, "\n%s DELAY_IMPORT_DESCRIPTOR\n", ASM_C); + fprintf (f, ".section\t.text$2\n"); + fprintf (f,"%s __DELAY_IMPORT_DESCRIPTOR_%s\n", ASM_GLOBAL,imp_name_lab); + fprintf (f, "__DELAY_IMPORT_DESCRIPTOR_%s:\n", imp_name_lab); + fprintf (f, "\t%s 1\t%s grAttrs\n", ASM_LONG, ASM_C); + fprintf (f, "\t%s__%s_iname%s\t%s rvaDLLName\n", + ASM_RVA_BEFORE, imp_name_lab, ASM_RVA_AFTER, ASM_C); + fprintf (f, "\t%s__DLL_HANDLE_%s%s\t%s rvaHmod\n", + ASM_RVA_BEFORE, imp_name_lab, ASM_RVA_AFTER, ASM_C); + fprintf (f, "\t%s__IAT_%s%s\t%s rvaIAT\n", + ASM_RVA_BEFORE, imp_name_lab, ASM_RVA_AFTER, ASM_C); + fprintf (f, "\t%s__INT_%s%s\t%s rvaINT\n", + ASM_RVA_BEFORE, imp_name_lab, ASM_RVA_AFTER, ASM_C); + fprintf (f, "\t%s\t0\t%s rvaBoundIAT\n", ASM_LONG, ASM_C); + fprintf (f, "\t%s\t0\t%s rvaUnloadIAT\n", ASM_LONG, ASM_C); + fprintf (f, "\t%s\t0\t%s dwTimeStamp\n", ASM_LONG, ASM_C); + + /* Output the dll_handle */ + fprintf (f, "\n.section .data\n"); + fprintf (f, "__DLL_HANDLE_%s:\n", imp_name_lab); + fprintf (f, "\t%s\t0\t%s Handle\n", ASM_LONG, ASM_C); + if (create_for_pep) + fprintf (f, "\t%s\t0\n", ASM_LONG); + fprintf (f, "\n"); + + fprintf (f, "%sStuff for compatibility\n", ASM_C); + + if (!no_idata5) + { + fprintf (f, "\t.section\t.idata$5\n"); + /* NULL terminating list. */ + if (create_for_pep) + fprintf (f,"\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + else + fprintf (f,"\t%s\t0\n", ASM_LONG); + fprintf (f, "__IAT_%s:\n", imp_name_lab); + } + + if (!no_idata4) + { + fprintf (f, "\t.section\t.idata$4\n"); + fprintf (f, "\t%s\t0\n", ASM_LONG); + if (create_for_pep) + fprintf (f, "\t%s\t0\n", ASM_LONG); + fprintf (f, "\t.section\t.idata$4\n"); + fprintf (f, "__INT_%s:\n", imp_name_lab); + } + + fprintf (f, "\t.section\t.idata$2\n"); + + fclose (f); + + assemble_file (TMP_HEAD_S, TMP_HEAD_O); + + abfd = bfd_openr (TMP_HEAD_O, HOW_BFD_READ_TARGET); + if (abfd == NULL) + /* xgettext:c-format */ + fatal (_("failed to open temporary head file: %s: %s"), + TMP_HEAD_O, bfd_get_errmsg ()); + + temp_file_to_remove[TEMP_HEAD_O_FILE] = TMP_HEAD_O; + return abfd; +} + +static bfd * +make_tail (void) +{ + FILE *f = fopen (TMP_TAIL_S, FOPEN_WT); + bfd *abfd; + + if (f == NULL) + { + fatal (_("failed to open temporary tail file: %s"), TMP_TAIL_S); + return NULL; + } + + temp_file_to_remove[TEMP_TAIL_FILE] = TMP_TAIL_S; + + if (!no_idata4) + { + fprintf (f, "\t.section\t.idata$4\n"); + if (create_for_pep) + fprintf (f,"\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + else + fprintf (f,"\t%s\t0\n", ASM_LONG); /* NULL terminating list. */ + } + + if (!no_idata5) + { + fprintf (f, "\t.section\t.idata$5\n"); + if (create_for_pep) + fprintf (f,"\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + else + fprintf (f,"\t%s\t0\n", ASM_LONG); /* NULL terminating list. */ + } + +#ifdef DLLTOOL_PPC + /* Normally, we need to see a null descriptor built in idata$3 to + act as the terminator for the list. The ideal way, I suppose, + would be to mark this section as a comdat type 2 section, so + only one would appear in the final .exe (if our linker supported + comdat, that is) or cause it to be inserted by something else (say + crt0). */ + + fprintf (f, "\t.section\t.idata$3\n"); + fprintf (f, "\t%s\t0\n", ASM_LONG); + fprintf (f, "\t%s\t0\n", ASM_LONG); + fprintf (f, "\t%s\t0\n", ASM_LONG); + fprintf (f, "\t%s\t0\n", ASM_LONG); + fprintf (f, "\t%s\t0\n", ASM_LONG); +#endif + +#ifdef DLLTOOL_PPC + /* Other PowerPC NT compilers use idata$6 for the dllname, so I + do too. Original, huh? */ + fprintf (f, "\t.section\t.idata$6\n"); +#else + fprintf (f, "\t.section\t.idata$7\n"); +#endif + + fprintf (f, "\t%s\t__%s_iname\n", ASM_GLOBAL, imp_name_lab); + fprintf (f, "__%s_iname:\t%s\t\"%s\"\n", + imp_name_lab, ASM_TEXT, dll_name); + + fclose (f); + + assemble_file (TMP_TAIL_S, TMP_TAIL_O); + + abfd = bfd_openr (TMP_TAIL_O, HOW_BFD_READ_TARGET); + if (abfd == NULL) + /* xgettext:c-format */ + fatal (_("failed to open temporary tail file: %s: %s"), + TMP_TAIL_O, bfd_get_errmsg ()); + + temp_file_to_remove[TEMP_TAIL_O_FILE] = TMP_TAIL_O; + return abfd; +} + +static void +gen_lib_file (int delay) +{ + int i; + export_type *exp; + bfd *ar_head; + bfd *ar_tail; + bfd *outarch; + bfd * head = 0; + + unlink (imp_name); + + outarch = bfd_openw (imp_name, HOW_BFD_WRITE_TARGET); + + if (!outarch) + /* xgettext:c-format */ + fatal (_("Can't create .lib file: %s: %s"), + imp_name, bfd_get_errmsg ()); + + /* xgettext:c-format */ + inform (_("Creating library file: %s"), imp_name); + + xatexit (unlink_temp_files); + + bfd_set_format (outarch, bfd_archive); + outarch->has_armap = 1; + outarch->is_thin_archive = 0; + + /* Work out a reasonable size of things to put onto one line. */ + if (delay) + { + ar_head = make_delay_head (); + } + else + { + ar_head = make_head (); + } + ar_tail = make_tail(); + + if (ar_head == NULL || ar_tail == NULL) + return; + + for (i = 0; (exp = d_exports_lexically[i]); i++) + { + bfd *n; + /* Don't add PRIVATE entries to import lib. */ + if (exp->private) + continue; + n = make_one_lib_file (exp, i, delay); + n->archive_next = head; + head = n; + if (ext_prefix_alias) + { + export_type alias_exp; + + assert (i < PREFIX_ALIAS_BASE); + alias_exp.name = make_imp_label (ext_prefix_alias, exp->name); + alias_exp.internal_name = exp->internal_name; + alias_exp.its_name = exp->its_name; + alias_exp.import_name = exp->name; + alias_exp.ordinal = exp->ordinal; + alias_exp.constant = exp->constant; + alias_exp.noname = exp->noname; + alias_exp.private = exp->private; + alias_exp.data = exp->data; + alias_exp.forward = exp->forward; + alias_exp.next = exp->next; + n = make_one_lib_file (&alias_exp, i + PREFIX_ALIAS_BASE, delay); + n->archive_next = head; + head = n; + } + } + + /* Now stick them all into the archive. */ + ar_head->archive_next = head; + ar_tail->archive_next = ar_head; + head = ar_tail; + + if (! bfd_set_archive_head (outarch, head)) + bfd_fatal ("bfd_set_archive_head"); + + if (! bfd_close (outarch)) + bfd_fatal (imp_name); + + while (head != NULL) + { + bfd *n = head->archive_next; + bfd_close (head); + head = n; + } + + /* Delete all the temp files. */ + unlink_temp_files (); + + if (dontdeltemps < 2) + { + char *name; + + name = xmalloc (strlen (TMP_STUB) + 10); + for (i = 0; (exp = d_exports_lexically[i]); i++) + { + /* Don't delete non-existent stubs for PRIVATE entries. */ + if (exp->private) + continue; + sprintf (name, "%s%05d.o", TMP_STUB, i); + if (unlink (name) < 0) + /* xgettext:c-format */ + non_fatal (_("cannot delete %s: %s"), name, strerror (errno)); + if (ext_prefix_alias) + { + sprintf (name, "%s%05d.o", TMP_STUB, i + PREFIX_ALIAS_BASE); + if (unlink (name) < 0) + /* xgettext:c-format */ + non_fatal (_("cannot delete %s: %s"), name, strerror (errno)); + } + } + free (name); + } + + inform (_("Created lib file")); +} + +/* Append a copy of data (cast to char *) to list. */ + +static void +dll_name_list_append (dll_name_list_type * list, bfd_byte * data) +{ + dll_name_list_node_type * entry; + + /* Error checking. */ + if (! list || ! list->tail) + return; + + /* Allocate new node. */ + entry = ((dll_name_list_node_type *) + xmalloc (sizeof (dll_name_list_node_type))); + + /* Initialize its values. */ + entry->dllname = xstrdup ((char *) data); + entry->next = NULL; + + /* Add to tail, and move tail. */ + list->tail->next = entry; + list->tail = entry; +} + +/* Count the number of entries in list. */ + +static int +dll_name_list_count (dll_name_list_type * list) +{ + dll_name_list_node_type * p; + int count = 0; + + /* Error checking. */ + if (! list || ! list->head) + return 0; + + p = list->head; + + while (p && p->next) + { + count++; + p = p->next; + } + return count; +} + +/* Print each entry in list to stdout. */ + +static void +dll_name_list_print (dll_name_list_type * list) +{ + dll_name_list_node_type * p; + + /* Error checking. */ + if (! list || ! list->head) + return; + + p = list->head; + + while (p && p->next && p->next->dllname && *(p->next->dllname)) + { + printf ("%s\n", p->next->dllname); + p = p->next; + } +} + +/* Free all entries in list, and list itself. */ + +static void +dll_name_list_free (dll_name_list_type * list) +{ + if (list) + { + dll_name_list_free_contents (list->head); + list->head = NULL; + list->tail = NULL; + free (list); + } +} + +/* Recursive function to free all nodes entry->next->next... + as well as entry itself. */ + +static void +dll_name_list_free_contents (dll_name_list_node_type * entry) +{ + if (entry) + { + if (entry->next) + { + dll_name_list_free_contents (entry->next); + entry->next = NULL; + } + if (entry->dllname) + { + free (entry->dllname); + entry->dllname = NULL; + } + free (entry); + } +} + +/* Allocate and initialize a dll_name_list_type object, + including its sentinel node. Caller is responsible + for calling dll_name_list_free when finished with + the list. */ + +static dll_name_list_type * +dll_name_list_create (void) +{ + /* Allocate list. */ + dll_name_list_type * list = xmalloc (sizeof (dll_name_list_type)); + + /* Allocate and initialize sentinel node. */ + list->head = xmalloc (sizeof (dll_name_list_node_type)); + list->head->dllname = NULL; + list->head->next = NULL; + + /* Bookkeeping for empty list. */ + list->tail = list->head; + + return list; +} + +/* Search the symbol table of the suppled BFD for a symbol whose name matches + OBJ (where obj is cast to const char *). If found, set global variable + identify_member_contains_symname_result TRUE. It is the caller's + responsibility to set the result variable FALSE before iterating with + this function. */ + +static void +identify_member_contains_symname (bfd * abfd, + bfd * archive_bfd ATTRIBUTE_UNUSED, + void * obj) +{ + long storage_needed; + asymbol ** symbol_table; + long number_of_symbols; + long i; + symname_search_data_type * search_data = (symname_search_data_type *) obj; + + /* If we already found the symbol in a different member, + short circuit. */ + if (search_data->found) + return; + + storage_needed = bfd_get_symtab_upper_bound (abfd); + if (storage_needed <= 0) + return; + + symbol_table = xmalloc (storage_needed); + number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); + if (number_of_symbols < 0) + { + free (symbol_table); + return; + } + + for (i = 0; i < number_of_symbols; i++) + { + if (strncmp (symbol_table[i]->name, + search_data->symname, + strlen (search_data->symname)) == 0) + { + search_data->found = TRUE; + break; + } + } + free (symbol_table); +} + +/* This is the main implementation for the --identify option. + Given the name of an import library in identify_imp_name, first determine + if the import library is a GNU binutils-style one (where the DLL name is + stored in an .idata$7 (.idata$6 on PPC) section, or if it is a MS-style + one (where the DLL name, along with much other data, is stored in the + .idata$6 section). We determine the style of import library by searching + for the DLL-structure symbol inserted by MS tools: + __NULL_IMPORT_DESCRIPTOR. + + Once we know which section to search, evaluate each section for the + appropriate properties that indicate it may contain the name of the + associated DLL (this differs depending on the style). Add the contents + of all sections which meet the criteria to a linked list of dll names. + + Finally, print them all to stdout. (If --identify-strict, an error is + reported if more than one match was found). */ + +static void +identify_dll_for_implib (void) +{ + bfd * abfd = NULL; + int count = 0; + identify_data_type identify_data; + symname_search_data_type search_data; + + /* Initialize identify_data. */ + identify_data.list = dll_name_list_create (); + identify_data.ms_style_implib = FALSE; + + /* Initialize search_data. */ + search_data.symname = "__NULL_IMPORT_DESCRIPTOR"; + search_data.found = FALSE; + + bfd_init (); + + abfd = bfd_openr (identify_imp_name, 0); + if (abfd == NULL) + /* xgettext:c-format */ + fatal (_("Can't open .lib file: %s: %s"), + identify_imp_name, bfd_get_errmsg ()); + + if (! bfd_check_format (abfd, bfd_archive)) + { + if (! bfd_close (abfd)) + bfd_fatal (identify_imp_name); + + fatal (_("%s is not a library"), identify_imp_name); + } + + /* Detect if this a Microsoft import library. */ + identify_search_archive (abfd, + identify_member_contains_symname, + (void *)(& search_data)); + if (search_data.found) + identify_data.ms_style_implib = TRUE; + + /* Rewind the bfd. */ + if (! bfd_close (abfd)) + bfd_fatal (identify_imp_name); + abfd = bfd_openr (identify_imp_name, 0); + if (abfd == NULL) + bfd_fatal (identify_imp_name); + + if (!bfd_check_format (abfd, bfd_archive)) + { + if (!bfd_close (abfd)) + bfd_fatal (identify_imp_name); + + fatal (_("%s is not a library"), identify_imp_name); + } + + /* Now search for the dll name. */ + identify_search_archive (abfd, + identify_search_member, + (void *)(& identify_data)); + + if (! bfd_close (abfd)) + bfd_fatal (identify_imp_name); + + count = dll_name_list_count (identify_data.list); + if (count > 0) + { + if (identify_strict && count > 1) + { + dll_name_list_free (identify_data.list); + identify_data.list = NULL; + fatal (_("Import library `%s' specifies two or more dlls"), + identify_imp_name); + } + dll_name_list_print (identify_data.list); + dll_name_list_free (identify_data.list); + identify_data.list = NULL; + } + else + { + dll_name_list_free (identify_data.list); + identify_data.list = NULL; + fatal (_("Unable to determine dll name for `%s' (not an import library?)"), + identify_imp_name); + } +} + +/* Loop over all members of the archive, applying the supplied function to + each member that is a bfd_object. The function will be called as if: + func (member_bfd, abfd, user_storage) */ + +static void +identify_search_archive (bfd * abfd, + void (* operation) (bfd *, bfd *, void *), + void * user_storage) +{ + bfd * arfile = NULL; + bfd * last_arfile = NULL; + char ** matching; + + while (1) + { + arfile = bfd_openr_next_archived_file (abfd, arfile); + + if (arfile == NULL) + { + if (bfd_get_error () != bfd_error_no_more_archived_files) + bfd_fatal (bfd_get_filename (abfd)); + break; + } + + if (bfd_check_format_matches (arfile, bfd_object, &matching)) + (*operation) (arfile, abfd, user_storage); + else + { + bfd_nonfatal (bfd_get_filename (arfile)); + free (matching); + } + + if (last_arfile != NULL) + { + bfd_close (last_arfile); + /* PR 17512: file: 8b2168d4. */ + if (last_arfile == arfile) + { + last_arfile = NULL; + break; + } + } + + last_arfile = arfile; + } + + if (last_arfile != NULL) + { + bfd_close (last_arfile); + } +} + +/* Call the identify_search_section() function for each section of this + archive member. */ + +static void +identify_search_member (bfd *abfd, + bfd *archive_bfd ATTRIBUTE_UNUSED, + void *obj) +{ + bfd_map_over_sections (abfd, identify_search_section, obj); +} + +/* This predicate returns true if section->name matches the desired value. + By default, this is .idata$7 (.idata$6 on PPC, or if the import + library is ms-style). */ + +static bfd_boolean +identify_process_section_p (asection * section, bfd_boolean ms_style_implib) +{ + static const char * SECTION_NAME = +#ifdef DLLTOOL_PPC + /* dllname is stored in idata$6 on PPC */ + ".idata$6"; +#else + ".idata$7"; +#endif + static const char * MS_SECTION_NAME = ".idata$6"; + + const char * section_name = + (ms_style_implib ? MS_SECTION_NAME : SECTION_NAME); + + if (strcmp (section_name, section->name) == 0) + return TRUE; + return FALSE; +} + +/* If *section has contents and its name is .idata$7 (.data$6 on PPC or if + import lib ms-generated) -- and it satisfies several other constraints + -- then add the contents of the section to obj->list. */ + +static void +identify_search_section (bfd * abfd, asection * section, void * obj) +{ + bfd_byte *data = 0; + bfd_size_type datasize; + identify_data_type * identify_data = (identify_data_type *)obj; + bfd_boolean ms_style = identify_data->ms_style_implib; + + if ((section->flags & SEC_HAS_CONTENTS) == 0) + return; + + if (! identify_process_section_p (section, ms_style)) + return; + + /* Binutils import libs seem distinguish the .idata$7 section that contains + the DLL name from other .idata$7 sections by the absence of the + SEC_RELOC flag. */ + if (!ms_style && ((section->flags & SEC_RELOC) == SEC_RELOC)) + return; + + /* MS import libs seem to distinguish the .idata$6 section + that contains the DLL name from other .idata$6 sections + by the presence of the SEC_DATA flag. */ + if (ms_style && ((section->flags & SEC_DATA) == 0)) + return; + + if ((datasize = bfd_section_size (abfd, section)) == 0) + return; + + data = (bfd_byte *) xmalloc (datasize + 1); + data[0] = '\0'; + + bfd_get_section_contents (abfd, section, data, 0, datasize); + data[datasize] = '\0'; + + /* Use a heuristic to determine if data is a dll name. + Possible to defeat this if (a) the library has MANY + (more than 0x302f) imports, (b) it is an ms-style + import library, but (c) it is buggy, in that the SEC_DATA + flag is set on the "wrong" sections. This heuristic might + also fail to record a valid dll name if the dllname uses + a multibyte or unicode character set (is that valid?). + + This heuristic is based on the fact that symbols names in + the chosen section -- as opposed to the dll name -- begin + at offset 2 in the data. The first two bytes are a 16bit + little-endian count, and start at 0x0000. However, the dll + name begins at offset 0 in the data. We assume that the + dll name does not contain unprintable characters. */ + if (data[0] != '\0' && ISPRINT (data[0]) + && ((datasize < 2) || ISPRINT (data[1]))) + dll_name_list_append (identify_data->list, data); + + free (data); +} + +/* Run through the information gathered from the .o files and the + .def file and work out the best stuff. */ + +static int +pfunc (const void *a, const void *b) +{ + export_type *ap = *(export_type **) a; + export_type *bp = *(export_type **) b; + + if (ap->ordinal == bp->ordinal) + return 0; + + /* Unset ordinals go to the bottom. */ + if (ap->ordinal == -1) + return 1; + if (bp->ordinal == -1) + return -1; + return (ap->ordinal - bp->ordinal); +} + +static int +nfunc (const void *a, const void *b) +{ + export_type *ap = *(export_type **) a; + export_type *bp = *(export_type **) b; + const char *an = ap->name; + const char *bn = bp->name; + if (ap->its_name) + an = ap->its_name; + if (bp->its_name) + an = bp->its_name; + if (killat) + { + an = (an[0] == '@') ? an + 1 : an; + bn = (bn[0] == '@') ? bn + 1 : bn; + } + + return (strcmp (an, bn)); +} + +static void +remove_null_names (export_type **ptr) +{ + int src; + int dst; + + for (dst = src = 0; src < d_nfuncs; src++) + { + if (ptr[src]) + { + ptr[dst] = ptr[src]; + dst++; + } + } + d_nfuncs = dst; +} + +static void +process_duplicates (export_type **d_export_vec) +{ + int more = 1; + int i; + + while (more) + { + more = 0; + /* Remove duplicates. */ + qsort (d_export_vec, d_nfuncs, sizeof (export_type *), nfunc); + + for (i = 0; i < d_nfuncs - 1; i++) + { + if (strcmp (d_export_vec[i]->name, + d_export_vec[i + 1]->name) == 0) + { + export_type *a = d_export_vec[i]; + export_type *b = d_export_vec[i + 1]; + + more = 1; + + /* xgettext:c-format */ + inform (_("Warning, ignoring duplicate EXPORT %s %d,%d"), + a->name, a->ordinal, b->ordinal); + + if (a->ordinal != -1 + && b->ordinal != -1) + /* xgettext:c-format */ + fatal (_("Error, duplicate EXPORT with ordinals: %s"), + a->name); + + /* Merge attributes. */ + b->ordinal = a->ordinal > 0 ? a->ordinal : b->ordinal; + b->constant |= a->constant; + b->noname |= a->noname; + b->data |= a->data; + d_export_vec[i] = 0; + } + + remove_null_names (d_export_vec); + } + } + + /* Count the names. */ + for (i = 0; i < d_nfuncs; i++) + if (!d_export_vec[i]->noname) + d_named_nfuncs++; +} + +static void +fill_ordinals (export_type **d_export_vec) +{ + int lowest = -1; + int i; + char *ptr; + int size = 65536; + + qsort (d_export_vec, d_nfuncs, sizeof (export_type *), pfunc); + + /* Fill in the unset ordinals with ones from our range. */ + ptr = (char *) xmalloc (size); + + memset (ptr, 0, size); + + /* Mark in our large vector all the numbers that are taken. */ + for (i = 0; i < d_nfuncs; i++) + { + if (d_export_vec[i]->ordinal != -1) + { + ptr[d_export_vec[i]->ordinal] = 1; + + if (lowest == -1 || d_export_vec[i]->ordinal < lowest) + lowest = d_export_vec[i]->ordinal; + } + } + + /* Start at 1 for compatibility with MS toolchain. */ + if (lowest == -1) + lowest = 1; + + /* Now fill in ordinals where the user wants us to choose. */ + for (i = 0; i < d_nfuncs; i++) + { + if (d_export_vec[i]->ordinal == -1) + { + int j; + + /* First try within or after any user supplied range. */ + for (j = lowest; j < size; j++) + if (ptr[j] == 0) + { + ptr[j] = 1; + d_export_vec[i]->ordinal = j; + goto done; + } + + /* Then try before the range. */ + for (j = lowest; j >0; j--) + if (ptr[j] == 0) + { + ptr[j] = 1; + d_export_vec[i]->ordinal = j; + goto done; + } + done:; + } + } + + free (ptr); + + /* And resort. */ + qsort (d_export_vec, d_nfuncs, sizeof (export_type *), pfunc); + + /* Work out the lowest and highest ordinal numbers. */ + if (d_nfuncs) + { + if (d_export_vec[0]) + d_low_ord = d_export_vec[0]->ordinal; + if (d_export_vec[d_nfuncs-1]) + d_high_ord = d_export_vec[d_nfuncs-1]->ordinal; + } +} + +static void +mangle_defs (void) +{ + /* First work out the minimum ordinal chosen. */ + export_type *exp; + export_type **d_export_vec = xmalloc (sizeof (export_type *) * d_nfuncs); + int i; + + inform (_("Processing definitions")); + + for (i = 0, exp = d_exports; exp; i++, exp = exp->next) + d_export_vec[i] = exp; + + process_duplicates (d_export_vec); + fill_ordinals (d_export_vec); + + /* Put back the list in the new order. */ + d_exports = 0; + for (i = d_nfuncs - 1; i >= 0; i--) + { + d_export_vec[i]->next = d_exports; + d_exports = d_export_vec[i]; + } + + /* Build list in alpha order. */ + d_exports_lexically = (export_type **) + xmalloc (sizeof (export_type *) * (d_nfuncs + 1)); + + for (i = 0, exp = d_exports; exp; i++, exp = exp->next) + d_exports_lexically[i] = exp; + + d_exports_lexically[i] = 0; + + qsort (d_exports_lexically, i, sizeof (export_type *), nfunc); + + inform (_("Processed definitions")); +} + +static void +usage (FILE *file, int status) +{ + /* xgetext:c-format */ + fprintf (file, _("Usage %s \n"), program_name); + /* xgetext:c-format */ + fprintf (file, _(" -m --machine Create as DLL for . [default: %s]\n"), mname); + fprintf (file, _(" possible : arm[_interwork], i386, mcore[-elf]{-le|-be}, ppc, thumb\n")); + fprintf (file, _(" -e --output-exp Generate an export file.\n")); + fprintf (file, _(" -l --output-lib Generate an interface library.\n")); + fprintf (file, _(" -y --output-delaylib Create a delay-import library.\n")); + fprintf (file, _(" -a --add-indirect Add dll indirects to export file.\n")); + fprintf (file, _(" -D --dllname Name of input dll to put into interface lib.\n")); + fprintf (file, _(" -d --input-def Name of .def file to be read in.\n")); + fprintf (file, _(" -z --output-def Name of .def file to be created.\n")); + fprintf (file, _(" --export-all-symbols Export all symbols to .def\n")); + fprintf (file, _(" --no-export-all-symbols Only export listed symbols\n")); + fprintf (file, _(" --exclude-symbols Don't export \n")); + fprintf (file, _(" --no-default-excludes Clear default exclude symbols\n")); + fprintf (file, _(" -b --base-file Read linker generated base file.\n")); + fprintf (file, _(" -x --no-idata4 Don't generate idata$4 section.\n")); + fprintf (file, _(" -c --no-idata5 Don't generate idata$5 section.\n")); + fprintf (file, _(" --use-nul-prefixed-import-tables Use zero prefixed idata$4 and idata$5.\n")); + fprintf (file, _(" -U --add-underscore Add underscores to all symbols in interface library.\n")); + fprintf (file, _(" --add-stdcall-underscore Add underscores to stdcall symbols in interface library.\n")); + fprintf (file, _(" --no-leading-underscore All symbols shouldn't be prefixed by an underscore.\n")); + fprintf (file, _(" --leading-underscore All symbols should be prefixed by an underscore.\n")); + fprintf (file, _(" -k --kill-at Kill @ from exported names.\n")); + fprintf (file, _(" -A --add-stdcall-alias Add aliases without @.\n")); + fprintf (file, _(" -p --ext-prefix-alias Add aliases with .\n")); + fprintf (file, _(" -S --as Use for assembler.\n")); + fprintf (file, _(" -f --as-flags Pass to the assembler.\n")); + fprintf (file, _(" -C --compat-implib Create backward compatible import library.\n")); + fprintf (file, _(" -n --no-delete Keep temp files (repeat for extra preservation).\n")); + fprintf (file, _(" -t --temp-prefix Use to construct temp file names.\n")); + fprintf (file, _(" -I --identify Report the name of the DLL associated with .\n")); + fprintf (file, _(" --identify-strict Causes --identify to report error when multiple DLLs.\n")); + fprintf (file, _(" -v --verbose Be verbose.\n")); + fprintf (file, _(" -V --version Display the program version.\n")); + fprintf (file, _(" -h --help Display this information.\n")); + fprintf (file, _(" @ Read options from .\n")); +#ifdef DLLTOOL_MCORE_ELF + fprintf (file, _(" -M --mcore-elf Process mcore-elf object files into .\n")); + fprintf (file, _(" -L --linker Use as the linker.\n")); + fprintf (file, _(" -F --linker-flags Pass to the linker.\n")); +#endif + if (REPORT_BUGS_TO[0] && status == 0) + fprintf (file, _("Report bugs to %s\n"), REPORT_BUGS_TO); + exit (status); +} + +#define OPTION_EXPORT_ALL_SYMS 150 +#define OPTION_NO_EXPORT_ALL_SYMS (OPTION_EXPORT_ALL_SYMS + 1) +#define OPTION_EXCLUDE_SYMS (OPTION_NO_EXPORT_ALL_SYMS + 1) +#define OPTION_NO_DEFAULT_EXCLUDES (OPTION_EXCLUDE_SYMS + 1) +#define OPTION_ADD_STDCALL_UNDERSCORE (OPTION_NO_DEFAULT_EXCLUDES + 1) +#define OPTION_USE_NUL_PREFIXED_IMPORT_TABLES \ + (OPTION_ADD_STDCALL_UNDERSCORE + 1) +#define OPTION_IDENTIFY_STRICT (OPTION_USE_NUL_PREFIXED_IMPORT_TABLES + 1) +#define OPTION_NO_LEADING_UNDERSCORE (OPTION_IDENTIFY_STRICT + 1) +#define OPTION_LEADING_UNDERSCORE (OPTION_NO_LEADING_UNDERSCORE + 1) + +static const struct option long_options[] = +{ + {"no-delete", no_argument, NULL, 'n'}, + {"dllname", required_argument, NULL, 'D'}, + {"no-idata4", no_argument, NULL, 'x'}, + {"no-idata5", no_argument, NULL, 'c'}, + {"use-nul-prefixed-import-tables", no_argument, NULL, + OPTION_USE_NUL_PREFIXED_IMPORT_TABLES}, + {"output-exp", required_argument, NULL, 'e'}, + {"output-def", required_argument, NULL, 'z'}, + {"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL_SYMS}, + {"no-export-all-symbols", no_argument, NULL, OPTION_NO_EXPORT_ALL_SYMS}, + {"exclude-symbols", required_argument, NULL, OPTION_EXCLUDE_SYMS}, + {"no-default-excludes", no_argument, NULL, OPTION_NO_DEFAULT_EXCLUDES}, + {"output-lib", required_argument, NULL, 'l'}, + {"def", required_argument, NULL, 'd'}, /* for compatibility with older versions */ + {"input-def", required_argument, NULL, 'd'}, + {"add-underscore", no_argument, NULL, 'U'}, + {"add-stdcall-underscore", no_argument, NULL, OPTION_ADD_STDCALL_UNDERSCORE}, + {"no-leading-underscore", no_argument, NULL, OPTION_NO_LEADING_UNDERSCORE}, + {"leading-underscore", no_argument, NULL, OPTION_LEADING_UNDERSCORE}, + {"kill-at", no_argument, NULL, 'k'}, + {"add-stdcall-alias", no_argument, NULL, 'A'}, + {"ext-prefix-alias", required_argument, NULL, 'p'}, + {"identify", required_argument, NULL, 'I'}, + {"identify-strict", no_argument, NULL, OPTION_IDENTIFY_STRICT}, + {"verbose", no_argument, NULL, 'v'}, + {"version", no_argument, NULL, 'V'}, + {"help", no_argument, NULL, 'h'}, + {"machine", required_argument, NULL, 'm'}, + {"add-indirect", no_argument, NULL, 'a'}, + {"base-file", required_argument, NULL, 'b'}, + {"as", required_argument, NULL, 'S'}, + {"as-flags", required_argument, NULL, 'f'}, + {"mcore-elf", required_argument, NULL, 'M'}, + {"compat-implib", no_argument, NULL, 'C'}, + {"temp-prefix", required_argument, NULL, 't'}, + {"output-delaylib", required_argument, NULL, 'y'}, + {NULL,0,NULL,0} +}; + +int main (int, char **); + +int +main (int ac, char **av) +{ + int c; + int i; + char *firstarg = 0; + program_name = av[0]; + oav = av; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + bfd_set_error_program_name (program_name); + expandargv (&ac, &av); + + while ((c = getopt_long (ac, av, +#ifdef DLLTOOL_MCORE_ELF + "m:e:l:aD:d:z:b:xp:cCuUkAS:t:f:nI:vVHhM:L:F:", +#else + "m:e:l:y:aD:d:z:b:xp:cCuUkAS:t:f:nI:vVHh", +#endif + long_options, 0)) + != EOF) + { + switch (c) + { + case OPTION_EXPORT_ALL_SYMS: + export_all_symbols = TRUE; + break; + case OPTION_NO_EXPORT_ALL_SYMS: + export_all_symbols = FALSE; + break; + case OPTION_EXCLUDE_SYMS: + add_excludes (optarg); + break; + case OPTION_NO_DEFAULT_EXCLUDES: + do_default_excludes = FALSE; + break; + case OPTION_USE_NUL_PREFIXED_IMPORT_TABLES: + use_nul_prefixed_import_tables = TRUE; + break; + case OPTION_ADD_STDCALL_UNDERSCORE: + add_stdcall_underscore = 1; + break; + case OPTION_NO_LEADING_UNDERSCORE: + leading_underscore = 0; + break; + case OPTION_LEADING_UNDERSCORE: + leading_underscore = 1; + break; + case OPTION_IDENTIFY_STRICT: + identify_strict = 1; + break; + case 'x': + no_idata4 = 1; + break; + case 'c': + no_idata5 = 1; + break; + case 'S': + as_name = optarg; + break; + case 't': + tmp_prefix = optarg; + break; + case 'f': + as_flags = optarg; + break; + + /* Ignored for compatibility. */ + case 'u': + break; + case 'a': + add_indirect = 1; + break; + case 'z': + output_def = fopen (optarg, FOPEN_WT); + if (!output_def) + /* xgettext:c-format */ + fatal (_("Unable to open def-file: %s"), optarg); + break; + case 'D': + dll_name = (char*) lbasename (optarg); + if (dll_name != optarg) + non_fatal (_("Path components stripped from dllname, '%s'."), + optarg); + break; + case 'l': + imp_name = optarg; + break; + case 'e': + exp_name = optarg; + break; + case 'H': + case 'h': + usage (stdout, 0); + break; + case 'm': + mname = optarg; + break; + case 'I': + identify_imp_name = optarg; + break; + case 'v': + verbose = 1; + break; + case 'V': + print_version (program_name); + break; + case 'U': + add_underscore = 1; + break; + case 'k': + killat = 1; + break; + case 'A': + add_stdcall_alias = 1; + break; + case 'p': + ext_prefix_alias = optarg; + break; + case 'd': + def_file = optarg; + break; + case 'n': + dontdeltemps++; + break; + case 'b': + base_file = fopen (optarg, FOPEN_RB); + + if (!base_file) + /* xgettext:c-format */ + fatal (_("Unable to open base-file: %s"), optarg); + + break; +#ifdef DLLTOOL_MCORE_ELF + case 'M': + mcore_elf_out_file = optarg; + break; + case 'L': + mcore_elf_linker = optarg; + break; + case 'F': + mcore_elf_linker_flags = optarg; + break; +#endif + case 'C': + create_compat_implib = 1; + break; + case 'y': + delayimp_name = optarg; + break; + default: + usage (stderr, 1); + break; + } + } + + if (!tmp_prefix) + tmp_prefix = prefix_encode ("d", getpid ()); + + for (i = 0; mtable[i].type; i++) + if (strcmp (mtable[i].type, mname) == 0) + break; + + if (!mtable[i].type) + /* xgettext:c-format */ + fatal (_("Machine '%s' not supported"), mname); + + machine = i; + + /* Check if we generated PE+. */ + create_for_pep = strcmp (mname, "i386:x86-64") == 0; + + { + /* Check the default underscore */ + int u = leading_underscore; /* Underscoring mode. -1 for use default. */ + if (u == -1) + bfd_get_target_info (mtable[machine].how_bfd_target, NULL, + NULL, &u, NULL); + if (u != -1) + leading_underscore = (u != 0 ? TRUE : FALSE); + } + + if (!dll_name && exp_name) + { + /* If we are inferring dll_name from exp_name, + strip off any path components, without emitting + a warning. */ + const char* exp_basename = lbasename (exp_name); + const int len = strlen (exp_basename) + 5; + dll_name = xmalloc (len); + strcpy (dll_name, exp_basename); + strcat (dll_name, ".dll"); + dll_name_set_by_exp_name = 1; + } + + if (as_name == NULL) + as_name = deduce_name ("as"); + + /* Don't use the default exclude list if we're reading only the + symbols in the .drectve section. The default excludes are meant + to avoid exporting DLL entry point and Cygwin32 impure_ptr. */ + if (! export_all_symbols) + do_default_excludes = FALSE; + + if (do_default_excludes) + set_default_excludes (); + + if (def_file) + process_def_file (def_file); + + while (optind < ac) + { + if (!firstarg) + firstarg = av[optind]; + scan_obj_file (av[optind]); + optind++; + } + + mangle_defs (); + + if (exp_name) + gen_exp_file (); + + if (imp_name) + { + /* Make imp_name safe for use as a label. */ + char *p; + + imp_name_lab = xstrdup (imp_name); + for (p = imp_name_lab; *p; p++) + { + if (!ISALNUM (*p)) + *p = '_'; + } + head_label = make_label("_head_", imp_name_lab); + gen_lib_file (0); + } + + if (delayimp_name) + { + /* Make delayimp_name safe for use as a label. */ + char *p; + + if (mtable[machine].how_dljtab == 0) + { + inform (_("Warning, machine type (%d) not supported for " + "delayimport."), machine); + } + else + { + killat = 1; + imp_name = delayimp_name; + imp_name_lab = xstrdup (imp_name); + for (p = imp_name_lab; *p; p++) + { + if (!ISALNUM (*p)) + *p = '_'; + } + head_label = make_label("__tailMerge_", imp_name_lab); + gen_lib_file (1); + } + } + + if (output_def) + gen_def_file (); + + if (identify_imp_name) + { + identify_dll_for_implib (); + } + +#ifdef DLLTOOL_MCORE_ELF + if (mcore_elf_out_file) + mcore_elf_gen_out_file (); +#endif + + return 0; +} + +/* Look for the program formed by concatenating PROG_NAME and the + string running from PREFIX to END_PREFIX. If the concatenated + string contains a '/', try appending EXECUTABLE_SUFFIX if it is + appropriate. */ + +static char * +look_for_prog (const char *prog_name, const char *prefix, int end_prefix) +{ + struct stat s; + char *cmd; + + cmd = xmalloc (strlen (prefix) + + strlen (prog_name) +#ifdef HAVE_EXECUTABLE_SUFFIX + + strlen (EXECUTABLE_SUFFIX) +#endif + + 10); + strcpy (cmd, prefix); + + sprintf (cmd + end_prefix, "%s", prog_name); + + if (strchr (cmd, '/') != NULL) + { + int found; + + found = (stat (cmd, &s) == 0 +#ifdef HAVE_EXECUTABLE_SUFFIX + || stat (strcat (cmd, EXECUTABLE_SUFFIX), &s) == 0 +#endif + ); + + if (! found) + { + /* xgettext:c-format */ + inform (_("Tried file: %s"), cmd); + free (cmd); + return NULL; + } + } + + /* xgettext:c-format */ + inform (_("Using file: %s"), cmd); + + return cmd; +} + +/* Deduce the name of the program we are want to invoke. + PROG_NAME is the basic name of the program we want to run, + eg "as" or "ld". The catch is that we might want actually + run "i386-pe-as" or "ppc-pe-ld". + + If argv[0] contains the full path, then try to find the program + in the same place, with and then without a target-like prefix. + + Given, argv[0] = /usr/local/bin/i586-cygwin32-dlltool, + deduce_name("as") uses the following search order: + + /usr/local/bin/i586-cygwin32-as + /usr/local/bin/as + as + + If there's an EXECUTABLE_SUFFIX, it'll use that as well; for each + name, it'll try without and then with EXECUTABLE_SUFFIX. + + Given, argv[0] = i586-cygwin32-dlltool, it will not even try "as" + as the fallback, but rather return i586-cygwin32-as. + + Oh, and given, argv[0] = dlltool, it'll return "as". + + Returns a dynamically allocated string. */ + +static char * +deduce_name (const char *prog_name) +{ + char *cmd; + char *dash, *slash, *cp; + + dash = NULL; + slash = NULL; + for (cp = program_name; *cp != '\0'; ++cp) + { + if (*cp == '-') + dash = cp; + if ( +#if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__) + *cp == ':' || *cp == '\\' || +#endif + *cp == '/') + { + slash = cp; + dash = NULL; + } + } + + cmd = NULL; + + if (dash != NULL) + { + /* First, try looking for a prefixed PROG_NAME in the + PROGRAM_NAME directory, with the same prefix as PROGRAM_NAME. */ + cmd = look_for_prog (prog_name, program_name, dash - program_name + 1); + } + + if (slash != NULL && cmd == NULL) + { + /* Next, try looking for a PROG_NAME in the same directory as + that of this program. */ + cmd = look_for_prog (prog_name, program_name, slash - program_name + 1); + } + + if (cmd == NULL) + { + /* Just return PROG_NAME as is. */ + cmd = xstrdup (prog_name); + } + + return cmd; +} + +#ifdef DLLTOOL_MCORE_ELF +typedef struct fname_cache +{ + const char * filename; + struct fname_cache * next; +} +fname_cache; + +static fname_cache fnames; + +static void +mcore_elf_cache_filename (const char * filename) +{ + fname_cache * ptr; + + ptr = & fnames; + + while (ptr->next != NULL) + ptr = ptr->next; + + ptr->filename = filename; + ptr->next = (fname_cache *) malloc (sizeof (fname_cache)); + if (ptr->next != NULL) + ptr->next->next = NULL; +} + +#define MCORE_ELF_TMP_OBJ "mcoreelf.o" +#define MCORE_ELF_TMP_EXP "mcoreelf.exp" +#define MCORE_ELF_TMP_LIB "mcoreelf.lib" + +static void +mcore_elf_gen_out_file (void) +{ + fname_cache * ptr; + dyn_string_t ds; + + /* Step one. Run 'ld -r' on the input object files in order to resolve + any internal references and to generate a single .exports section. */ + ptr = & fnames; + + ds = dyn_string_new (100); + dyn_string_append_cstr (ds, "-r "); + + if (mcore_elf_linker_flags != NULL) + dyn_string_append_cstr (ds, mcore_elf_linker_flags); + + while (ptr->next != NULL) + { + dyn_string_append_cstr (ds, ptr->filename); + dyn_string_append_cstr (ds, " "); + + ptr = ptr->next; + } + + dyn_string_append_cstr (ds, "-o "); + dyn_string_append_cstr (ds, MCORE_ELF_TMP_OBJ); + + if (mcore_elf_linker == NULL) + mcore_elf_linker = deduce_name ("ld"); + + run (mcore_elf_linker, ds->s); + + dyn_string_delete (ds); + + /* Step two. Create a .exp file and a .lib file from the temporary file. + Do this by recursively invoking dlltool... */ + ds = dyn_string_new (100); + + dyn_string_append_cstr (ds, "-S "); + dyn_string_append_cstr (ds, as_name); + + dyn_string_append_cstr (ds, " -e "); + dyn_string_append_cstr (ds, MCORE_ELF_TMP_EXP); + dyn_string_append_cstr (ds, " -l "); + dyn_string_append_cstr (ds, MCORE_ELF_TMP_LIB); + dyn_string_append_cstr (ds, " " ); + dyn_string_append_cstr (ds, MCORE_ELF_TMP_OBJ); + + if (verbose) + dyn_string_append_cstr (ds, " -v"); + + if (dontdeltemps) + { + dyn_string_append_cstr (ds, " -n"); + + if (dontdeltemps > 1) + dyn_string_append_cstr (ds, " -n"); + } + + /* XXX - FIME: ought to check/copy other command line options as well. */ + run (program_name, ds->s); + + dyn_string_delete (ds); + + /* Step four. Feed the .exp and object files to ld -shared to create the dll. */ + ds = dyn_string_new (100); + + dyn_string_append_cstr (ds, "-shared "); + + if (mcore_elf_linker_flags) + dyn_string_append_cstr (ds, mcore_elf_linker_flags); + + dyn_string_append_cstr (ds, " "); + dyn_string_append_cstr (ds, MCORE_ELF_TMP_EXP); + dyn_string_append_cstr (ds, " "); + dyn_string_append_cstr (ds, MCORE_ELF_TMP_OBJ); + dyn_string_append_cstr (ds, " -o "); + dyn_string_append_cstr (ds, mcore_elf_out_file); + + run (mcore_elf_linker, ds->s); + + dyn_string_delete (ds); + + if (dontdeltemps == 0) + unlink (MCORE_ELF_TMP_EXP); + + if (dontdeltemps < 2) + unlink (MCORE_ELF_TMP_OBJ); +} +#endif /* DLLTOOL_MCORE_ELF */ diff --git a/support/sdbinutils/binutils/dlltool.h b/support/sdbinutils/binutils/dlltool.h new file mode 100644 index 0000000..5d2257e --- /dev/null +++ b/support/sdbinutils/binutils/dlltool.h @@ -0,0 +1,39 @@ +/* dlltool.h -- header file for dlltool + Copyright (C) 1997-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +extern void def_code (int); +extern void def_data (int); +extern void def_description (const char *); +extern void def_exports (const char *, const char *, int, int, int, int, int, const char *); +extern void def_heapsize (int, int); +extern void def_import + (const char *, const char *, const char *, const char *, int, const char *); +extern void def_library (const char *, int); +extern void def_name (const char *, int); +extern void def_section (const char *, int); +extern void def_stacksize (int, int); +extern void def_version (int, int); +extern int yyparse (void); +extern int yyerror (const char *); +extern int yylex (void); + +extern int yydebug; +extern FILE *yyin; +extern int linenumber; diff --git a/support/sdbinutils/binutils/dllwrap.c b/support/sdbinutils/binutils/dllwrap.c new file mode 100644 index 0000000..b7e1afc --- /dev/null +++ b/support/sdbinutils/binutils/dllwrap.c @@ -0,0 +1,1254 @@ +/* dllwrap.c -- wrapper for DLLTOOL and GCC to generate PE style DLLs + Copyright (C) 1998-2018 Free Software Foundation, Inc. + Contributed by Mumit Khan (khan@xraylith.wisc.edu). + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "sysdep.h" +#include "bfd.h" +#include "libiberty.h" +#include "getopt.h" +#include "dyn-string.h" +#include "bucomm.h" + +#include + +#ifdef HAVE_SYS_WAIT_H +#include +#else /* ! HAVE_SYS_WAIT_H */ +#if ! defined (_WIN32) || defined (__CYGWIN32__) +#ifndef WIFEXITED +#define WIFEXITED(w) (((w)&0377) == 0) +#endif +#ifndef WIFSIGNALED +#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0) +#endif +#ifndef WTERMSIG +#define WTERMSIG(w) ((w) & 0177) +#endif +#ifndef WEXITSTATUS +#define WEXITSTATUS(w) (((w) >> 8) & 0377) +#endif +#else /* defined (_WIN32) && ! defined (__CYGWIN32__) */ +#ifndef WIFEXITED +#define WIFEXITED(w) (((w) & 0xff) == 0) +#endif +#ifndef WIFSIGNALED +#define WIFSIGNALED(w) (((w) & 0xff) != 0 && ((w) & 0xff) != 0x7f) +#endif +#ifndef WTERMSIG +#define WTERMSIG(w) ((w) & 0x7f) +#endif +#ifndef WEXITSTATUS +#define WEXITSTATUS(w) (((w) & 0xff00) >> 8) +#endif +#endif /* defined (_WIN32) && ! defined (__CYGWIN32__) */ +#endif /* ! HAVE_SYS_WAIT_H */ + +static char *driver_name = NULL; +static char *cygwin_driver_flags = + "-Wl,--dll -nostartfiles"; +static char *mingw32_driver_flags = "-mdll"; +static char *generic_driver_flags = "-Wl,--dll"; + +static char *entry_point; + +static char *dlltool_name = NULL; + +static char *target = TARGET; + +/* -1: use default, 0: no underscoring, 1: underscore. */ +static int is_leading_underscore = -1; + +typedef enum { + UNKNOWN_TARGET, + CYGWIN_TARGET, + MINGW_TARGET +} +target_type; + +typedef enum { + UNKNOWN_CPU, + X86_CPU, + X64_CPU, + ARM_CPU +} +target_cpu; + +static target_type which_target = UNKNOWN_TARGET; +static target_cpu which_cpu = UNKNOWN_CPU; + +static int dontdeltemps = 0; +static int dry_run = 0; + +static char *prog_name; + +static int verbose = 0; + +static char *dll_file_name; +static char *dll_name; +static char *base_file_name; +static char *exp_file_name; +static char *def_file_name; +static int delete_base_file = 1; +static int delete_exp_file = 1; +static int delete_def_file = 1; + +static int run (const char *, char *); +static char *mybasename (const char *); +static int strhash (const char *); +static void usage (FILE *, int); +static void display (const char *, va_list) ATTRIBUTE_PRINTF(1,0); +static void inform (const char *, ...) ATTRIBUTE_PRINTF_1; +static void warn (const char *, ...) ATTRIBUTE_PRINTF_1; +static char *look_for_prog (const char *, const char *, int); +static char *deduce_name (const char *); +static void delete_temp_files (void); +static void cleanup_and_exit (int); + +/**********************************************************************/ + +/* Please keep the following 4 routines in sync with dlltool.c: + display () + inform () + look_for_prog () + deduce_name () + It's not worth the hassle to break these out since dllwrap will + (hopefully) soon be retired in favor of `ld --shared. */ + +static void +display (const char * message, va_list args) +{ + if (prog_name != NULL) + fprintf (stderr, "%s: ", prog_name); + + vfprintf (stderr, message, args); + fputc ('\n', stderr); +} + + +static void +inform (const char *message, ...) +{ + va_list args; + + va_start (args, message); + + if (!verbose) + return; + + display (message, args); + + va_end (args); +} + +static void +warn (const char *format, ...) +{ + va_list args; + + va_start (args, format); + + display (format, args); + + va_end (args); +} + +/* Look for the program formed by concatenating PROG_NAME and the + string running from PREFIX to END_PREFIX. If the concatenated + string contains a '/', try appending EXECUTABLE_SUFFIX if it is + appropriate. */ + +static char * +look_for_prog (const char *progname, const char *prefix, int end_prefix) +{ + struct stat s; + char *cmd; + + cmd = xmalloc (strlen (prefix) + + strlen (progname) +#ifdef HAVE_EXECUTABLE_SUFFIX + + strlen (EXECUTABLE_SUFFIX) +#endif + + 10); + strcpy (cmd, prefix); + + sprintf (cmd + end_prefix, "%s", progname); + + if (strchr (cmd, '/') != NULL) + { + int found; + + found = (stat (cmd, &s) == 0 +#ifdef HAVE_EXECUTABLE_SUFFIX + || stat (strcat (cmd, EXECUTABLE_SUFFIX), &s) == 0 +#endif + ); + + if (! found) + { + /* xgettext:c-format */ + inform (_("Tried file: %s"), cmd); + free (cmd); + return NULL; + } + } + + /* xgettext:c-format */ + inform (_("Using file: %s"), cmd); + + return cmd; +} + +/* Deduce the name of the program we are want to invoke. + PROG_NAME is the basic name of the program we want to run, + eg "as" or "ld". The catch is that we might want actually + run "i386-pe-as" or "ppc-pe-ld". + + If argv[0] contains the full path, then try to find the program + in the same place, with and then without a target-like prefix. + + Given, argv[0] = /usr/local/bin/i586-cygwin32-dlltool, + deduce_name("as") uses the following search order: + + /usr/local/bin/i586-cygwin32-as + /usr/local/bin/as + as + + If there's an EXECUTABLE_SUFFIX, it'll use that as well; for each + name, it'll try without and then with EXECUTABLE_SUFFIX. + + Given, argv[0] = i586-cygwin32-dlltool, it will not even try "as" + as the fallback, but rather return i586-cygwin32-as. + + Oh, and given, argv[0] = dlltool, it'll return "as". + + Returns a dynamically allocated string. */ + +static char * +deduce_name (const char * name) +{ + char *cmd; + const char *dash; + const char *slash; + const char *cp; + + dash = NULL; + slash = NULL; + for (cp = prog_name; *cp != '\0'; ++cp) + { + if (*cp == '-') + dash = cp; + + if ( +#if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__) + *cp == ':' || *cp == '\\' || +#endif + *cp == '/') + { + slash = cp; + dash = NULL; + } + } + + cmd = NULL; + + if (dash != NULL) + /* First, try looking for a prefixed NAME in the + PROG_NAME directory, with the same prefix as PROG_NAME. */ + cmd = look_for_prog (name, prog_name, dash - prog_name + 1); + + if (slash != NULL && cmd == NULL) + /* Next, try looking for a NAME in the same directory as + that of this program. */ + cmd = look_for_prog (name, prog_name, slash - prog_name + 1); + + if (cmd == NULL) + /* Just return NAME as is. */ + cmd = xstrdup (name); + + return cmd; +} + +static void +delete_temp_files (void) +{ + if (delete_base_file && base_file_name) + { + if (verbose) + { + if (dontdeltemps) + warn (_("Keeping temporary base file %s"), base_file_name); + else + warn (_("Deleting temporary base file %s"), base_file_name); + } + if (! dontdeltemps) + { + unlink (base_file_name); + free (base_file_name); + } + } + + if (delete_exp_file && exp_file_name) + { + if (verbose) + { + if (dontdeltemps) + warn (_("Keeping temporary exp file %s"), exp_file_name); + else + warn (_("Deleting temporary exp file %s"), exp_file_name); + } + if (! dontdeltemps) + { + unlink (exp_file_name); + free (exp_file_name); + } + } + if (delete_def_file && def_file_name) + { + if (verbose) + { + if (dontdeltemps) + warn (_("Keeping temporary def file %s"), def_file_name); + else + warn (_("Deleting temporary def file %s"), def_file_name); + } + if (! dontdeltemps) + { + unlink (def_file_name); + free (def_file_name); + } + } +} + +static void +cleanup_and_exit (int status) +{ + delete_temp_files (); + exit (status); +} + +static int +run (const char *what, char *args) +{ + char *s; + int pid, wait_status, retcode; + int i; + const char **argv; + char *errmsg_fmt, *errmsg_arg; + char *temp_base = choose_temp_base (); + int in_quote; + char sep; + + if (verbose || dry_run) + fprintf (stderr, "%s %s\n", what, args); + + /* Count the args */ + i = 0; + for (s = args; *s; s++) + if (*s == ' ') + i++; + i++; + argv = xmalloc (sizeof (char *) * (i + 3)); + i = 0; + argv[i++] = what; + s = args; + while (1) + { + while (*s == ' ' && *s != 0) + s++; + if (*s == 0) + break; + in_quote = (*s == '\'' || *s == '"'); + sep = (in_quote) ? *s++ : ' '; + argv[i++] = s; + while (*s != sep && *s != 0) + s++; + if (*s == 0) + break; + *s++ = 0; + if (in_quote) + s++; + } + argv[i++] = NULL; + + if (dry_run) + return 0; + + pid = pexecute (argv[0], (char * const *) argv, prog_name, temp_base, + &errmsg_fmt, &errmsg_arg, PEXECUTE_ONE | PEXECUTE_SEARCH); + free (argv); + + if (pid == -1) + { + int errno_val = errno; + + fprintf (stderr, "%s: ", prog_name); + fprintf (stderr, errmsg_fmt, errmsg_arg); + fprintf (stderr, ": %s\n", strerror (errno_val)); + return 1; + } + + retcode = 0; + pid = pwait (pid, &wait_status, 0); + if (pid == -1) + { + warn (_("pwait returns: %s"), strerror (errno)); + retcode = 1; + } + else if (WIFSIGNALED (wait_status)) + { + warn (_("subprocess got fatal signal %d"), WTERMSIG (wait_status)); + retcode = 1; + } + else if (WIFEXITED (wait_status)) + { + if (WEXITSTATUS (wait_status) != 0) + { + warn (_("%s exited with status %d"), what, WEXITSTATUS (wait_status)); + retcode = 1; + } + } + else + retcode = 1; + + return retcode; +} + +static char * +mybasename (const char *name) +{ + const char *base = name; + + while (*name) + { + if (*name == '/' || *name == '\\') + { + base = name + 1; + } + ++name; + } + return (char *) base; +} + +static int +strhash (const char *str) +{ + const unsigned char *s; + unsigned long hash; + unsigned int c; + unsigned int len; + + hash = 0; + len = 0; + s = (const unsigned char *) str; + while ((c = *s++) != '\0') + { + hash += c + (c << 17); + hash ^= hash >> 2; + ++len; + } + hash += len + (len << 17); + hash ^= hash >> 2; + + return hash; +} + +/**********************************************************************/ + +static void +usage (FILE *file, int status) +{ + fprintf (file, _("Usage %s \n"), prog_name); + fprintf (file, _(" Generic options:\n")); + fprintf (file, _(" @ Read options from \n")); + fprintf (file, _(" --quiet, -q Work quietly\n")); + fprintf (file, _(" --verbose, -v Verbose\n")); + fprintf (file, _(" --version Print dllwrap version\n")); + fprintf (file, _(" --implib Synonym for --output-lib\n")); + fprintf (file, _(" Options for %s:\n"), prog_name); + fprintf (file, _(" --driver-name Defaults to \"gcc\"\n")); + fprintf (file, _(" --driver-flags Override default ld flags\n")); + fprintf (file, _(" --dlltool-name Defaults to \"dlltool\"\n")); + fprintf (file, _(" --entry Specify alternate DLL entry point\n")); + fprintf (file, _(" --image-base Specify image base address\n")); + fprintf (file, _(" --target i386-cygwin32 or i386-mingw32\n")); + fprintf (file, _(" --dry-run Show what needs to be run\n")); + fprintf (file, _(" --mno-cygwin Create Mingw DLL\n")); + fprintf (file, _(" Options passed to DLLTOOL:\n")); + fprintf (file, _(" --machine \n")); + fprintf (file, _(" --output-exp Generate export file.\n")); + fprintf (file, _(" --output-lib Generate input library.\n")); + fprintf (file, _(" --add-indirect Add dll indirects to export file.\n")); + fprintf (file, _(" --dllname Name of input dll to put into output lib.\n")); + fprintf (file, _(" --def Name input .def file\n")); + fprintf (file, _(" --output-def Name output .def file\n")); + fprintf (file, _(" --export-all-symbols Export all symbols to .def\n")); + fprintf (file, _(" --no-export-all-symbols Only export .drectve symbols\n")); + fprintf (file, _(" --exclude-symbols Exclude from .def\n")); + fprintf (file, _(" --no-default-excludes Zap default exclude symbols\n")); + fprintf (file, _(" --base-file Read linker generated base file\n")); + fprintf (file, _(" --no-idata4 Don't generate idata$4 section\n")); + fprintf (file, _(" --no-idata5 Don't generate idata$5 section\n")); + fprintf (file, _(" -U Add underscores to .lib\n")); + fprintf (file, _(" -k Kill @ from exported names\n")); + fprintf (file, _(" --add-stdcall-alias Add aliases without @\n")); + fprintf (file, _(" --as Use for assembler\n")); + fprintf (file, _(" --nodelete Keep temp files.\n")); + fprintf (file, _(" --no-leading-underscore Entrypoint without underscore\n")); + fprintf (file, _(" --leading-underscore Entrypoint with underscore.\n")); + fprintf (file, _(" Rest are passed unmodified to the language driver\n")); + fprintf (file, "\n\n"); + if (REPORT_BUGS_TO[0] && status == 0) + fprintf (file, _("Report bugs to %s\n"), REPORT_BUGS_TO); + exit (status); +} + +#define OPTION_START 149 + +/* GENERIC options. */ +#define OPTION_QUIET (OPTION_START + 1) +#define OPTION_VERBOSE (OPTION_QUIET + 1) +#define OPTION_VERSION (OPTION_VERBOSE + 1) + +/* DLLWRAP options. */ +#define OPTION_DRY_RUN (OPTION_VERSION + 1) +#define OPTION_DRIVER_NAME (OPTION_DRY_RUN + 1) +#define OPTION_DRIVER_FLAGS (OPTION_DRIVER_NAME + 1) +#define OPTION_DLLTOOL_NAME (OPTION_DRIVER_FLAGS + 1) +#define OPTION_ENTRY (OPTION_DLLTOOL_NAME + 1) +#define OPTION_IMAGE_BASE (OPTION_ENTRY + 1) +#define OPTION_TARGET (OPTION_IMAGE_BASE + 1) +#define OPTION_MNO_CYGWIN (OPTION_TARGET + 1) +#define OPTION_NO_LEADING_UNDERSCORE (OPTION_MNO_CYGWIN + 1) +#define OPTION_LEADING_UNDERSCORE (OPTION_NO_LEADING_UNDERSCORE + 1) + +/* DLLTOOL options. */ +#define OPTION_NODELETE (OPTION_LEADING_UNDERSCORE + 1) +#define OPTION_DLLNAME (OPTION_NODELETE + 1) +#define OPTION_NO_IDATA4 (OPTION_DLLNAME + 1) +#define OPTION_NO_IDATA5 (OPTION_NO_IDATA4 + 1) +#define OPTION_OUTPUT_EXP (OPTION_NO_IDATA5 + 1) +#define OPTION_OUTPUT_DEF (OPTION_OUTPUT_EXP + 1) +#define OPTION_EXPORT_ALL_SYMS (OPTION_OUTPUT_DEF + 1) +#define OPTION_NO_EXPORT_ALL_SYMS (OPTION_EXPORT_ALL_SYMS + 1) +#define OPTION_EXCLUDE_SYMS (OPTION_NO_EXPORT_ALL_SYMS + 1) +#define OPTION_NO_DEFAULT_EXCLUDES (OPTION_EXCLUDE_SYMS + 1) +#define OPTION_OUTPUT_LIB (OPTION_NO_DEFAULT_EXCLUDES + 1) +#define OPTION_DEF (OPTION_OUTPUT_LIB + 1) +#define OPTION_ADD_UNDERSCORE (OPTION_DEF + 1) +#define OPTION_KILLAT (OPTION_ADD_UNDERSCORE + 1) +#define OPTION_HELP (OPTION_KILLAT + 1) +#define OPTION_MACHINE (OPTION_HELP + 1) +#define OPTION_ADD_INDIRECT (OPTION_MACHINE + 1) +#define OPTION_BASE_FILE (OPTION_ADD_INDIRECT + 1) +#define OPTION_AS (OPTION_BASE_FILE + 1) + +static const struct option long_options[] = +{ + /* generic options. */ + {"quiet", no_argument, NULL, 'q'}, + {"verbose", no_argument, NULL, 'v'}, + {"version", no_argument, NULL, OPTION_VERSION}, + {"implib", required_argument, NULL, OPTION_OUTPUT_LIB}, + + /* dllwrap options. */ + {"dry-run", no_argument, NULL, OPTION_DRY_RUN}, + {"driver-name", required_argument, NULL, OPTION_DRIVER_NAME}, + {"driver-flags", required_argument, NULL, OPTION_DRIVER_FLAGS}, + {"dlltool-name", required_argument, NULL, OPTION_DLLTOOL_NAME}, + {"entry", required_argument, NULL, 'e'}, + {"image-base", required_argument, NULL, OPTION_IMAGE_BASE}, + {"target", required_argument, NULL, OPTION_TARGET}, + {"no-leading-underscore", no_argument, NULL, OPTION_NO_LEADING_UNDERSCORE}, + {"leading-underscore", no_argument, NULL, OPTION_NO_LEADING_UNDERSCORE}, + + /* dlltool options. */ + {"no-delete", no_argument, NULL, 'n'}, + {"dllname", required_argument, NULL, OPTION_DLLNAME}, + {"no-idata4", no_argument, NULL, OPTION_NO_IDATA4}, + {"no-idata5", no_argument, NULL, OPTION_NO_IDATA5}, + {"output-exp", required_argument, NULL, OPTION_OUTPUT_EXP}, + {"output-def", required_argument, NULL, OPTION_OUTPUT_DEF}, + {"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL_SYMS}, + {"no-export-all-symbols", no_argument, NULL, OPTION_NO_EXPORT_ALL_SYMS}, + {"exclude-symbols", required_argument, NULL, OPTION_EXCLUDE_SYMS}, + {"no-default-excludes", no_argument, NULL, OPTION_NO_DEFAULT_EXCLUDES}, + {"output-lib", required_argument, NULL, OPTION_OUTPUT_LIB}, + {"def", required_argument, NULL, OPTION_DEF}, + {"add-underscore", no_argument, NULL, 'U'}, + {"killat", no_argument, NULL, 'k'}, + {"add-stdcall-alias", no_argument, NULL, 'A'}, + {"help", no_argument, NULL, 'h'}, + {"machine", required_argument, NULL, OPTION_MACHINE}, + {"add-indirect", no_argument, NULL, OPTION_ADD_INDIRECT}, + {"base-file", required_argument, NULL, OPTION_BASE_FILE}, + {"as", required_argument, NULL, OPTION_AS}, + {0, 0, 0, 0} +}; + +int main (int, char **); + +int +main (int argc, char **argv) +{ + int c; + int i; + + char **saved_argv = 0; + int cmdline_len = 0; + + int export_all = 0; + + int *dlltool_arg_indices; + int *driver_arg_indices; + + char *driver_flags = 0; + char *output_lib_file_name = 0; + + dyn_string_t dlltool_cmdline; + dyn_string_t driver_cmdline; + + int def_file_seen = 0; + + char *image_base_str = 0; + + prog_name = argv[0]; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + expandargv (&argc, &argv); + + saved_argv = (char **) xmalloc (argc * sizeof (char*)); + dlltool_arg_indices = (int *) xmalloc (argc * sizeof (int)); + driver_arg_indices = (int *) xmalloc (argc * sizeof (int)); + for (i = 0; i < argc; ++i) + { + size_t len = strlen (argv[i]); + char *arg = (char *) xmalloc (len + 1); + strcpy (arg, argv[i]); + cmdline_len += len; + saved_argv[i] = arg; + dlltool_arg_indices[i] = 0; + driver_arg_indices[i] = 1; + } + cmdline_len++; + + /* We recognize dllwrap and dlltool options, and everything else is + passed onto the language driver (eg., to GCC). We collect options + to dlltool and driver in dlltool_args and driver_args. */ + + opterr = 0; + while ((c = getopt_long_only (argc, argv, "nkAqve:Uho:l:L:I:", + long_options, (int *) 0)) != EOF) + { + int dlltool_arg; + int driver_arg; + int single_word_option_value_pair; + + dlltool_arg = 0; + driver_arg = 1; + single_word_option_value_pair = 0; + + if (c != '?') + { + /* We recognize this option, so it has to be either dllwrap or + dlltool option. Do not pass to driver unless it's one of the + generic options that are passed to all the tools (such as -v) + which are dealt with later. */ + driver_arg = 0; + } + + /* deal with generic and dllwrap options first. */ + switch (c) + { + case 'h': + usage (stdout, 0); + break; + case 'q': + verbose = 0; + break; + case 'v': + verbose = 1; + break; + case OPTION_VERSION: + print_version (prog_name); + break; + case 'e': + entry_point = optarg; + break; + case OPTION_IMAGE_BASE: + image_base_str = optarg; + break; + case OPTION_DEF: + def_file_name = optarg; + def_file_seen = 1; + delete_def_file = 0; + break; + case 'n': + dontdeltemps = 1; + dlltool_arg = 1; + break; + case 'o': + dll_file_name = optarg; + break; + case 'I': + case 'l': + case 'L': + driver_arg = 1; + break; + case OPTION_DLLNAME: + dll_name = optarg; + break; + case OPTION_DRY_RUN: + dry_run = 1; + break; + case OPTION_DRIVER_NAME: + driver_name = optarg; + break; + case OPTION_DRIVER_FLAGS: + driver_flags = optarg; + break; + case OPTION_DLLTOOL_NAME: + dlltool_name = optarg; + break; + case OPTION_TARGET: + target = optarg; + break; + case OPTION_MNO_CYGWIN: + target = "i386-mingw32"; + break; + case OPTION_NO_LEADING_UNDERSCORE: + is_leading_underscore = 0; + break; + case OPTION_LEADING_UNDERSCORE: + is_leading_underscore = 1; + break; + case OPTION_BASE_FILE: + base_file_name = optarg; + delete_base_file = 0; + break; + case OPTION_OUTPUT_EXP: + exp_file_name = optarg; + delete_exp_file = 0; + break; + case OPTION_EXPORT_ALL_SYMS: + export_all = 1; + break; + case OPTION_OUTPUT_LIB: + output_lib_file_name = optarg; + break; + case '?': + break; + default: + dlltool_arg = 1; + break; + } + + /* Handle passing through --option=value case. */ + if (optarg + && saved_argv[optind-1][0] == '-' + && saved_argv[optind-1][1] == '-' + && strchr (saved_argv[optind-1], '=')) + single_word_option_value_pair = 1; + + if (dlltool_arg) + { + dlltool_arg_indices[optind-1] = 1; + if (optarg && ! single_word_option_value_pair) + { + dlltool_arg_indices[optind-2] = 1; + } + } + + if (! driver_arg) + { + driver_arg_indices[optind-1] = 0; + if (optarg && ! single_word_option_value_pair) + { + driver_arg_indices[optind-2] = 0; + } + } + } + + /* Sanity checks. */ + if (! dll_name && ! dll_file_name) + { + warn (_("Must provide at least one of -o or --dllname options")); + exit (1); + } + else if (! dll_name) + { + dll_name = xstrdup (mybasename (dll_file_name)); + } + else if (! dll_file_name) + { + dll_file_name = xstrdup (dll_name); + } + + /* Deduce driver-name and dlltool-name from our own. */ + if (driver_name == NULL) + driver_name = deduce_name ("gcc"); + + if (dlltool_name == NULL) + dlltool_name = deduce_name ("dlltool"); + + if (! def_file_seen) + { + char *fileprefix = choose_temp_base (); + + def_file_name = (char *) xmalloc (strlen (fileprefix) + 5); + sprintf (def_file_name, "%s.def", + (dontdeltemps) ? mybasename (fileprefix) : fileprefix); + delete_def_file = 1; + free (fileprefix); + delete_def_file = 1; + warn (_("no export definition file provided.\n\ +Creating one, but that may not be what you want")); + } + + /* Set the target platform. */ + if (strstr (target, "cygwin")) + which_target = CYGWIN_TARGET; + else if (strstr (target, "mingw")) + which_target = MINGW_TARGET; + else + which_target = UNKNOWN_TARGET; + + if (! strncmp (target, "arm", 3)) + which_cpu = ARM_CPU; + else if (!strncmp (target, "x86_64", 6) + || !strncmp (target, "athlon64", 8) + || !strncmp (target, "amd64", 5)) + which_cpu = X64_CPU; + else if (target[0] == 'i' && (target[1] >= '3' && target[1] <= '6') + && target[2] == '8' && target[3] == '6') + which_cpu = X86_CPU; + else + which_cpu = UNKNOWN_CPU; + + if (is_leading_underscore == -1) + is_leading_underscore = (which_cpu != X64_CPU && which_cpu != ARM_CPU); + + /* Re-create the command lines as a string, taking care to quote stuff. */ + dlltool_cmdline = dyn_string_new (cmdline_len); + if (verbose) + dyn_string_append_cstr (dlltool_cmdline, " -v"); + + dyn_string_append_cstr (dlltool_cmdline, " --dllname "); + dyn_string_append_cstr (dlltool_cmdline, dll_name); + + for (i = 1; i < argc; ++i) + { + if (dlltool_arg_indices[i]) + { + char *arg = saved_argv[i]; + int quote = (strchr (arg, ' ') || strchr (arg, '\t')); + dyn_string_append_cstr (dlltool_cmdline, + (quote) ? " \"" : " "); + dyn_string_append_cstr (dlltool_cmdline, arg); + dyn_string_append_cstr (dlltool_cmdline, + (quote) ? "\"" : ""); + } + } + + driver_cmdline = dyn_string_new (cmdline_len); + if (! driver_flags || strlen (driver_flags) == 0) + { + switch (which_target) + { + case CYGWIN_TARGET: + driver_flags = cygwin_driver_flags; + break; + + case MINGW_TARGET: + driver_flags = mingw32_driver_flags; + break; + + default: + driver_flags = generic_driver_flags; + break; + } + } + dyn_string_append_cstr (driver_cmdline, driver_flags); + dyn_string_append_cstr (driver_cmdline, " -o "); + dyn_string_append_cstr (driver_cmdline, dll_file_name); + + if (is_leading_underscore == 0) + dyn_string_append_cstr (driver_cmdline, " --no-leading-underscore"); + else if (is_leading_underscore == 1) + dyn_string_append_cstr (driver_cmdline, " --leading-underscore"); + + if (! entry_point || strlen (entry_point) == 0) + { + const char *prefix = (is_leading_underscore != 0 ? "_" : ""); + const char *postfix = ""; + const char *name_entry; + + if (which_cpu == X86_CPU || which_cpu == UNKNOWN_CPU) + postfix = "@12"; + + switch (which_target) + { + case CYGWIN_TARGET: + name_entry = "_cygwin_dll_entry"; + break; + + case MINGW_TARGET: + name_entry = "DllMainCRTStartup"; + break; + + default: + name_entry = "DllMain"; + break; + } + entry_point = + (char *) malloc (strlen (name_entry) + strlen (prefix) + + strlen (postfix) + 1); + sprintf (entry_point, "%s%s%s", prefix, name_entry, postfix); + } + dyn_string_append_cstr (driver_cmdline, " -Wl,-e,"); + dyn_string_append_cstr (driver_cmdline, entry_point); + dyn_string_append_cstr (dlltool_cmdline, " --exclude-symbol="); + dyn_string_append_cstr (dlltool_cmdline, + (entry_point[0] == '_') ? entry_point+1 : entry_point); + + if (! image_base_str || strlen (image_base_str) == 0) + { + char *tmpbuf = (char *) xmalloc (sizeof ("0x12345678") + 1); + unsigned long hash = strhash (dll_file_name); + sprintf (tmpbuf, "0x%.8lX", 0x60000000|((hash<<16)&0xFFC0000)); + image_base_str = tmpbuf; + } + + dyn_string_append_cstr (driver_cmdline, " -Wl,--image-base,"); + dyn_string_append_cstr (driver_cmdline, image_base_str); + + if (verbose) + { + dyn_string_append_cstr (driver_cmdline, " -v"); + } + + for (i = 1; i < argc; ++i) + { + if (driver_arg_indices[i]) + { + char *arg = saved_argv[i]; + int quote = (strchr (arg, ' ') || strchr (arg, '\t')); + dyn_string_append_cstr (driver_cmdline, + (quote) ? " \"" : " "); + dyn_string_append_cstr (driver_cmdline, arg); + dyn_string_append_cstr (driver_cmdline, + (quote) ? "\"" : ""); + } + } + + /* Step pre-1. If no --def is specified, + then create it and then pass it on. */ + + if (! def_file_seen) + { + dyn_string_t step_pre1; + + step_pre1 = dyn_string_new (1024); + + dyn_string_append_cstr (step_pre1, dlltool_cmdline->s); + if (export_all) + { + dyn_string_append_cstr (step_pre1, " --export-all --exclude-symbol="); + dyn_string_append_cstr (step_pre1, + "_cygwin_dll_entry@12,DllMainCRTStartup@12,DllMain@12,DllEntryPoint@12"); + } + dyn_string_append_cstr (step_pre1, " --output-def "); + dyn_string_append_cstr (step_pre1, def_file_name); + + for (i = 1; i < argc; ++i) + { + if (driver_arg_indices[i]) + { + char *arg = saved_argv[i]; + size_t len = strlen (arg); + if (len >= 2 && arg[len-2] == '.' + && (arg[len-1] == 'o' || arg[len-1] == 'a')) + { + int quote = (strchr (arg, ' ') || strchr (arg, '\t')); + dyn_string_append_cstr (step_pre1, + (quote) ? " \"" : " "); + dyn_string_append_cstr (step_pre1, arg); + dyn_string_append_cstr (step_pre1, + (quote) ? "\"" : ""); + } + } + } + + if (run (dlltool_name, step_pre1->s)) + cleanup_and_exit (1); + + dyn_string_delete (step_pre1); + } + + dyn_string_append_cstr (dlltool_cmdline, " --def "); + dyn_string_append_cstr (dlltool_cmdline, def_file_name); + + if (verbose) + { + fprintf (stderr, _("DLLTOOL name : %s\n"), dlltool_name); + fprintf (stderr, _("DLLTOOL options : %s\n"), dlltool_cmdline->s); + fprintf (stderr, _("DRIVER name : %s\n"), driver_name); + fprintf (stderr, _("DRIVER options : %s\n"), driver_cmdline->s); + } + + /* Step 1. Call GCC/LD to create base relocation file. If using GCC, the + driver command line will look like the following: + + % gcc -Wl,--dll --Wl,--base-file,foo.base [rest of command line] + + If the user does not specify a base name, create temporary one that + is deleted at exit. */ + + if (! base_file_name) + { + char *fileprefix = choose_temp_base (); + base_file_name = (char *) xmalloc (strlen (fileprefix) + 6); + sprintf (base_file_name, "%s.base", + (dontdeltemps) ? mybasename (fileprefix) : fileprefix); + delete_base_file = 1; + free (fileprefix); + } + + { + int quote; + + dyn_string_t step1 = dyn_string_new (driver_cmdline->length + + strlen (base_file_name) + + 20); + dyn_string_append_cstr (step1, "-Wl,--base-file,"); + quote = (strchr (base_file_name, ' ') + || strchr (base_file_name, '\t')); + dyn_string_append_cstr (step1, + (quote) ? "\"" : ""); + dyn_string_append_cstr (step1, base_file_name); + dyn_string_append_cstr (step1, + (quote) ? "\"" : ""); + if (driver_cmdline->length) + { + dyn_string_append_cstr (step1, " "); + dyn_string_append_cstr (step1, driver_cmdline->s); + } + + if (run (driver_name, step1->s)) + cleanup_and_exit (1); + + dyn_string_delete (step1); + } + + /* Step 2. generate the exp file by running dlltool. + dlltool command line will look like the following: + + % dlltool -Wl,--dll --Wl,--base-file,foo.base [rest of command line] + + If the user does not specify a base name, create temporary one that + is deleted at exit. */ + + if (! exp_file_name) + { + char *p = strrchr (dll_name, '.'); + size_t prefix_len = (p) ? (size_t) (p - dll_name) : strlen (dll_name); + + exp_file_name = (char *) xmalloc (prefix_len + 4 + 1); + strncpy (exp_file_name, dll_name, prefix_len); + exp_file_name[prefix_len] = '\0'; + strcat (exp_file_name, ".exp"); + delete_exp_file = 1; + } + + { + int quote; + + dyn_string_t step2 = dyn_string_new (dlltool_cmdline->length + + strlen (base_file_name) + + strlen (exp_file_name) + + 20); + + dyn_string_append_cstr (step2, "--base-file "); + quote = (strchr (base_file_name, ' ') + || strchr (base_file_name, '\t')); + dyn_string_append_cstr (step2, + (quote) ? "\"" : ""); + dyn_string_append_cstr (step2, base_file_name); + dyn_string_append_cstr (step2, + (quote) ? "\" " : " "); + + dyn_string_append_cstr (step2, "--output-exp "); + quote = (strchr (exp_file_name, ' ') + || strchr (exp_file_name, '\t')); + dyn_string_append_cstr (step2, + (quote) ? "\"" : ""); + dyn_string_append_cstr (step2, exp_file_name); + dyn_string_append_cstr (step2, + (quote) ? "\"" : ""); + + if (dlltool_cmdline->length) + { + dyn_string_append_cstr (step2, " "); + dyn_string_append_cstr (step2, dlltool_cmdline->s); + } + + if (run (dlltool_name, step2->s)) + cleanup_and_exit (1); + + dyn_string_delete (step2); + } + + /* + * Step 3. Call GCC/LD to again, adding the exp file this time. + * driver command line will look like the following: + * + * % gcc -Wl,--dll --Wl,--base-file,foo.base foo.exp [rest ...] + */ + + { + int quote; + + dyn_string_t step3 = dyn_string_new (driver_cmdline->length + + strlen (exp_file_name) + + strlen (base_file_name) + + 20); + dyn_string_append_cstr (step3, "-Wl,--base-file,"); + quote = (strchr (base_file_name, ' ') + || strchr (base_file_name, '\t')); + dyn_string_append_cstr (step3, + (quote) ? "\"" : ""); + dyn_string_append_cstr (step3, base_file_name); + dyn_string_append_cstr (step3, + (quote) ? "\" " : " "); + + quote = (strchr (exp_file_name, ' ') + || strchr (exp_file_name, '\t')); + dyn_string_append_cstr (step3, + (quote) ? "\"" : ""); + dyn_string_append_cstr (step3, exp_file_name); + dyn_string_append_cstr (step3, + (quote) ? "\"" : ""); + + if (driver_cmdline->length) + { + dyn_string_append_cstr (step3, " "); + dyn_string_append_cstr (step3, driver_cmdline->s); + } + + if (run (driver_name, step3->s)) + cleanup_and_exit (1); + + dyn_string_delete (step3); + } + + + /* + * Step 4. Run DLLTOOL again using the same command line. + */ + + { + int quote; + dyn_string_t step4 = dyn_string_new (dlltool_cmdline->length + + strlen (base_file_name) + + strlen (exp_file_name) + + 20); + + dyn_string_append_cstr (step4, "--base-file "); + quote = (strchr (base_file_name, ' ') + || strchr (base_file_name, '\t')); + dyn_string_append_cstr (step4, + (quote) ? "\"" : ""); + dyn_string_append_cstr (step4, base_file_name); + dyn_string_append_cstr (step4, + (quote) ? "\" " : " "); + + dyn_string_append_cstr (step4, "--output-exp "); + quote = (strchr (exp_file_name, ' ') + || strchr (exp_file_name, '\t')); + dyn_string_append_cstr (step4, + (quote) ? "\"" : ""); + dyn_string_append_cstr (step4, exp_file_name); + dyn_string_append_cstr (step4, + (quote) ? "\"" : ""); + + if (dlltool_cmdline->length) + { + dyn_string_append_cstr (step4, " "); + dyn_string_append_cstr (step4, dlltool_cmdline->s); + } + + if (output_lib_file_name) + { + dyn_string_append_cstr (step4, " --output-lib "); + dyn_string_append_cstr (step4, output_lib_file_name); + } + + if (run (dlltool_name, step4->s)) + cleanup_and_exit (1); + + dyn_string_delete (step4); + } + + + /* + * Step 5. Link it all together and be done with it. + * driver command line will look like the following: + * + * % gcc -Wl,--dll foo.exp [rest ...] + * + */ + + { + int quote; + + dyn_string_t step5 = dyn_string_new (driver_cmdline->length + + strlen (exp_file_name) + + 20); + quote = (strchr (exp_file_name, ' ') + || strchr (exp_file_name, '\t')); + dyn_string_append_cstr (step5, + (quote) ? "\"" : ""); + dyn_string_append_cstr (step5, exp_file_name); + dyn_string_append_cstr (step5, + (quote) ? "\"" : ""); + + if (driver_cmdline->length) + { + dyn_string_append_cstr (step5, " "); + dyn_string_append_cstr (step5, driver_cmdline->s); + } + + if (run (driver_name, step5->s)) + cleanup_and_exit (1); + + dyn_string_delete (step5); + } + + cleanup_and_exit (0); + + return 0; +} diff --git a/support/sdbinutils/binutils/doc/Makefile.am b/support/sdbinutils/binutils/doc/Makefile.am new file mode 100644 index 0000000..0848ee5 --- /dev/null +++ b/support/sdbinutils/binutils/doc/Makefile.am @@ -0,0 +1,201 @@ +## Process this file with automake to generate Makefile.in +# +# Copyright (C) 2012-2018 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . +# + +AUTOMAKE_OPTIONS = cygnus + +# What version of the manual you want; "all" includes everything +CONFIG=all + +# Options to extract the man page from as.texinfo +MANCONF = -Dman + +TEXI2POD = perl $(top_srcdir)/../etc/texi2pod.pl $(AM_MAKEINFOFLAGS) + +POD2MAN = pod2man --center="GNU Development Tools" \ + --release="binutils-$(VERSION)" --section=1 + +# List of man pages generated from binutils.texi +man_MANS = \ + addr2line.1 \ + ar.1 \ + dlltool.1 \ + nlmconv.1 \ + nm.1 \ + objcopy.1 \ + objdump.1 \ + ranlib.1 \ + readelf.1 \ + size.1 \ + strings.1 \ + strip.1 \ + elfedit.1 \ + windres.1 \ + windmc.1 \ + $(DEMANGLER_NAME).1 + +info_TEXINFOS = binutils.texi +binutils_TEXI = $(srcdir)/binutils.texi + +AM_MAKEINFOFLAGS = -I "$(srcdir)" -I "$(top_srcdir)/../libiberty" \ + -I "$(top_srcdir)/../bfd/doc" -I ../../bfd/doc +TEXI2DVI = texi2dvi -I "$(srcdir)" -I "$(top_srcdir)/../libiberty" \ + -I "$(top_srcdir)/../bfd/doc" -I ../../bfd/doc + +# Man page generation from texinfo +addr2line.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Daddr2line < $(binutils_TEXI) > addr2line.pod + -($(POD2MAN) addr2line.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f addr2line.pod + +ar.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dar < $(binutils_TEXI) > ar.pod + -($(POD2MAN) ar.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f ar.pod + +dlltool.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Ddlltool < $(binutils_TEXI) > dlltool.pod + -($(POD2MAN) dlltool.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f dlltool.pod + +nlmconv.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dnlmconv < $(binutils_TEXI) > nlmconv.pod + -($(POD2MAN) nlmconv.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f nlmconv.pod + +nm.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dnm < $(binutils_TEXI) > nm.pod + -($(POD2MAN) nm.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f nm.pod + +objcopy.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dobjcopy < $(binutils_TEXI) > objcopy.pod + -($(POD2MAN) objcopy.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f objcopy.pod + +objdump.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dobjdump < $(binutils_TEXI) > objdump.pod + -($(POD2MAN) objdump.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f objdump.pod + +ranlib.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dranlib < $(binutils_TEXI) > ranlib.pod + -($(POD2MAN) ranlib.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f ranlib.pod + +readelf.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dreadelf < $(binutils_TEXI) > readelf.pod + -($(POD2MAN) readelf.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f readelf.pod + +size.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dsize < $(binutils_TEXI) > size.pod + -($(POD2MAN) size.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f size.pod + +strings.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dstrings < $(binutils_TEXI) > strings.pod + -($(POD2MAN) strings.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f strings.pod + +strip.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dstrip < $(binutils_TEXI) > strip.pod + -($(POD2MAN) strip.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f strip.pod + +elfedit.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Delfedit < $(binutils_TEXI) > elfedit.pod + -($(POD2MAN) elfedit.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f elfedit.pod + +windres.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dwindres < $(binutils_TEXI) > windres.pod + -($(POD2MAN) windres.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f windres.pod + +windmc.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dwindmc < $(binutils_TEXI) > windmc.pod + -($(POD2MAN) windmc.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f windmc.pod + +cxxfilt.man: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dcxxfilt < $(binutils_TEXI) > $(DEMANGLER_NAME).pod + -($(POD2MAN) $(DEMANGLER_NAME).pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f $(DEMANGLER_NAME).pod + +MOSTLYCLEANFILES = $(DEMANGLER_NAME).1 + +$(DEMANGLER_NAME).1: cxxfilt.man Makefile + if test -f cxxfilt.man; then \ + man=cxxfilt.man; \ + else \ + man=$(srcdir)/cxxfilt.man; \ + fi; \ + sed -e 's/@PROGRAM@/$(DEMANGLER_NAME)/' \ + -e 's/cxxfilt/$(DEMANGLER_NAME)/' < $$man \ + > $(DEMANGLER_NAME).1 + +# We want install to imply install-info as per GNU standards, despite the +# cygnus option. +install-data-local: install-info + +MAINTAINERCLEANFILES = binutils.info + +# Automake 1.9 will only build info files in the objdir if they are +# mentioned in DISTCLEANFILES. It doesn't have to be unconditional, +# though, so we use a bogus condition. +if GENINSRC_NEVER +DISTCLEANFILES = binutils.info +endif + +# Maintenance + +# We need it for the taz target in ../../Makefile.in. +info-local: $(MANS) diff --git a/support/sdbinutils/binutils/doc/Makefile.in b/support/sdbinutils/binutils/doc/Makefile.in new file mode 100644 index 0000000..705dab5 --- /dev/null +++ b/support/sdbinutils/binutils/doc/Makefile.in @@ -0,0 +1,943 @@ +# Makefile.in generated by automake 1.11.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# +# Copyright (C) 2012-2018 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . +# +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = doc +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \ + $(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/gettext-sister.m4 \ + $(top_srcdir)/../config/iconv.m4 \ + $(top_srcdir)/../config/largefile.m4 \ + $(top_srcdir)/../config/lcmessage.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/lib-ld.m4 \ + $(top_srcdir)/../config/lib-link.m4 \ + $(top_srcdir)/../config/lib-prefix.m4 \ + $(top_srcdir)/../config/nls.m4 \ + $(top_srcdir)/../config/override.m4 \ + $(top_srcdir)/../config/plugins.m4 \ + $(top_srcdir)/../config/po.m4 \ + $(top_srcdir)/../config/progtest.m4 \ + $(top_srcdir)/../config/zlib.m4 $(top_srcdir)/../libtool.m4 \ + $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ + $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ + $(top_srcdir)/../bfd/version.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +depcomp = +am__depfiles_maybe = +SOURCES = +INFO_DEPS = binutils.info +TEXINFO_TEX = $(top_srcdir)/../texinfo/texinfo.tex +am__TEXINFO_TEX_DIR = $(top_srcdir)/../texinfo +DVIS = binutils.dvi +PDFS = binutils.pdf +PSS = binutils.ps +HTMLS = binutils.html +TEXINFOS = binutils.texi +TEXI2PDF = $(TEXI2DVI) --pdf --batch +MAKEINFOHTML = $(MAKEINFO) --html +AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS) +DVIPS = dvips +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +man1dir = $(mandir)/man1 +am__installdirs = "$(DESTDIR)$(man1dir)" +NROFF = nroff +MANS = $(man_MANS) +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_DLLTOOL = @BUILD_DLLTOOL@ +BUILD_DLLWRAP = @BUILD_DLLWRAP@ +BUILD_INSTALL_MISC = @BUILD_INSTALL_MISC@ +BUILD_MISC = @BUILD_MISC@ +BUILD_NLMCONV = @BUILD_NLMCONV@ +BUILD_SRCONV = @BUILD_SRCONV@ +BUILD_WINDMC = @BUILD_WINDMC@ +BUILD_WINDRES = @BUILD_WINDRES@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CC_FOR_BUILD = @CC_FOR_BUILD@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DEFS = @DEFS@ +DEMANGLER_NAME = @DEMANGLER_NAME@ +DEPDIR = @DEPDIR@ +DLLTOOL_DEFS = @DLLTOOL_DEFS@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EMULATION = @EMULATION@ +EMULATION_VECTOR = @EMULATION_VECTOR@ +EXEEXT = @EXEEXT@ +EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@ +FGREP = @FGREP@ +GENCAT = @GENCAT@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +HDEFINES = @HDEFINES@ +INCINTL = @INCINTL@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBINTL_DEP = @LIBINTL_DEP@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NLMCONV_DEFS = @NLMCONV_DEFS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NO_WERROR = @NO_WERROR@ +OBJDUMP = @OBJDUMP@ +OBJDUMP_DEFS = @OBJDUMP_DEFS@ +OBJDUMP_PRIVATE_OFILES = @OBJDUMP_PRIVATE_OFILES@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@ +WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +zlibdir = @zlibdir@ +zlibinc = @zlibinc@ +AUTOMAKE_OPTIONS = cygnus + +# What version of the manual you want; "all" includes everything +CONFIG = all + +# Options to extract the man page from as.texinfo +MANCONF = -Dman +TEXI2POD = perl $(top_srcdir)/../etc/texi2pod.pl $(AM_MAKEINFOFLAGS) +POD2MAN = pod2man --center="GNU Development Tools" \ + --release="binutils-$(VERSION)" --section=1 + + +# List of man pages generated from binutils.texi +man_MANS = \ + addr2line.1 \ + ar.1 \ + dlltool.1 \ + nlmconv.1 \ + nm.1 \ + objcopy.1 \ + objdump.1 \ + ranlib.1 \ + readelf.1 \ + size.1 \ + strings.1 \ + strip.1 \ + elfedit.1 \ + windres.1 \ + windmc.1 \ + $(DEMANGLER_NAME).1 + +info_TEXINFOS = binutils.texi +binutils_TEXI = $(srcdir)/binutils.texi +AM_MAKEINFOFLAGS = -I "$(srcdir)" -I "$(top_srcdir)/../libiberty" \ + -I "$(top_srcdir)/../bfd/doc" -I ../../bfd/doc + +TEXI2DVI = texi2dvi -I "$(srcdir)" -I "$(top_srcdir)/../libiberty" \ + -I "$(top_srcdir)/../bfd/doc" -I ../../bfd/doc + +MOSTLYCLEANFILES = $(DEMANGLER_NAME).1 +MAINTAINERCLEANFILES = binutils.info + +# Automake 1.9 will only build info files in the objdir if they are +# mentioned in DISTCLEANFILES. It doesn't have to be unconditional, +# though, so we use a bogus condition. +@GENINSRC_NEVER_TRUE@DISTCLEANFILES = binutils.info +all: all-am + +.SUFFIXES: +.SUFFIXES: .dvi .ps +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign doc/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +binutils.info: binutils.texi + restore=: && backupdir="$(am__leading_dot)am$$$$" && \ + rm -rf $$backupdir && mkdir $$backupdir && \ + if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ + for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \ + if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \ + done; \ + else :; fi && \ + if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ + -o $@ `test -f 'binutils.texi' || echo '$(srcdir)/'`binutils.texi; \ + then \ + rc=0; \ + else \ + rc=$$?; \ + $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \ + fi; \ + rm -rf $$backupdir; exit $$rc + +binutils.dvi: binutils.texi + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ + $(TEXI2DVI) -o $@ `test -f 'binutils.texi' || echo '$(srcdir)/'`binutils.texi + +binutils.pdf: binutils.texi + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ + $(TEXI2PDF) -o $@ `test -f 'binutils.texi' || echo '$(srcdir)/'`binutils.texi + +binutils.html: binutils.texi + rm -rf $(@:.html=.htp) + if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ + -o $(@:.html=.htp) `test -f 'binutils.texi' || echo '$(srcdir)/'`binutils.texi; \ + then \ + rm -rf $@; \ + if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ + mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \ + else \ + if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ + rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \ + exit 1; \ + fi +.dvi.ps: + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + $(DVIPS) -o $@ $< + +uninstall-dvi-am: + @$(NORMAL_UNINSTALL) + @list='$(DVIS)'; test -n "$(dvidir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \ + rm -f "$(DESTDIR)$(dvidir)/$$f"; \ + done + +uninstall-html-am: + @$(NORMAL_UNINSTALL) + @list='$(HTMLS)'; test -n "$(htmldir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " rm -rf '$(DESTDIR)$(htmldir)/$$f'"; \ + rm -rf "$(DESTDIR)$(htmldir)/$$f"; \ + done + +uninstall-info-am: + @$(PRE_UNINSTALL) + @if test -d '$(DESTDIR)$(infodir)' && $(am__can_run_installinfo); then \ + list='$(INFO_DEPS)'; \ + for file in $$list; do \ + relfile=`echo "$$file" | sed 's|^.*/||'`; \ + echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \ + if install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \ + then :; else test ! -f "$(DESTDIR)$(infodir)/$$relfile" || exit 1; fi; \ + done; \ + else :; fi + @$(NORMAL_UNINSTALL) + @list='$(INFO_DEPS)'; \ + for file in $$list; do \ + relfile=`echo "$$file" | sed 's|^.*/||'`; \ + relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \ + (if test -d "$(DESTDIR)$(infodir)" && cd "$(DESTDIR)$(infodir)"; then \ + echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \ + rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \ + else :; fi); \ + done + +uninstall-pdf-am: + @$(NORMAL_UNINSTALL) + @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(pdfdir)/$$f'"; \ + rm -f "$(DESTDIR)$(pdfdir)/$$f"; \ + done + +uninstall-ps-am: + @$(NORMAL_UNINSTALL) + @list='$(PSS)'; test -n "$(psdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(psdir)/$$f'"; \ + rm -f "$(DESTDIR)$(psdir)/$$f"; \ + done + +dist-info: $(INFO_DEPS) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + list='$(INFO_DEPS)'; \ + for base in $$list; do \ + case $$base in \ + $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \ + esac; \ + if test -f $$base; then d=.; else d=$(srcdir); fi; \ + base_i=`echo "$$base" | sed 's|\.info$$||;s|$$|.i|'`; \ + for file in $$d/$$base $$d/$$base-[0-9] $$d/$$base-[0-9][0-9] $$d/$$base_i[0-9] $$d/$$base_i[0-9][0-9]; do \ + if test -f $$file; then \ + relfile=`expr "$$file" : "$$d/\(.*\)"`; \ + test -f "$(distdir)/$$relfile" || \ + cp -p $$file "$(distdir)/$$relfile"; \ + else :; fi; \ + done; \ + done + +mostlyclean-aminfo: + -rm -rf binutils.aux binutils.cp binutils.cps binutils.fn binutils.fns \ + binutils.ky binutils.log binutils.pg binutils.pgs \ + binutils.tmp binutils.toc binutils.tp binutils.tps \ + binutils.vr binutils.vrs + +clean-aminfo: + -test -z "binutils.dvi binutils.pdf binutils.ps binutils.html" \ + || rm -rf binutils.dvi binutils.pdf binutils.ps binutils.html + +maintainer-clean-aminfo: + @list='$(INFO_DEPS)'; for i in $$list; do \ + i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \ + echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \ + rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \ + done + +clean-info: mostlyclean-aminfo clean-aminfo +install-man1: $(man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(man_MANS)'; \ + test -n "$(man1dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.1[a-z]*$$/p'; \ + fi; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ + done; } + +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man1dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.1[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + +check-am: +check: check-am +all-am: Makefile $(MANS) +installdirs: + for dir in "$(DESTDIR)$(man1dir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-aminfo clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: $(DVIS) + +html: html-am + +html-am: $(HTMLS) + +info: info-am + +info-am: $(INFO_DEPS) info-local + +install-data-am: install-data-local install-man + +install-dvi: install-dvi-am + +install-dvi-am: $(DVIS) + @$(NORMAL_INSTALL) + @list='$(DVIS)'; test -n "$(dvidir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(dvidir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(dvidir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dvidir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(dvidir)" || exit $$?; \ + done +install-exec-am: + +install-html: install-html-am + +install-html-am: $(HTMLS) + @$(NORMAL_INSTALL) + @list='$(HTMLS)'; list2=; test -n "$(htmldir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(htmldir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \ + $(am__strip_dir) \ + d2=$$d$$p; \ + if test -d "$$d2"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/$$f'"; \ + $(MKDIR_P) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \ + echo " $(INSTALL_DATA) '$$d2'/* '$(DESTDIR)$(htmldir)/$$f'"; \ + $(INSTALL_DATA) "$$d2"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \ + else \ + list2="$$list2 $$d2"; \ + fi; \ + done; \ + test -z "$$list2" || { echo "$$list2" | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(htmldir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(htmldir)" || exit $$?; \ + done; } +install-info: install-info-am + +install-info-am: $(INFO_DEPS) + @$(NORMAL_INSTALL) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(infodir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(infodir)" || exit 1; \ + fi; \ + for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + esac; \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \ + for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \ + $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \ + if test -f $$ifile; then \ + echo "$$ifile"; \ + else : ; fi; \ + done; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(infodir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(infodir)" || exit $$?; done + @$(POST_INSTALL) + @if $(am__can_run_installinfo); then \ + list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \ + for file in $$list; do \ + relfile=`echo "$$file" | sed 's|^.*/||'`; \ + echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\ + install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\ + done; \ + else : ; fi +install-man: install-man1 + +install-pdf: install-pdf-am + +install-pdf-am: $(PDFS) + @$(NORMAL_INSTALL) + @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pdfdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pdfdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pdfdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(pdfdir)" || exit $$?; done +install-ps: install-ps-am + +install-ps-am: $(PSS) + @$(NORMAL_INSTALL) + @list='$(PSS)'; test -n "$(psdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(psdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(psdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(psdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(psdir)" || exit $$?; done +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-aminfo \ + maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-aminfo mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: $(PDFS) + +ps: ps-am + +ps-am: $(PSS) + +uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \ + uninstall-man uninstall-pdf-am uninstall-ps-am + +uninstall-man: uninstall-man1 + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-aminfo clean-generic \ + clean-info clean-libtool dist-info distclean distclean-generic \ + distclean-libtool dvi dvi-am html html-am info info-am \ + info-local install install-am install-data install-data-am \ + install-data-local install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-man1 install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-aminfo maintainer-clean-generic mostlyclean \ + mostlyclean-aminfo mostlyclean-generic mostlyclean-libtool pdf \ + pdf-am ps ps-am uninstall uninstall-am uninstall-dvi-am \ + uninstall-html-am uninstall-info-am uninstall-man \ + uninstall-man1 uninstall-pdf-am uninstall-ps-am + + +# Man page generation from texinfo +addr2line.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Daddr2line < $(binutils_TEXI) > addr2line.pod + -($(POD2MAN) addr2line.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f addr2line.pod + +ar.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dar < $(binutils_TEXI) > ar.pod + -($(POD2MAN) ar.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f ar.pod + +dlltool.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Ddlltool < $(binutils_TEXI) > dlltool.pod + -($(POD2MAN) dlltool.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f dlltool.pod + +nlmconv.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dnlmconv < $(binutils_TEXI) > nlmconv.pod + -($(POD2MAN) nlmconv.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f nlmconv.pod + +nm.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dnm < $(binutils_TEXI) > nm.pod + -($(POD2MAN) nm.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f nm.pod + +objcopy.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dobjcopy < $(binutils_TEXI) > objcopy.pod + -($(POD2MAN) objcopy.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f objcopy.pod + +objdump.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dobjdump < $(binutils_TEXI) > objdump.pod + -($(POD2MAN) objdump.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f objdump.pod + +ranlib.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dranlib < $(binutils_TEXI) > ranlib.pod + -($(POD2MAN) ranlib.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f ranlib.pod + +readelf.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dreadelf < $(binutils_TEXI) > readelf.pod + -($(POD2MAN) readelf.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f readelf.pod + +size.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dsize < $(binutils_TEXI) > size.pod + -($(POD2MAN) size.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f size.pod + +strings.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dstrings < $(binutils_TEXI) > strings.pod + -($(POD2MAN) strings.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f strings.pod + +strip.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dstrip < $(binutils_TEXI) > strip.pod + -($(POD2MAN) strip.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f strip.pod + +elfedit.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Delfedit < $(binutils_TEXI) > elfedit.pod + -($(POD2MAN) elfedit.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f elfedit.pod + +windres.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dwindres < $(binutils_TEXI) > windres.pod + -($(POD2MAN) windres.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f windres.pod + +windmc.1: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dwindmc < $(binutils_TEXI) > windmc.pod + -($(POD2MAN) windmc.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f windmc.pod + +cxxfilt.man: $(binutils_TEXI) $(binutils_TEXINFOS) + touch $@ + -$(TEXI2POD) $(MANCONF) -Dcxxfilt < $(binutils_TEXI) > $(DEMANGLER_NAME).pod + -($(POD2MAN) $(DEMANGLER_NAME).pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ + mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) + rm -f $(DEMANGLER_NAME).pod + +$(DEMANGLER_NAME).1: cxxfilt.man Makefile + if test -f cxxfilt.man; then \ + man=cxxfilt.man; \ + else \ + man=$(srcdir)/cxxfilt.man; \ + fi; \ + sed -e 's/@PROGRAM@/$(DEMANGLER_NAME)/' \ + -e 's/cxxfilt/$(DEMANGLER_NAME)/' < $$man \ + > $(DEMANGLER_NAME).1 + +# We want install to imply install-info as per GNU standards, despite the +# cygnus option. +install-data-local: install-info + +# Maintenance + +# We need it for the taz target in ../../Makefile.in. +info-local: $(MANS) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/support/sdbinutils/binutils/doc/addr2line.1 b/support/sdbinutils/binutils/doc/addr2line.1 new file mode 100644 index 0000000..f0a5518 --- /dev/null +++ b/support/sdbinutils/binutils/doc/addr2line.1 @@ -0,0 +1,311 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "ADDR2LINE 1" +.TH ADDR2LINE 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +addr2line \- convert addresses into file names and line numbers. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +addr2line [\fB\-a\fR|\fB\-\-addresses\fR] + [\fB\-b\fR \fIbfdname\fR|\fB\-\-target=\fR\fIbfdname\fR] + [\fB\-C\fR|\fB\-\-demangle\fR[=\fIstyle\fR]] + [\fB\-e\fR \fIfilename\fR|\fB\-\-exe=\fR\fIfilename\fR] + [\fB\-f\fR|\fB\-\-functions\fR] [\fB\-s\fR|\fB\-\-basename\fR] + [\fB\-i\fR|\fB\-\-inlines\fR] + [\fB\-p\fR|\fB\-\-pretty\-print\fR] + [\fB\-j\fR|\fB\-\-section=\fR\fIname\fR] + [\fB\-H\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] + [addr addr ...] +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\fBaddr2line\fR translates addresses into file names and line numbers. +Given an address in an executable or an offset in a section of a relocatable +object, it uses the debugging information to figure out which file name and +line number are associated with it. +.PP +The executable or relocatable object to use is specified with the \fB\-e\fR +option. The default is the file \fIa.out\fR. The section in the relocatable +object to use is specified with the \fB\-j\fR option. +.PP +\&\fBaddr2line\fR has two modes of operation. +.PP +In the first, hexadecimal addresses are specified on the command line, +and \fBaddr2line\fR displays the file name and line number for each +address. +.PP +In the second, \fBaddr2line\fR reads hexadecimal addresses from +standard input, and prints the file name and line number for each +address on standard output. In this mode, \fBaddr2line\fR may be used +in a pipe to convert dynamically chosen addresses. +.PP +The format of the output is \fB\s-1FILENAME:LINENO\s0\fR. By default +each input address generates one line of output. +.PP +Two options can generate additional lines before each +\&\fB\s-1FILENAME:LINENO\s0\fR line (in that order). +.PP +If the \fB\-a\fR option is used then a line with the input address +is displayed. +.PP +If the \fB\-f\fR option is used, then a line with the +\&\fB\s-1FUNCTIONNAME\s0\fR is displayed. This is the name of the function +containing the address. +.PP +One option can generate additional lines after the +\&\fB\s-1FILENAME:LINENO\s0\fR line. +.PP +If the \fB\-i\fR option is used and the code at the given address is +present there because of inlining by the compiler then additional +lines are displayed afterwards. One or two extra lines (if the +\&\fB\-f\fR option is used) are displayed for each inlined function. +.PP +Alternatively if the \fB\-p\fR option is used then each input +address generates a single, long, output line containing the address, +the function name, the file name and the line number. If the +\&\fB\-i\fR option has also been used then any inlined functions will +be displayed in the same manner, but on separate lines, and prefixed +by the text \fB(inlined by)\fR. +.PP +If the file name or function name can not be determined, +\&\fBaddr2line\fR will print two question marks in their place. If the +line number can not be determined, \fBaddr2line\fR will print 0. +.SH "OPTIONS" +.IX Header "OPTIONS" +The long and short forms of options, shown here as alternatives, are +equivalent. +.IP "\fB\-a\fR" 4 +.IX Item "-a" +.PD 0 +.IP "\fB\-\-addresses\fR" 4 +.IX Item "--addresses" +.PD +Display the address before the function name, file and line number +information. The address is printed with a \fB0x\fR prefix to easily +identify it. +.IP "\fB\-b\fR \fIbfdname\fR" 4 +.IX Item "-b bfdname" +.PD 0 +.IP "\fB\-\-target=\fR\fIbfdname\fR" 4 +.IX Item "--target=bfdname" +.PD +Specify that the object-code format for the object files is +\&\fIbfdname\fR. +.IP "\fB\-C\fR" 4 +.IX Item "-C" +.PD 0 +.IP "\fB\-\-demangle[=\fR\fIstyle\fR\fB]\fR" 4 +.IX Item "--demangle[=style]" +.PD +Decode (\fIdemangle\fR) low-level symbol names into user-level names. +Besides removing any initial underscore prepended by the system, this +makes \*(C+ function names readable. Different compilers have different +mangling styles. The optional demangling style argument can be used to +choose an appropriate demangling style for your compiler. +.IP "\fB\-e\fR \fIfilename\fR" 4 +.IX Item "-e filename" +.PD 0 +.IP "\fB\-\-exe=\fR\fIfilename\fR" 4 +.IX Item "--exe=filename" +.PD +Specify the name of the executable for which addresses should be +translated. The default file is \fIa.out\fR. +.IP "\fB\-f\fR" 4 +.IX Item "-f" +.PD 0 +.IP "\fB\-\-functions\fR" 4 +.IX Item "--functions" +.PD +Display function names as well as file and line number information. +.IP "\fB\-s\fR" 4 +.IX Item "-s" +.PD 0 +.IP "\fB\-\-basenames\fR" 4 +.IX Item "--basenames" +.PD +Display only the base of each file name. +.IP "\fB\-i\fR" 4 +.IX Item "-i" +.PD 0 +.IP "\fB\-\-inlines\fR" 4 +.IX Item "--inlines" +.PD +If the address belongs to a function that was inlined, the source +information for all enclosing scopes back to the first non-inlined +function will also be printed. For example, if \f(CW\*(C`main\*(C'\fR inlines +\&\f(CW\*(C`callee1\*(C'\fR which inlines \f(CW\*(C`callee2\*(C'\fR, and address is from +\&\f(CW\*(C`callee2\*(C'\fR, the source information for \f(CW\*(C`callee1\*(C'\fR and \f(CW\*(C`main\*(C'\fR +will also be printed. +.IP "\fB\-j\fR" 4 +.IX Item "-j" +.PD 0 +.IP "\fB\-\-section\fR" 4 +.IX Item "--section" +.PD +Read offsets relative to the specified section instead of absolute addresses. +.IP "\fB\-p\fR" 4 +.IX Item "-p" +.PD 0 +.IP "\fB\-\-pretty\-print\fR" 4 +.IX Item "--pretty-print" +.PD +Make the output more human friendly: each location are printed on one line. +If option \fB\-i\fR is specified, lines for all enclosing scopes are +prefixed with \fB(inlined by)\fR. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/ar.1 b/support/sdbinutils/binutils/doc/ar.1 new file mode 100644 index 0000000..c3dca72 --- /dev/null +++ b/support/sdbinutils/binutils/doc/ar.1 @@ -0,0 +1,490 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "AR 1" +.TH AR 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +ar \- create, modify, and extract from archives +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +ar [\fB\-X32_64\fR] [\fB\-\fR]\fIp\fR[\fImod\fR] [\fB\-\-plugin\fR \fIname\fR] [\fB\-\-target\fR \fIbfdname\fR] [\fIrelpos\fR] [\fIcount\fR] \fIarchive\fR [\fImember\fR...] +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +The \s-1GNU\s0 \fBar\fR program creates, modifies, and extracts from +archives. An \fIarchive\fR is a single file holding a collection of +other files in a structure that makes it possible to retrieve +the original individual files (called \fImembers\fR of the archive). +.PP +The original files' contents, mode (permissions), timestamp, owner, and +group are preserved in the archive, and can be restored on +extraction. +.PP +\&\s-1GNU\s0 \fBar\fR can maintain archives whose members have names of any +length; however, depending on how \fBar\fR is configured on your +system, a limit on member-name length may be imposed for compatibility +with archive formats maintained with other tools. If it exists, the +limit is often 15 characters (typical of formats related to a.out) or 16 +characters (typical of formats related to coff). +.PP +\&\fBar\fR is considered a binary utility because archives of this sort +are most often used as \fIlibraries\fR holding commonly needed +subroutines. +.PP +\&\fBar\fR creates an index to the symbols defined in relocatable +object modules in the archive when you specify the modifier \fBs\fR. +Once created, this index is updated in the archive whenever \fBar\fR +makes a change to its contents (save for the \fBq\fR update operation). +An archive with such an index speeds up linking to the library, and +allows routines in the library to call each other without regard to +their placement in the archive. +.PP +You may use \fBnm \-s\fR or \fBnm \-\-print\-armap\fR to list this index +table. If an archive lacks the table, another form of \fBar\fR called +\&\fBranlib\fR can be used to add just the table. +.PP +\&\s-1GNU\s0 \fBar\fR can optionally create a \fIthin\fR archive, +which contains a symbol index and references to the original copies +of the member files of the archive. This is useful for building +libraries for use within a local build tree, where the relocatable +objects are expected to remain available, and copying the contents of +each object would only waste time and space. +.PP +An archive can either be \fIthin\fR or it can be normal. It cannot +be both at the same time. Once an archive is created its format +cannot be changed without first deleting it and then creating a new +archive in its place. +.PP +Thin archives are also \fIflattened\fR, so that adding one thin +archive to another thin archive does not nest it, as would happen with +a normal archive. Instead the elements of the first archive are added +individually to the second archive. +.PP +The paths to the elements of the archive are stored relative to the +archive itself. +.PP +\&\s-1GNU\s0 \fBar\fR is designed to be compatible with two different +facilities. You can control its activity using command-line options, +like the different varieties of \fBar\fR on Unix systems; or, if you +specify the single command-line option \fB\-M\fR, you can control it +with a script supplied via standard input, like the \s-1MRI\s0 \*(L"librarian\*(R" +program. +.SH "OPTIONS" +.IX Header "OPTIONS" +\&\s-1GNU\s0 \fBar\fR allows you to mix the operation code \fIp\fR and modifier +flags \fImod\fR in any order, within the first command-line argument. +.PP +If you wish, you may begin the first command-line argument with a +dash. +.PP +The \fIp\fR keyletter specifies what operation to execute; it may be +any of the following, but you must specify only one of them: +.IP "\fBd\fR" 4 +.IX Item "d" +\&\fIDelete\fR modules from the archive. Specify the names of modules to +be deleted as \fImember\fR...; the archive is untouched if you +specify no files to delete. +.Sp +If you specify the \fBv\fR modifier, \fBar\fR lists each module +as it is deleted. +.IP "\fBm\fR" 4 +.IX Item "m" +Use this operation to \fImove\fR members in an archive. +.Sp +The ordering of members in an archive can make a difference in how +programs are linked using the library, if a symbol is defined in more +than one member. +.Sp +If no modifiers are used with \f(CW\*(C`m\*(C'\fR, any members you name in the +\&\fImember\fR arguments are moved to the \fIend\fR of the archive; +you can use the \fBa\fR, \fBb\fR, or \fBi\fR modifiers to move them to a +specified place instead. +.IP "\fBp\fR" 4 +.IX Item "p" +\&\fIPrint\fR the specified members of the archive, to the standard +output file. If the \fBv\fR modifier is specified, show the member +name before copying its contents to standard output. +.Sp +If you specify no \fImember\fR arguments, all the files in the archive are +printed. +.IP "\fBq\fR" 4 +.IX Item "q" +\&\fIQuick append\fR; Historically, add the files \fImember\fR... to the end of +\&\fIarchive\fR, without checking for replacement. +.Sp +The modifiers \fBa\fR, \fBb\fR, and \fBi\fR do \fInot\fR affect this +operation; new members are always placed at the end of the archive. +.Sp +The modifier \fBv\fR makes \fBar\fR list each file as it is appended. +.Sp +Since the point of this operation is speed, implementations of +\&\fBar\fR have the option of not updating the archive's symbol +table if one exists. Too many different systems however assume that +symbol tables are always up-to-date, so \s-1GNU\s0 \fBar\fR will +rebuild the table even with a quick append. +.Sp +Note \- \s-1GNU\s0 \fBar\fR treats the command \fBqs\fR as a +synonym for \fBr\fR \- replacing already existing files in the +archive and appending new ones at the end. +.IP "\fBr\fR" 4 +.IX Item "r" +Insert the files \fImember\fR... into \fIarchive\fR (with +\&\fIreplacement\fR). This operation differs from \fBq\fR in that any +previously existing members are deleted if their names match those being +added. +.Sp +If one of the files named in \fImember\fR... does not exist, \fBar\fR +displays an error message, and leaves undisturbed any existing members +of the archive matching that name. +.Sp +By default, new members are added at the end of the file; but you may +use one of the modifiers \fBa\fR, \fBb\fR, or \fBi\fR to request +placement relative to some existing member. +.Sp +The modifier \fBv\fR used with this operation elicits a line of +output for each file inserted, along with one of the letters \fBa\fR or +\&\fBr\fR to indicate whether the file was appended (no old member +deleted) or replaced. +.IP "\fBs\fR" 4 +.IX Item "s" +Add an index to the archive, or update it if it already exists. Note +this command is an exception to the rule that there can only be one +command letter, as it is possible to use it as either a command or a +modifier. In either case it does the same thing. +.IP "\fBt\fR" 4 +.IX Item "t" +Display a \fItable\fR listing the contents of \fIarchive\fR, or those +of the files listed in \fImember\fR... that are present in the +archive. Normally only the member name is shown; if you also want to +see the modes (permissions), timestamp, owner, group, and size, you can +request that by also specifying the \fBv\fR modifier. +.Sp +If you do not specify a \fImember\fR, all files in the archive +are listed. +.Sp +If there is more than one file with the same name (say, \fBfie\fR) in +an archive (say \fBb.a\fR), \fBar t b.a fie\fR lists only the +first instance; to see them all, you must ask for a complete +listing\-\-\-in our example, \fBar t b.a\fR. +.IP "\fBx\fR" 4 +.IX Item "x" +\&\fIExtract\fR members (named \fImember\fR) from the archive. You can +use the \fBv\fR modifier with this operation, to request that +\&\fBar\fR list each name as it extracts it. +.Sp +If you do not specify a \fImember\fR, all files in the archive +are extracted. +.Sp +Files cannot be extracted from a thin archive. +.PP +A number of modifiers (\fImod\fR) may immediately follow the \fIp\fR +keyletter, to specify variations on an operation's behavior: +.IP "\fBa\fR" 4 +.IX Item "a" +Add new files \fIafter\fR an existing member of the +archive. If you use the modifier \fBa\fR, the name of an existing archive +member must be present as the \fIrelpos\fR argument, before the +\&\fIarchive\fR specification. +.IP "\fBb\fR" 4 +.IX Item "b" +Add new files \fIbefore\fR an existing member of the +archive. If you use the modifier \fBb\fR, the name of an existing archive +member must be present as the \fIrelpos\fR argument, before the +\&\fIarchive\fR specification. (same as \fBi\fR). +.IP "\fBc\fR" 4 +.IX Item "c" +\&\fICreate\fR the archive. The specified \fIarchive\fR is always +created if it did not exist, when you request an update. But a warning is +issued unless you specify in advance that you expect to create it, by +using this modifier. +.IP "\fBD\fR" 4 +.IX Item "D" +Operate in \fIdeterministic\fR mode. When adding files and the archive +index use zero for UIDs, GIDs, timestamps, and use consistent file modes +for all files. When this option is used, if \fBar\fR is used with +identical options and identical input files, multiple runs will create +identical output files regardless of the input files' owners, groups, +file modes, or modification times. +.Sp +If \fIbinutils\fR was configured with +\&\fB\-\-enable\-deterministic\-archives\fR, then this mode is on by default. +It can be disabled with the \fBU\fR modifier, below. +.IP "\fBf\fR" 4 +.IX Item "f" +Truncate names in the archive. \s-1GNU\s0 \fBar\fR will normally permit file +names of any length. This will cause it to create archives which are +not compatible with the native \fBar\fR program on some systems. If +this is a concern, the \fBf\fR modifier may be used to truncate file +names when putting them in the archive. +.IP "\fBi\fR" 4 +.IX Item "i" +Insert new files \fIbefore\fR an existing member of the +archive. If you use the modifier \fBi\fR, the name of an existing archive +member must be present as the \fIrelpos\fR argument, before the +\&\fIarchive\fR specification. (same as \fBb\fR). +.IP "\fBl\fR" 4 +.IX Item "l" +This modifier is accepted but not used. +.IP "\fBN\fR" 4 +.IX Item "N" +Uses the \fIcount\fR parameter. This is used if there are multiple +entries in the archive with the same name. Extract or delete instance +\&\fIcount\fR of the given name from the archive. +.IP "\fBo\fR" 4 +.IX Item "o" +Preserve the \fIoriginal\fR dates of members when extracting them. If +you do not specify this modifier, files extracted from the archive +are stamped with the time of extraction. +.IP "\fBP\fR" 4 +.IX Item "P" +Use the full path name when matching names in the archive. \s-1GNU\s0 +\&\fBar\fR can not create an archive with a full path name (such archives +are not \s-1POSIX\s0 complaint), but other archive creators can. This option +will cause \s-1GNU\s0 \fBar\fR to match file names using a complete path +name, which can be convenient when extracting a single file from an +archive created by another tool. +.IP "\fBs\fR" 4 +.IX Item "s" +Write an object-file index into the archive, or update an existing one, +even if no other change is made to the archive. You may use this modifier +flag either with any operation, or alone. Running \fBar s\fR on an +archive is equivalent to running \fBranlib\fR on it. +.IP "\fBS\fR" 4 +.IX Item "S" +Do not generate an archive symbol table. This can speed up building a +large library in several steps. The resulting archive can not be used +with the linker. In order to build a symbol table, you must omit the +\&\fBS\fR modifier on the last execution of \fBar\fR, or you must run +\&\fBranlib\fR on the archive. +.IP "\fBT\fR" 4 +.IX Item "T" +Make the specified \fIarchive\fR a \fIthin\fR archive. If it already +exists and is a regular archive, the existing members must be present +in the same directory as \fIarchive\fR. +.IP "\fBu\fR" 4 +.IX Item "u" +Normally, \fBar r\fR... inserts all files +listed into the archive. If you would like to insert \fIonly\fR those +of the files you list that are newer than existing members of the same +names, use this modifier. The \fBu\fR modifier is allowed only for the +operation \fBr\fR (replace). In particular, the combination \fBqu\fR is +not allowed, since checking the timestamps would lose any speed +advantage from the operation \fBq\fR. +.IP "\fBU\fR" 4 +.IX Item "U" +Do \fInot\fR operate in \fIdeterministic\fR mode. This is the inverse +of the \fBD\fR modifier, above: added files and the archive index will +get their actual \s-1UID, GID,\s0 timestamp, and file mode values. +.Sp +This is the default unless \fIbinutils\fR was configured with +\&\fB\-\-enable\-deterministic\-archives\fR. +.IP "\fBv\fR" 4 +.IX Item "v" +This modifier requests the \fIverbose\fR version of an operation. Many +operations display additional information, such as filenames processed, +when the modifier \fBv\fR is appended. +.IP "\fBV\fR" 4 +.IX Item "V" +This modifier shows the version number of \fBar\fR. +.PP +The \fBar\fR program also supports some command line options which +are neither modifiers nor actions, but which do change its behaviour +in specific ways: +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +Displays the list of command line options supported by \fBar\fR +and then exits. +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +Displays the version information of \fBar\fR and then exits. +.IP "\fB\-X32_64\fR" 4 +.IX Item "-X32_64" +\&\fBar\fR ignores an initial option spelt \fB\-X32_64\fR, for +compatibility with \s-1AIX.\s0 The behaviour produced by this option is the +default for \s-1GNU\s0 \fBar\fR. \fBar\fR does not support any +of the other \fB\-X\fR options; in particular, it does not support +\&\fB\-X32\fR which is the default for \s-1AIX\s0 \fBar\fR. +.IP "\fB\-\-plugin\fR \fIname\fR" 4 +.IX Item "--plugin name" +The optional command line switch \fB\-\-plugin\fR \fIname\fR causes +\&\fBar\fR to load the plugin called \fIname\fR which adds support +for more file formats, including object files with link-time +optimization information. +.Sp +This option is only available if the toolchain has been built with +plugin support enabled. +.Sp +If \fB\-\-plugin\fR is not provided, but plugin support has been +enabled then \fBar\fR iterates over the files in +\&\fI${libdir}/bfd\-plugins\fR in alphabetic order and the first +plugin that claims the object in question is used. +.Sp +Please note that this plugin search directory is \fInot\fR the one +used by \fBld\fR's \fB\-plugin\fR option. In order to make +\&\fBar\fR use the linker plugin it must be copied into the +\&\fI${libdir}/bfd\-plugins\fR directory. For \s-1GCC\s0 based compilations +the linker plugin is called \fIliblto_plugin.so.0.0.0\fR. For Clang +based compilations it is called \fILLVMgold.so\fR. The \s-1GCC\s0 plugin +is always backwards compatible with earlier versions, so it is +sufficient to just copy the newest one. +.IP "\fB\-\-target\fR \fItarget\fR" 4 +.IX Item "--target target" +The optional command line switch \fB\-\-target\fR \fIbfdname\fR +specifies that the archive members are in an object code format +different from your system's default format. See +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fInm\fR\|(1), \fIranlib\fR\|(1), and the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/binutils.info b/support/sdbinutils/binutils/doc/binutils.info new file mode 100644 index 0000000..25b4e93 --- /dev/null +++ b/support/sdbinutils/binutils/doc/binutils.info @@ -0,0 +1,5496 @@ +This is binutils.info, produced by makeinfo version 6.3 from +binutils.texi. + +Copyright (C) 1991-2018 Free Software Foundation, Inc. + + Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license is included in the section entitled "GNU +Free Documentation License". + +INFO-DIR-SECTION Software development +START-INFO-DIR-ENTRY +* Binutils: (binutils). The GNU binary utilities. +END-INFO-DIR-ENTRY + +INFO-DIR-SECTION Individual utilities +START-INFO-DIR-ENTRY +* addr2line: (binutils)addr2line. Convert addresses to file and line. +* ar: (binutils)ar. Create, modify, and extract from archives. +* c++filt: (binutils)c++filt. Filter to demangle encoded C++ symbols. +* cxxfilt: (binutils)c++filt. MS-DOS name for c++filt. +* dlltool: (binutils)dlltool. Create files needed to build and use DLLs. +* nlmconv: (binutils)nlmconv. Converts object code into an NLM. +* nm: (binutils)nm. List symbols from object files. +* objcopy: (binutils)objcopy. Copy and translate object files. +* objdump: (binutils)objdump. Display information from object files. +* ranlib: (binutils)ranlib. Generate index to archive contents. +* readelf: (binutils)readelf. Display the contents of ELF format files. +* size: (binutils)size. List section sizes and total size. +* strings: (binutils)strings. List printable strings from files. +* strip: (binutils)strip. Discard symbols. +* elfedit: (binutils)elfedit. Update the ELF header of ELF files. +* windmc: (binutils)windmc. Generator for Windows message resources. +* windres: (binutils)windres. Manipulate Windows resources. +END-INFO-DIR-ENTRY + + +File: binutils.info, Node: Top, Next: ar, Up: (dir) + +Introduction +************ + +This brief manual contains documentation for the GNU binary utilities +(GNU Binutils) version 2.30: + + This document is distributed under the terms of the GNU Free +Documentation License version 1.3. A copy of the license is included in +the section entitled "GNU Free Documentation License". + +* Menu: + +* ar:: Create, modify, and extract from archives +* nm:: List symbols from object files +* objcopy:: Copy and translate object files +* objdump:: Display information from object files +* ranlib:: Generate index to archive contents +* size:: List section sizes and total size +* strings:: List printable strings from files +* strip:: Discard symbols +* c++filt:: Filter to demangle encoded C++ symbols +* cxxfilt: c++filt. MS-DOS name for c++filt +* addr2line:: Convert addresses to file and line +* nlmconv:: Converts object code into an NLM +* windmc:: Generator for Windows message resources +* windres:: Manipulate Windows resources +* dlltool:: Create files needed to build and use DLLs +* readelf:: Display the contents of ELF format files +* elfedit:: Update the ELF header of ELF files +* Common Options:: Command-line options for all utilities +* Selecting the Target System:: How these utilities determine the target +* Reporting Bugs:: Reporting Bugs +* GNU Free Documentation License:: GNU Free Documentation License +* Binutils Index:: Binutils Index + + +File: binutils.info, Node: ar, Next: nm, Prev: Top, Up: Top + +1 ar +**** + + ar [-]P[MOD] [--plugin NAME] [--target BFDNAME] [RELPOS] [COUNT] ARCHIVE [MEMBER...] + ar -M [ '), and continues executing even after errors. If you redirect +standard input to a script file, no prompts are issued, and 'ar' +abandons execution (with a nonzero exit code) on any error. + + The 'ar' command language is _not_ designed to be equivalent to the +command-line options; in fact, it provides somewhat less control over +archives. The only purpose of the command language is to ease the +transition to GNU 'ar' for developers who already have scripts written +for the MRI "librarian" program. + + The syntax for the 'ar' command language is straightforward: + * commands are recognized in upper or lower case; for example, 'LIST' + is the same as 'list'. In the following descriptions, commands are + shown in upper case for clarity. + + * a single command may appear on each line; it is the first word on + the line. + + * empty lines are allowed, and have no effect. + + * comments are allowed; text after either of the characters '*' or + ';' is ignored. + + * Whenever you use a list of names as part of the argument to an 'ar' + command, you can separate the individual names with either commas + or blanks. Commas are shown in the explanations below, for + clarity. + + * '+' is used as a line continuation character; if '+' appears at the + end of a line, the text on the following line is considered part of + the current command. + + Here are the commands you can use in 'ar' scripts, or when using 'ar' +interactively. Three of them have special significance: + + 'OPEN' or 'CREATE' specify a "current archive", which is a temporary +file required for most of the other commands. + + 'SAVE' commits the changes so far specified by the script. Prior to +'SAVE', commands affect only the temporary copy of the current archive. + +'ADDLIB ARCHIVE' +'ADDLIB ARCHIVE (MODULE, MODULE, ... MODULE)' + Add all the contents of ARCHIVE (or, if specified, each named + MODULE from ARCHIVE) to the current archive. + + Requires prior use of 'OPEN' or 'CREATE'. + +'ADDMOD MEMBER, MEMBER, ... MEMBER' + Add each named MEMBER as a module in the current archive. + + Requires prior use of 'OPEN' or 'CREATE'. + +'CLEAR' + Discard the contents of the current archive, canceling the effect + of any operations since the last 'SAVE'. May be executed (with no + effect) even if no current archive is specified. + +'CREATE ARCHIVE' + Creates an archive, and makes it the current archive (required for + many other commands). The new archive is created with a temporary + name; it is not actually saved as ARCHIVE until you use 'SAVE'. + You can overwrite existing archives; similarly, the contents of any + existing file named ARCHIVE will not be destroyed until 'SAVE'. + +'DELETE MODULE, MODULE, ... MODULE' + Delete each listed MODULE from the current archive; equivalent to + 'ar -d ARCHIVE MODULE ... MODULE'. + + Requires prior use of 'OPEN' or 'CREATE'. + +'DIRECTORY ARCHIVE (MODULE, ... MODULE)' +'DIRECTORY ARCHIVE (MODULE, ... MODULE) OUTPUTFILE' + List each named MODULE present in ARCHIVE. The separate command + 'VERBOSE' specifies the form of the output: when verbose output is + off, output is like that of 'ar -t ARCHIVE MODULE...'. When + verbose output is on, the listing is like 'ar -tv ARCHIVE + MODULE...'. + + Output normally goes to the standard output stream; however, if you + specify OUTPUTFILE as a final argument, 'ar' directs the output to + that file. + +'END' + Exit from 'ar', with a '0' exit code to indicate successful + completion. This command does not save the output file; if you + have changed the current archive since the last 'SAVE' command, + those changes are lost. + +'EXTRACT MODULE, MODULE, ... MODULE' + Extract each named MODULE from the current archive, writing them + into the current directory as separate files. Equivalent to 'ar -x + ARCHIVE MODULE...'. + + Requires prior use of 'OPEN' or 'CREATE'. + +'LIST' + Display full contents of the current archive, in "verbose" style + regardless of the state of 'VERBOSE'. The effect is like 'ar tv + ARCHIVE'. (This single command is a GNU 'ar' enhancement, rather + than present for MRI compatibility.) + + Requires prior use of 'OPEN' or 'CREATE'. + +'OPEN ARCHIVE' + Opens an existing archive for use as the current archive (required + for many other commands). Any changes as the result of subsequent + commands will not actually affect ARCHIVE until you next use + 'SAVE'. + +'REPLACE MODULE, MODULE, ... MODULE' + In the current archive, replace each existing MODULE (named in the + 'REPLACE' arguments) from files in the current working directory. + To execute this command without errors, both the file, and the + module in the current archive, must exist. + + Requires prior use of 'OPEN' or 'CREATE'. + +'VERBOSE' + Toggle an internal flag governing the output from 'DIRECTORY'. + When the flag is on, 'DIRECTORY' output matches output from 'ar -tv + '.... + +'SAVE' + Commit your changes to the current archive, and actually save it as + a file with the name specified in the last 'CREATE' or 'OPEN' + command. + + Requires prior use of 'OPEN' or 'CREATE'. + + +File: binutils.info, Node: nm, Next: objcopy, Prev: ar, Up: Top + +2 nm +**** + + nm [-A|-o|--print-file-name] [-a|--debug-syms] + [-B|--format=bsd] [-C|--demangle[=STYLE]] + [-D|--dynamic] [-fFORMAT|--format=FORMAT] + [-g|--extern-only] [-h|--help] + [-l|--line-numbers] [--inlines] + [-n|-v|--numeric-sort] + [-P|--portability] [-p|--no-sort] + [-r|--reverse-sort] [-S|--print-size] + [-s|--print-armap] [-t RADIX|--radix=RADIX] + [-u|--undefined-only] [-V|--version] + [-X 32_64] [--defined-only] [--no-demangle] + [--plugin NAME] [--size-sort] [--special-syms] + [--synthetic] [--with-symbol-versions] [--target=BFDNAME] + [OBJFILE...] + + GNU 'nm' lists the symbols from object files OBJFILE.... If no +object files are listed as arguments, 'nm' assumes the file 'a.out'. + + For each symbol, 'nm' shows: + + * The symbol value, in the radix selected by options (see below), or + hexadecimal by default. + + * The symbol type. At least the following types are used; others + are, as well, depending on the object file format. If lowercase, + the symbol is usually local; if uppercase, the symbol is global + (external). There are however a few lowercase symbols that are + shown for special global symbols ('u', 'v' and 'w'). + + 'A' + The symbol's value is absolute, and will not be changed by + further linking. + + 'B' + 'b' + The symbol is in the uninitialized data section (known as + BSS). + + 'C' + The symbol is common. Common symbols are uninitialized data. + When linking, multiple common symbols may appear with the same + name. If the symbol is defined anywhere, the common symbols + are treated as undefined references. For more details on + common symbols, see the discussion of -warn-common in *note + Linker options: (ld.info)Options. + + 'D' + 'd' + The symbol is in the initialized data section. + + 'G' + 'g' + The symbol is in an initialized data section for small + objects. Some object file formats permit more efficient + access to small data objects, such as a global int variable as + opposed to a large global array. + + 'i' + For PE format files this indicates that the symbol is in a + section specific to the implementation of DLLs. For ELF + format files this indicates that the symbol is an indirect + function. This is a GNU extension to the standard set of ELF + symbol types. It indicates a symbol which if referenced by a + relocation does not evaluate to its address, but instead must + be invoked at runtime. The runtime execution will then return + the value to be used in the relocation. + + 'I' + The symbol is an indirect reference to another symbol. + + 'N' + The symbol is a debugging symbol. + + 'p' + The symbols is in a stack unwind section. + + 'R' + 'r' + The symbol is in a read only data section. + + 'S' + 's' + The symbol is in an uninitialized data section for small + objects. + + 'T' + 't' + The symbol is in the text (code) section. + + 'U' + The symbol is undefined. + + 'u' + The symbol is a unique global symbol. This is a GNU extension + to the standard set of ELF symbol bindings. For such a symbol + the dynamic linker will make sure that in the entire process + there is just one symbol with this name and type in use. + + 'V' + 'v' + The symbol is a weak object. When a weak defined symbol is + linked with a normal defined symbol, the normal defined symbol + is used with no error. When a weak undefined symbol is linked + and the symbol is not defined, the value of the weak symbol + becomes zero with no error. On some systems, uppercase + indicates that a default value has been specified. + + 'W' + 'w' + The symbol is a weak symbol that has not been specifically + tagged as a weak object symbol. When a weak defined symbol is + linked with a normal defined symbol, the normal defined symbol + is used with no error. When a weak undefined symbol is linked + and the symbol is not defined, the value of the symbol is + determined in a system-specific manner without error. On some + systems, uppercase indicates that a default value has been + specified. + + '-' + The symbol is a stabs symbol in an a.out object file. In this + case, the next values printed are the stabs other field, the + stabs desc field, and the stab type. Stabs symbols are used + to hold debugging information. + + '?' + The symbol type is unknown, or object file format specific. + + * The symbol name. + + The long and short forms of options, shown here as alternatives, are +equivalent. + +'-A' +'-o' +'--print-file-name' + Precede each symbol by the name of the input file (or archive + member) in which it was found, rather than identifying the input + file once only, before all of its symbols. + +'-a' +'--debug-syms' + Display all symbols, even debugger-only symbols; normally these are + not listed. + +'-B' + The same as '--format=bsd' (for compatibility with the MIPS 'nm'). + +'-C' +'--demangle[=STYLE]' + Decode ("demangle") low-level symbol names into user-level names. + Besides removing any initial underscore prepended by the system, + this makes C++ function names readable. Different compilers have + different mangling styles. The optional demangling style argument + can be used to choose an appropriate demangling style for your + compiler. *Note c++filt::, for more information on demangling. + +'--no-demangle' + Do not demangle low-level symbol names. This is the default. + +'-D' +'--dynamic' + Display the dynamic symbols rather than the normal symbols. This + is only meaningful for dynamic objects, such as certain types of + shared libraries. + +'-f FORMAT' +'--format=FORMAT' + Use the output format FORMAT, which can be 'bsd', 'sysv', or + 'posix'. The default is 'bsd'. Only the first character of FORMAT + is significant; it can be either upper or lower case. + +'-g' +'--extern-only' + Display only external symbols. + +'-h' +'--help' + Show a summary of the options to 'nm' and exit. + +'-l' +'--line-numbers' + For each symbol, use debugging information to try to find a + filename and line number. For a defined symbol, look for the line + number of the address of the symbol. For an undefined symbol, look + for the line number of a relocation entry which refers to the + symbol. If line number information can be found, print it after + the other symbol information. + +'--inlines' + When option '-l' is active, if the address belongs to a function + that was inlined, then this option causes the source information + for all enclosing scopes back to the first non-inlined function to + be printed as well. For example, if 'main' inlines 'callee1' which + inlines 'callee2', and address is from 'callee2', the source + information for 'callee1' and 'main' will also be printed. + +'-n' +'-v' +'--numeric-sort' + Sort symbols numerically by their addresses, rather than + alphabetically by their names. + +'-p' +'--no-sort' + Do not bother to sort the symbols in any order; print them in the + order encountered. + +'-P' +'--portability' + Use the POSIX.2 standard output format instead of the default + format. Equivalent to '-f posix'. + +'-r' +'--reverse-sort' + Reverse the order of the sort (whether numeric or alphabetic); let + the last come first. + +'-S' +'--print-size' + Print both value and size of defined symbols for the 'bsd' output + style. This option has no effect for object formats that do not + record symbol sizes, unless '--size-sort' is also used in which + case a calculated size is displayed. + +'-s' +'--print-armap' + When listing symbols from archive members, include the index: a + mapping (stored in the archive by 'ar' or 'ranlib') of which + modules contain definitions for which names. + +'-t RADIX' +'--radix=RADIX' + Use RADIX as the radix for printing the symbol values. It must be + 'd' for decimal, 'o' for octal, or 'x' for hexadecimal. + +'-u' +'--undefined-only' + Display only undefined symbols (those external to each object + file). + +'-V' +'--version' + Show the version number of 'nm' and exit. + +'-X' + This option is ignored for compatibility with the AIX version of + 'nm'. It takes one parameter which must be the string '32_64'. + The default mode of AIX 'nm' corresponds to '-X 32', which is not + supported by GNU 'nm'. + +'--defined-only' + Display only defined symbols for each object file. + +'--plugin NAME' + Load the plugin called NAME to add support for extra target types. + This option is only available if the toolchain has been built with + plugin support enabled. + + If '--plugin' is not provided, but plugin support has been enabled + then 'nm' iterates over the files in '${libdir}/bfd-plugins' in + alphabetic order and the first plugin that claims the object in + question is used. + + Please note that this plugin search directory is _not_ the one used + by 'ld''s '-plugin' option. In order to make 'nm' use the linker + plugin it must be copied into the '${libdir}/bfd-plugins' + directory. For GCC based compilations the linker plugin is called + 'liblto_plugin.so.0.0.0'. For Clang based compilations it is + called 'LLVMgold.so'. The GCC plugin is always backwards + compatible with earlier versions, so it is sufficient to just copy + the newest one. + +'--size-sort' + Sort symbols by size. For ELF objects symbol sizes are read from + the ELF, for other object types the symbol sizes are computed as + the difference between the value of the symbol and the value of the + symbol with the next higher value. If the 'bsd' output format is + used the size of the symbol is printed, rather than the value, and + '-S' must be used in order both size and value to be printed. + +'--special-syms' + Display symbols which have a target-specific special meaning. + These symbols are usually used by the target for some special + processing and are not normally helpful when included in the normal + symbol lists. For example for ARM targets this option would skip + the mapping symbols used to mark transitions between ARM code, + THUMB code and data. + +'--synthetic' + Include synthetic symbols in the output. These are special symbols + created by the linker for various purposes. They are not shown by + default since they are not part of the binary's original source + code. + +'--with-symbol-versions' + Enables the display of symbol version information if any exists. + The version string is displayed as a suffix to the symbol name, + preceeded by an @ character. For example 'foo@VER_1'. If the + version is the default version to be used when resolving + unversioned references to the symbol then it is displayed as a + suffix preceeded by two @ characters. For example 'foo@@VER_2'. + +'--target=BFDNAME' + Specify an object code format other than your system's default + format. *Note Target Selection::, for more information. + + +File: binutils.info, Node: objcopy, Next: objdump, Prev: nm, Up: Top + +3 objcopy +********* + + objcopy [-F BFDNAME|--target=BFDNAME] + [-I BFDNAME|--input-target=BFDNAME] + [-O BFDNAME|--output-target=BFDNAME] + [-B BFDARCH|--binary-architecture=BFDARCH] + [-S|--strip-all] + [-g|--strip-debug] + [--strip-unneeded] + [-K SYMBOLNAME|--keep-symbol=SYMBOLNAME] + [-N SYMBOLNAME|--strip-symbol=SYMBOLNAME] + [--strip-unneeded-symbol=SYMBOLNAME] + [-G SYMBOLNAME|--keep-global-symbol=SYMBOLNAME] + [--localize-hidden] + [-L SYMBOLNAME|--localize-symbol=SYMBOLNAME] + [--globalize-symbol=SYMBOLNAME] + [-W SYMBOLNAME|--weaken-symbol=SYMBOLNAME] + [-w|--wildcard] + [-x|--discard-all] + [-X|--discard-locals] + [-b BYTE|--byte=BYTE] + [-i [BREADTH]|--interleave[=BREADTH]] + [--interleave-width=WIDTH] + [-j SECTIONPATTERN|--only-section=SECTIONPATTERN] + [-R SECTIONPATTERN|--remove-section=SECTIONPATTERN] + [--remove-relocations=SECTIONPATTERN] + [-p|--preserve-dates] + [-D|--enable-deterministic-archives] + [-U|--disable-deterministic-archives] + [--debugging] + [--gap-fill=VAL] + [--pad-to=ADDRESS] + [--set-start=VAL] + [--adjust-start=INCR] + [--change-addresses=INCR] + [--change-section-address SECTIONPATTERN{=,+,-}VAL] + [--change-section-lma SECTIONPATTERN{=,+,-}VAL] + [--change-section-vma SECTIONPATTERN{=,+,-}VAL] + [--change-warnings] [--no-change-warnings] + [--set-section-flags SECTIONPATTERN=FLAGS] + [--add-section SECTIONNAME=FILENAME] + [--dump-section SECTIONNAME=FILENAME] + [--update-section SECTIONNAME=FILENAME] + [--rename-section OLDNAME=NEWNAME[,FLAGS]] + [--long-section-names {enable,disable,keep}] + [--change-leading-char] [--remove-leading-char] + [--reverse-bytes=NUM] + [--srec-len=IVAL] [--srec-forceS3] + [--redefine-sym OLD=NEW] + [--redefine-syms=FILENAME] + [--weaken] + [--keep-symbols=FILENAME] + [--strip-symbols=FILENAME] + [--strip-unneeded-symbols=FILENAME] + [--keep-global-symbols=FILENAME] + [--localize-symbols=FILENAME] + [--globalize-symbols=FILENAME] + [--weaken-symbols=FILENAME] + [--add-symbol NAME=[SECTION:]VALUE[,FLAGS] + [--alt-machine-code=INDEX] + [--prefix-symbols=STRING] + [--prefix-sections=STRING] + [--prefix-alloc-sections=STRING] + [--add-gnu-debuglink=PATH-TO-FILE] + [--keep-file-symbols] + [--only-keep-debug] + [--strip-dwo] + [--extract-dwo] + [--extract-symbol] + [--writable-text] + [--readonly-text] + [--pure] + [--impure] + [--file-alignment=NUM] + [--heap=SIZE] + [--image-base=ADDRESS] + [--section-alignment=NUM] + [--stack=SIZE] + [--subsystem=WHICH:MAJOR.MINOR] + [--compress-debug-sections] + [--decompress-debug-sections] + [--elf-stt-common=VAL] + [--merge-notes] + [--no-merge-notes] + [-v|--verbose] + [-V|--version] + [--help] [--info] + INFILE [OUTFILE] + + The GNU 'objcopy' utility copies the contents of an object file to +another. 'objcopy' uses the GNU BFD Library to read and write the +object files. It can write the destination object file in a format +different from that of the source object file. The exact behavior of +'objcopy' is controlled by command-line options. Note that 'objcopy' +should be able to copy a fully linked file between any two formats. +However, copying a relocatable object file between any two formats may +not work as expected. + + 'objcopy' creates temporary files to do its translations and deletes +them afterward. 'objcopy' uses BFD to do all its translation work; it +has access to all the formats described in BFD and thus is able to +recognize most formats without being told explicitly. *Note BFD: +(ld.info)BFD. + + 'objcopy' can be used to generate S-records by using an output target +of 'srec' (e.g., use '-O srec'). + + 'objcopy' can be used to generate a raw binary file by using an +output target of 'binary' (e.g., use '-O binary'). When 'objcopy' +generates a raw binary file, it will essentially produce a memory dump +of the contents of the input object file. All symbols and relocation +information will be discarded. The memory dump will start at the load +address of the lowest section copied into the output file. + + When generating an S-record or a raw binary file, it may be helpful +to use '-S' to remove sections containing debugging information. In +some cases '-R' will be useful to remove sections which contain +information that is not needed by the binary file. + + Note--'objcopy' is not able to change the endianness of its input +files. If the input format has an endianness (some formats do not), +'objcopy' can only copy the inputs into file formats that have the same +endianness or which have no endianness (e.g., 'srec'). (However, see +the '--reverse-bytes' option.) + +'INFILE' +'OUTFILE' + The input and output files, respectively. If you do not specify + OUTFILE, 'objcopy' creates a temporary file and destructively + renames the result with the name of INFILE. + +'-I BFDNAME' +'--input-target=BFDNAME' + Consider the source file's object format to be BFDNAME, rather than + attempting to deduce it. *Note Target Selection::, for more + information. + +'-O BFDNAME' +'--output-target=BFDNAME' + Write the output file using the object format BFDNAME. *Note + Target Selection::, for more information. + +'-F BFDNAME' +'--target=BFDNAME' + Use BFDNAME as the object format for both the input and the output + file; i.e., simply transfer data from source to destination with no + translation. *Note Target Selection::, for more information. + +'-B BFDARCH' +'--binary-architecture=BFDARCH' + Useful when transforming a architecture-less input file into an + object file. In this case the output architecture can be set to + BFDARCH. This option will be ignored if the input file has a known + BFDARCH. You can access this binary data inside a program by + referencing the special symbols that are created by the conversion + process. These symbols are called _binary_OBJFILE_start, + _binary_OBJFILE_end and _binary_OBJFILE_size. e.g. you can + transform a picture file into an object file and then access it in + your code using these symbols. + +'-j SECTIONPATTERN' +'--only-section=SECTIONPATTERN' + Copy only the indicated sections from the input file to the output + file. This option may be given more than once. Note that using + this option inappropriately may make the output file unusable. + Wildcard characters are accepted in SECTIONPATTERN. + + If the first character of SECTIONPATTERN is the exclamation point + (!) then matching sections will not be copied, even if earlier use + of '--only-section' on the same command line would otherwise copy + it. For example: + + --only-section=.text.* --only-section=!.text.foo + + will copy all sectinos maching '.text.*' but not the section + '.text.foo'. + +'-R SECTIONPATTERN' +'--remove-section=SECTIONPATTERN' + Remove any section matching SECTIONPATTERN from the output file. + This option may be given more than once. Note that using this + option inappropriately may make the output file unusable. Wildcard + characters are accepted in SECTIONPATTERN. Using both the '-j' and + '-R' options together results in undefined behaviour. + + If the first character of SECTIONPATTERN is the exclamation point + (!) then matching sections will not be removed even if an earlier + use of '--remove-section' on the same command line would otherwise + remove it. For example: + + --remove-section=.text.* --remove-section=!.text.foo + + will remove all sections matching the pattern '.text.*', but will + not remove the section '.text.foo'. + +'--remove-relocations=SECTIONPATTERN' + Remove relocations from the output file for any section matching + SECTIONPATTERN. This option may be given more than once. Note + that using this option inappropriately may make the output file + unusable. Wildcard characters are accepted in SECTIONPATTERN. For + example: + + --remove-relocations=.text.* + + will remove the relocations for all sections matching the patter + '.text.*'. + + If the first character of SECTIONPATTERN is the exclamation point + (!) then matching sections will not have their relocation removed + even if an earlier use of '--remove-relocations' on the same + command line would otherwise cause the relocations to be removed. + For example: + + --remove-relocations=.text.* --remove-relocations=!.text.foo + + will remove all relocations for sections matching the pattern + '.text.*', but will not remove relocations for the section + '.text.foo'. + +'-S' +'--strip-all' + Do not copy relocation and symbol information from the source file. + +'-g' +'--strip-debug' + Do not copy debugging symbols or sections from the source file. + +'--strip-unneeded' + Strip all symbols that are not needed for relocation processing. + +'-K SYMBOLNAME' +'--keep-symbol=SYMBOLNAME' + When stripping symbols, keep symbol SYMBOLNAME even if it would + normally be stripped. This option may be given more than once. + +'-N SYMBOLNAME' +'--strip-symbol=SYMBOLNAME' + Do not copy symbol SYMBOLNAME from the source file. This option + may be given more than once. + +'--strip-unneeded-symbol=SYMBOLNAME' + Do not copy symbol SYMBOLNAME from the source file unless it is + needed by a relocation. This option may be given more than once. + +'-G SYMBOLNAME' +'--keep-global-symbol=SYMBOLNAME' + Keep only symbol SYMBOLNAME global. Make all other symbols local + to the file, so that they are not visible externally. This option + may be given more than once. + +'--localize-hidden' + In an ELF object, mark all symbols that have hidden or internal + visibility as local. This option applies on top of symbol-specific + localization options such as '-L'. + +'-L SYMBOLNAME' +'--localize-symbol=SYMBOLNAME' + Convert a global or weak symbol called SYMBOLNAME into a local + symbol, so that it is not visible externally. This option may be + given more than once. Note - unique symbols are not converted. + +'-W SYMBOLNAME' +'--weaken-symbol=SYMBOLNAME' + Make symbol SYMBOLNAME weak. This option may be given more than + once. + +'--globalize-symbol=SYMBOLNAME' + Give symbol SYMBOLNAME global scoping so that it is visible outside + of the file in which it is defined. This option may be given more + than once. + +'-w' +'--wildcard' + Permit regular expressions in SYMBOLNAMEs used in other command + line options. The question mark (?), asterisk (*), backslash (\) + and square brackets ([]) operators can be used anywhere in the + symbol name. If the first character of the symbol name is the + exclamation point (!) then the sense of the switch is reversed for + that symbol. For example: + + -w -W !foo -W fo* + + would cause objcopy to weaken all symbols that start with "fo" + except for the symbol "foo". + +'-x' +'--discard-all' + Do not copy non-global symbols from the source file. + +'-X' +'--discard-locals' + Do not copy compiler-generated local symbols. (These usually start + with 'L' or '.'.) + +'-b BYTE' +'--byte=BYTE' + If interleaving has been enabled via the '--interleave' option then + start the range of bytes to keep at the BYTEth byte. BYTE can be + in the range from 0 to BREADTH-1, where BREADTH is the value given + by the '--interleave' option. + +'-i [BREADTH]' +'--interleave[=BREADTH]' + Only copy a range out of every BREADTH bytes. (Header data is not + affected). Select which byte in the range begins the copy with the + '--byte' option. Select the width of the range with the + '--interleave-width' option. + + This option is useful for creating files to program ROM. It is + typically used with an 'srec' output target. Note that 'objcopy' + will complain if you do not specify the '--byte' option as well. + + The default interleave breadth is 4, so with '--byte' set to 0, + 'objcopy' would copy the first byte out of every four bytes from + the input to the output. + +'--interleave-width=WIDTH' + When used with the '--interleave' option, copy WIDTH bytes at a + time. The start of the range of bytes to be copied is set by the + '--byte' option, and the extent of the range is set with the + '--interleave' option. + + The default value for this option is 1. The value of WIDTH plus + the BYTE value set by the '--byte' option must not exceed the + interleave breadth set by the '--interleave' option. + + This option can be used to create images for two 16-bit flashes + interleaved in a 32-bit bus by passing '-b 0 -i 4 + --interleave-width=2' and '-b 2 -i 4 --interleave-width=2' to two + 'objcopy' commands. If the input was '12345678' then the outputs + would be '1256' and '3478' respectively. + +'-p' +'--preserve-dates' + Set the access and modification dates of the output file to be the + same as those of the input file. + +'-D' +'--enable-deterministic-archives' + Operate in _deterministic_ mode. When copying archive members and + writing the archive index, use zero for UIDs, GIDs, timestamps, and + use consistent file modes for all files. + + If 'binutils' was configured with + '--enable-deterministic-archives', then this mode is on by default. + It can be disabled with the '-U' option, below. + +'-U' +'--disable-deterministic-archives' + Do _not_ operate in _deterministic_ mode. This is the inverse of + the '-D' option, above: when copying archive members and writing + the archive index, use their actual UID, GID, timestamp, and file + mode values. + + This is the default unless 'binutils' was configured with + '--enable-deterministic-archives'. + +'--debugging' + Convert debugging information, if possible. This is not the + default because only certain debugging formats are supported, and + the conversion process can be time consuming. + +'--gap-fill VAL' + Fill gaps between sections with VAL. This operation applies to the + _load address_ (LMA) of the sections. It is done by increasing the + size of the section with the lower address, and filling in the + extra space created with VAL. + +'--pad-to ADDRESS' + Pad the output file up to the load address ADDRESS. This is done + by increasing the size of the last section. The extra space is + filled in with the value specified by '--gap-fill' (default zero). + +'--set-start VAL' + Set the start address of the new file to VAL. Not all object file + formats support setting the start address. + +'--change-start INCR' +'--adjust-start INCR' + Change the start address by adding INCR. Not all object file + formats support setting the start address. + +'--change-addresses INCR' +'--adjust-vma INCR' + Change the VMA and LMA addresses of all sections, as well as the + start address, by adding INCR. Some object file formats do not + permit section addresses to be changed arbitrarily. Note that this + does not relocate the sections; if the program expects sections to + be loaded at a certain address, and this option is used to change + the sections such that they are loaded at a different address, the + program may fail. + +'--change-section-address SECTIONPATTERN{=,+,-}VAL' +'--adjust-section-vma SECTIONPATTERN{=,+,-}VAL' + Set or change both the VMA address and the LMA address of any + section matching SECTIONPATTERN. If '=' is used, the section + address is set to VAL. Otherwise, VAL is added to or subtracted + from the section address. See the comments under + '--change-addresses', above. If SECTIONPATTERN does not match any + sections in the input file, a warning will be issued, unless + '--no-change-warnings' is used. + +'--change-section-lma SECTIONPATTERN{=,+,-}VAL' + Set or change the LMA address of any sections matching + SECTIONPATTERN. The LMA address is the address where the section + will be loaded into memory at program load time. Normally this is + the same as the VMA address, which is the address of the section at + program run time, but on some systems, especially those where a + program is held in ROM, the two can be different. If '=' is used, + the section address is set to VAL. Otherwise, VAL is added to or + subtracted from the section address. See the comments under + '--change-addresses', above. If SECTIONPATTERN does not match any + sections in the input file, a warning will be issued, unless + '--no-change-warnings' is used. + +'--change-section-vma SECTIONPATTERN{=,+,-}VAL' + Set or change the VMA address of any section matching + SECTIONPATTERN. The VMA address is the address where the section + will be located once the program has started executing. Normally + this is the same as the LMA address, which is the address where the + section will be loaded into memory, but on some systems, especially + those where a program is held in ROM, the two can be different. If + '=' is used, the section address is set to VAL. Otherwise, VAL is + added to or subtracted from the section address. See the comments + under '--change-addresses', above. If SECTIONPATTERN does not + match any sections in the input file, a warning will be issued, + unless '--no-change-warnings' is used. + +'--change-warnings' +'--adjust-warnings' + If '--change-section-address' or '--change-section-lma' or + '--change-section-vma' is used, and the section pattern does not + match any sections, issue a warning. This is the default. + +'--no-change-warnings' +'--no-adjust-warnings' + Do not issue a warning if '--change-section-address' or + '--adjust-section-lma' or '--adjust-section-vma' is used, even if + the section pattern does not match any sections. + +'--set-section-flags SECTIONPATTERN=FLAGS' + Set the flags for any sections matching SECTIONPATTERN. The FLAGS + argument is a comma separated string of flag names. The recognized + names are 'alloc', 'contents', 'load', 'noload', 'readonly', + 'code', 'data', 'rom', 'share', and 'debug'. You can set the + 'contents' flag for a section which does not have contents, but it + is not meaningful to clear the 'contents' flag of a section which + does have contents-just remove the section instead. Not all flags + are meaningful for all object file formats. + +'--add-section SECTIONNAME=FILENAME' + Add a new section named SECTIONNAME while copying the file. The + contents of the new section are taken from the file FILENAME. The + size of the section will be the size of the file. This option only + works on file formats which can support sections with arbitrary + names. Note - it may be necessary to use the '--set-section-flags' + option to set the attributes of the newly created section. + +'--dump-section SECTIONNAME=FILENAME' + Place the contents of section named SECTIONNAME into the file + FILENAME, overwriting any contents that may have been there + previously. This option is the inverse of '--add-section'. This + option is similar to the '--only-section' option except that it + does not create a formatted file, it just dumps the contents as raw + binary data, without applying any relocations. The option can be + specified more than once. + +'--update-section SECTIONNAME=FILENAME' + Replace the existing contents of a section named SECTIONNAME with + the contents of file FILENAME. The size of the section will be + adjusted to the size of the file. The section flags for + SECTIONNAME will be unchanged. For ELF format files the section to + segment mapping will also remain unchanged, something which is not + possible using '--remove-section' followed by '--add-section'. The + option can be specified more than once. + + Note - it is possible to use '--rename-section' and + '--update-section' to both update and rename a section from one + command line. In this case, pass the original section name to + '--update-section', and the original and new section names to + '--rename-section'. + +'--add-symbol NAME=[SECTION:]VALUE[,FLAGS]' + Add a new symbol named NAME while copying the file. This option + may be specified multiple times. If the SECTION is given, the + symbol will be associated with and relative to that section, + otherwise it will be an ABS symbol. Specifying an undefined + section will result in a fatal error. There is no check for the + value, it will be taken as specified. Symbol flags can be + specified and not all flags will be meaningful for all object file + formats. By default, the symbol will be global. The special flag + 'before=OTHERSYM' will insert the new symbol in front of the + specified OTHERSYM, otherwise the symbol(s) will be added at the + end of the symbol table in the order they appear. + +'--rename-section OLDNAME=NEWNAME[,FLAGS]' + Rename a section from OLDNAME to NEWNAME, optionally changing the + section's flags to FLAGS in the process. This has the advantage + over using a linker script to perform the rename in that the output + stays as an object file and does not become a linked executable. + + This option is particularly helpful when the input format is + binary, since this will always create a section called .data. If + for example, you wanted instead to create a section called .rodata + containing binary data you could use the following command line to + achieve it: + + objcopy -I binary -O -B \ + --rename-section .data=.rodata,alloc,load,readonly,data,contents \ + + +'--long-section-names {enable,disable,keep}' + Controls the handling of long section names when processing 'COFF' + and 'PE-COFF' object formats. The default behaviour, 'keep', is to + preserve long section names if any are present in the input file. + The 'enable' and 'disable' options forcibly enable or disable the + use of long section names in the output object; when 'disable' is + in effect, any long section names in the input object will be + truncated. The 'enable' option will only emit long section names + if any are present in the inputs; this is mostly the same as + 'keep', but it is left undefined whether the 'enable' option might + force the creation of an empty string table in the output file. + +'--change-leading-char' + Some object file formats use special characters at the start of + symbols. The most common such character is underscore, which + compilers often add before every symbol. This option tells + 'objcopy' to change the leading character of every symbol when it + converts between object file formats. If the object file formats + use the same leading character, this option has no effect. + Otherwise, it will add a character, or remove a character, or + change a character, as appropriate. + +'--remove-leading-char' + If the first character of a global symbol is a special symbol + leading character used by the object file format, remove the + character. The most common symbol leading character is underscore. + This option will remove a leading underscore from all global + symbols. This can be useful if you want to link together objects + of different file formats with different conventions for symbol + names. This is different from '--change-leading-char' because it + always changes the symbol name when appropriate, regardless of the + object file format of the output file. + +'--reverse-bytes=NUM' + Reverse the bytes in a section with output contents. A section + length must be evenly divisible by the value given in order for the + swap to be able to take place. Reversing takes place before the + interleaving is performed. + + This option is used typically in generating ROM images for + problematic target systems. For example, on some target boards, + the 32-bit words fetched from 8-bit ROMs are re-assembled in + little-endian byte order regardless of the CPU byte order. + Depending on the programming model, the endianness of the ROM may + need to be modified. + + Consider a simple file with a section containing the following + eight bytes: '12345678'. + + Using '--reverse-bytes=2' for the above example, the bytes in the + output file would be ordered '21436587'. + + Using '--reverse-bytes=4' for the above example, the bytes in the + output file would be ordered '43218765'. + + By using '--reverse-bytes=2' for the above example, followed by + '--reverse-bytes=4' on the output file, the bytes in the second + output file would be ordered '34127856'. + +'--srec-len=IVAL' + Meaningful only for srec output. Set the maximum length of the + Srecords being produced to IVAL. This length covers both address, + data and crc fields. + +'--srec-forceS3' + Meaningful only for srec output. Avoid generation of S1/S2 + records, creating S3-only record format. + +'--redefine-sym OLD=NEW' + Change the name of a symbol OLD, to NEW. This can be useful when + one is trying link two things together for which you have no + source, and there are name collisions. + +'--redefine-syms=FILENAME' + Apply '--redefine-sym' to each symbol pair "OLD NEW" listed in the + file FILENAME. FILENAME is simply a flat file, with one symbol + pair per line. Line comments may be introduced by the hash + character. This option may be given more than once. + +'--weaken' + Change all global symbols in the file to be weak. This can be + useful when building an object which will be linked against other + objects using the '-R' option to the linker. This option is only + effective when using an object file format which supports weak + symbols. + +'--keep-symbols=FILENAME' + Apply '--keep-symbol' option to each symbol listed in the file + FILENAME. FILENAME is simply a flat file, with one symbol name per + line. Line comments may be introduced by the hash character. This + option may be given more than once. + +'--strip-symbols=FILENAME' + Apply '--strip-symbol' option to each symbol listed in the file + FILENAME. FILENAME is simply a flat file, with one symbol name per + line. Line comments may be introduced by the hash character. This + option may be given more than once. + +'--strip-unneeded-symbols=FILENAME' + Apply '--strip-unneeded-symbol' option to each symbol listed in the + file FILENAME. FILENAME is simply a flat file, with one symbol + name per line. Line comments may be introduced by the hash + character. This option may be given more than once. + +'--keep-global-symbols=FILENAME' + Apply '--keep-global-symbol' option to each symbol listed in the + file FILENAME. FILENAME is simply a flat file, with one symbol + name per line. Line comments may be introduced by the hash + character. This option may be given more than once. + +'--localize-symbols=FILENAME' + Apply '--localize-symbol' option to each symbol listed in the file + FILENAME. FILENAME is simply a flat file, with one symbol name per + line. Line comments may be introduced by the hash character. This + option may be given more than once. + +'--globalize-symbols=FILENAME' + Apply '--globalize-symbol' option to each symbol listed in the file + FILENAME. FILENAME is simply a flat file, with one symbol name per + line. Line comments may be introduced by the hash character. This + option may be given more than once. + +'--weaken-symbols=FILENAME' + Apply '--weaken-symbol' option to each symbol listed in the file + FILENAME. FILENAME is simply a flat file, with one symbol name per + line. Line comments may be introduced by the hash character. This + option may be given more than once. + +'--alt-machine-code=INDEX' + If the output architecture has alternate machine codes, use the + INDEXth code instead of the default one. This is useful in case a + machine is assigned an official code and the tool-chain adopts the + new code, but other applications still depend on the original code + being used. For ELF based architectures if the INDEX alternative + does not exist then the value is treated as an absolute number to + be stored in the e_machine field of the ELF header. + +'--writable-text' + Mark the output text as writable. This option isn't meaningful for + all object file formats. + +'--readonly-text' + Make the output text write protected. This option isn't meaningful + for all object file formats. + +'--pure' + Mark the output file as demand paged. This option isn't meaningful + for all object file formats. + +'--impure' + Mark the output file as impure. This option isn't meaningful for + all object file formats. + +'--prefix-symbols=STRING' + Prefix all symbols in the output file with STRING. + +'--prefix-sections=STRING' + Prefix all section names in the output file with STRING. + +'--prefix-alloc-sections=STRING' + Prefix all the names of all allocated sections in the output file + with STRING. + +'--add-gnu-debuglink=PATH-TO-FILE' + Creates a .gnu_debuglink section which contains a reference to + PATH-TO-FILE and adds it to the output file. Note: the file at + PATH-TO-FILE must exist. Part of the process of adding the + .gnu_debuglink section involves embedding a checksum of the + contents of the debug info file into the section. + + If the debug info file is built in one location but it is going to + be installed at a later time into a different location then do not + use the path to the installed location. The '--add-gnu-debuglink' + option will fail because the installed file does not exist yet. + Instead put the debug info file in the current directory and use + the '--add-gnu-debuglink' option without any directory components, + like this: + + objcopy --add-gnu-debuglink=foo.debug + + At debug time the debugger will attempt to look for the separate + debug info file in a set of known locations. The exact set of + these locations varies depending upon the distribution being used, + but it typically includes: + + '* The same directory as the executable.' + + '* A sub-directory of the directory containing the executable' + called .debug + + '* A global debug directory such as /usr/lib/debug.' + + As long as the debug info file has been installed into one of these + locations before the debugger is run everything should work + correctly. + +'--keep-file-symbols' + When stripping a file, perhaps with '--strip-debug' or + '--strip-unneeded', retain any symbols specifying source file + names, which would otherwise get stripped. + +'--only-keep-debug' + Strip a file, removing contents of any sections that would not be + stripped by '--strip-debug' and leaving the debugging sections + intact. In ELF files, this preserves all note sections in the + output. + + Note - the section headers of the stripped sections are preserved, + including their sizes, but the contents of the section are + discarded. The section headers are preserved so that other tools + can match up the debuginfo file with the real executable, even if + that executable has been relocated to a different address space. + + The intention is that this option will be used in conjunction with + '--add-gnu-debuglink' to create a two part executable. One a + stripped binary which will occupy less space in RAM and in a + distribution and the second a debugging information file which is + only needed if debugging abilities are required. The suggested + procedure to create these files is as follows: + + 1. Link the executable as normal. Assuming that is is called + 'foo' then... + 2. Run 'objcopy --only-keep-debug foo foo.dbg' to create a file + containing the debugging info. + 3. Run 'objcopy --strip-debug foo' to create a stripped + executable. + 4. Run 'objcopy --add-gnu-debuglink=foo.dbg foo' to add a link to + the debugging info into the stripped executable. + + Note--the choice of '.dbg' as an extension for the debug info file + is arbitrary. Also the '--only-keep-debug' step is optional. You + could instead do this: + + 1. Link the executable as normal. + 2. Copy 'foo' to 'foo.full' + 3. Run 'objcopy --strip-debug foo' + 4. Run 'objcopy --add-gnu-debuglink=foo.full foo' + + i.e., the file pointed to by the '--add-gnu-debuglink' can be the + full executable. It does not have to be a file created by the + '--only-keep-debug' switch. + + Note--this switch is only intended for use on fully linked files. + It does not make sense to use it on object files where the + debugging information may be incomplete. Besides the gnu_debuglink + feature currently only supports the presence of one filename + containing debugging information, not multiple filenames on a + one-per-object-file basis. + +'--strip-dwo' + Remove the contents of all DWARF .dwo sections, leaving the + remaining debugging sections and all symbols intact. This option + is intended for use by the compiler as part of the '-gsplit-dwarf' + option, which splits debug information between the .o file and a + separate .dwo file. The compiler generates all debug information + in the same file, then uses the '--extract-dwo' option to copy the + .dwo sections to the .dwo file, then the '--strip-dwo' option to + remove those sections from the original .o file. + +'--extract-dwo' + Extract the contents of all DWARF .dwo sections. See the + '--strip-dwo' option for more information. + +'--file-alignment NUM' + Specify the file alignment. Sections in the file will always begin + at file offsets which are multiples of this number. This defaults + to 512. [This option is specific to PE targets.] + +'--heap RESERVE' +'--heap RESERVE,COMMIT' + Specify the number of bytes of memory to reserve (and optionally + commit) to be used as heap for this program. [This option is + specific to PE targets.] + +'--image-base VALUE' + Use VALUE as the base address of your program or dll. This is the + lowest memory location that will be used when your program or dll + is loaded. To reduce the need to relocate and improve performance + of your dlls, each should have a unique base address and not + overlap any other dlls. The default is 0x400000 for executables, + and 0x10000000 for dlls. [This option is specific to PE targets.] + +'--section-alignment NUM' + Sets the section alignment. Sections in memory will always begin + at addresses which are a multiple of this number. Defaults to + 0x1000. [This option is specific to PE targets.] + +'--stack RESERVE' +'--stack RESERVE,COMMIT' + Specify the number of bytes of memory to reserve (and optionally + commit) to be used as stack for this program. [This option is + specific to PE targets.] + +'--subsystem WHICH' +'--subsystem WHICH:MAJOR' +'--subsystem WHICH:MAJOR.MINOR' + Specifies the subsystem under which your program will execute. The + legal values for WHICH are 'native', 'windows', 'console', 'posix', + 'efi-app', 'efi-bsd', 'efi-rtd', 'sal-rtd', and 'xbox'. You may + optionally set the subsystem version also. Numeric values are also + accepted for WHICH. [This option is specific to PE targets.] + +'--extract-symbol' + Keep the file's section flags and symbols but remove all section + data. Specifically, the option: + + * removes the contents of all sections; + * sets the size of every section to zero; and + * sets the file's start address to zero. + + This option is used to build a '.sym' file for a VxWorks kernel. + It can also be a useful way of reducing the size of a + '--just-symbols' linker input file. + +'--compress-debug-sections' + Compress DWARF debug sections using zlib with SHF_COMPRESSED from + the ELF ABI. Note - if compression would actually make a section + _larger_, then it is not compressed. + +'--compress-debug-sections=none' +'--compress-debug-sections=zlib' +'--compress-debug-sections=zlib-gnu' +'--compress-debug-sections=zlib-gabi' + For ELF files, these options control how DWARF debug sections are + compressed. '--compress-debug-sections=none' is equivalent to + '--decompress-debug-sections'. '--compress-debug-sections=zlib' + and '--compress-debug-sections=zlib-gabi' are equivalent to + '--compress-debug-sections'. '--compress-debug-sections=zlib-gnu' + compresses DWARF debug sections using zlib. The debug sections are + renamed to begin with '.zdebug' instead of '.debug'. Note - if + compression would actually make a section _larger_, then it is not + compressed nor renamed. + +'--decompress-debug-sections' + Decompress DWARF debug sections using zlib. The original section + names of the compressed sections are restored. + +'--elf-stt-common=yes' +'--elf-stt-common=no' + For ELF files, these options control whether common symbols should + be converted to the 'STT_COMMON' or 'STT_OBJECT' type. + '--elf-stt-common=yes' converts common symbol type to 'STT_COMMON'. + '--elf-stt-common=no' converts common symbol type to 'STT_OBJECT'. + +'--merge-notes' +'--no-merge-notes' + For ELF files, attempt (or do not attempt) to reduce the size of + any SHT_NOTE type sections by removing duplicate notes. + +'-V' +'--version' + Show the version number of 'objcopy'. + +'-v' +'--verbose' + Verbose output: list all object files modified. In the case of + archives, 'objcopy -V' lists all members of the archive. + +'--help' + Show a summary of the options to 'objcopy'. + +'--info' + Display a list showing all architectures and object formats + available. + + +File: binutils.info, Node: objdump, Next: ranlib, Prev: objcopy, Up: Top + +4 objdump +********* + + objdump [-a|--archive-headers] + [-b BFDNAME|--target=BFDNAME] + [-C|--demangle[=STYLE] ] + [-d|--disassemble] + [-D|--disassemble-all] + [-z|--disassemble-zeroes] + [-EB|-EL|--endian={big | little }] + [-f|--file-headers] + [-F|--file-offsets] + [--file-start-context] + [-g|--debugging] + [-e|--debugging-tags] + [-h|--section-headers|--headers] + [-i|--info] + [-j SECTION|--section=SECTION] + [-l|--line-numbers] + [-S|--source] + [-m MACHINE|--architecture=MACHINE] + [-M OPTIONS|--disassembler-options=OPTIONS] + [-p|--private-headers] + [-P OPTIONS|--private=OPTIONS] + [-r|--reloc] + [-R|--dynamic-reloc] + [-s|--full-contents] + [-W[lLiaprmfFsoRtUuTgAckK]| + --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links] + [-G|--stabs] + [-t|--syms] + [-T|--dynamic-syms] + [-x|--all-headers] + [-w|--wide] + [--start-address=ADDRESS] + [--stop-address=ADDRESS] + [--prefix-addresses] + [--[no-]show-raw-insn] + [--adjust-vma=OFFSET] + [--dwarf-depth=N] + [--dwarf-start=N] + [--special-syms] + [--prefix=PREFIX] + [--prefix-strip=LEVEL] + [--insn-width=WIDTH] + [-V|--version] + [-H|--help] + OBJFILE... + + 'objdump' displays information about one or more object files. The +options control what particular information to display. This +information is mostly useful to programmers who are working on the +compilation tools, as opposed to programmers who just want their program +to compile and work. + + OBJFILE... are the object files to be examined. When you specify +archives, 'objdump' shows information on each of the member object +files. + + The long and short forms of options, shown here as alternatives, are +equivalent. At least one option from the list +'-a,-d,-D,-e,-f,-g,-G,-h,-H,-p,-P,-r,-R,-s,-S,-t,-T,-V,-x' must be +given. + +'-a' +'--archive-header' + If any of the OBJFILE files are archives, display the archive + header information (in a format similar to 'ls -l'). Besides the + information you could list with 'ar tv', 'objdump -a' shows the + object file format of each archive member. + +'--adjust-vma=OFFSET' + When dumping information, first add OFFSET to all the section + addresses. This is useful if the section addresses do not + correspond to the symbol table, which can happen when putting + sections at particular addresses when using a format which can not + represent section addresses, such as a.out. + +'-b BFDNAME' +'--target=BFDNAME' + Specify that the object-code format for the object files is + BFDNAME. This option may not be necessary; OBJDUMP can + automatically recognize many formats. + + For example, + objdump -b oasys -m vax -h fu.o + displays summary information from the section headers ('-h') of + 'fu.o', which is explicitly identified ('-m') as a VAX object file + in the format produced by Oasys compilers. You can list the + formats available with the '-i' option. *Note Target Selection::, + for more information. + +'-C' +'--demangle[=STYLE]' + Decode ("demangle") low-level symbol names into user-level names. + Besides removing any initial underscore prepended by the system, + this makes C++ function names readable. Different compilers have + different mangling styles. The optional demangling style argument + can be used to choose an appropriate demangling style for your + compiler. *Note c++filt::, for more information on demangling. + +'-g' +'--debugging' + Display debugging information. This attempts to parse STABS and + IEEE debugging format information stored in the file and print it + out using a C like syntax. If neither of these formats are found + this option falls back on the '-W' option to print any DWARF + information in the file. + +'-e' +'--debugging-tags' + Like '-g', but the information is generated in a format compatible + with ctags tool. + +'-d' +'--disassemble' + Display the assembler mnemonics for the machine instructions from + OBJFILE. This option only disassembles those sections which are + expected to contain instructions. + +'-D' +'--disassemble-all' + Like '-d', but disassemble the contents of all sections, not just + those expected to contain instructions. + + This option also has a subtle effect on the disassembly of + instructions in code sections. When option '-d' is in effect + objdump will assume that any symbols present in a code section + occur on the boundary between instructions and it will refuse to + disassemble across such a boundary. When option '-D' is in effect + however this assumption is supressed. This means that it is + possible for the output of '-d' and '-D' to differ if, for example, + data is stored in code sections. + + If the target is an ARM architecture this switch also has the + effect of forcing the disassembler to decode pieces of data found + in code sections as if they were instructions. + +'--prefix-addresses' + When disassembling, print the complete address on each line. This + is the older disassembly format. + +'-EB' +'-EL' +'--endian={big|little}' + Specify the endianness of the object files. This only affects + disassembly. This can be useful when disassembling a file format + which does not describe endianness information, such as S-records. + +'-f' +'--file-headers' + Display summary information from the overall header of each of the + OBJFILE files. + +'-F' +'--file-offsets' + When disassembling sections, whenever a symbol is displayed, also + display the file offset of the region of data that is about to be + dumped. If zeroes are being skipped, then when disassembly + resumes, tell the user how many zeroes were skipped and the file + offset of the location from where the disassembly resumes. When + dumping sections, display the file offset of the location from + where the dump starts. + +'--file-start-context' + Specify that when displaying interlisted source code/disassembly + (assumes '-S') from a file that has not yet been displayed, extend + the context to the start of the file. + +'-h' +'--section-headers' +'--headers' + Display summary information from the section headers of the object + file. + + File segments may be relocated to nonstandard addresses, for + example by using the '-Ttext', '-Tdata', or '-Tbss' options to + 'ld'. However, some object file formats, such as a.out, do not + store the starting address of the file segments. In those + situations, although 'ld' relocates the sections correctly, using + 'objdump -h' to list the file section headers cannot show the + correct addresses. Instead, it shows the usual addresses, which + are implicit for the target. + + Note, in some cases it is possible for a section to have both the + READONLY and the NOREAD attributes set. In such cases the NOREAD + attribute takes precedence, but 'objdump' will report both since + the exact setting of the flag bits might be important. + +'-H' +'--help' + Print a summary of the options to 'objdump' and exit. + +'-i' +'--info' + Display a list showing all architectures and object formats + available for specification with '-b' or '-m'. + +'-j NAME' +'--section=NAME' + Display information only for section NAME. + +'-l' +'--line-numbers' + Label the display (using debugging information) with the filename + and source line numbers corresponding to the object code or relocs + shown. Only useful with '-d', '-D', or '-r'. + +'-m MACHINE' +'--architecture=MACHINE' + Specify the architecture to use when disassembling object files. + This can be useful when disassembling object files which do not + describe architecture information, such as S-records. You can list + the available architectures with the '-i' option. + + If the target is an ARM architecture then this switch has an + additional effect. It restricts the disassembly to only those + instructions supported by the architecture specified by MACHINE. + If it is necessary to use this switch because the input file does + not contain any architecture information, but it is also desired to + disassemble all the instructions use '-marm'. + +'-M OPTIONS' +'--disassembler-options=OPTIONS' + Pass target specific information to the disassembler. Only + supported on some targets. If it is necessary to specify more than + one disassembler option then multiple '-M' options can be used or + can be placed together into a comma separated list. + + For ARC, 'dsp' controls the printing of DSP instructions, 'spfp' + selects the printing of FPX single precision FP instructions, + 'dpfp' selects the printing of FPX double precision FP + instructions, 'quarkse_em' selects the printing of special + QuarkSE-EM instructions, 'fpuda' selects the printing of double + precision assist instructions, 'fpus' selects the printing of FPU + single precision FP instructions, while 'fpud' selects the printing + of FPU souble precision FP instructions. Additionally, one can + choose to have all the immediates printed in hexadecimal using + 'hex'. By default, the short immediates are printed using the + decimal representation, while the long immediate values are printed + as hexadecimal. + + 'cpu=...' allows to enforce a particular ISA when disassembling + instructions, overriding the '-m' value or whatever is in the ELF + file. This might be useful to select ARC EM or HS ISA, because + architecture is same for those and disassembler relies on private + ELF header data to decide if code is for EM or HS. This option + might be specified multiple times - only the latest value will be + used. Valid values are same as for the assembler '-mcpu=...' + option. + + If the target is an ARM architecture then this switch can be used + to select which register name set is used during disassembler. + Specifying '-M reg-names-std' (the default) will select the + register names as used in ARM's instruction set documentation, but + with register 13 called 'sp', register 14 called 'lr' and register + 15 called 'pc'. Specifying '-M reg-names-apcs' will select the + name set used by the ARM Procedure Call Standard, whilst specifying + '-M reg-names-raw' will just use 'r' followed by the register + number. + + There are also two variants on the APCS register naming scheme + enabled by '-M reg-names-atpcs' and '-M reg-names-special-atpcs' + which use the ARM/Thumb Procedure Call Standard naming conventions. + (Either with the normal register names or the special register + names). + + This option can also be used for ARM architectures to force the + disassembler to interpret all instructions as Thumb instructions by + using the switch '--disassembler-options=force-thumb'. This can be + useful when attempting to disassemble thumb code produced by other + compilers. + + For the x86, some of the options duplicate functions of the '-m' + switch, but allow finer grained control. Multiple selections from + the following may be specified as a comma separated string. + 'x86-64' + 'i386' + 'i8086' + Select disassembly for the given architecture. + + 'intel' + 'att' + Select between intel syntax mode and AT&T syntax mode. + + 'amd64' + 'intel64' + Select between AMD64 ISA and Intel64 ISA. + + 'intel-mnemonic' + 'att-mnemonic' + Select between intel mnemonic mode and AT&T mnemonic mode. + Note: 'intel-mnemonic' implies 'intel' and 'att-mnemonic' + implies 'att'. + + 'addr64' + 'addr32' + 'addr16' + 'data32' + 'data16' + Specify the default address size and operand size. These four + options will be overridden if 'x86-64', 'i386' or 'i8086' + appear later in the option string. + + 'suffix' + When in AT&T mode, instructs the disassembler to print a + mnemonic suffix even when the suffix could be inferred by the + operands. + + For PowerPC, the '-M' argument 'raw' selects disasssembly of + hardware insns rather than aliases. For example, you will see + 'rlwinm' rather than 'clrlwi', and 'addi' rather than 'li'. All of + the '-m' arguments for 'gas' that select a CPU are supported. + These are: '403', '405', '440', '464', '476', '601', '603', '604', + '620', '7400', '7410', '7450', '7455', '750cl', '821', '850', + '860', 'a2', 'booke', 'booke32', 'cell', 'com', 'e200z4', 'e300', + 'e500', 'e500mc', 'e500mc64', 'e500x2', 'e5500', 'e6500', 'efs', + 'power4', 'power5', 'power6', 'power7', 'power8', 'power9', 'ppc', + 'ppc32', 'ppc64', 'ppc64bridge', 'ppcps', 'pwr', 'pwr2', 'pwr4', + 'pwr5', 'pwr5x', 'pwr6', 'pwr7', 'pwr8', 'pwr9', 'pwrx', 'titan', + and 'vle'. '32' and '64' modify the default or a prior CPU + selection, disabling and enabling 64-bit insns respectively. In + addition, 'altivec', 'any', 'htm', 'vsx', and 'spe' add + capabilities to a previous _or later_ CPU selection. 'any' will + disassemble any opcode known to binutils, but in cases where an + opcode has two different meanings or different arguments, you may + not see the disassembly you expect. If you disassemble without + giving a CPU selection, a default will be chosen from information + gleaned by BFD from the object files headers, but the result again + may not be as you expect. + + For MIPS, this option controls the printing of instruction mnemonic + names and register names in disassembled instructions. Multiple + selections from the following may be specified as a comma separated + string, and invalid options are ignored: + + 'no-aliases' + Print the 'raw' instruction mnemonic instead of some pseudo + instruction mnemonic. I.e., print 'daddu' or 'or' instead of + 'move', 'sll' instead of 'nop', etc. + + 'msa' + Disassemble MSA instructions. + + 'virt' + Disassemble the virtualization ASE instructions. + + 'xpa' + Disassemble the eXtended Physical Address (XPA) ASE + instructions. + + 'gpr-names=ABI' + Print GPR (general-purpose register) names as appropriate for + the specified ABI. By default, GPR names are selected + according to the ABI of the binary being disassembled. + + 'fpr-names=ABI' + Print FPR (floating-point register) names as appropriate for + the specified ABI. By default, FPR numbers are printed rather + than names. + + 'cp0-names=ARCH' + Print CP0 (system control coprocessor; coprocessor 0) register + names as appropriate for the CPU or architecture specified by + ARCH. By default, CP0 register names are selected according + to the architecture and CPU of the binary being disassembled. + + 'hwr-names=ARCH' + Print HWR (hardware register, used by the 'rdhwr' instruction) + names as appropriate for the CPU or architecture specified by + ARCH. By default, HWR names are selected according to the + architecture and CPU of the binary being disassembled. + + 'reg-names=ABI' + Print GPR and FPR names as appropriate for the selected ABI. + + 'reg-names=ARCH' + Print CPU-specific register names (CP0 register and HWR names) + as appropriate for the selected CPU or architecture. + + For any of the options listed above, ABI or ARCH may be specified + as 'numeric' to have numbers printed rather than names, for the + selected types of registers. You can list the available values of + ABI and ARCH using the '--help' option. + + For VAX, you can specify function entry addresses with '-M + entry:0xf00ba'. You can use this multiple times to properly + disassemble VAX binary files that don't contain symbol tables (like + ROM dumps). In these cases, the function entry mask would + otherwise be decoded as VAX instructions, which would probably lead + the rest of the function being wrongly disassembled. + +'-p' +'--private-headers' + Print information that is specific to the object file format. The + exact information printed depends upon the object file format. For + some object file formats, no additional information is printed. + +'-P OPTIONS' +'--private=OPTIONS' + Print information that is specific to the object file format. The + argument OPTIONS is a comma separated list that depends on the + format (the lists of options is displayed with the help). + + For XCOFF, the available options are: + 'header' + 'aout' + 'sections' + 'syms' + 'relocs' + 'lineno,' + 'loader' + 'except' + 'typchk' + 'traceback' + 'toc' + 'ldinfo' + + Not all object formats support this option. In particular the ELF + format does not use it. + +'-r' +'--reloc' + Print the relocation entries of the file. If used with '-d' or + '-D', the relocations are printed interspersed with the + disassembly. + +'-R' +'--dynamic-reloc' + Print the dynamic relocation entries of the file. This is only + meaningful for dynamic objects, such as certain types of shared + libraries. As for '-r', if used with '-d' or '-D', the relocations + are printed interspersed with the disassembly. + +'-s' +'--full-contents' + Display the full contents of any sections requested. By default + all non-empty sections are displayed. + +'-S' +'--source' + Display source code intermixed with disassembly, if possible. + Implies '-d'. + +'--prefix=PREFIX' + Specify PREFIX to add to the absolute paths when used with '-S'. + +'--prefix-strip=LEVEL' + Indicate how many initial directory names to strip off the + hardwired absolute paths. It has no effect without + '--prefix='PREFIX. + +'--show-raw-insn' + When disassembling instructions, print the instruction in hex as + well as in symbolic form. This is the default except when + '--prefix-addresses' is used. + +'--no-show-raw-insn' + When disassembling instructions, do not print the instruction + bytes. This is the default when '--prefix-addresses' is used. + +'--insn-width=WIDTH' + Display WIDTH bytes on a single line when disassembling + instructions. + +'-W[lLiaprmfFsoRtUuTgAckK]' +'--dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]' + + Displays the contents of the DWARF debug sections in the file, if + any are present. Compressed debug sections are automatically + decompressed (temporarily) before they are displayed. If one or + more of the optional letters or words follows the switch then only + those type(s) of data will be dumped. The letters and words refer + to the following information: + + 'a' + '=abbrev' + Displays the contents of the '.debug_abbrev' section. + + 'A' + '=addr' + Displays the contents of the '.debug_addr' section. + + 'c' + '=cu_index' + Displays the contents of the '.debug_cu_index' and/or + '.debug_tu_index' sections. + + 'f' + '=frames' + Display the raw contents of a '.debug_frame' section. + + 'F' + '=frame-interp' + Display the interpreted contents of a '.debug_frame' section. + + 'g' + '=gdb_index' + Displays the contents of the '.gdb_index' and/or + '.debug_names' sections. + + 'i' + '=info' + Displays the contents of the '.debug_info' section. Note: the + output from this option can also be restricted by the use of + the '--dwarf-depth' and '--dwarf-start' options. + + 'k' + '=links' + Displays the contents of the '.gnu_debuglink' and/or + '.gnu_debugaltlink' sections. Also displays the link to a + separate dwarf object file (dwo), if one is specified by the + DW_AT_GNU_dwo_name or DW_AT_dwo_name attributes in the + '.debug_info' section. + + 'K' + '=follow-links' + Display the contents of any selected debug sections that are + found in a linked, separate debug info file. This can result + in multiple versions of the same debug section being displayed + if both the main file and the separate debug info file contain + sections with the same name. + + In addition, when displaying DWARF attributes, if a form is + found that references the separate debug info file, then the + referenced contents will also be displayed. + + 'l' + '=rawline' + Displays the contents of the '.debug_line' section in a raw + format. + + 'L' + '=decodedline' + Displays the interpreted contents of the '.debug_line' + section. + + 'm' + '=macro' + Displays the contents of the '.debug_macro' and/or + '.debug_macinfo' sections. + + 'o' + '=loc' + Displays the contents of the '.debug_loc' and/or + '.debug_loclists' sections. + + 'p' + '=pubnames' + Displays the contents of the '.debug_pubnames' and/or + '.debug_gnu_pubnames' sections. + + 'r' + '=aranges' + Displays the contents of the '.debug_aranges' section. + + 'R' + '=Ranges' + Displays the contents of the '.debug_ranges' and/or + '.debug_rnglists' sections. + + 's' + '=str' + Displays the contents of the '.debug_str', '.debug_line_str' + and/or '.debug_str_offsets' sections. + + 't' + '=pubtype' + Displays the contents of the '.debug_pubtypes' and/or + '.debug_gnu_pubtypes' sections. + + 'T' + '=trace_aranges' + Displays the contents of the '.trace_aranges' section. + + 'u' + '=trace_abbrev' + Displays the contents of the '.trace_abbrev' section. + + 'U' + '=trace_info' + Displays the contents of the '.trace_info' section. + + Note: displaying the contents of '.debug_static_funcs', + '.debug_static_vars' and 'debug_weaknames' sections is not + currently supported. + +'--dwarf-depth=N' + Limit the dump of the '.debug_info' section to N children. This is + only useful with '--debug-dump=info'. The default is to print all + DIEs; the special value 0 for N will also have this effect. + + With a non-zero value for N, DIEs at or deeper than N levels will + not be printed. The range for N is zero-based. + +'--dwarf-start=N' + Print only DIEs beginning with the DIE numbered N. This is only + useful with '--debug-dump=info'. + + If specified, this option will suppress printing of any header + information and all DIEs before the DIE numbered N. Only siblings + and children of the specified DIE will be printed. + + This can be used in conjunction with '--dwarf-depth'. + +'--dwarf-check' + Enable additional checks for consistency of Dwarf information. + +'-G' +'--stabs' + Display the full contents of any sections requested. Display the + contents of the .stab and .stab.index and .stab.excl sections from + an ELF file. This is only useful on systems (such as Solaris 2.0) + in which '.stab' debugging symbol-table entries are carried in an + ELF section. In most other file formats, debugging symbol-table + entries are interleaved with linkage symbols, and are visible in + the '--syms' output. + +'--start-address=ADDRESS' + Start displaying data at the specified address. This affects the + output of the '-d', '-r' and '-s' options. + +'--stop-address=ADDRESS' + Stop displaying data at the specified address. This affects the + output of the '-d', '-r' and '-s' options. + +'-t' +'--syms' + Print the symbol table entries of the file. This is similar to the + information provided by the 'nm' program, although the display + format is different. The format of the output depends upon the + format of the file being dumped, but there are two main types. One + looks like this: + + [ 4](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss + [ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 fred + + where the number inside the square brackets is the number of the + entry in the symbol table, the SEC number is the section number, + the FL value are the symbol's flag bits, the TY number is the + symbol's type, the SCL number is the symbol's storage class and the + NX value is the number of auxilary entries associated with the + symbol. The last two fields are the symbol's value and its name. + + The other common output format, usually seen with ELF based files, + looks like this: + + 00000000 l d .bss 00000000 .bss + 00000000 g .text 00000000 fred + + Here the first number is the symbol's value (sometimes refered to + as its address). The next field is actually a set of characters + and spaces indicating the flag bits that are set on the symbol. + These characters are described below. Next is the section with + which the symbol is associated or _*ABS*_ if the section is + absolute (ie not connected with any section), or _*UND*_ if the + section is referenced in the file being dumped, but not defined + there. + + After the section name comes another field, a number, which for + common symbols is the alignment and for other symbol is the size. + Finally the symbol's name is displayed. + + The flag characters are divided into 7 groups as follows: + 'l' + 'g' + 'u' + '!' + The symbol is a local (l), global (g), unique global (u), + neither global nor local (a space) or both global and local + (!). A symbol can be neither local or global for a variety of + reasons, e.g., because it is used for debugging, but it is + probably an indication of a bug if it is ever both local and + global. Unique global symbols are a GNU extension to the + standard set of ELF symbol bindings. For such a symbol the + dynamic linker will make sure that in the entire process there + is just one symbol with this name and type in use. + + 'w' + The symbol is weak (w) or strong (a space). + + 'C' + The symbol denotes a constructor (C) or an ordinary symbol (a + space). + + 'W' + The symbol is a warning (W) or a normal symbol (a space). A + warning symbol's name is a message to be displayed if the + symbol following the warning symbol is ever referenced. + + 'I' + 'i' + The symbol is an indirect reference to another symbol (I), a + function to be evaluated during reloc processing (i) or a + normal symbol (a space). + + 'd' + 'D' + The symbol is a debugging symbol (d) or a dynamic symbol (D) + or a normal symbol (a space). + + 'F' + 'f' + 'O' + The symbol is the name of a function (F) or a file (f) or an + object (O) or just a normal symbol (a space). + +'-T' +'--dynamic-syms' + Print the dynamic symbol table entries of the file. This is only + meaningful for dynamic objects, such as certain types of shared + libraries. This is similar to the information provided by the 'nm' + program when given the '-D' ('--dynamic') option. + + The output format is similar to that produced by the '--syms' + option, except that an extra field is inserted before the symbol's + name, giving the version information associated with the symbol. + If the version is the default version to be used when resolving + unversioned references to the symbol then it's displayed as is, + otherwise it's put into parentheses. + +'--special-syms' + When displaying symbols include those which the target considers to + be special in some way and which would not normally be of interest + to the user. + +'-V' +'--version' + Print the version number of 'objdump' and exit. + +'-x' +'--all-headers' + Display all available header information, including the symbol + table and relocation entries. Using '-x' is equivalent to + specifying all of '-a -f -h -p -r -t'. + +'-w' +'--wide' + Format some lines for output devices that have more than 80 + columns. Also do not truncate symbol names when they are + displayed. + +'-z' +'--disassemble-zeroes' + Normally the disassembly output will skip blocks of zeroes. This + option directs the disassembler to disassemble those blocks, just + like any other data. + + +File: binutils.info, Node: ranlib, Next: size, Prev: objdump, Up: Top + +5 ranlib +******** + + ranlib [--plugin NAME] [-DhHvVt] ARCHIVE + + 'ranlib' generates an index to the contents of an archive and stores +it in the archive. The index lists each symbol defined by a member of +an archive that is a relocatable object file. + + You may use 'nm -s' or 'nm --print-armap' to list this index. + + An archive with such an index speeds up linking to the library and +allows routines in the library to call each other without regard to +their placement in the archive. + + The GNU 'ranlib' program is another form of GNU 'ar'; running +'ranlib' is completely equivalent to executing 'ar -s'. *Note ar::. + +'-h' +'-H' +'--help' + Show usage information for 'ranlib'. + +'-v' +'-V' +'--version' + Show the version number of 'ranlib'. + +'-D' + Operate in _deterministic_ mode. The symbol map archive member's + header will show zero for the UID, GID, and timestamp. When this + option is used, multiple runs will produce identical output files. + + If 'binutils' was configured with + '--enable-deterministic-archives', then this mode is on by default. + It can be disabled with the '-U' option, described below. + +'-t' + Update the timestamp of the symbol map of an archive. + +'-U' + Do _not_ operate in _deterministic_ mode. This is the inverse of + the '-D' option, above: the archive index will get actual UID, GID, + timestamp, and file mode values. + + If 'binutils' was configured _without_ + '--enable-deterministic-archives', then this mode is on by default. + + +File: binutils.info, Node: size, Next: strings, Prev: ranlib, Up: Top + +6 size +****** + + size [-A|-B|--format=COMPATIBILITY] + [--help] + [-d|-o|-x|--radix=NUMBER] + [--common] + [-t|--totals] + [--target=BFDNAME] [-V|--version] + [OBJFILE...] + + The GNU 'size' utility lists the section sizes--and the total +size--for each of the object or archive files OBJFILE in its argument +list. By default, one line of output is generated for each object file +or each module in an archive. + + OBJFILE... are the object files to be examined. If none are +specified, the file 'a.out' will be used. + + The command line options have the following meanings: + +'-A' +'-B' +'--format=COMPATIBILITY' + Using one of these options, you can choose whether the output from + GNU 'size' resembles output from System V 'size' (using '-A', or + '--format=sysv'), or Berkeley 'size' (using '-B', or + '--format=berkeley'). The default is the one-line format similar + to Berkeley's. + + Here is an example of the Berkeley (default) format of output from + 'size': + $ size --format=Berkeley ranlib size + text data bss dec hex filename + 294880 81920 11592 388392 5ed28 ranlib + 294880 81920 11888 388688 5ee50 size + + This is the same data, but displayed closer to System V + conventions: + + $ size --format=SysV ranlib size + ranlib : + section size addr + .text 294880 8192 + .data 81920 303104 + .bss 11592 385024 + Total 388392 + + + size : + section size addr + .text 294880 8192 + .data 81920 303104 + .bss 11888 385024 + Total 388688 + +'--help' + Show a summary of acceptable arguments and options. + +'-d' +'-o' +'-x' +'--radix=NUMBER' + Using one of these options, you can control whether the size of + each section is given in decimal ('-d', or '--radix=10'); octal + ('-o', or '--radix=8'); or hexadecimal ('-x', or '--radix=16'). In + '--radix=NUMBER', only the three values (8, 10, 16) are supported. + The total size is always given in two radices; decimal and + hexadecimal for '-d' or '-x' output, or octal and hexadecimal if + you're using '-o'. + +'--common' + Print total size of common symbols in each file. When using + Berkeley format these are included in the bss size. + +'-t' +'--totals' + Show totals of all objects listed (Berkeley format listing mode + only). + +'--target=BFDNAME' + Specify that the object-code format for OBJFILE is BFDNAME. This + option may not be necessary; 'size' can automatically recognize + many formats. *Note Target Selection::, for more information. + +'-V' +'--version' + Display the version number of 'size'. + + +File: binutils.info, Node: strings, Next: strip, Prev: size, Up: Top + +7 strings +********* + + strings [-afovV] [-MIN-LEN] + [-n MIN-LEN] [--bytes=MIN-LEN] + [-t RADIX] [--radix=RADIX] + [-e ENCODING] [--encoding=ENCODING] + [-] [--all] [--print-file-name] + [-T BFDNAME] [--target=BFDNAME] + [-w] [--include-all-whitespace] + [-s] [--output-separatorSEP_STRING] + [--help] [--version] FILE... + + For each FILE given, GNU 'strings' prints the printable character +sequences that are at least 4 characters long (or the number given with +the options below) and are followed by an unprintable character. + + Depending upon how the strings program was configured it will default +to either displaying all the printable sequences that it can find in +each file, or only those sequences that are in loadable, initialized +data sections. If the file type in unrecognizable, or if strings is +reading from stdin then it will always display all of the printable +sequences that it can find. + + For backwards compatibility any file that occurs after a command line +option of just '-' will also be scanned in full, regardless of the +presence of any '-d' option. + + 'strings' is mainly useful for determining the contents of non-text +files. + +'-a' +'--all' +'-' + Scan the whole file, regardless of what sections it contains or + whether those sections are loaded or initialized. Normally this is + the default behaviour, but strings can be configured so that the + '-d' is the default instead. + + The '-' option is position dependent and forces strings to perform + full scans of any file that is mentioned after the '-' on the + command line, even if the '-d' option has been specified. + +'-d' +'--data' + Only print strings from initialized, loaded data sections in the + file. This may reduce the amount of garbage in the output, but it + also exposes the strings program to any security flaws that may be + present in the BFD library used to scan and load sections. Strings + can be configured so that this option is the default behaviour. In + such cases the '-a' option can be used to avoid using the BFD + library and instead just print all of the strings found in the + file. + +'-f' +'--print-file-name' + Print the name of the file before each string. + +'--help' + Print a summary of the program usage on the standard output and + exit. + +'-MIN-LEN' +'-n MIN-LEN' +'--bytes=MIN-LEN' + Print sequences of characters that are at least MIN-LEN characters + long, instead of the default 4. + +'-o' + Like '-t o'. Some other versions of 'strings' have '-o' act like + '-t d' instead. Since we can not be compatible with both ways, we + simply chose one. + +'-t RADIX' +'--radix=RADIX' + Print the offset within the file before each string. The single + character argument specifies the radix of the offset--'o' for + octal, 'x' for hexadecimal, or 'd' for decimal. + +'-e ENCODING' +'--encoding=ENCODING' + Select the character encoding of the strings that are to be found. + Possible values for ENCODING are: 's' = single-7-bit-byte + characters (ASCII, ISO 8859, etc., default), 'S' = + single-8-bit-byte characters, 'b' = 16-bit bigendian, 'l' = 16-bit + littleendian, 'B' = 32-bit bigendian, 'L' = 32-bit littleendian. + Useful for finding wide character strings. ('l' and 'b' apply to, + for example, Unicode UTF-16/UCS-2 encodings). + +'-T BFDNAME' +'--target=BFDNAME' + Specify an object code format other than your system's default + format. *Note Target Selection::, for more information. + +'-v' +'-V' +'--version' + Print the program version number on the standard output and exit. + +'-w' +'--include-all-whitespace' + By default tab and space characters are included in the strings + that are displayed, but other whitespace characters, such a + newlines and carriage returns, are not. The '-w' option changes + this so that all whitespace characters are considered to be part of + a string. + +'-s' +'--output-separator' + By default, output strings are delimited by a new-line. This + option allows you to supply any string to be used as the output + record separator. Useful with -include-all-whitespace where + strings may contain new-lines internally. + + +File: binutils.info, Node: strip, Next: c++filt, Prev: strings, Up: Top + +8 strip +******* + + strip [-F BFDNAME |--target=BFDNAME] + [-I BFDNAME |--input-target=BFDNAME] + [-O BFDNAME |--output-target=BFDNAME] + [-s|--strip-all] + [-S|-g|-d|--strip-debug] + [--strip-dwo] + [-K SYMBOLNAME|--keep-symbol=SYMBOLNAME] + [-M|--merge-notes][--no-merge-notes] + [-N SYMBOLNAME |--strip-symbol=SYMBOLNAME] + [-w|--wildcard] + [-x|--discard-all] [-X |--discard-locals] + [-R SECTIONNAME |--remove-section=SECTIONNAME] + [--remove-relocations=SECTIONPATTERN] + [-o FILE] [-p|--preserve-dates] + [-D|--enable-deterministic-archives] + [-U|--disable-deterministic-archives] + [--keep-file-symbols] + [--only-keep-debug] + [-v |--verbose] [-V|--version] + [--help] [--info] + OBJFILE... + + GNU 'strip' discards all symbols from object files OBJFILE. The list +of object files may include archives. At least one object file must be +given. + + 'strip' modifies the files named in its argument, rather than writing +modified copies under different names. + +'-F BFDNAME' +'--target=BFDNAME' + Treat the original OBJFILE as a file with the object code format + BFDNAME, and rewrite it in the same format. *Note Target + Selection::, for more information. + +'--help' + Show a summary of the options to 'strip' and exit. + +'--info' + Display a list showing all architectures and object formats + available. + +'-I BFDNAME' +'--input-target=BFDNAME' + Treat the original OBJFILE as a file with the object code format + BFDNAME. *Note Target Selection::, for more information. + +'-O BFDNAME' +'--output-target=BFDNAME' + Replace OBJFILE with a file in the output format BFDNAME. *Note + Target Selection::, for more information. + +'-R SECTIONNAME' +'--remove-section=SECTIONNAME' + Remove any section named SECTIONNAME from the output file, in + addition to whatever sections would otherwise be removed. This + option may be given more than once. Note that using this option + inappropriately may make the output file unusable. The wildcard + character '*' may be given at the end of SECTIONNAME. If so, then + any section starting with SECTIONNAME will be removed. + + If the first character of SECTIONPATTERN is the exclamation point + (!) then matching sections will not be removed even if an earlier + use of '--remove-section' on the same command line would otherwise + remove it. For example: + + --remove-section=.text.* --remove-section=!.text.foo + + will remove all sections matching the pattern '.text.*', but will + not remove the section '.text.foo'. + +'--remove-relocations=SECTIONPATTERN' + Remove relocations from the output file for any section matching + SECTIONPATTERN. This option may be given more than once. Note + that using this option inappropriately may make the output file + unusable. Wildcard characters are accepted in SECTIONPATTERN. For + example: + + --remove-relocations=.text.* + + will remove the relocations for all sections matching the patter + '.text.*'. + + If the first character of SECTIONPATTERN is the exclamation point + (!) then matching sections will not have their relocation removed + even if an earlier use of '--remove-relocations' on the same + command line would otherwise cause the relocations to be removed. + For example: + + --remove-relocations=.text.* --remove-relocations=!.text.foo + + will remove all relocations for sections matching the pattern + '.text.*', but will not remove relocations for the section + '.text.foo'. + +'-s' +'--strip-all' + Remove all symbols. + +'-g' +'-S' +'-d' +'--strip-debug' + Remove debugging symbols only. + +'--strip-dwo' + Remove the contents of all DWARF .dwo sections, leaving the + remaining debugging sections and all symbols intact. See the + description of this option in the 'objcopy' section for more + information. + +'--strip-unneeded' + Remove all symbols that are not needed for relocation processing. + +'-K SYMBOLNAME' +'--keep-symbol=SYMBOLNAME' + When stripping symbols, keep symbol SYMBOLNAME even if it would + normally be stripped. This option may be given more than once. + +'-M' +'--merge-notes' +'--no-merge-notes' + For ELF files, attempt (or do not attempt) to reduce the size of + any SHT_NOTE type sections by removing duplicate notes. The + default is to attempt this reduction. + +'-N SYMBOLNAME' +'--strip-symbol=SYMBOLNAME' + Remove symbol SYMBOLNAME from the source file. This option may be + given more than once, and may be combined with strip options other + than '-K'. + +'-o FILE' + Put the stripped output in FILE, rather than replacing the existing + file. When this argument is used, only one OBJFILE argument may be + specified. + +'-p' +'--preserve-dates' + Preserve the access and modification dates of the file. + +'-D' +'--enable-deterministic-archives' + Operate in _deterministic_ mode. When copying archive members and + writing the archive index, use zero for UIDs, GIDs, timestamps, and + use consistent file modes for all files. + + If 'binutils' was configured with + '--enable-deterministic-archives', then this mode is on by default. + It can be disabled with the '-U' option, below. + +'-U' +'--disable-deterministic-archives' + Do _not_ operate in _deterministic_ mode. This is the inverse of + the '-D' option, above: when copying archive members and writing + the archive index, use their actual UID, GID, timestamp, and file + mode values. + + This is the default unless 'binutils' was configured with + '--enable-deterministic-archives'. + +'-w' +'--wildcard' + Permit regular expressions in SYMBOLNAMEs used in other command + line options. The question mark (?), asterisk (*), backslash (\) + and square brackets ([]) operators can be used anywhere in the + symbol name. If the first character of the symbol name is the + exclamation point (!) then the sense of the switch is reversed for + that symbol. For example: + + -w -K !foo -K fo* + + would cause strip to only keep symbols that start with the letters + "fo", but to discard the symbol "foo". + +'-x' +'--discard-all' + Remove non-global symbols. + +'-X' +'--discard-locals' + Remove compiler-generated local symbols. (These usually start with + 'L' or '.'.) + +'--keep-file-symbols' + When stripping a file, perhaps with '--strip-debug' or + '--strip-unneeded', retain any symbols specifying source file + names, which would otherwise get stripped. + +'--only-keep-debug' + Strip a file, emptying the contents of any sections that would not + be stripped by '--strip-debug' and leaving the debugging sections + intact. In ELF files, this preserves all the note sections in the + output as well. + + Note - the section headers of the stripped sections are preserved, + including their sizes, but the contents of the section are + discarded. The section headers are preserved so that other tools + can match up the debuginfo file with the real executable, even if + that executable has been relocated to a different address space. + + The intention is that this option will be used in conjunction with + '--add-gnu-debuglink' to create a two part executable. One a + stripped binary which will occupy less space in RAM and in a + distribution and the second a debugging information file which is + only needed if debugging abilities are required. The suggested + procedure to create these files is as follows: + + 1. Link the executable as normal. Assuming that is is called + 'foo' then... + 2. Run 'objcopy --only-keep-debug foo foo.dbg' to create a file + containing the debugging info. + 3. Run 'objcopy --strip-debug foo' to create a stripped + executable. + 4. Run 'objcopy --add-gnu-debuglink=foo.dbg foo' to add a link to + the debugging info into the stripped executable. + + Note--the choice of '.dbg' as an extension for the debug info file + is arbitrary. Also the '--only-keep-debug' step is optional. You + could instead do this: + + 1. Link the executable as normal. + 2. Copy 'foo' to 'foo.full' + 3. Run 'strip --strip-debug foo' + 4. Run 'objcopy --add-gnu-debuglink=foo.full foo' + + i.e., the file pointed to by the '--add-gnu-debuglink' can be the + full executable. It does not have to be a file created by the + '--only-keep-debug' switch. + + Note--this switch is only intended for use on fully linked files. + It does not make sense to use it on object files where the + debugging information may be incomplete. Besides the gnu_debuglink + feature currently only supports the presence of one filename + containing debugging information, not multiple filenames on a + one-per-object-file basis. + +'-V' +'--version' + Show the version number for 'strip'. + +'-v' +'--verbose' + Verbose output: list all object files modified. In the case of + archives, 'strip -v' lists all members of the archive. + + +File: binutils.info, Node: c++filt, Next: addr2line, Prev: strip, Up: Top + +9 c++filt +********* + + c++filt [-_|--strip-underscore] + [-n|--no-strip-underscore] + [-p|--no-params] + [-t|--types] + [-i|--no-verbose] + [-s FORMAT|--format=FORMAT] + [--help] [--version] [SYMBOL...] + + The C++ and Java languages provide function overloading, which means +that you can write many functions with the same name, providing that +each function takes parameters of different types. In order to be able +to distinguish these similarly named functions C++ and Java encode them +into a low-level assembler name which uniquely identifies each different +version. This process is known as "mangling". The 'c++filt' (1) +program does the inverse mapping: it decodes ("demangles") low-level +names into user-level names so that they can be read. + + Every alphanumeric word (consisting of letters, digits, underscores, +dollars, or periods) seen in the input is a potential mangled name. If +the name decodes into a C++ name, the C++ name replaces the low-level +name in the output, otherwise the original word is output. In this way +you can pass an entire assembler source file, containing mangled names, +through 'c++filt' and see the same source file containing demangled +names. + + You can also use 'c++filt' to decipher individual symbols by passing +them on the command line: + + c++filt SYMBOL + + If no SYMBOL arguments are given, 'c++filt' reads symbol names from +the standard input instead. All the results are printed on the standard +output. The difference between reading names from the command line +versus reading names from the standard input is that command line +arguments are expected to be just mangled names and no checking is +performed to separate them from surrounding text. Thus for example: + + c++filt -n _Z1fv + + will work and demangle the name to "f()" whereas: + + c++filt -n _Z1fv, + + will not work. (Note the extra comma at the end of the mangled name +which makes it invalid). This command however will work: + + echo _Z1fv, | c++filt -n + + and will display "f(),", i.e., the demangled name followed by a +trailing comma. This behaviour is because when the names are read from +the standard input it is expected that they might be part of an +assembler source file where there might be extra, extraneous characters +trailing after a mangled name. For example: + + .type _Z1fv, @function + +'-_' +'--strip-underscore' + On some systems, both the C and C++ compilers put an underscore in + front of every name. For example, the C name 'foo' gets the + low-level name '_foo'. This option removes the initial underscore. + Whether 'c++filt' removes the underscore by default is target + dependent. + +'-n' +'--no-strip-underscore' + Do not remove the initial underscore. + +'-p' +'--no-params' + When demangling the name of a function, do not display the types of + the function's parameters. + +'-t' +'--types' + Attempt to demangle types as well as function names. This is + disabled by default since mangled types are normally only used + internally in the compiler, and they can be confused with + non-mangled names. For example, a function called "a" treated as a + mangled type name would be demangled to "signed char". + +'-i' +'--no-verbose' + Do not include implementation details (if any) in the demangled + output. + +'-s FORMAT' +'--format=FORMAT' + 'c++filt' can decode various methods of mangling, used by different + compilers. The argument to this option selects which method it + uses: + + 'auto' + Automatic selection based on executable (the default method) + 'gnu' + the one used by the GNU C++ compiler (g++) + 'lucid' + the one used by the Lucid compiler (lcc) + 'arm' + the one specified by the C++ Annotated Reference Manual + 'hp' + the one used by the HP compiler (aCC) + 'edg' + the one used by the EDG compiler + 'gnu-v3' + the one used by the GNU C++ compiler (g++) with the V3 ABI. + 'java' + the one used by the GNU Java compiler (gcj) + 'gnat' + the one used by the GNU Ada compiler (GNAT). + +'--help' + Print a summary of the options to 'c++filt' and exit. + +'--version' + Print the version number of 'c++filt' and exit. + + _Warning:_ 'c++filt' is a new utility, and the details of its user + interface are subject to change in future releases. In particular, + a command-line option may be required in the future to decode a + name passed as an argument on the command line; in other words, + + c++filt SYMBOL + + may in a future release become + + c++filt OPTION SYMBOL + + ---------- Footnotes ---------- + + (1) MS-DOS does not allow '+' characters in file names, so on MS-DOS +this program is named 'CXXFILT'. + + +File: binutils.info, Node: addr2line, Next: nlmconv, Prev: c++filt, Up: Top + +10 addr2line +************ + + addr2line [-a|--addresses] + [-b BFDNAME|--target=BFDNAME] + [-C|--demangle[=STYLE]] + [-e FILENAME|--exe=FILENAME] + [-f|--functions] [-s|--basename] + [-i|--inlines] + [-p|--pretty-print] + [-j|--section=NAME] + [-H|--help] [-V|--version] + [addr addr ...] + + 'addr2line' translates addresses into file names and line numbers. +Given an address in an executable or an offset in a section of a +relocatable object, it uses the debugging information to figure out +which file name and line number are associated with it. + + The executable or relocatable object to use is specified with the +'-e' option. The default is the file 'a.out'. The section in the +relocatable object to use is specified with the '-j' option. + + 'addr2line' has two modes of operation. + + In the first, hexadecimal addresses are specified on the command +line, and 'addr2line' displays the file name and line number for each +address. + + In the second, 'addr2line' reads hexadecimal addresses from standard +input, and prints the file name and line number for each address on +standard output. In this mode, 'addr2line' may be used in a pipe to +convert dynamically chosen addresses. + + The format of the output is 'FILENAME:LINENO'. By default each input +address generates one line of output. + + Two options can generate additional lines before each +'FILENAME:LINENO' line (in that order). + + If the '-a' option is used then a line with the input address is +displayed. + + If the '-f' option is used, then a line with the 'FUNCTIONNAME' is +displayed. This is the name of the function containing the address. + + One option can generate additional lines after the 'FILENAME:LINENO' +line. + + If the '-i' option is used and the code at the given address is +present there because of inlining by the compiler then additional lines +are displayed afterwards. One or two extra lines (if the '-f' option is +used) are displayed for each inlined function. + + Alternatively if the '-p' option is used then each input address +generates a single, long, output line containing the address, the +function name, the file name and the line number. If the '-i' option +has also been used then any inlined functions will be displayed in the +same manner, but on separate lines, and prefixed by the text '(inlined +by)'. + + If the file name or function name can not be determined, 'addr2line' +will print two question marks in their place. If the line number can +not be determined, 'addr2line' will print 0. + + The long and short forms of options, shown here as alternatives, are +equivalent. + +'-a' +'--addresses' + Display the address before the function name, file and line number + information. The address is printed with a '0x' prefix to easily + identify it. + +'-b BFDNAME' +'--target=BFDNAME' + Specify that the object-code format for the object files is + BFDNAME. + +'-C' +'--demangle[=STYLE]' + Decode ("demangle") low-level symbol names into user-level names. + Besides removing any initial underscore prepended by the system, + this makes C++ function names readable. Different compilers have + different mangling styles. The optional demangling style argument + can be used to choose an appropriate demangling style for your + compiler. *Note c++filt::, for more information on demangling. + +'-e FILENAME' +'--exe=FILENAME' + Specify the name of the executable for which addresses should be + translated. The default file is 'a.out'. + +'-f' +'--functions' + Display function names as well as file and line number information. + +'-s' +'--basenames' + Display only the base of each file name. + +'-i' +'--inlines' + If the address belongs to a function that was inlined, the source + information for all enclosing scopes back to the first non-inlined + function will also be printed. For example, if 'main' inlines + 'callee1' which inlines 'callee2', and address is from 'callee2', + the source information for 'callee1' and 'main' will also be + printed. + +'-j' +'--section' + Read offsets relative to the specified section instead of absolute + addresses. + +'-p' +'--pretty-print' + Make the output more human friendly: each location are printed on + one line. If option '-i' is specified, lines for all enclosing + scopes are prefixed with '(inlined by)'. + + +File: binutils.info, Node: nlmconv, Next: windmc, Prev: addr2line, Up: Top + +11 nlmconv +********** + +'nlmconv' converts a relocatable object file into a NetWare Loadable +Module. + + _Warning:_ 'nlmconv' is not always built as part of the binary + utilities, since it is only useful for NLM targets. + + nlmconv [-I BFDNAME|--input-target=BFDNAME] + [-O BFDNAME|--output-target=BFDNAME] + [-T HEADERFILE|--header-file=HEADERFILE] + [-d|--debug] [-l LINKER|--linker=LINKER] + [-h|--help] [-V|--version] + INFILE OUTFILE + + 'nlmconv' converts the relocatable 'i386' object file INFILE into the +NetWare Loadable Module OUTFILE, optionally reading HEADERFILE for NLM +header information. For instructions on writing the NLM command file +language used in header files, see the 'linkers' section, 'NLMLINK' in +particular, of the 'NLM Development and Tools Overview', which is part +of the NLM Software Developer's Kit ("NLM SDK"), available from Novell, +Inc. 'nlmconv' uses the GNU Binary File Descriptor library to read +INFILE; see *note BFD: (ld.info)BFD, for more information. + + 'nlmconv' can perform a link step. In other words, you can list more +than one object file for input if you list them in the definitions file +(rather than simply specifying one input file on the command line). In +this case, 'nlmconv' calls the linker for you. + +'-I BFDNAME' +'--input-target=BFDNAME' + Object format of the input file. 'nlmconv' can usually determine + the format of a given file (so no default is necessary). *Note + Target Selection::, for more information. + +'-O BFDNAME' +'--output-target=BFDNAME' + Object format of the output file. 'nlmconv' infers the output + format based on the input format, e.g. for a 'i386' input file the + output format is 'nlm32-i386'. *Note Target Selection::, for more + information. + +'-T HEADERFILE' +'--header-file=HEADERFILE' + Reads HEADERFILE for NLM header information. For instructions on + writing the NLM command file language used in header files, see see + the 'linkers' section, of the 'NLM Development and Tools Overview', + which is part of the NLM Software Developer's Kit, available from + Novell, Inc. + +'-d' +'--debug' + Displays (on standard error) the linker command line used by + 'nlmconv'. + +'-l LINKER' +'--linker=LINKER' + Use LINKER for any linking. LINKER can be an absolute or a + relative pathname. + +'-h' +'--help' + Prints a usage summary. + +'-V' +'--version' + Prints the version number for 'nlmconv'. + + +File: binutils.info, Node: windmc, Next: windres, Prev: nlmconv, Up: Top + +12 windmc +********* + +'windmc' may be used to generator Windows message resources. + + _Warning:_ 'windmc' is not always built as part of the binary + utilities, since it is only useful for Windows targets. + + windmc [options] input-file + + 'windmc' reads message definitions from an input file (.mc) and +translate them into a set of output files. The output files may be of +four kinds: + +'h' + A C header file containing the message definitions. + +'rc' + A resource file compilable by the 'windres' tool. + +'bin' + One or more binary files containing the resource data for a + specific message language. + +'dbg' + A C include file that maps message id's to their symbolic name. + + The exact description of these different formats is available in +documentation from Microsoft. + + When 'windmc' converts from the 'mc' format to the 'bin' format, +'rc', 'h', and optional 'dbg' it is acting like the Windows Message +Compiler. + +'-a' +'--ascii_in' + Specifies that the input file specified is ASCII. This is the + default behaviour. + +'-A' +'--ascii_out' + Specifies that messages in the output 'bin' files should be in + ASCII format. + +'-b' +'--binprefix' + Specifies that 'bin' filenames should have to be prefixed by the + basename of the source file. + +'-c' +'--customflag' + Sets the customer bit in all message id's. + +'-C CODEPAGE' +'--codepage_in CODEPAGE' + Sets the default codepage to be used to convert input file to + UTF16. The default is ocdepage 1252. + +'-d' +'--decimal_values' + Outputs the constants in the header file in decimal. Default is + using hexadecimal output. + +'-e EXT' +'--extension EXT' + The extension for the header file. The default is .h extension. + +'-F TARGET' +'--target TARGET' + Specify the BFD format to use for a bin file as output. This is a + BFD target name; you can use the '--help' option to see a list of + supported targets. Normally 'windmc' will use the default format, + which is the first one listed by the '--help' option. *note Target + Selection::. + +'-h PATH' +'--headerdir PATH' + The target directory of the generated header file. The default is + the current directory. + +'-H' +'--help' + Displays a list of command line options and then exits. + +'-m CHARACTERS' +'--maxlength CHARACTERS' + Instructs 'windmc' to generate a warning if the length of any + message exceeds the number specified. + +'-n' +'--nullterminate' + Terminate message text in 'bin' files by zero. By default they are + terminated by CR/LF. + +'-o' +'--hresult_use' + Not yet implemented. Instructs 'windmc' to generate an OLE2 header + file, using HRESULT definitions. Status codes are used if the flag + is not specified. + +'-O CODEPAGE' +'--codepage_out CODEPAGE' + Sets the default codepage to be used to output text files. The + default is ocdepage 1252. + +'-r PATH' +'--rcdir PATH' + The target directory for the generated 'rc' script and the + generated 'bin' files that the resource compiler script includes. + The default is the current directory. + +'-u' +'--unicode_in' + Specifies that the input file is UTF16. + +'-U' +'--unicode_out' + Specifies that messages in the output 'bin' file should be in UTF16 + format. This is the default behaviour. + +'-v' +'--verbose' + Enable verbose mode. + +'-V' +'--version' + Prints the version number for 'windmc'. + +'-x PATH' +'--xdgb PATH' + The path of the 'dbg' C include file that maps message id's to the + symbolic name. No such file is generated without specifying the + switch. + + +File: binutils.info, Node: windres, Next: dlltool, Prev: windmc, Up: Top + +13 windres +********** + +'windres' may be used to manipulate Windows resources. + + _Warning:_ 'windres' is not always built as part of the binary + utilities, since it is only useful for Windows targets. + + windres [options] [input-file] [output-file] + + 'windres' reads resources from an input file and copies them into an +output file. Either file may be in one of three formats: + +'rc' + A text format read by the Resource Compiler. + +'res' + A binary format generated by the Resource Compiler. + +'coff' + A COFF object or executable. + + The exact description of these different formats is available in +documentation from Microsoft. + + When 'windres' converts from the 'rc' format to the 'res' format, it +is acting like the Windows Resource Compiler. When 'windres' converts +from the 'res' format to the 'coff' format, it is acting like the +Windows 'CVTRES' program. + + When 'windres' generates an 'rc' file, the output is similar but not +identical to the format expected for the input. When an input 'rc' file +refers to an external filename, an output 'rc' file will instead include +the file contents. + + If the input or output format is not specified, 'windres' will guess +based on the file name, or, for the input file, the file contents. A +file with an extension of '.rc' will be treated as an 'rc' file, a file +with an extension of '.res' will be treated as a 'res' file, and a file +with an extension of '.o' or '.exe' will be treated as a 'coff' file. + + If no output file is specified, 'windres' will print the resources in +'rc' format to standard output. + + The normal use is for you to write an 'rc' file, use 'windres' to +convert it to a COFF object file, and then link the COFF file into your +application. This will make the resources described in the 'rc' file +available to Windows. + +'-i FILENAME' +'--input FILENAME' + The name of the input file. If this option is not used, then + 'windres' will use the first non-option argument as the input file + name. If there are no non-option arguments, then 'windres' will + read from standard input. 'windres' can not read a COFF file from + standard input. + +'-o FILENAME' +'--output FILENAME' + The name of the output file. If this option is not used, then + 'windres' will use the first non-option argument, after any used + for the input file name, as the output file name. If there is no + non-option argument, then 'windres' will write to standard output. + 'windres' can not write a COFF file to standard output. Note, for + compatibility with 'rc' the option '-fo' is also accepted, but its + use is not recommended. + +'-J FORMAT' +'--input-format FORMAT' + The input format to read. FORMAT may be 'res', 'rc', or 'coff'. + If no input format is specified, 'windres' will guess, as described + above. + +'-O FORMAT' +'--output-format FORMAT' + The output format to generate. FORMAT may be 'res', 'rc', or + 'coff'. If no output format is specified, 'windres' will guess, as + described above. + +'-F TARGET' +'--target TARGET' + Specify the BFD format to use for a COFF file as input or output. + This is a BFD target name; you can use the '--help' option to see a + list of supported targets. Normally 'windres' will use the default + format, which is the first one listed by the '--help' option. + *note Target Selection::. + +'--preprocessor PROGRAM' + When 'windres' reads an 'rc' file, it runs it through the C + preprocessor first. This option may be used to specify the + preprocessor to use, including any leading arguments. The default + preprocessor argument is 'gcc -E -xc-header -DRC_INVOKED'. + +'--preprocessor-arg OPTION' + When 'windres' reads an 'rc' file, it runs it through the C + preprocessor first. This option may be used to specify additional + text to be passed to preprocessor on its command line. This option + can be used multiple times to add multiple options to the + preprocessor command line. + +'-I DIRECTORY' +'--include-dir DIRECTORY' + Specify an include directory to use when reading an 'rc' file. + 'windres' will pass this to the preprocessor as an '-I' option. + 'windres' will also search this directory when looking for files + named in the 'rc' file. If the argument passed to this command + matches any of the supported FORMATS (as described in the '-J' + option), it will issue a deprecation warning, and behave just like + the '-J' option. New programs should not use this behaviour. If a + directory happens to match a FORMAT, simple prefix it with './' to + disable the backward compatibility. + +'-D TARGET' +'--define SYM[=VAL]' + Specify a '-D' option to pass to the preprocessor when reading an + 'rc' file. + +'-U TARGET' +'--undefine SYM' + Specify a '-U' option to pass to the preprocessor when reading an + 'rc' file. + +'-r' + Ignored for compatibility with rc. + +'-v' + Enable verbose mode. This tells you what the preprocessor is if + you didn't specify one. + +'-c VAL' +'--codepage VAL' + Specify the default codepage to use when reading an 'rc' file. VAL + should be a hexadecimal prefixed by '0x' or decimal codepage code. + The valid range is from zero up to 0xffff, but the validity of the + codepage is host and configuration dependent. + +'-l VAL' +'--language VAL' + Specify the default language to use when reading an 'rc' file. VAL + should be a hexadecimal language code. The low eight bits are the + language, and the high eight bits are the sublanguage. + +'--use-temp-file' + Use a temporary file to instead of using popen to read the output + of the preprocessor. Use this option if the popen implementation + is buggy on the host (eg., certain non-English language versions of + Windows 95 and Windows 98 are known to have buggy popen where the + output will instead go the console). + +'--no-use-temp-file' + Use popen, not a temporary file, to read the output of the + preprocessor. This is the default behaviour. + +'-h' +'--help' + Prints a usage summary. + +'-V' +'--version' + Prints the version number for 'windres'. + +'--yydebug' + If 'windres' is compiled with 'YYDEBUG' defined as '1', this will + turn on parser debugging. + + +File: binutils.info, Node: dlltool, Next: readelf, Prev: windres, Up: Top + +14 dlltool +********** + +'dlltool' is used to create the files needed to create dynamic link +libraries (DLLs) on systems which understand PE format image files such +as Windows. A DLL contains an export table which contains information +that the runtime loader needs to resolve references from a referencing +program. + + The export table is generated by this program by reading in a '.def' +file or scanning the '.a' and '.o' files which will be in the DLL. A +'.o' file can contain information in special '.drectve' sections with +export information. + + _Note:_ 'dlltool' is not always built as part of the binary + utilities, since it is only useful for those targets which support + DLLs. + + dlltool [-d|--input-def DEF-FILE-NAME] + [-b|--base-file BASE-FILE-NAME] + [-e|--output-exp EXPORTS-FILE-NAME] + [-z|--output-def DEF-FILE-NAME] + [-l|--output-lib LIBRARY-FILE-NAME] + [-y|--output-delaylib LIBRARY-FILE-NAME] + [--export-all-symbols] [--no-export-all-symbols] + [--exclude-symbols LIST] + [--no-default-excludes] + [-S|--as PATH-TO-ASSEMBLER] [-f|--as-flags OPTIONS] + [-D|--dllname NAME] [-m|--machine MACHINE] + [-a|--add-indirect] + [-U|--add-underscore] [--add-stdcall-underscore] + [-k|--kill-at] [-A|--add-stdcall-alias] + [-p|--ext-prefix-alias PREFIX] + [-x|--no-idata4] [-c|--no-idata5] + [--use-nul-prefixed-import-tables] + [-I|--identify LIBRARY-FILE-NAME] [--identify-strict] + [-i|--interwork] + [-n|--nodelete] [-t|--temp-prefix PREFIX] + [-v|--verbose] + [-h|--help] [-V|--version] + [--no-leading-underscore] [--leading-underscore] + [object-file ...] + + 'dlltool' reads its inputs, which can come from the '-d' and '-b' +options as well as object files specified on the command line. It then +processes these inputs and if the '-e' option has been specified it +creates a exports file. If the '-l' option has been specified it +creates a library file and if the '-z' option has been specified it +creates a def file. Any or all of the '-e', '-l' and '-z' options can +be present in one invocation of dlltool. + + When creating a DLL, along with the source for the DLL, it is +necessary to have three other files. 'dlltool' can help with the +creation of these files. + + The first file is a '.def' file which specifies which functions are +exported from the DLL, which functions the DLL imports, and so on. This +is a text file and can be created by hand, or 'dlltool' can be used to +create it using the '-z' option. In this case 'dlltool' will scan the +object files specified on its command line looking for those functions +which have been specially marked as being exported and put entries for +them in the '.def' file it creates. + + In order to mark a function as being exported from a DLL, it needs to +have an '-export:' entry in the '.drectve' section of +the object file. This can be done in C by using the asm() operator: + + asm (".section .drectve"); + asm (".ascii \"-export:my_func\""); + + int my_func (void) { ... } + + The second file needed for DLL creation is an exports file. This +file is linked with the object files that make up the body of the DLL +and it handles the interface between the DLL and the outside world. +This is a binary file and it can be created by giving the '-e' option to +'dlltool' when it is creating or reading in a '.def' file. + + The third file needed for DLL creation is the library file that +programs will link with in order to access the functions in the DLL (an +'import library'). This file can be created by giving the '-l' option +to dlltool when it is creating or reading in a '.def' file. + + If the '-y' option is specified, dlltool generates a delay-import +library that can be used instead of the normal import library to allow a +program to link to the dll only as soon as an imported function is +called for the first time. The resulting executable will need to be +linked to the static delayimp library containing __delayLoadHelper2(), +which in turn will import LoadLibraryA and GetProcAddress from kernel32. + + 'dlltool' builds the library file by hand, but it builds the exports +file by creating temporary files containing assembler statements and +then assembling these. The '-S' command line option can be used to +specify the path to the assembler that dlltool will use, and the '-f' +option can be used to pass specific flags to that assembler. The '-n' +can be used to prevent dlltool from deleting these temporary assembler +files when it is done, and if '-n' is specified twice then this will +prevent dlltool from deleting the temporary object files it used to +build the library. + + Here is an example of creating a DLL from a source file 'dll.c' and +also creating a program (from an object file called 'program.o') that +uses that DLL: + + gcc -c dll.c + dlltool -e exports.o -l dll.lib dll.o + gcc dll.o exports.o -o dll.dll + gcc program.o dll.lib -o program + + 'dlltool' may also be used to query an existing import library to +determine the name of the DLL to which it is associated. See the +description of the '-I' or '--identify' option. + + The command line options have the following meanings: + +'-d FILENAME' +'--input-def FILENAME' + Specifies the name of a '.def' file to be read in and processed. + +'-b FILENAME' +'--base-file FILENAME' + Specifies the name of a base file to be read in and processed. The + contents of this file will be added to the relocation section in + the exports file generated by dlltool. + +'-e FILENAME' +'--output-exp FILENAME' + Specifies the name of the export file to be created by dlltool. + +'-z FILENAME' +'--output-def FILENAME' + Specifies the name of the '.def' file to be created by dlltool. + +'-l FILENAME' +'--output-lib FILENAME' + Specifies the name of the library file to be created by dlltool. + +'-y FILENAME' +'--output-delaylib FILENAME' + Specifies the name of the delay-import library file to be created + by dlltool. + +'--export-all-symbols' + Treat all global and weak defined symbols found in the input object + files as symbols to be exported. There is a small list of symbols + which are not exported by default; see the '--no-default-excludes' + option. You may add to the list of symbols to not export by using + the '--exclude-symbols' option. + +'--no-export-all-symbols' + Only export symbols explicitly listed in an input '.def' file or in + '.drectve' sections in the input object files. This is the default + behaviour. The '.drectve' sections are created by 'dllexport' + attributes in the source code. + +'--exclude-symbols LIST' + Do not export the symbols in LIST. This is a list of symbol names + separated by comma or colon characters. The symbol names should + not contain a leading underscore. This is only meaningful when + '--export-all-symbols' is used. + +'--no-default-excludes' + When '--export-all-symbols' is used, it will by default avoid + exporting certain special symbols. The current list of symbols to + avoid exporting is 'DllMain@12', 'DllEntryPoint@0', 'impure_ptr'. + You may use the '--no-default-excludes' option to go ahead and + export these special symbols. This is only meaningful when + '--export-all-symbols' is used. + +'-S PATH' +'--as PATH' + Specifies the path, including the filename, of the assembler to be + used to create the exports file. + +'-f OPTIONS' +'--as-flags OPTIONS' + Specifies any specific command line options to be passed to the + assembler when building the exports file. This option will work + even if the '-S' option is not used. This option only takes one + argument, and if it occurs more than once on the command line, then + later occurrences will override earlier occurrences. So if it is + necessary to pass multiple options to the assembler they should be + enclosed in double quotes. + +'-D NAME' +'--dll-name NAME' + Specifies the name to be stored in the '.def' file as the name of + the DLL when the '-e' option is used. If this option is not + present, then the filename given to the '-e' option will be used as + the name of the DLL. + +'-m MACHINE' +'-machine MACHINE' + Specifies the type of machine for which the library file should be + built. 'dlltool' has a built in default type, depending upon how + it was created, but this option can be used to override that. This + is normally only useful when creating DLLs for an ARM processor, + when the contents of the DLL are actually encode using Thumb + instructions. + +'-a' +'--add-indirect' + Specifies that when 'dlltool' is creating the exports file it + should add a section which allows the exported functions to be + referenced without using the import library. Whatever the hell + that means! + +'-U' +'--add-underscore' + Specifies that when 'dlltool' is creating the exports file it + should prepend an underscore to the names of _all_ exported + symbols. + +'--no-leading-underscore' +'--leading-underscore' + Specifies whether standard symbol should be forced to be prefixed, + or not. + +'--add-stdcall-underscore' + Specifies that when 'dlltool' is creating the exports file it + should prepend an underscore to the names of exported _stdcall_ + functions. Variable names and non-stdcall function names are not + modified. This option is useful when creating GNU-compatible + import libs for third party DLLs that were built with MS-Windows + tools. + +'-k' +'--kill-at' + Specifies that '@' suffixes should be omitted from the + names of stdcall functions that will be imported from the DLL. This + is useful when creating an import library for a DLL which exports + stdcall functions but without the usual '@' symbol name + suffix. + + This does not change the naming of symbols provided by the import + library to programs linked against it, but only the entries in the + import table (ie the .idata section). + +'-A' +'--add-stdcall-alias' + Specifies that when 'dlltool' is creating the exports file it + should add aliases for stdcall symbols without '@ ' in + addition to the symbols with '@ '. + +'-p' +'--ext-prefix-alias PREFIX' + Causes 'dlltool' to create external aliases for all DLL imports + with the specified prefix. The aliases are created for both + external and import symbols with no leading underscore. + +'-x' +'--no-idata4' + Specifies that when 'dlltool' is creating the exports and library + files it should omit the '.idata4' section. This is for + compatibility with certain operating systems. + +'--use-nul-prefixed-import-tables' + Specifies that when 'dlltool' is creating the exports and library + files it should prefix the '.idata4' and '.idata5' by zero an + element. This emulates old gnu import library generation of + 'dlltool'. By default this option is turned off. + +'-c' +'--no-idata5' + Specifies that when 'dlltool' is creating the exports and library + files it should omit the '.idata5' section. This is for + compatibility with certain operating systems. + +'-I FILENAME' +'--identify FILENAME' + Specifies that 'dlltool' should inspect the import library + indicated by FILENAME and report, on 'stdout', the name(s) of the + associated DLL(s). This can be performed in addition to any other + operations indicated by the other options and arguments. 'dlltool' + fails if the import library does not exist or is not actually an + import library. See also '--identify-strict'. + +'--identify-strict' + Modifies the behavior of the '--identify' option, such that an + error is reported if FILENAME is associated with more than one DLL. + +'-i' +'--interwork' + Specifies that 'dlltool' should mark the objects in the library + file and exports file that it produces as supporting interworking + between ARM and Thumb code. + +'-n' +'--nodelete' + Makes 'dlltool' preserve the temporary assembler files it used to + create the exports file. If this option is repeated then dlltool + will also preserve the temporary object files it uses to create the + library file. + +'-t PREFIX' +'--temp-prefix PREFIX' + Makes 'dlltool' use PREFIX when constructing the names of temporary + assembler and object files. By default, the temp file prefix is + generated from the pid. + +'-v' +'--verbose' + Make dlltool describe what it is doing. + +'-h' +'--help' + Displays a list of command line options and then exits. + +'-V' +'--version' + Displays dlltool's version number and then exits. + +* Menu: + +* def file format:: The format of the dlltool '.def' file + + +File: binutils.info, Node: def file format, Up: dlltool + +14.1 The format of the 'dlltool' '.def' file +============================================ + +A '.def' file contains any number of the following commands: + +'NAME' NAME '[ ,' BASE ']' + The result is going to be named NAME'.exe'. + +'LIBRARY' NAME '[ ,' BASE ']' + The result is going to be named NAME'.dll'. Note: If you want to + use LIBRARY as name then you need to quote. Otherwise this will + fail due a necessary hack for libtool (see PR binutils/13710 for + more details). + +'EXPORTS ( ( (' NAME1 '[ = ' NAME2 '] ) | ( ' NAME1 '=' MODULE-NAME '.' EXTERNAL-NAME ') ) [ == ' ITS_NAME ']' +'[' INTEGER '] [ NONAME ] [ CONSTANT ] [ DATA ] [ PRIVATE ] ) *' + Declares NAME1 as an exported symbol from the DLL, with optional + ordinal number INTEGER, or declares NAME1 as an alias (forward) of + the function EXTERNAL-NAME in the DLL. If ITS_NAME is specified, + this name is used as string in export table. MODULE-NAME. Note: + The 'EXPORTS' has to be the last command in .def file, as keywords + are treated - beside 'LIBRARY' - as simple name-identifiers. If + you want to use LIBRARY as name then you need to quote it. + +'IMPORTS ( (' INTERNAL-NAME '=' MODULE-NAME '.' INTEGER ') | [' INTERNAL-NAME '= ]' MODULE-NAME '.' EXTERNAL-NAME ') [ == ) ITS_NAME ] *' + Declares that EXTERNAL-NAME or the exported function whose ordinal + number is INTEGER is to be imported from the file MODULE-NAME. If + INTERNAL-NAME is specified then this is the name that the imported + function will be referred to in the body of the DLL. If ITS_NAME is + specified, this name is used as string in import table. Note: The + 'IMPORTS' has to be the last command in .def file, as keywords are + treated - beside 'LIBRARY' - as simple name-identifiers. If you + want to use LIBRARY as name then you need to quote it. + +'DESCRIPTION' STRING + Puts STRING into the output '.exp' file in the '.rdata' section. + +'STACKSIZE' NUMBER-RESERVE '[, ' NUMBER-COMMIT ']' +'HEAPSIZE' NUMBER-RESERVE '[, ' NUMBER-COMMIT ']' + Generates '--stack' or '--heap' NUMBER-RESERVE,NUMBER-COMMIT in the + output '.drectve' section. The linker will see this and act upon + it. + +'CODE' ATTR '+' +'DATA' ATTR '+' +'SECTIONS (' SECTION-NAME ATTR' + ) *' + Generates '--attr' SECTION-NAME ATTR in the output '.drectve' + section, where ATTR is one of 'READ', 'WRITE', 'EXECUTE' or + 'SHARED'. The linker will see this and act upon it. + + +File: binutils.info, Node: readelf, Next: elfedit, Prev: dlltool, Up: Top + +15 readelf +********** + + readelf [-a|--all] + [-h|--file-header] + [-l|--program-headers|--segments] + [-S|--section-headers|--sections] + [-g|--section-groups] + [-t|--section-details] + [-e|--headers] + [-s|--syms|--symbols] + [--dyn-syms] + [-n|--notes] + [-r|--relocs] + [-u|--unwind] + [-d|--dynamic] + [-V|--version-info] + [-A|--arch-specific] + [-D|--use-dynamic] + [-x |--hex-dump=] + [-p |--string-dump=] + [-R |--relocated-dump=] + [-z|--decompress] + [-c|--archive-index] + [-w[lLiaprmfFsoRtUuTgAckK]| + --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]] + [--dwarf-depth=N] + [--dwarf-start=N] + [-I|--histogram] + [-v|--version] + [-W|--wide] + [-H|--help] + ELFFILE... + + 'readelf' displays information about one or more ELF format object +files. The options control what particular information to display. + + ELFFILE... are the object files to be examined. 32-bit and 64-bit +ELF files are supported, as are archives containing ELF files. + + This program performs a similar function to 'objdump' but it goes +into more detail and it exists independently of the BFD library, so if +there is a bug in BFD then readelf will not be affected. + + The long and short forms of options, shown here as alternatives, are +equivalent. At least one option besides '-v' or '-H' must be given. + +'-a' +'--all' + Equivalent to specifying '--file-header', '--program-headers', + '--sections', '--symbols', '--relocs', '--dynamic', '--notes', + '--version-info', '--arch-specific', '--unwind', '--section-groups' + and '--histogram'. + + Note - this option does not enable '--use-dynamic' itself, so if + that option is not present on the command line then dynamic symbols + and dynamic relocs will not be displayed. + +'-h' +'--file-header' + Displays the information contained in the ELF header at the start + of the file. + +'-l' +'--program-headers' +'--segments' + Displays the information contained in the file's segment headers, + if it has any. + +'-S' +'--sections' +'--section-headers' + Displays the information contained in the file's section headers, + if it has any. + +'-g' +'--section-groups' + Displays the information contained in the file's section groups, if + it has any. + +'-t' +'--section-details' + Displays the detailed section information. Implies '-S'. + +'-s' +'--symbols' +'--syms' + Displays the entries in symbol table section of the file, if it has + one. If a symbol has version information associated with it then + this is displayed as well. The version string is displayed as a + suffix to the symbol name, preceeded by an @ character. For + example 'foo@VER_1'. If the version is the default version to be + used when resolving unversioned references to the symbol then it is + displayed as a suffix preceeded by two @ characters. For example + 'foo@@VER_2'. + +'--dyn-syms' + Displays the entries in dynamic symbol table section of the file, + if it has one. The output format is the same as the format used by + the '--syms' option. + +'-e' +'--headers' + Display all the headers in the file. Equivalent to '-h -l -S'. + +'-n' +'--notes' + Displays the contents of the NOTE segments and/or sections, if any. + +'-r' +'--relocs' + Displays the contents of the file's relocation section, if it has + one. + +'-u' +'--unwind' + Displays the contents of the file's unwind section, if it has one. + Only the unwind sections for IA64 ELF files, as well as ARM unwind + tables ('.ARM.exidx' / '.ARM.extab') are currently supported. + +'-d' +'--dynamic' + Displays the contents of the file's dynamic section, if it has one. + +'-V' +'--version-info' + Displays the contents of the version sections in the file, it they + exist. + +'-A' +'--arch-specific' + Displays architecture-specific information in the file, if there is + any. + +'-D' +'--use-dynamic' + When displaying symbols, this option makes 'readelf' use the symbol + hash tables in the file's dynamic section, rather than the symbol + table sections. + + When displaying relocations, this option makes 'readelf' display + the dynamic relocations rather than the static relocations. + +'-x ' +'--hex-dump=' + Displays the contents of the indicated section as a hexadecimal + bytes. A number identifies a particular section by index in the + section table; any other string identifies all sections with that + name in the object file. + +'-R ' +'--relocated-dump=' + Displays the contents of the indicated section as a hexadecimal + bytes. A number identifies a particular section by index in the + section table; any other string identifies all sections with that + name in the object file. The contents of the section will be + relocated before they are displayed. + +'-p ' +'--string-dump=' + Displays the contents of the indicated section as printable + strings. A number identifies a particular section by index in the + section table; any other string identifies all sections with that + name in the object file. + +'-z' +'--decompress' + Requests that the section(s) being dumped by 'x', 'R' or 'p' + options are decompressed before being displayed. If the section(s) + are not compressed then they are displayed as is. + +'-c' +'--archive-index' + Displays the file symbol index information contained in the header + part of binary archives. Performs the same function as the 't' + command to 'ar', but without using the BFD library. *Note ar::. + +'-w[lLiaprmfFsoRtUuTgAckK]' +'--debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]' + + Displays the contents of the DWARF debug sections in the file, if + any are present. Compressed debug sections are automatically + decompressed (temporarily) before they are displayed. If one or + more of the optional letters or words follows the switch then only + those type(s) of data will be dumped. The letters and words refer + to the following information: + + 'a' + '=abbrev' + Displays the contents of the '.debug_abbrev' section. + + 'A' + '=addr' + Displays the contents of the '.debug_addr' section. + + 'c' + '=cu_index' + Displays the contents of the '.debug_cu_index' and/or + '.debug_tu_index' sections. + + 'f' + '=frames' + Display the raw contents of a '.debug_frame' section. + + 'F' + '=frame-interp' + Display the interpreted contents of a '.debug_frame' section. + + 'g' + '=gdb_index' + Displays the contents of the '.gdb_index' and/or + '.debug_names' sections. + + 'i' + '=info' + Displays the contents of the '.debug_info' section. Note: the + output from this option can also be restricted by the use of + the '--dwarf-depth' and '--dwarf-start' options. + + 'k' + '=links' + Displays the contents of the '.gnu_debuglink' and/or + '.gnu_debugaltlink' sections. Also displays the link to a + separate dwarf object file (dwo), if one is specified by the + DW_AT_GNU_dwo_name or DW_AT_dwo_name attributes in the + '.debug_info' section. + + 'K' + '=follow-links' + Display the contents of any selected debug sections that are + found in a linked, separate debug info file. This can result + in multiple versions of the same debug section being displayed + if both the main file and the separate debug info file contain + sections with the same name. + + In addition, when displaying DWARF attributes, if a form is + found that references the separate debug info file, then the + referenced contents will also be displayed. + + 'l' + '=rawline' + Displays the contents of the '.debug_line' section in a raw + format. + + 'L' + '=decodedline' + Displays the interpreted contents of the '.debug_line' + section. + + 'm' + '=macro' + Displays the contents of the '.debug_macro' and/or + '.debug_macinfo' sections. + + 'o' + '=loc' + Displays the contents of the '.debug_loc' and/or + '.debug_loclists' sections. + + 'p' + '=pubnames' + Displays the contents of the '.debug_pubnames' and/or + '.debug_gnu_pubnames' sections. + + 'r' + '=aranges' + Displays the contents of the '.debug_aranges' section. + + 'R' + '=Ranges' + Displays the contents of the '.debug_ranges' and/or + '.debug_rnglists' sections. + + 's' + '=str' + Displays the contents of the '.debug_str', '.debug_line_str' + and/or '.debug_str_offsets' sections. + + 't' + '=pubtype' + Displays the contents of the '.debug_pubtypes' and/or + '.debug_gnu_pubtypes' sections. + + 'T' + '=trace_aranges' + Displays the contents of the '.trace_aranges' section. + + 'u' + '=trace_abbrev' + Displays the contents of the '.trace_abbrev' section. + + 'U' + '=trace_info' + Displays the contents of the '.trace_info' section. + + Note: displaying the contents of '.debug_static_funcs', + '.debug_static_vars' and 'debug_weaknames' sections is not + currently supported. + +'--dwarf-depth=N' + Limit the dump of the '.debug_info' section to N children. This is + only useful with '--debug-dump=info'. The default is to print all + DIEs; the special value 0 for N will also have this effect. + + With a non-zero value for N, DIEs at or deeper than N levels will + not be printed. The range for N is zero-based. + +'--dwarf-start=N' + Print only DIEs beginning with the DIE numbered N. This is only + useful with '--debug-dump=info'. + + If specified, this option will suppress printing of any header + information and all DIEs before the DIE numbered N. Only siblings + and children of the specified DIE will be printed. + + This can be used in conjunction with '--dwarf-depth'. + +'-I' +'--histogram' + Display a histogram of bucket list lengths when displaying the + contents of the symbol tables. + +'-v' +'--version' + Display the version number of readelf. + +'-W' +'--wide' + Don't break output lines to fit into 80 columns. By default + 'readelf' breaks section header and segment listing lines for + 64-bit ELF files, so that they fit into 80 columns. This option + causes 'readelf' to print each section header resp. each segment + one a single line, which is far more readable on terminals wider + than 80 columns. + +'-H' +'--help' + Display the command line options understood by 'readelf'. + + +File: binutils.info, Node: elfedit, Next: Common Options, Prev: readelf, Up: Top + +16 elfedit +********** + + elfedit [--input-mach=MACHINE] + [--input-type=TYPE] + [--input-osabi=OSABI] + --output-mach=MACHINE + --output-type=TYPE + --output-osabi=OSABI + [-v|--version] + [-h|--help] + ELFFILE... + + 'elfedit' updates the ELF header of ELF files which have the matching +ELF machine and file types. The options control how and which fields in +the ELF header should be updated. + + ELFFILE... are the ELF files to be updated. 32-bit and 64-bit ELF +files are supported, as are archives containing ELF files. + + The long and short forms of options, shown here as alternatives, are +equivalent. At least one of the '--output-mach', '--output-type' and +'--output-osabi' options must be given. + +'--input-mach=MACHINE' + Set the matching input ELF machine type to MACHINE. If + '--input-mach' isn't specified, it will match any ELF machine + types. + + The supported ELF machine types are, I386, IAMCU, L1OM, K1OM and + X86-64. + +'--output-mach=MACHINE' + Change the ELF machine type in the ELF header to MACHINE. The + supported ELF machine types are the same as '--input-mach'. + +'--input-type=TYPE' + Set the matching input ELF file type to TYPE. If '--input-type' + isn't specified, it will match any ELF file types. + + The supported ELF file types are, REL, EXEC and DYN. + +'--output-type=TYPE' + Change the ELF file type in the ELF header to TYPE. The supported + ELF types are the same as '--input-type'. + +'--input-osabi=OSABI' + Set the matching input ELF file OSABI to OSABI. If '--input-osabi' + isn't specified, it will match any ELF OSABIs. + + The supported ELF OSABIs are, NONE, HPUX, NETBSD, GNU, LINUX (alias + for GNU), SOLARIS, AIX, IRIX, FREEBSD, TRU64, MODESTO, OPENBSD, + OPENVMS, NSK, AROS and FENIXOS. + +'--output-osabi=OSABI' + Change the ELF OSABI in the ELF header to OSABI. The supported ELF + OSABI are the same as '--input-osabi'. + +'-v' +'--version' + Display the version number of 'elfedit'. + +'-h' +'--help' + Display the command line options understood by 'elfedit'. + + +File: binutils.info, Node: Common Options, Next: Selecting the Target System, Prev: elfedit, Up: Top + +17 Common Options +***************** + +The following command-line options are supported by all of the programs +described in this manual. + +'@FILE' + Read command-line options from FILE. The options read are inserted + in place of the original @FILE option. If FILE does not exist, or + cannot be read, then the option will be treated literally, and not + removed. + + Options in FILE are separated by whitespace. A whitespace + character may be included in an option by surrounding the entire + option in either single or double quotes. Any character (including + a backslash) may be included by prefixing the character to be + included with a backslash. The FILE may itself contain additional + @FILE options; any such options will be processed recursively. + +'--help' + Display the command-line options supported by the program. + +'--version' + Display the version number of the program. + + +File: binutils.info, Node: Selecting the Target System, Next: Reporting Bugs, Prev: Common Options, Up: Top + +18 Selecting the Target System +****************************** + +You can specify two aspects of the target system to the GNU binary file +utilities, each in several ways: + + * the target + + * the architecture + + In the following summaries, the lists of ways to specify values are +in order of decreasing precedence. The ways listed first override those +listed later. + + The commands to list valid values only list the values for which the +programs you are running were configured. If they were configured with +'--enable-targets=all', the commands list most of the available values, +but a few are left out; not all targets can be configured in at once +because some of them can only be configured "native" (on hosts with the +same type as the target system). + +* Menu: + +* Target Selection:: +* Architecture Selection:: + + +File: binutils.info, Node: Target Selection, Next: Architecture Selection, Up: Selecting the Target System + +18.1 Target Selection +===================== + +A "target" is an object file format. A given target may be supported +for multiple architectures (*note Architecture Selection::). A target +selection may also have variations for different operating systems or +architectures. + + The command to list valid target values is 'objdump -i' (the first +column of output contains the relevant information). + + Some sample values are: 'a.out-hp300bsd', 'ecoff-littlemips', +'a.out-sunos-big'. + + You can also specify a target using a configuration triplet. This is +the same sort of name that is passed to 'configure' to specify a target. +When you use a configuration triplet as an argument, it must be fully +canonicalized. You can see the canonical version of a triplet by +running the shell script 'config.sub' which is included with the +sources. + + Some sample configuration triplets are: 'm68k-hp-bsd', +'mips-dec-ultrix', 'sparc-sun-sunos'. + +'objdump' Target +---------------- + +Ways to specify: + + 1. command line option: '-b' or '--target' + + 2. environment variable 'GNUTARGET' + + 3. deduced from the input file + +'objcopy' and 'strip' Input Target +---------------------------------- + +Ways to specify: + + 1. command line options: '-I' or '--input-target', or '-F' or + '--target' + + 2. environment variable 'GNUTARGET' + + 3. deduced from the input file + +'objcopy' and 'strip' Output Target +----------------------------------- + +Ways to specify: + + 1. command line options: '-O' or '--output-target', or '-F' or + '--target' + + 2. the input target (see "'objcopy' and 'strip' Input Target" above) + + 3. environment variable 'GNUTARGET' + + 4. deduced from the input file + +'nm', 'size', and 'strings' Target +---------------------------------- + +Ways to specify: + + 1. command line option: '--target' + + 2. environment variable 'GNUTARGET' + + 3. deduced from the input file + + +File: binutils.info, Node: Architecture Selection, Prev: Target Selection, Up: Selecting the Target System + +18.2 Architecture Selection +=========================== + +An "architecture" is a type of CPU on which an object file is to run. +Its name may contain a colon, separating the name of the processor +family from the name of the particular CPU. + + The command to list valid architecture values is 'objdump -i' (the +second column contains the relevant information). + + Sample values: 'm68k:68020', 'mips:3000', 'sparc'. + +'objdump' Architecture +---------------------- + +Ways to specify: + + 1. command line option: '-m' or '--architecture' + + 2. deduced from the input file + +'objcopy', 'nm', 'size', 'strings' Architecture +----------------------------------------------- + +Ways to specify: + + 1. deduced from the input file + + +File: binutils.info, Node: Reporting Bugs, Next: GNU Free Documentation License, Prev: Selecting the Target System, Up: Top + +19 Reporting Bugs +***************** + +Your bug reports play an essential role in making the binary utilities +reliable. + + Reporting a bug may help you by bringing a solution to your problem, +or it may not. But in any case the principal function of a bug report +is to help the entire community by making the next version of the binary +utilities work better. Bug reports are your contribution to their +maintenance. + + In order for a bug report to serve its purpose, you must include the +information that enables us to fix the bug. + +* Menu: + +* Bug Criteria:: Have you found a bug? +* Bug Reporting:: How to report bugs + + +File: binutils.info, Node: Bug Criteria, Next: Bug Reporting, Up: Reporting Bugs + +19.1 Have You Found a Bug? +========================== + +If you are not sure whether you have found a bug, here are some +guidelines: + + * If a binary utility gets a fatal signal, for any input whatever, + that is a bug. Reliable utilities never crash. + + * If a binary utility produces an error message for valid input, that + is a bug. + + * If you are an experienced user of binary utilities, your + suggestions for improvement are welcome in any case. + + +File: binutils.info, Node: Bug Reporting, Prev: Bug Criteria, Up: Reporting Bugs + +19.2 How to Report Bugs +======================= + +A number of companies and individuals offer support for GNU products. +If you obtained the binary utilities from a support organization, we +recommend you contact that organization first. + + You can find contact information for many support companies and +individuals in the file 'etc/SERVICE' in the GNU Emacs distribution. + + In any event, we also recommend that you send bug reports for the +binary utilities to . + + The fundamental principle of reporting bugs usefully is this: *report +all the facts*. If you are not sure whether to state a fact or leave it +out, state it! + + Often people omit facts because they think they know what causes the +problem and assume that some details do not matter. Thus, you might +assume that the name of a file you use in an example does not matter. +Well, probably it does not, but one cannot be sure. Perhaps the bug is +a stray memory reference which happens to fetch from the location where +that pathname is stored in memory; perhaps, if the pathname were +different, the contents of that location would fool the utility into +doing the right thing despite the bug. Play it safe and give a +specific, complete example. That is the easiest thing for you to do, +and the most helpful. + + Keep in mind that the purpose of a bug report is to enable us to fix +the bug if it is new to us. Therefore, always write your bug reports on +the assumption that the bug has not been reported previously. + + Sometimes people give a few sketchy facts and ask, "Does this ring a +bell?" This cannot help us fix a bug, so it is basically useless. We +respond by asking for enough details to enable us to investigate. You +might as well expedite matters by sending them to begin with. + + To enable us to fix the bug, you should include all these things: + + * The version of the utility. Each utility announces it if you start + it with the '--version' argument. + + Without this, we will not know whether there is any point in + looking for the bug in the current version of the binary utilities. + + * Any patches you may have applied to the source, including any + patches made to the 'BFD' library. + + * The type of machine you are using, and the operating system name + and version number. + + * What compiler (and its version) was used to compile the + utilities--e.g. "'gcc-2.7'". + + * The command arguments you gave the utility to observe the bug. To + guarantee you will not omit something important, list them all. A + copy of the Makefile (or the output from make) is sufficient. + + If we were to try to guess the arguments, we would probably guess + wrong and then we might not encounter the bug. + + * A complete input file, or set of input files, that will reproduce + the bug. If the utility is reading an object file or files, then + it is generally most helpful to send the actual object files. + + If the source files were produced exclusively using GNU programs + (e.g., 'gcc', 'gas', and/or the GNU 'ld'), then it may be OK to + send the source files rather than the object files. In this case, + be sure to say exactly what version of 'gcc', or whatever, was used + to produce the object files. Also say how 'gcc', or whatever, was + configured. + + * A description of what behavior you observe that you believe is + incorrect. For example, "It gets a fatal signal." + + Of course, if the bug is that the utility gets a fatal signal, then + we will certainly notice it. But if the bug is incorrect output, + we might not notice unless it is glaringly wrong. You might as + well not give us a chance to make a mistake. + + Even if the problem you experience is a fatal signal, you should + still say so explicitly. Suppose something strange is going on, + such as your copy of the utility is out of sync, or you have + encountered a bug in the C library on your system. (This has + happened!) Your copy might crash and ours would not. If you told + us to expect a crash, then when ours fails to crash, we would know + that the bug was not happening for us. If you had not told us to + expect a crash, then we would not be able to draw any conclusion + from our observations. + + * If you wish to suggest changes to the source, send us context + diffs, as generated by 'diff' with the '-u', '-c', or '-p' option. + Always send diffs from the old file to the new file. If you wish + to discuss something in the 'ld' source, refer to it by context, + not by line number. + + The line numbers in our development sources will not match those in + your sources. Your line numbers would convey no useful information + to us. + + Here are some things that are not necessary: + + * A description of the envelope of the bug. + + Often people who encounter a bug spend a lot of time investigating + which changes to the input file will make the bug go away and which + changes will not affect it. + + This is often time consuming and not very useful, because the way + we will find the bug is by running a single example under the + debugger with breakpoints, not by pure deduction from a series of + examples. We recommend that you save your time for something else. + + Of course, if you can find a simpler example to report _instead_ of + the original one, that is a convenience for us. Errors in the + output will be easier to spot, running under the debugger will take + less time, and so on. + + However, simplification is not vital; if you do not want to do + this, report the bug anyway and send us the entire test case you + used. + + * A patch for the bug. + + A patch for the bug does help us if it is a good one. But do not + omit the necessary information, such as the test case, on the + assumption that a patch is all we need. We might see problems with + your patch and decide to fix the problem another way, or we might + not understand it at all. + + Sometimes with programs as complicated as the binary utilities it + is very hard to construct an example that will make the program + follow a certain path through the code. If you do not send us the + example, we will not be able to construct one, so we will not be + able to verify that the bug is fixed. + + And if we cannot understand what bug you are trying to fix, or why + your patch should be an improvement, we will not install it. A + test case will help us to understand. + + * A guess about what the bug is or what it depends on. + + Such guesses are usually wrong. Even we cannot guess right about + such things without first using the debugger to find the facts. + + +File: binutils.info, Node: GNU Free Documentation License, Next: Binutils Index, Prev: Reporting Bugs, Up: Top + +Appendix A GNU Free Documentation License +***************************************** + + Version 1.3, 3 November 2008 + + Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. + + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + 0. PREAMBLE + + The purpose of this License is to make a manual, textbook, or other + functional and useful document "free" in the sense of freedom: to + assure everyone the effective freedom to copy and redistribute it, + with or without modifying it, either commercially or + noncommercially. Secondarily, this License preserves for the + author and publisher a way to get credit for their work, while not + being considered responsible for modifications made by others. + + This License is a kind of "copyleft", which means that derivative + works of the document must themselves be free in the same sense. + It complements the GNU General Public License, which is a copyleft + license designed for free software. + + We have designed this License in order to use it for manuals for + free software, because free software needs free documentation: a + free program should come with manuals providing the same freedoms + that the software does. But this License is not limited to + software manuals; it can be used for any textual work, regardless + of subject matter or whether it is published as a printed book. We + recommend this License principally for works whose purpose is + instruction or reference. + + 1. APPLICABILITY AND DEFINITIONS + + This License applies to any manual or other work, in any medium, + that contains a notice placed by the copyright holder saying it can + be distributed under the terms of this License. Such a notice + grants a world-wide, royalty-free license, unlimited in duration, + to use that work under the conditions stated herein. The + "Document", below, refers to any such manual or work. Any member + of the public is a licensee, and is addressed as "you". You accept + the license if you copy, modify or distribute the work in a way + requiring permission under copyright law. + + A "Modified Version" of the Document means any work containing the + Document or a portion of it, either copied verbatim, or with + modifications and/or translated into another language. + + A "Secondary Section" is a named appendix or a front-matter section + of the Document that deals exclusively with the relationship of the + publishers or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that could + fall directly within that overall subject. (Thus, if the Document + is in part a textbook of mathematics, a Secondary Section may not + explain any mathematics.) The relationship could be a matter of + historical connection with the subject or with related matters, or + of legal, commercial, philosophical, ethical or political position + regarding them. + + The "Invariant Sections" are certain Secondary Sections whose + titles are designated, as being those of Invariant Sections, in the + notice that says that the Document is released under this License. + If a section does not fit the above definition of Secondary then it + is not allowed to be designated as Invariant. The Document may + contain zero Invariant Sections. If the Document does not identify + any Invariant Sections then there are none. + + The "Cover Texts" are certain short passages of text that are + listed, as Front-Cover Texts or Back-Cover Texts, in the notice + that says that the Document is released under this License. A + Front-Cover Text may be at most 5 words, and a Back-Cover Text may + be at most 25 words. + + A "Transparent" copy of the Document means a machine-readable copy, + represented in a format whose specification is available to the + general public, that is suitable for revising the document + straightforwardly with generic text editors or (for images composed + of pixels) generic paint programs or (for drawings) some widely + available drawing editor, and that is suitable for input to text + formatters or for automatic translation to a variety of formats + suitable for input to text formatters. A copy made in an otherwise + Transparent file format whose markup, or absence of markup, has + been arranged to thwart or discourage subsequent modification by + readers is not Transparent. An image format is not Transparent if + used for any substantial amount of text. A copy that is not + "Transparent" is called "Opaque". + + Examples of suitable formats for Transparent copies include plain + ASCII without markup, Texinfo input format, LaTeX input format, + SGML or XML using a publicly available DTD, and standard-conforming + simple HTML, PostScript or PDF designed for human modification. + Examples of transparent image formats include PNG, XCF and JPG. + Opaque formats include proprietary formats that can be read and + edited only by proprietary word processors, SGML or XML for which + the DTD and/or processing tools are not generally available, and + the machine-generated HTML, PostScript or PDF produced by some word + processors for output purposes only. + + The "Title Page" means, for a printed book, the title page itself, + plus such following pages as are needed to hold, legibly, the + material this License requires to appear in the title page. For + works in formats which do not have any title page as such, "Title + Page" means the text near the most prominent appearance of the + work's title, preceding the beginning of the body of the text. + + The "publisher" means any person or entity that distributes copies + of the Document to the public. + + A section "Entitled XYZ" means a named subunit of the Document + whose title either is precisely XYZ or contains XYZ in parentheses + following text that translates XYZ in another language. (Here XYZ + stands for a specific section name mentioned below, such as + "Acknowledgements", "Dedications", "Endorsements", or "History".) + To "Preserve the Title" of such a section when you modify the + Document means that it remains a section "Entitled XYZ" according + to this definition. + + The Document may include Warranty Disclaimers next to the notice + which states that this License applies to the Document. These + Warranty Disclaimers are considered to be included by reference in + this License, but only as regards disclaiming warranties: any other + implication that these Warranty Disclaimers may have is void and + has no effect on the meaning of this License. + + 2. VERBATIM COPYING + + You may copy and distribute the Document in any medium, either + commercially or noncommercially, provided that this License, the + copyright notices, and the license notice saying this License + applies to the Document are reproduced in all copies, and that you + add no other conditions whatsoever to those of this License. You + may not use technical measures to obstruct or control the reading + or further copying of the copies you make or distribute. However, + you may accept compensation in exchange for copies. If you + distribute a large enough number of copies you must also follow the + conditions in section 3. + + You may also lend copies, under the same conditions stated above, + and you may publicly display copies. + + 3. COPYING IN QUANTITY + + If you publish printed copies (or copies in media that commonly + have printed covers) of the Document, numbering more than 100, and + the Document's license notice requires Cover Texts, you must + enclose the copies in covers that carry, clearly and legibly, all + these Cover Texts: Front-Cover Texts on the front cover, and + Back-Cover Texts on the back cover. Both covers must also clearly + and legibly identify you as the publisher of these copies. The + front cover must present the full title with all words of the title + equally prominent and visible. You may add other material on the + covers in addition. Copying with changes limited to the covers, as + long as they preserve the title of the Document and satisfy these + conditions, can be treated as verbatim copying in other respects. + + If the required texts for either cover are too voluminous to fit + legibly, you should put the first ones listed (as many as fit + reasonably) on the actual cover, and continue the rest onto + adjacent pages. + + If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a machine-readable + Transparent copy along with each Opaque copy, or state in or with + each Opaque copy a computer-network location from which the general + network-using public has access to download using public-standard + network protocols a complete Transparent copy of the Document, free + of added material. If you use the latter option, you must take + reasonably prudent steps, when you begin distribution of Opaque + copies in quantity, to ensure that this Transparent copy will + remain thus accessible at the stated location until at least one + year after the last time you distribute an Opaque copy (directly or + through your agents or retailers) of that edition to the public. + + It is requested, but not required, that you contact the authors of + the Document well before redistributing any large number of copies, + to give them a chance to provide you with an updated version of the + Document. + + 4. MODIFICATIONS + + You may copy and distribute a Modified Version of the Document + under the conditions of sections 2 and 3 above, provided that you + release the Modified Version under precisely this License, with the + Modified Version filling the role of the Document, thus licensing + distribution and modification of the Modified Version to whoever + possesses a copy of it. In addition, you must do these things in + the Modified Version: + + A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of previous + versions (which should, if there were any, be listed in the + History section of the Document). You may use the same title + as a previous version if the original publisher of that + version gives permission. + + B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in + the Modified Version, together with at least five of the + principal authors of the Document (all of its principal + authors, if it has fewer than five), unless they release you + from this requirement. + + C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + + D. Preserve all the copyright notices of the Document. + + E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + + F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified + Version under the terms of this License, in the form shown in + the Addendum below. + + G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's + license notice. + + H. Include an unaltered copy of this License. + + I. Preserve the section Entitled "History", Preserve its Title, + and add to it an item stating at least the title, year, new + authors, and publisher of the Modified Version as given on the + Title Page. If there is no section Entitled "History" in the + Document, create one stating the title, year, authors, and + publisher of the Document as given on its Title Page, then add + an item describing the Modified Version as stated in the + previous sentence. + + J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for + previous versions it was based on. These may be placed in the + "History" section. You may omit a network location for a work + that was published at least four years before the Document + itself, or if the original publisher of the version it refers + to gives permission. + + K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the section + all the substance and tone of each of the contributor + acknowledgements and/or dedications given therein. + + L. Preserve all the Invariant Sections of the Document, unaltered + in their text and in their titles. Section numbers or the + equivalent are not considered part of the section titles. + + M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + + N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant + Section. + + O. Preserve any Warranty Disclaimers. + + If the Modified Version includes new front-matter sections or + appendices that qualify as Secondary Sections and contain no + material copied from the Document, you may at your option designate + some or all of these sections as invariant. To do this, add their + titles to the list of Invariant Sections in the Modified Version's + license notice. These titles must be distinct from any other + section titles. + + You may add a section Entitled "Endorsements", provided it contains + nothing but endorsements of your Modified Version by various + parties--for example, statements of peer review or that the text + has been approved by an organization as the authoritative + definition of a standard. + + You may add a passage of up to five words as a Front-Cover Text, + and a passage of up to 25 words as a Back-Cover Text, to the end of + the list of Cover Texts in the Modified Version. Only one passage + of Front-Cover Text and one of Back-Cover Text may be added by (or + through arrangements made by) any one entity. If the Document + already includes a cover text for the same cover, previously added + by you or by arrangement made by the same entity you are acting on + behalf of, you may not add another; but you may replace the old + one, on explicit permission from the previous publisher that added + the old one. + + The author(s) and publisher(s) of the Document do not by this + License give permission to use their names for publicity for or to + assert or imply endorsement of any Modified Version. + + 5. COMBINING DOCUMENTS + + You may combine the Document with other documents released under + this License, under the terms defined in section 4 above for + modified versions, provided that you include in the combination all + of the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + + The combined work need only contain one copy of this License, and + multiple identical Invariant Sections may be replaced with a single + copy. If there are multiple Invariant Sections with the same name + but different contents, make the title of each such section unique + by adding at the end of it, in parentheses, the name of the + original author or publisher of that section if known, or else a + unique number. Make the same adjustment to the section titles in + the list of Invariant Sections in the license notice of the + combined work. + + In the combination, you must combine any sections Entitled + "History" in the various original documents, forming one section + Entitled "History"; likewise combine any sections Entitled + "Acknowledgements", and any sections Entitled "Dedications". You + must delete all sections Entitled "Endorsements." + + 6. COLLECTIONS OF DOCUMENTS + + You may make a collection consisting of the Document and other + documents released under this License, and replace the individual + copies of this License in the various documents with a single copy + that is included in the collection, provided that you follow the + rules of this License for verbatim copying of each of the documents + in all other respects. + + You may extract a single document from such a collection, and + distribute it individually under this License, provided you insert + a copy of this License into the extracted document, and follow this + License in all other respects regarding verbatim copying of that + document. + + 7. AGGREGATION WITH INDEPENDENT WORKS + + A compilation of the Document or its derivatives with other + separate and independent documents or works, in or on a volume of a + storage or distribution medium, is called an "aggregate" if the + copyright resulting from the compilation is not used to limit the + legal rights of the compilation's users beyond what the individual + works permit. When the Document is included in an aggregate, this + License does not apply to the other works in the aggregate which + are not themselves derivative works of the Document. + + If the Cover Text requirement of section 3 is applicable to these + copies of the Document, then if the Document is less than one half + of the entire aggregate, the Document's Cover Texts may be placed + on covers that bracket the Document within the aggregate, or the + electronic equivalent of covers if the Document is in electronic + form. Otherwise they must appear on printed covers that bracket + the whole aggregate. + + 8. TRANSLATION + + Translation is considered a kind of modification, so you may + distribute translations of the Document under the terms of section + 4. Replacing Invariant Sections with translations requires special + permission from their copyright holders, but you may include + translations of some or all Invariant Sections in addition to the + original versions of these Invariant Sections. You may include a + translation of this License, and all the license notices in the + Document, and any Warranty Disclaimers, provided that you also + include the original English version of this License and the + original versions of those notices and disclaimers. In case of a + disagreement between the translation and the original version of + this License or a notice or disclaimer, the original version will + prevail. + + If a section in the Document is Entitled "Acknowledgements", + "Dedications", or "History", the requirement (section 4) to + Preserve its Title (section 1) will typically require changing the + actual title. + + 9. TERMINATION + + You may not copy, modify, sublicense, or distribute the Document + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense, or distribute it is void, + and will automatically terminate your rights under this License. + + However, if you cease all violation of this License, then your + license from a particular copyright holder is reinstated (a) + provisionally, unless and until the copyright holder explicitly and + finally terminates your license, and (b) permanently, if the + copyright holder fails to notify you of the violation by some + reasonable means prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is + reinstated permanently if the copyright holder notifies you of the + violation by some reasonable means, this is the first time you have + received notice of violation of this License (for any work) from + that copyright holder, and you cure the violation prior to 30 days + after your receipt of the notice. + + Termination of your rights under this section does not terminate + the licenses of parties who have received copies or rights from you + under this License. If your rights have been terminated and not + permanently reinstated, receipt of a copy of some or all of the + same material does not give you any rights to use it. + + 10. FUTURE REVISIONS OF THIS LICENSE + + The Free Software Foundation may publish new, revised versions of + the GNU Free Documentation License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. See + . + + Each version of the License is given a distinguishing version + number. If the Document specifies that a particular numbered + version of this License "or any later version" applies to it, you + have the option of following the terms and conditions either of + that specified version or of any later version that has been + published (not as a draft) by the Free Software Foundation. If the + Document does not specify a version number of this License, you may + choose any version ever published (not as a draft) by the Free + Software Foundation. If the Document specifies that a proxy can + decide which future versions of this License can be used, that + proxy's public statement of acceptance of a version permanently + authorizes you to choose that version for the Document. + + 11. RELICENSING + + "Massive Multiauthor Collaboration Site" (or "MMC Site") means any + World Wide Web server that publishes copyrightable works and also + provides prominent facilities for anybody to edit those works. A + public wiki that anybody can edit is an example of such a server. + A "Massive Multiauthor Collaboration" (or "MMC") contained in the + site means any set of copyrightable works thus published on the MMC + site. + + "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 + license published by Creative Commons Corporation, a not-for-profit + corporation with a principal place of business in San Francisco, + California, as well as future copyleft versions of that license + published by that same organization. + + "Incorporate" means to publish or republish a Document, in whole or + in part, as part of another Document. + + An MMC is "eligible for relicensing" if it is licensed under this + License, and if all works that were first published under this + License somewhere other than this MMC, and subsequently + incorporated in whole or in part into the MMC, (1) had no cover + texts or invariant sections, and (2) were thus incorporated prior + to November 1, 2008. + + The operator of an MMC Site may republish an MMC contained in the + site under CC-BY-SA on the same site at any time before August 1, + 2009, provided the MMC is eligible for relicensing. + +ADDENDUM: How to use this License for your documents +==================================================== + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and license +notices just after the title page: + + Copyright (C) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + + If you have Invariant Sections, Front-Cover Texts and Back-Cover +Texts, replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover Texts + being LIST. + + If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + + If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of free +software license, such as the GNU General Public License, to permit +their use in free software. + + +File: binutils.info, Node: Binutils Index, Prev: GNU Free Documentation License, Up: Top + +Binutils Index +************** + +[index] +* Menu: + +* -enable-deterministic-archives: ar cmdline. (line 143) +* -enable-deterministic-archives <1>: ar cmdline. (line 216) +* -enable-deterministic-archives <2>: objcopy. (line 343) +* -enable-deterministic-archives <3>: objcopy. (line 353) +* -enable-deterministic-archives <4>: ranlib. (line 32) +* -enable-deterministic-archives <5>: ranlib. (line 44) +* -enable-deterministic-archives <6>: strip. (line 149) +* -enable-deterministic-archives <7>: strip. (line 159) +* .stab: objdump. (line 613) +* Add prefix to absolute paths: objdump. (line 448) +* addr2line: addr2line. (line 6) +* address to file name and line number: addr2line. (line 6) +* all header information, object file: objdump. (line 735) +* ar: ar. (line 6) +* ar compatibility: ar. (line 60) +* architecture: objdump. (line 213) +* architectures available: objdump. (line 198) +* archive contents: ranlib. (line 6) +* Archive file symbol index information: readelf. (line 176) +* archive headers: objdump. (line 69) +* archives: ar. (line 6) +* base files: dlltool. (line 124) +* bug criteria: Bug Criteria. (line 6) +* bug reports: Bug Reporting. (line 6) +* bugs: Reporting Bugs. (line 6) +* bugs, reporting: Bug Reporting. (line 6) +* c++filt: c++filt. (line 6) +* changing object addresses: objcopy. (line 388) +* changing section address: objcopy. (line 398) +* changing section LMA: objcopy. (line 407) +* changing section VMA: objcopy. (line 420) +* changing start address: objcopy. (line 383) +* collections of files: ar. (line 6) +* compatibility, ar: ar. (line 60) +* contents of archive: ar cmdline. (line 97) +* crash: Bug Criteria. (line 9) +* creating archives: ar cmdline. (line 137) +* creating thin archive: ar cmdline. (line 202) +* cxxfilt: c++filt. (line 14) +* dates in archive: ar cmdline. (line 176) +* debug symbols: objdump. (line 613) +* debugging symbols: nm. (line 147) +* deleting from archive: ar cmdline. (line 26) +* demangling C++ symbols: c++filt. (line 6) +* demangling in nm: nm. (line 155) +* demangling in objdump: objdump. (line 97) +* demangling in objdump <1>: addr2line. (line 84) +* deterministic archives: ar cmdline. (line 143) +* deterministic archives <1>: ar cmdline. (line 216) +* deterministic archives <2>: objcopy. (line 343) +* deterministic archives <3>: objcopy. (line 353) +* deterministic archives <4>: ranlib. (line 32) +* deterministic archives <5>: ranlib. (line 44) +* deterministic archives <6>: strip. (line 149) +* deterministic archives <7>: strip. (line 159) +* disassembling object code: objdump. (line 119) +* disassembly architecture: objdump. (line 213) +* disassembly endianness: objdump. (line 148) +* disassembly, with source: objdump. (line 444) +* discarding symbols: strip. (line 6) +* DLL: dlltool. (line 6) +* dlltool: dlltool. (line 6) +* dynamic relocation entries, in object file: objdump. (line 432) +* dynamic symbol table entries, printing: objdump. (line 712) +* dynamic symbols: nm. (line 167) +* ELF dynamic section information: readelf. (line 125) +* ELF dynamic symbol table information: readelf. (line 100) +* ELF file header information: readelf. (line 63) +* ELF file information: readelf. (line 6) +* ELF notes: readelf. (line 110) +* ELF object file format: objdump. (line 613) +* ELF program header information: readelf. (line 69) +* ELF reloc information: readelf. (line 114) +* ELF section group information: readelf. (line 80) +* ELF section information: readelf. (line 75) +* ELF section information <1>: readelf. (line 85) +* ELF segment information: readelf. (line 69) +* ELF symbol table information: readelf. (line 90) +* ELF version sections information: readelf. (line 129) +* elfedit: elfedit. (line 6) +* endianness: objdump. (line 148) +* error on valid input: Bug Criteria. (line 12) +* external symbols: nm. (line 179) +* external symbols <1>: nm. (line 243) +* external symbols <2>: nm. (line 257) +* extract from archive: ar cmdline. (line 112) +* fatal signal: Bug Criteria. (line 9) +* file name: nm. (line 141) +* header information, all: objdump. (line 735) +* input .def file: dlltool. (line 120) +* input file name: nm. (line 141) +* Instruction width: objdump. (line 465) +* libraries: ar. (line 25) +* listings strings: strings. (line 6) +* machine instructions: objdump. (line 119) +* moving in archive: ar cmdline. (line 34) +* MRI compatibility, ar: ar scripts. (line 8) +* name duplication in archive: ar cmdline. (line 106) +* name length: ar. (line 18) +* nm: nm. (line 6) +* nm compatibility: nm. (line 151) +* nm compatibility <1>: nm. (line 173) +* nm format: nm. (line 151) +* nm format <1>: nm. (line 173) +* not writing archive index: ar cmdline. (line 195) +* objdump: objdump. (line 6) +* objdump inlines: nm. (line 195) +* object code format: nm. (line 309) +* object code format <1>: objdump. (line 83) +* object code format <2>: size. (line 84) +* object code format <3>: strings. (line 94) +* object code format <4>: addr2line. (line 79) +* object file header: objdump. (line 154) +* object file information: objdump. (line 6) +* object file offsets: objdump. (line 159) +* object file sections: objdump. (line 439) +* object formats available: objdump. (line 198) +* operations on archive: ar cmdline. (line 22) +* plugins: ar cmdline. (line 250) +* plugins <1>: nm. (line 260) +* printing from archive: ar cmdline. (line 46) +* printing strings: strings. (line 6) +* quick append to archive: ar cmdline. (line 54) +* radix for section sizes: size. (line 66) +* ranlib: ranlib. (line 6) +* ranlib <1>: ar cmdline. (line 91) +* readelf: readelf. (line 6) +* relative placement in archive: ar cmdline. (line 125) +* relocation entries, in object file: objdump. (line 426) +* removing symbols: strip. (line 6) +* repeated names in archive: ar cmdline. (line 106) +* replacement in archive: ar cmdline. (line 73) +* reporting bugs: Reporting Bugs. (line 6) +* scripts, ar: ar scripts. (line 8) +* section addresses in objdump: objdump. (line 75) +* section headers: objdump. (line 175) +* section information: objdump. (line 203) +* section sizes: size. (line 6) +* sections, full contents: objdump. (line 439) +* size: size. (line 6) +* size display format: size. (line 27) +* size number format: size. (line 66) +* sorting symbols: nm. (line 210) +* source code context: objdump. (line 168) +* source disassembly: objdump. (line 444) +* source file name: nm. (line 141) +* source filenames for object files: objdump. (line 207) +* stab: objdump. (line 613) +* start-address: objdump. (line 622) +* stop-address: objdump. (line 626) +* strings: strings. (line 6) +* strings, printing: strings. (line 6) +* strip: strip. (line 6) +* Strip absolute paths: objdump. (line 451) +* symbol index: ar. (line 28) +* symbol index <1>: ranlib. (line 6) +* symbol index, listing: nm. (line 232) +* symbol line numbers: nm. (line 187) +* symbol table entries, printing: objdump. (line 631) +* symbols: nm. (line 6) +* symbols, discarding: strip. (line 6) +* thin archives: ar. (line 40) +* undefined symbols: nm. (line 243) +* undefined symbols <1>: nm. (line 257) +* Unix compatibility, ar: ar cmdline. (line 8) +* unwind information: readelf. (line 119) +* Update ELF header: elfedit. (line 6) +* updating an archive: ar cmdline. (line 207) +* version: Top. (line 6) +* VMA in objdump: objdump. (line 75) +* wide output, printing: objdump. (line 741) +* writing archive index: ar cmdline. (line 189) + + + +Tag Table: +Node: Top1893 +Node: ar3603 +Node: ar cmdline6737 +Node: ar scripts18135 +Node: nm23821 +Node: objcopy35373 +Node: objdump74337 +Node: ranlib103625 +Node: size105224 +Node: strings108200 +Node: strip112572 +Node: c++filt121878 +Ref: c++filt-Footnote-1126692 +Node: addr2line126798 +Node: nlmconv131327 +Node: windmc133906 +Node: windres137563 +Node: dlltool143922 +Node: def file format156919 +Node: readelf159449 +Node: elfedit170963 +Node: Common Options173215 +Node: Selecting the Target System174249 +Node: Target Selection175181 +Node: Architecture Selection177162 +Node: Reporting Bugs177990 +Node: Bug Criteria178769 +Node: Bug Reporting179322 +Node: GNU Free Documentation License186192 +Node: Binutils Index211352 + +End Tag Table diff --git a/support/sdbinutils/binutils/doc/binutils.texi b/support/sdbinutils/binutils/doc/binutils.texi new file mode 100644 index 0000000..b862a79 --- /dev/null +++ b/support/sdbinutils/binutils/doc/binutils.texi @@ -0,0 +1,5287 @@ +\input texinfo @c -*- Texinfo -*- +@setfilename binutils.info +@settitle @sc{gnu} Binary Utilities +@finalout +@synindex ky cp + +@c man begin INCLUDE +@include bfdver.texi +@c man end + +@copying +@c man begin COPYRIGHT +Copyright @copyright{} 1991-2018 Free Software Foundation, Inc. + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled ``GNU Free Documentation License''. + +@c man end +@end copying + +@dircategory Software development +@direntry +* Binutils: (binutils). The GNU binary utilities. +@end direntry + +@dircategory Individual utilities +@direntry +* addr2line: (binutils)addr2line. Convert addresses to file and line. +* ar: (binutils)ar. Create, modify, and extract from archives. +* c++filt: (binutils)c++filt. Filter to demangle encoded C++ symbols. +* cxxfilt: (binutils)c++filt. MS-DOS name for c++filt. +* dlltool: (binutils)dlltool. Create files needed to build and use DLLs. +* nlmconv: (binutils)nlmconv. Converts object code into an NLM. +* nm: (binutils)nm. List symbols from object files. +* objcopy: (binutils)objcopy. Copy and translate object files. +* objdump: (binutils)objdump. Display information from object files. +* ranlib: (binutils)ranlib. Generate index to archive contents. +* readelf: (binutils)readelf. Display the contents of ELF format files. +* size: (binutils)size. List section sizes and total size. +* strings: (binutils)strings. List printable strings from files. +* strip: (binutils)strip. Discard symbols. +* elfedit: (binutils)elfedit. Update the ELF header of ELF files. +* windmc: (binutils)windmc. Generator for Windows message resources. +* windres: (binutils)windres. Manipulate Windows resources. +@end direntry + +@titlepage +@title The @sc{gnu} Binary Utilities +@ifset VERSION_PACKAGE +@subtitle @value{VERSION_PACKAGE} +@end ifset +@subtitle Version @value{VERSION} +@sp 1 +@subtitle @value{UPDATED} +@author Roland H. Pesch +@author Jeffrey M. Osier +@author Cygnus Support +@page + +@tex +{\parskip=0pt \hfill Cygnus Support\par \hfill +Texinfo \texinfoversion\par } +@end tex + +@vskip 0pt plus 1filll +@insertcopying +@end titlepage +@contents + +@node Top +@top Introduction + +@cindex version +This brief manual contains documentation for the @sc{gnu} binary +utilities +@ifset VERSION_PACKAGE +@value{VERSION_PACKAGE} +@end ifset +version @value{VERSION}: + +@iftex +@table @code +@item ar +Create, modify, and extract from archives + +@item nm +List symbols from object files + +@item objcopy +Copy and translate object files + +@item objdump +Display information from object files + +@item ranlib +Generate index to archive contents + +@item readelf +Display the contents of ELF format files. + +@item size +List file section sizes and total size + +@item strings +List printable strings from files + +@item strip +Discard symbols + +@item elfedit +Update the ELF header of ELF files. + +@item c++filt +Demangle encoded C++ symbols (on MS-DOS, this program is named +@code{cxxfilt}) + +@item addr2line +Convert addresses into file names and line numbers + +@item nlmconv +Convert object code into a Netware Loadable Module + +@item windres +Manipulate Windows resources + +@item windmc +Generator for Windows message resources + +@item dlltool +Create the files needed to build and use Dynamic Link Libraries +@end table +@end iftex + +This document is distributed under the terms of the GNU Free +Documentation License version 1.3. A copy of the license is included +in the section entitled ``GNU Free Documentation License''. + +@menu +* ar:: Create, modify, and extract from archives +* nm:: List symbols from object files +* objcopy:: Copy and translate object files +* objdump:: Display information from object files +* ranlib:: Generate index to archive contents +* size:: List section sizes and total size +* strings:: List printable strings from files +* strip:: Discard symbols +* c++filt:: Filter to demangle encoded C++ symbols +* cxxfilt: c++filt. MS-DOS name for c++filt +* addr2line:: Convert addresses to file and line +* nlmconv:: Converts object code into an NLM +* windmc:: Generator for Windows message resources +* windres:: Manipulate Windows resources +* dlltool:: Create files needed to build and use DLLs +* readelf:: Display the contents of ELF format files +* elfedit:: Update the ELF header of ELF files +* Common Options:: Command-line options for all utilities +* Selecting the Target System:: How these utilities determine the target +* Reporting Bugs:: Reporting Bugs +* GNU Free Documentation License:: GNU Free Documentation License +* Binutils Index:: Binutils Index +@end menu + +@node ar +@chapter ar + +@kindex ar +@cindex archives +@cindex collections of files + +@c man title ar create, modify, and extract from archives + +@smallexample +ar [-]@var{p}[@var{mod}] [@option{--plugin} @var{name}] [@option{--target} @var{bfdname}] [@var{relpos}] [@var{count}] @var{archive} [@var{member}@dots{}] +ar -M [ }), and continues executing even after +errors. If you redirect standard input to a script file, no prompts are +issued, and @command{ar} abandons execution (with a nonzero exit code) +on any error. + +The @command{ar} command language is @emph{not} designed to be equivalent +to the command-line options; in fact, it provides somewhat less control +over archives. The only purpose of the command language is to ease the +transition to @sc{gnu} @command{ar} for developers who already have scripts +written for the MRI ``librarian'' program. + +The syntax for the @command{ar} command language is straightforward: +@itemize @bullet +@item +commands are recognized in upper or lower case; for example, @code{LIST} +is the same as @code{list}. In the following descriptions, commands are +shown in upper case for clarity. + +@item +a single command may appear on each line; it is the first word on the +line. + +@item +empty lines are allowed, and have no effect. + +@item +comments are allowed; text after either of the characters @samp{*} +or @samp{;} is ignored. + +@item +Whenever you use a list of names as part of the argument to an @command{ar} +command, you can separate the individual names with either commas or +blanks. Commas are shown in the explanations below, for clarity. + +@item +@samp{+} is used as a line continuation character; if @samp{+} appears +at the end of a line, the text on the following line is considered part +of the current command. +@end itemize + +Here are the commands you can use in @command{ar} scripts, or when using +@command{ar} interactively. Three of them have special significance: + +@code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is +a temporary file required for most of the other commands. + +@code{SAVE} commits the changes so far specified by the script. Prior +to @code{SAVE}, commands affect only the temporary copy of the current +archive. + +@table @code +@item ADDLIB @var{archive} +@itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module}) +Add all the contents of @var{archive} (or, if specified, each named +@var{module} from @var{archive}) to the current archive. + +Requires prior use of @code{OPEN} or @code{CREATE}. + +@item ADDMOD @var{member}, @var{member}, @dots{} @var{member} +@c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}" +@c else like "ar q..." +Add each named @var{member} as a module in the current archive. + +Requires prior use of @code{OPEN} or @code{CREATE}. + +@item CLEAR +Discard the contents of the current archive, canceling the effect of +any operations since the last @code{SAVE}. May be executed (with no +effect) even if no current archive is specified. + +@item CREATE @var{archive} +Creates an archive, and makes it the current archive (required for many +other commands). The new archive is created with a temporary name; it +is not actually saved as @var{archive} until you use @code{SAVE}. +You can overwrite existing archives; similarly, the contents of any +existing file named @var{archive} will not be destroyed until @code{SAVE}. + +@item DELETE @var{module}, @var{module}, @dots{} @var{module} +Delete each listed @var{module} from the current archive; equivalent to +@samp{ar -d @var{archive} @var{module} @dots{} @var{module}}. + +Requires prior use of @code{OPEN} or @code{CREATE}. + +@item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) +@itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile} +List each named @var{module} present in @var{archive}. The separate +command @code{VERBOSE} specifies the form of the output: when verbose +output is off, output is like that of @samp{ar -t @var{archive} +@var{module}@dots{}}. When verbose output is on, the listing is like +@samp{ar -tv @var{archive} @var{module}@dots{}}. + +Output normally goes to the standard output stream; however, if you +specify @var{outputfile} as a final argument, @command{ar} directs the +output to that file. + +@item END +Exit from @command{ar}, with a @code{0} exit code to indicate successful +completion. This command does not save the output file; if you have +changed the current archive since the last @code{SAVE} command, those +changes are lost. + +@item EXTRACT @var{module}, @var{module}, @dots{} @var{module} +Extract each named @var{module} from the current archive, writing them +into the current directory as separate files. Equivalent to @samp{ar -x +@var{archive} @var{module}@dots{}}. + +Requires prior use of @code{OPEN} or @code{CREATE}. + +@ignore +@c FIXME Tokens but no commands??? +@item FULLDIR + +@item HELP +@end ignore + +@item LIST +Display full contents of the current archive, in ``verbose'' style +regardless of the state of @code{VERBOSE}. The effect is like @samp{ar +tv @var{archive}}. (This single command is a @sc{gnu} @command{ar} +enhancement, rather than present for MRI compatibility.) + +Requires prior use of @code{OPEN} or @code{CREATE}. + +@item OPEN @var{archive} +Opens an existing archive for use as the current archive (required for +many other commands). Any changes as the result of subsequent commands +will not actually affect @var{archive} until you next use @code{SAVE}. + +@item REPLACE @var{module}, @var{module}, @dots{} @var{module} +In the current archive, replace each existing @var{module} (named in +the @code{REPLACE} arguments) from files in the current working directory. +To execute this command without errors, both the file, and the module in +the current archive, must exist. + +Requires prior use of @code{OPEN} or @code{CREATE}. + +@item VERBOSE +Toggle an internal flag governing the output from @code{DIRECTORY}. +When the flag is on, @code{DIRECTORY} output matches output from +@samp{ar -tv }@dots{}. + +@item SAVE +Commit your changes to the current archive, and actually save it as a +file with the name specified in the last @code{CREATE} or @code{OPEN} +command. + +Requires prior use of @code{OPEN} or @code{CREATE}. + +@end table + +@iftex +@node ld +@chapter ld +@cindex linker +@kindex ld +The @sc{gnu} linker @command{ld} is now described in a separate manual. +@xref{Top,, Overview,, Using LD: the @sc{gnu} linker}. +@end iftex + +@node nm +@chapter nm +@cindex symbols +@kindex nm + +@c man title nm list symbols from object files + +@smallexample +@c man begin SYNOPSIS nm +nm [@option{-A}|@option{-o}|@option{--print-file-name}] [@option{-a}|@option{--debug-syms}] + [@option{-B}|@option{--format=bsd}] [@option{-C}|@option{--demangle}[=@var{style}]] + [@option{-D}|@option{--dynamic}] [@option{-f}@var{format}|@option{--format=}@var{format}] + [@option{-g}|@option{--extern-only}] [@option{-h}|@option{--help}] + [@option{-l}|@option{--line-numbers}] [@option{--inlines}] + [@option{-n}|@option{-v}|@option{--numeric-sort}] + [@option{-P}|@option{--portability}] [@option{-p}|@option{--no-sort}] + [@option{-r}|@option{--reverse-sort}] [@option{-S}|@option{--print-size}] + [@option{-s}|@option{--print-armap}] [@option{-t} @var{radix}|@option{--radix=}@var{radix}] + [@option{-u}|@option{--undefined-only}] [@option{-V}|@option{--version}] + [@option{-X 32_64}] [@option{--defined-only}] [@option{--no-demangle}] + [@option{--plugin} @var{name}] [@option{--size-sort}] [@option{--special-syms}] + [@option{--synthetic}] [@option{--with-symbol-versions}] [@option{--target=}@var{bfdname}] + [@var{objfile}@dots{}] +@c man end +@end smallexample + +@c man begin DESCRIPTION nm +@sc{gnu} @command{nm} lists the symbols from object files @var{objfile}@dots{}. +If no object files are listed as arguments, @command{nm} assumes the file +@file{a.out}. + +For each symbol, @command{nm} shows: + +@itemize @bullet +@item +The symbol value, in the radix selected by options (see below), or +hexadecimal by default. + +@item +The symbol type. At least the following types are used; others are, as +well, depending on the object file format. If lowercase, the symbol is +usually local; if uppercase, the symbol is global (external). There +are however a few lowercase symbols that are shown for special global +symbols (@code{u}, @code{v} and @code{w}). + +@c Some more detail on exactly what these symbol types are used for +@c would be nice. +@table @code +@item A +The symbol's value is absolute, and will not be changed by further +linking. + +@item B +@itemx b +The symbol is in the uninitialized data section (known as BSS). + +@item C +The symbol is common. Common symbols are uninitialized data. When +linking, multiple common symbols may appear with the same name. If the +symbol is defined anywhere, the common symbols are treated as undefined +references. +@ifclear man +For more details on common symbols, see the discussion of +--warn-common in @ref{Options,,Linker options,ld.info,The GNU linker}. +@end ifclear + +@item D +@itemx d +The symbol is in the initialized data section. + +@item G +@itemx g +The symbol is in an initialized data section for small objects. Some +object file formats permit more efficient access to small data objects, +such as a global int variable as opposed to a large global array. + +@item i +For PE format files this indicates that the symbol is in a section +specific to the implementation of DLLs. For ELF format files this +indicates that the symbol is an indirect function. This is a GNU +extension to the standard set of ELF symbol types. It indicates a +symbol which if referenced by a relocation does not evaluate to its +address, but instead must be invoked at runtime. The runtime +execution will then return the value to be used in the relocation. + +@item I +The symbol is an indirect reference to another symbol. + +@item N +The symbol is a debugging symbol. + +@item p +The symbols is in a stack unwind section. + +@item R +@itemx r +The symbol is in a read only data section. + +@item S +@itemx s +The symbol is in an uninitialized data section for small objects. + +@item T +@itemx t +The symbol is in the text (code) section. + +@item U +The symbol is undefined. + +@item u +The symbol is a unique global symbol. This is a GNU extension to the +standard set of ELF symbol bindings. For such a symbol the dynamic linker +will make sure that in the entire process there is just one symbol with +this name and type in use. + +@item V +@itemx v +The symbol is a weak object. When a weak defined symbol is linked with +a normal defined symbol, the normal defined symbol is used with no error. +When a weak undefined symbol is linked and the symbol is not defined, +the value of the weak symbol becomes zero with no error. On some +systems, uppercase indicates that a default value has been specified. + +@item W +@itemx w +The symbol is a weak symbol that has not been specifically tagged as a +weak object symbol. When a weak defined symbol is linked with a normal +defined symbol, the normal defined symbol is used with no error. +When a weak undefined symbol is linked and the symbol is not defined, +the value of the symbol is determined in a system-specific manner without +error. On some systems, uppercase indicates that a default value has been +specified. + +@item - +The symbol is a stabs symbol in an a.out object file. In this case, the +next values printed are the stabs other field, the stabs desc field, and +the stab type. Stabs symbols are used to hold debugging information. + +@item ? +The symbol type is unknown, or object file format specific. +@end table + +@item +The symbol name. +@end itemize + +@c man end + +@c man begin OPTIONS nm +The long and short forms of options, shown here as alternatives, are +equivalent. + +@table @env +@item -A +@itemx -o +@itemx --print-file-name +@cindex input file name +@cindex file name +@cindex source file name +Precede each symbol by the name of the input file (or archive member) +in which it was found, rather than identifying the input file once only, +before all of its symbols. + +@item -a +@itemx --debug-syms +@cindex debugging symbols +Display all symbols, even debugger-only symbols; normally these are not +listed. + +@item -B +@cindex @command{nm} format +@cindex @command{nm} compatibility +The same as @option{--format=bsd} (for compatibility with the MIPS @command{nm}). + +@item -C +@itemx --demangle[=@var{style}] +@cindex demangling in nm +Decode (@dfn{demangle}) low-level symbol names into user-level names. +Besides removing any initial underscore prepended by the system, this +makes C++ function names readable. Different compilers have different +mangling styles. The optional demangling style argument can be used to +choose an appropriate demangling style for your compiler. @xref{c++filt}, +for more information on demangling. + +@item --no-demangle +Do not demangle low-level symbol names. This is the default. + +@item -D +@itemx --dynamic +@cindex dynamic symbols +Display the dynamic symbols rather than the normal symbols. This is +only meaningful for dynamic objects, such as certain types of shared +libraries. + +@item -f @var{format} +@itemx --format=@var{format} +@cindex @command{nm} format +@cindex @command{nm} compatibility +Use the output format @var{format}, which can be @code{bsd}, +@code{sysv}, or @code{posix}. The default is @code{bsd}. +Only the first character of @var{format} is significant; it can be +either upper or lower case. + +@item -g +@itemx --extern-only +@cindex external symbols +Display only external symbols. + +@item -h +@itemx --help +Show a summary of the options to @command{nm} and exit. + +@item -l +@itemx --line-numbers +@cindex symbol line numbers +For each symbol, use debugging information to try to find a filename and +line number. For a defined symbol, look for the line number of the +address of the symbol. For an undefined symbol, look for the line +number of a relocation entry which refers to the symbol. If line number +information can be found, print it after the other symbol information. + +@item --inlines +@cindex objdump inlines +When option @option{-l} is active, if the address belongs to a +function that was inlined, then this option causes the source +information for all enclosing scopes back to the first non-inlined +function to be printed as well. For example, if @code{main} inlines +@code{callee1} which inlines @code{callee2}, and address is from +@code{callee2}, the source information for @code{callee1} and @code{main} +will also be printed. + +@item -n +@itemx -v +@itemx --numeric-sort +Sort symbols numerically by their addresses, rather than alphabetically +by their names. + +@item -p +@itemx --no-sort +@cindex sorting symbols +Do not bother to sort the symbols in any order; print them in the order +encountered. + +@item -P +@itemx --portability +Use the POSIX.2 standard output format instead of the default format. +Equivalent to @samp{-f posix}. + +@item -r +@itemx --reverse-sort +Reverse the order of the sort (whether numeric or alphabetic); let the +last come first. + +@item -S +@itemx --print-size +Print both value and size of defined symbols for the @code{bsd} output style. +This option has no effect for object formats that do not record symbol +sizes, unless @samp{--size-sort} is also used in which case a +calculated size is displayed. + +@item -s +@itemx --print-armap +@cindex symbol index, listing +When listing symbols from archive members, include the index: a mapping +(stored in the archive by @command{ar} or @command{ranlib}) of which modules +contain definitions for which names. + +@item -t @var{radix} +@itemx --radix=@var{radix} +Use @var{radix} as the radix for printing the symbol values. It must be +@samp{d} for decimal, @samp{o} for octal, or @samp{x} for hexadecimal. + +@item -u +@itemx --undefined-only +@cindex external symbols +@cindex undefined symbols +Display only undefined symbols (those external to each object file). + +@item -V +@itemx --version +Show the version number of @command{nm} and exit. + +@item -X +This option is ignored for compatibility with the AIX version of +@command{nm}. It takes one parameter which must be the string +@option{32_64}. The default mode of AIX @command{nm} corresponds +to @option{-X 32}, which is not supported by @sc{gnu} @command{nm}. + +@item --defined-only +@cindex external symbols +@cindex undefined symbols +Display only defined symbols for each object file. + +@item --plugin @var{name} +@cindex plugins +Load the plugin called @var{name} to add support for extra target +types. This option is only available if the toolchain has been built +with plugin support enabled. + +If @option{--plugin} is not provided, but plugin support has been +enabled then @command{nm} iterates over the files in +@file{$@{libdir@}/bfd-plugins} in alphabetic order and the first +plugin that claims the object in question is used. + +Please note that this plugin search directory is @emph{not} the one +used by @command{ld}'s @option{-plugin} option. In order to make +@command{nm} use the linker plugin it must be copied into the +@file{$@{libdir@}/bfd-plugins} directory. For GCC based compilations +the linker plugin is called @file{liblto_plugin.so.0.0.0}. For Clang +based compilations it is called @file{LLVMgold.so}. The GCC plugin +is always backwards compatible with earlier versions, so it is +sufficient to just copy the newest one. + +@item --size-sort +Sort symbols by size. For ELF objects symbol sizes are read from the +ELF, for other object types the symbol sizes are computed as the +difference between the value of the symbol and the value of the symbol +with the next higher value. If the @code{bsd} output format is used +the size of the symbol is printed, rather than the value, and +@samp{-S} must be used in order both size and value to be printed. + +@item --special-syms +Display symbols which have a target-specific special meaning. These +symbols are usually used by the target for some special processing and +are not normally helpful when included in the normal symbol lists. +For example for ARM targets this option would skip the mapping symbols +used to mark transitions between ARM code, THUMB code and data. + +@item --synthetic +Include synthetic symbols in the output. These are special symbols +created by the linker for various purposes. They are not shown by +default since they are not part of the binary's original source code. + +@item --with-symbol-versions +Enables the display of symbol version information if any exists. The +version string is displayed as a suffix to the symbol name, preceeded by +an @@ character. For example @samp{foo@@VER_1}. If the version is +the default version to be used when resolving unversioned references +to the symbol then it is displayed as a suffix preceeded by two @@ +characters. For example @samp{foo@@@@VER_2}. + +@item --target=@var{bfdname} +@cindex object code format +Specify an object code format other than your system's default format. +@xref{Target Selection}, for more information. + +@end table + +@c man end + +@ignore +@c man begin SEEALSO nm +ar(1), objdump(1), ranlib(1), and the Info entries for @file{binutils}. +@c man end +@end ignore + +@node objcopy +@chapter objcopy + +@c man title objcopy copy and translate object files + +@smallexample +@c man begin SYNOPSIS objcopy +objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}] + [@option{-I} @var{bfdname}|@option{--input-target=}@var{bfdname}] + [@option{-O} @var{bfdname}|@option{--output-target=}@var{bfdname}] + [@option{-B} @var{bfdarch}|@option{--binary-architecture=}@var{bfdarch}] + [@option{-S}|@option{--strip-all}] + [@option{-g}|@option{--strip-debug}] + [@option{--strip-unneeded}] + [@option{-K} @var{symbolname}|@option{--keep-symbol=}@var{symbolname}] + [@option{-N} @var{symbolname}|@option{--strip-symbol=}@var{symbolname}] + [@option{--strip-unneeded-symbol=}@var{symbolname}] + [@option{-G} @var{symbolname}|@option{--keep-global-symbol=}@var{symbolname}] + [@option{--localize-hidden}] + [@option{-L} @var{symbolname}|@option{--localize-symbol=}@var{symbolname}] + [@option{--globalize-symbol=}@var{symbolname}] + [@option{-W} @var{symbolname}|@option{--weaken-symbol=}@var{symbolname}] + [@option{-w}|@option{--wildcard}] + [@option{-x}|@option{--discard-all}] + [@option{-X}|@option{--discard-locals}] + [@option{-b} @var{byte}|@option{--byte=}@var{byte}] + [@option{-i} [@var{breadth}]|@option{--interleave}[=@var{breadth}]] + [@option{--interleave-width=}@var{width}] + [@option{-j} @var{sectionpattern}|@option{--only-section=}@var{sectionpattern}] + [@option{-R} @var{sectionpattern}|@option{--remove-section=}@var{sectionpattern}] + [@option{--remove-relocations=}@var{sectionpattern}] + [@option{-p}|@option{--preserve-dates}] + [@option{-D}|@option{--enable-deterministic-archives}] + [@option{-U}|@option{--disable-deterministic-archives}] + [@option{--debugging}] + [@option{--gap-fill=}@var{val}] + [@option{--pad-to=}@var{address}] + [@option{--set-start=}@var{val}] + [@option{--adjust-start=}@var{incr}] + [@option{--change-addresses=}@var{incr}] + [@option{--change-section-address} @var{sectionpattern}@{=,+,-@}@var{val}] + [@option{--change-section-lma} @var{sectionpattern}@{=,+,-@}@var{val}] + [@option{--change-section-vma} @var{sectionpattern}@{=,+,-@}@var{val}] + [@option{--change-warnings}] [@option{--no-change-warnings}] + [@option{--set-section-flags} @var{sectionpattern}=@var{flags}] + [@option{--add-section} @var{sectionname}=@var{filename}] + [@option{--dump-section} @var{sectionname}=@var{filename}] + [@option{--update-section} @var{sectionname}=@var{filename}] + [@option{--rename-section} @var{oldname}=@var{newname}[,@var{flags}]] + [@option{--long-section-names} @{enable,disable,keep@}] + [@option{--change-leading-char}] [@option{--remove-leading-char}] + [@option{--reverse-bytes=}@var{num}] + [@option{--srec-len=}@var{ival}] [@option{--srec-forceS3}] + [@option{--redefine-sym} @var{old}=@var{new}] + [@option{--redefine-syms=}@var{filename}] + [@option{--weaken}] + [@option{--keep-symbols=}@var{filename}] + [@option{--strip-symbols=}@var{filename}] + [@option{--strip-unneeded-symbols=}@var{filename}] + [@option{--keep-global-symbols=}@var{filename}] + [@option{--localize-symbols=}@var{filename}] + [@option{--globalize-symbols=}@var{filename}] + [@option{--weaken-symbols=}@var{filename}] + [@option{--add-symbol} @var{name}=[@var{section}:]@var{value}[,@var{flags}] + [@option{--alt-machine-code=}@var{index}] + [@option{--prefix-symbols=}@var{string}] + [@option{--prefix-sections=}@var{string}] + [@option{--prefix-alloc-sections=}@var{string}] + [@option{--add-gnu-debuglink=}@var{path-to-file}] + [@option{--keep-file-symbols}] + [@option{--only-keep-debug}] + [@option{--strip-dwo}] + [@option{--extract-dwo}] + [@option{--extract-symbol}] + [@option{--writable-text}] + [@option{--readonly-text}] + [@option{--pure}] + [@option{--impure}] + [@option{--file-alignment=}@var{num}] + [@option{--heap=}@var{size}] + [@option{--image-base=}@var{address}] + [@option{--section-alignment=}@var{num}] + [@option{--stack=}@var{size}] + [@option{--subsystem=}@var{which}:@var{major}.@var{minor}] + [@option{--compress-debug-sections}] + [@option{--decompress-debug-sections}] + [@option{--elf-stt-common=@var{val}}] + [@option{--merge-notes}] + [@option{--no-merge-notes}] + [@option{-v}|@option{--verbose}] + [@option{-V}|@option{--version}] + [@option{--help}] [@option{--info}] + @var{infile} [@var{outfile}] +@c man end +@end smallexample + +@c man begin DESCRIPTION objcopy +The @sc{gnu} @command{objcopy} utility copies the contents of an object +file to another. @command{objcopy} uses the @sc{gnu} @sc{bfd} Library to +read and write the object files. It can write the destination object +file in a format different from that of the source object file. The +exact behavior of @command{objcopy} is controlled by command-line options. +Note that @command{objcopy} should be able to copy a fully linked file +between any two formats. However, copying a relocatable object file +between any two formats may not work as expected. + +@command{objcopy} creates temporary files to do its translations and +deletes them afterward. @command{objcopy} uses @sc{bfd} to do all its +translation work; it has access to all the formats described in @sc{bfd} +and thus is able to recognize most formats without being told +explicitly. @xref{BFD,,BFD,ld.info,Using LD}. + +@command{objcopy} can be used to generate S-records by using an output +target of @samp{srec} (e.g., use @samp{-O srec}). + +@command{objcopy} can be used to generate a raw binary file by using an +output target of @samp{binary} (e.g., use @option{-O binary}). When +@command{objcopy} generates a raw binary file, it will essentially produce +a memory dump of the contents of the input object file. All symbols and +relocation information will be discarded. The memory dump will start at +the load address of the lowest section copied into the output file. + +When generating an S-record or a raw binary file, it may be helpful to +use @option{-S} to remove sections containing debugging information. In +some cases @option{-R} will be useful to remove sections which contain +information that is not needed by the binary file. + +Note---@command{objcopy} is not able to change the endianness of its input +files. If the input format has an endianness (some formats do not), +@command{objcopy} can only copy the inputs into file formats that have the +same endianness or which have no endianness (e.g., @samp{srec}). +(However, see the @option{--reverse-bytes} option.) + +@c man end + +@c man begin OPTIONS objcopy + +@table @env +@item @var{infile} +@itemx @var{outfile} +The input and output files, respectively. +If you do not specify @var{outfile}, @command{objcopy} creates a +temporary file and destructively renames the result with +the name of @var{infile}. + +@item -I @var{bfdname} +@itemx --input-target=@var{bfdname} +Consider the source file's object format to be @var{bfdname}, rather than +attempting to deduce it. @xref{Target Selection}, for more information. + +@item -O @var{bfdname} +@itemx --output-target=@var{bfdname} +Write the output file using the object format @var{bfdname}. +@xref{Target Selection}, for more information. + +@item -F @var{bfdname} +@itemx --target=@var{bfdname} +Use @var{bfdname} as the object format for both the input and the output +file; i.e., simply transfer data from source to destination with no +translation. @xref{Target Selection}, for more information. + +@item -B @var{bfdarch} +@itemx --binary-architecture=@var{bfdarch} +Useful when transforming a architecture-less input file into an object file. +In this case the output architecture can be set to @var{bfdarch}. This +option will be ignored if the input file has a known @var{bfdarch}. You +can access this binary data inside a program by referencing the special +symbols that are created by the conversion process. These symbols are +called _binary_@var{objfile}_start, _binary_@var{objfile}_end and +_binary_@var{objfile}_size. e.g. you can transform a picture file into +an object file and then access it in your code using these symbols. + +@item -j @var{sectionpattern} +@itemx --only-section=@var{sectionpattern} +Copy only the indicated sections from the input file to the output file. +This option may be given more than once. Note that using this option +inappropriately may make the output file unusable. Wildcard +characters are accepted in @var{sectionpattern}. + +If the first character of @var{sectionpattern} is the exclamation +point (!) then matching sections will not be copied, even if earlier +use of @option{--only-section} on the same command line would +otherwise copy it. For example: + +@smallexample + --only-section=.text.* --only-section=!.text.foo +@end smallexample + +will copy all sectinos maching '.text.*' but not the section +'.text.foo'. + +@item -R @var{sectionpattern} +@itemx --remove-section=@var{sectionpattern} +Remove any section matching @var{sectionpattern} from the output file. +This option may be given more than once. Note that using this option +inappropriately may make the output file unusable. Wildcard +characters are accepted in @var{sectionpattern}. Using both the +@option{-j} and @option{-R} options together results in undefined +behaviour. + +If the first character of @var{sectionpattern} is the exclamation +point (!) then matching sections will not be removed even if an +earlier use of @option{--remove-section} on the same command line +would otherwise remove it. For example: + +@smallexample + --remove-section=.text.* --remove-section=!.text.foo +@end smallexample + +will remove all sections matching the pattern '.text.*', but will not +remove the section '.text.foo'. + +@item --remove-relocations=@var{sectionpattern} +Remove relocations from the output file for any section matching +@var{sectionpattern}. This option may be given more than once. Note +that using this option inappropriately may make the output file +unusable. Wildcard characters are accepted in @var{sectionpattern}. +For example: + +@smallexample + --remove-relocations=.text.* +@end smallexample + +will remove the relocations for all sections matching the patter +'.text.*'. + +If the first character of @var{sectionpattern} is the exclamation +point (!) then matching sections will not have their relocation +removed even if an earlier use of @option{--remove-relocations} on the +same command line would otherwise cause the relocations to be removed. +For example: + +@smallexample + --remove-relocations=.text.* --remove-relocations=!.text.foo +@end smallexample + +will remove all relocations for sections matching the pattern +'.text.*', but will not remove relocations for the section +'.text.foo'. + +@item -S +@itemx --strip-all +Do not copy relocation and symbol information from the source file. + +@item -g +@itemx --strip-debug +Do not copy debugging symbols or sections from the source file. + +@item --strip-unneeded +Strip all symbols that are not needed for relocation processing. + +@item -K @var{symbolname} +@itemx --keep-symbol=@var{symbolname} +When stripping symbols, keep symbol @var{symbolname} even if it would +normally be stripped. This option may be given more than once. + +@item -N @var{symbolname} +@itemx --strip-symbol=@var{symbolname} +Do not copy symbol @var{symbolname} from the source file. This option +may be given more than once. + +@item --strip-unneeded-symbol=@var{symbolname} +Do not copy symbol @var{symbolname} from the source file unless it is needed +by a relocation. This option may be given more than once. + +@item -G @var{symbolname} +@itemx --keep-global-symbol=@var{symbolname} +Keep only symbol @var{symbolname} global. Make all other symbols local +to the file, so that they are not visible externally. This option may +be given more than once. + +@item --localize-hidden +In an ELF object, mark all symbols that have hidden or internal visibility +as local. This option applies on top of symbol-specific localization options +such as @option{-L}. + +@item -L @var{symbolname} +@itemx --localize-symbol=@var{symbolname} +Convert a global or weak symbol called @var{symbolname} into a local +symbol, so that it is not visible externally. This option may be +given more than once. Note - unique symbols are not converted. + +@item -W @var{symbolname} +@itemx --weaken-symbol=@var{symbolname} +Make symbol @var{symbolname} weak. This option may be given more than once. + +@item --globalize-symbol=@var{symbolname} +Give symbol @var{symbolname} global scoping so that it is visible +outside of the file in which it is defined. This option may be given +more than once. + +@item -w +@itemx --wildcard +Permit regular expressions in @var{symbolname}s used in other command +line options. The question mark (?), asterisk (*), backslash (\) and +square brackets ([]) operators can be used anywhere in the symbol +name. If the first character of the symbol name is the exclamation +point (!) then the sense of the switch is reversed for that symbol. +For example: + +@smallexample + -w -W !foo -W fo* +@end smallexample + +would cause objcopy to weaken all symbols that start with ``fo'' +except for the symbol ``foo''. + +@item -x +@itemx --discard-all +Do not copy non-global symbols from the source file. +@c FIXME any reason to prefer "non-global" to "local" here? + +@item -X +@itemx --discard-locals +Do not copy compiler-generated local symbols. +(These usually start with @samp{L} or @samp{.}.) + +@item -b @var{byte} +@itemx --byte=@var{byte} +If interleaving has been enabled via the @option{--interleave} option +then start the range of bytes to keep at the @var{byte}th byte. +@var{byte} can be in the range from 0 to @var{breadth}-1, where +@var{breadth} is the value given by the @option{--interleave} option. + +@item -i [@var{breadth}] +@itemx --interleave[=@var{breadth}] +Only copy a range out of every @var{breadth} bytes. (Header data is +not affected). Select which byte in the range begins the copy with +the @option{--byte} option. Select the width of the range with the +@option{--interleave-width} option. + +This option is useful for creating files to program @sc{rom}. It is +typically used with an @code{srec} output target. Note that +@command{objcopy} will complain if you do not specify the +@option{--byte} option as well. + +The default interleave breadth is 4, so with @option{--byte} set to 0, +@command{objcopy} would copy the first byte out of every four bytes +from the input to the output. + +@item --interleave-width=@var{width} +When used with the @option{--interleave} option, copy @var{width} +bytes at a time. The start of the range of bytes to be copied is set +by the @option{--byte} option, and the extent of the range is set with +the @option{--interleave} option. + +The default value for this option is 1. The value of @var{width} plus +the @var{byte} value set by the @option{--byte} option must not exceed +the interleave breadth set by the @option{--interleave} option. + +This option can be used to create images for two 16-bit flashes interleaved +in a 32-bit bus by passing @option{-b 0 -i 4 --interleave-width=2} +and @option{-b 2 -i 4 --interleave-width=2} to two @command{objcopy} +commands. If the input was '12345678' then the outputs would be +'1256' and '3478' respectively. + +@item -p +@itemx --preserve-dates +Set the access and modification dates of the output file to be the same +as those of the input file. + +@item -D +@itemx --enable-deterministic-archives +@cindex deterministic archives +@kindex --enable-deterministic-archives +Operate in @emph{deterministic} mode. When copying archive members +and writing the archive index, use zero for UIDs, GIDs, timestamps, +and use consistent file modes for all files. + +If @file{binutils} was configured with +@option{--enable-deterministic-archives}, then this mode is on by default. +It can be disabled with the @samp{-U} option, below. + +@item -U +@itemx --disable-deterministic-archives +@cindex deterministic archives +@kindex --enable-deterministic-archives +Do @emph{not} operate in @emph{deterministic} mode. This is the +inverse of the @option{-D} option, above: when copying archive members +and writing the archive index, use their actual UID, GID, timestamp, +and file mode values. + +This is the default unless @file{binutils} was configured with +@option{--enable-deterministic-archives}. + +@item --debugging +Convert debugging information, if possible. This is not the default +because only certain debugging formats are supported, and the +conversion process can be time consuming. + +@item --gap-fill @var{val} +Fill gaps between sections with @var{val}. This operation applies to +the @emph{load address} (LMA) of the sections. It is done by increasing +the size of the section with the lower address, and filling in the extra +space created with @var{val}. + +@item --pad-to @var{address} +Pad the output file up to the load address @var{address}. This is +done by increasing the size of the last section. The extra space is +filled in with the value specified by @option{--gap-fill} (default zero). + +@item --set-start @var{val} +Set the start address of the new file to @var{val}. Not all object file +formats support setting the start address. + +@item --change-start @var{incr} +@itemx --adjust-start @var{incr} +@cindex changing start address +Change the start address by adding @var{incr}. Not all object file +formats support setting the start address. + +@item --change-addresses @var{incr} +@itemx --adjust-vma @var{incr} +@cindex changing object addresses +Change the VMA and LMA addresses of all sections, as well as the start +address, by adding @var{incr}. Some object file formats do not permit +section addresses to be changed arbitrarily. Note that this does not +relocate the sections; if the program expects sections to be loaded at a +certain address, and this option is used to change the sections such +that they are loaded at a different address, the program may fail. + +@item --change-section-address @var{sectionpattern}@{=,+,-@}@var{val} +@itemx --adjust-section-vma @var{sectionpattern}@{=,+,-@}@var{val} +@cindex changing section address +Set or change both the VMA address and the LMA address of any section +matching @var{sectionpattern}. If @samp{=} is used, the section +address is set to @var{val}. Otherwise, @var{val} is added to or +subtracted from the section address. See the comments under +@option{--change-addresses}, above. If @var{sectionpattern} does not +match any sections in the input file, a warning will be issued, unless +@option{--no-change-warnings} is used. + +@item --change-section-lma @var{sectionpattern}@{=,+,-@}@var{val} +@cindex changing section LMA +Set or change the LMA address of any sections matching +@var{sectionpattern}. The LMA address is the address where the +section will be loaded into memory at program load time. Normally +this is the same as the VMA address, which is the address of the +section at program run time, but on some systems, especially those +where a program is held in ROM, the two can be different. If @samp{=} +is used, the section address is set to @var{val}. Otherwise, +@var{val} is added to or subtracted from the section address. See the +comments under @option{--change-addresses}, above. If +@var{sectionpattern} does not match any sections in the input file, a +warning will be issued, unless @option{--no-change-warnings} is used. + +@item --change-section-vma @var{sectionpattern}@{=,+,-@}@var{val} +@cindex changing section VMA +Set or change the VMA address of any section matching +@var{sectionpattern}. The VMA address is the address where the +section will be located once the program has started executing. +Normally this is the same as the LMA address, which is the address +where the section will be loaded into memory, but on some systems, +especially those where a program is held in ROM, the two can be +different. If @samp{=} is used, the section address is set to +@var{val}. Otherwise, @var{val} is added to or subtracted from the +section address. See the comments under @option{--change-addresses}, +above. If @var{sectionpattern} does not match any sections in the +input file, a warning will be issued, unless +@option{--no-change-warnings} is used. + +@item --change-warnings +@itemx --adjust-warnings +If @option{--change-section-address} or @option{--change-section-lma} or +@option{--change-section-vma} is used, and the section pattern does not +match any sections, issue a warning. This is the default. + +@item --no-change-warnings +@itemx --no-adjust-warnings +Do not issue a warning if @option{--change-section-address} or +@option{--adjust-section-lma} or @option{--adjust-section-vma} is used, even +if the section pattern does not match any sections. + +@item --set-section-flags @var{sectionpattern}=@var{flags} +Set the flags for any sections matching @var{sectionpattern}. The +@var{flags} argument is a comma separated string of flag names. The +recognized names are @samp{alloc}, @samp{contents}, @samp{load}, +@samp{noload}, @samp{readonly}, @samp{code}, @samp{data}, @samp{rom}, +@samp{share}, and @samp{debug}. You can set the @samp{contents} flag +for a section which does not have contents, but it is not meaningful +to clear the @samp{contents} flag of a section which does have +contents--just remove the section instead. Not all flags are +meaningful for all object file formats. + +@item --add-section @var{sectionname}=@var{filename} +Add a new section named @var{sectionname} while copying the file. The +contents of the new section are taken from the file @var{filename}. The +size of the section will be the size of the file. This option only +works on file formats which can support sections with arbitrary names. +Note - it may be necessary to use the @option{--set-section-flags} +option to set the attributes of the newly created section. + +@item --dump-section @var{sectionname}=@var{filename} +Place the contents of section named @var{sectionname} into the file +@var{filename}, overwriting any contents that may have been there +previously. This option is the inverse of @option{--add-section}. +This option is similar to the @option{--only-section} option except +that it does not create a formatted file, it just dumps the contents +as raw binary data, without applying any relocations. The option can +be specified more than once. + +@item --update-section @var{sectionname}=@var{filename} +Replace the existing contents of a section named @var{sectionname} +with the contents of file @var{filename}. The size of the section +will be adjusted to the size of the file. The section flags for +@var{sectionname} will be unchanged. For ELF format files the section +to segment mapping will also remain unchanged, something which is not +possible using @option{--remove-section} followed by +@option{--add-section}. The option can be specified more than once. + +Note - it is possible to use @option{--rename-section} and +@option{--update-section} to both update and rename a section from one +command line. In this case, pass the original section name to +@option{--update-section}, and the original and new section names to +@option{--rename-section}. + +@item --add-symbol @var{name}=[@var{section}:]@var{value}[,@var{flags}] +Add a new symbol named @var{name} while copying the file. This option may be +specified multiple times. If the @var{section} is given, the symbol will be +associated with and relative to that section, otherwise it will be an ABS +symbol. Specifying an undefined section will result in a fatal error. There +is no check for the value, it will be taken as specified. Symbol flags can +be specified and not all flags will be meaningful for all object file +formats. By default, the symbol will be global. The special flag +'before=@var{othersym}' will insert the new symbol in front of the specified +@var{othersym}, otherwise the symbol(s) will be added at the end of the +symbol table in the order they appear. + +@item --rename-section @var{oldname}=@var{newname}[,@var{flags}] +Rename a section from @var{oldname} to @var{newname}, optionally +changing the section's flags to @var{flags} in the process. This has +the advantage over using a linker script to perform the rename in that +the output stays as an object file and does not become a linked +executable. + +This option is particularly helpful when the input format is binary, +since this will always create a section called .data. If for example, +you wanted instead to create a section called .rodata containing binary +data you could use the following command line to achieve it: + +@smallexample + objcopy -I binary -O -B \ + --rename-section .data=.rodata,alloc,load,readonly,data,contents \ + +@end smallexample + +@item --long-section-names @{enable,disable,keep@} +Controls the handling of long section names when processing @code{COFF} +and @code{PE-COFF} object formats. The default behaviour, @samp{keep}, +is to preserve long section names if any are present in the input file. +The @samp{enable} and @samp{disable} options forcibly enable or disable +the use of long section names in the output object; when @samp{disable} +is in effect, any long section names in the input object will be truncated. +The @samp{enable} option will only emit long section names if any are +present in the inputs; this is mostly the same as @samp{keep}, but it +is left undefined whether the @samp{enable} option might force the +creation of an empty string table in the output file. + +@item --change-leading-char +Some object file formats use special characters at the start of +symbols. The most common such character is underscore, which compilers +often add before every symbol. This option tells @command{objcopy} to +change the leading character of every symbol when it converts between +object file formats. If the object file formats use the same leading +character, this option has no effect. Otherwise, it will add a +character, or remove a character, or change a character, as +appropriate. + +@item --remove-leading-char +If the first character of a global symbol is a special symbol leading +character used by the object file format, remove the character. The +most common symbol leading character is underscore. This option will +remove a leading underscore from all global symbols. This can be useful +if you want to link together objects of different file formats with +different conventions for symbol names. This is different from +@option{--change-leading-char} because it always changes the symbol name +when appropriate, regardless of the object file format of the output +file. + +@item --reverse-bytes=@var{num} +Reverse the bytes in a section with output contents. A section length must +be evenly divisible by the value given in order for the swap to be able to +take place. Reversing takes place before the interleaving is performed. + +This option is used typically in generating ROM images for problematic +target systems. For example, on some target boards, the 32-bit words +fetched from 8-bit ROMs are re-assembled in little-endian byte order +regardless of the CPU byte order. Depending on the programming model, the +endianness of the ROM may need to be modified. + +Consider a simple file with a section containing the following eight +bytes: @code{12345678}. + +Using @samp{--reverse-bytes=2} for the above example, the bytes in the +output file would be ordered @code{21436587}. + +Using @samp{--reverse-bytes=4} for the above example, the bytes in the +output file would be ordered @code{43218765}. + +By using @samp{--reverse-bytes=2} for the above example, followed by +@samp{--reverse-bytes=4} on the output file, the bytes in the second +output file would be ordered @code{34127856}. + +@item --srec-len=@var{ival} +Meaningful only for srec output. Set the maximum length of the Srecords +being produced to @var{ival}. This length covers both address, data and +crc fields. + +@item --srec-forceS3 +Meaningful only for srec output. Avoid generation of S1/S2 records, +creating S3-only record format. + +@item --redefine-sym @var{old}=@var{new} +Change the name of a symbol @var{old}, to @var{new}. This can be useful +when one is trying link two things together for which you have no +source, and there are name collisions. + +@item --redefine-syms=@var{filename} +Apply @option{--redefine-sym} to each symbol pair "@var{old} @var{new}" +listed in the file @var{filename}. @var{filename} is simply a flat file, +with one symbol pair per line. Line comments may be introduced by the hash +character. This option may be given more than once. + +@item --weaken +Change all global symbols in the file to be weak. This can be useful +when building an object which will be linked against other objects using +the @option{-R} option to the linker. This option is only effective when +using an object file format which supports weak symbols. + +@item --keep-symbols=@var{filename} +Apply @option{--keep-symbol} option to each symbol listed in the file +@var{filename}. @var{filename} is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. + +@item --strip-symbols=@var{filename} +Apply @option{--strip-symbol} option to each symbol listed in the file +@var{filename}. @var{filename} is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. + +@item --strip-unneeded-symbols=@var{filename} +Apply @option{--strip-unneeded-symbol} option to each symbol listed in +the file @var{filename}. @var{filename} is simply a flat file, with one +symbol name per line. Line comments may be introduced by the hash +character. This option may be given more than once. + +@item --keep-global-symbols=@var{filename} +Apply @option{--keep-global-symbol} option to each symbol listed in the +file @var{filename}. @var{filename} is simply a flat file, with one +symbol name per line. Line comments may be introduced by the hash +character. This option may be given more than once. + +@item --localize-symbols=@var{filename} +Apply @option{--localize-symbol} option to each symbol listed in the file +@var{filename}. @var{filename} is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. + +@item --globalize-symbols=@var{filename} +Apply @option{--globalize-symbol} option to each symbol listed in the file +@var{filename}. @var{filename} is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. + +@item --weaken-symbols=@var{filename} +Apply @option{--weaken-symbol} option to each symbol listed in the file +@var{filename}. @var{filename} is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. + +@item --alt-machine-code=@var{index} +If the output architecture has alternate machine codes, use the +@var{index}th code instead of the default one. This is useful in case +a machine is assigned an official code and the tool-chain adopts the +new code, but other applications still depend on the original code +being used. For ELF based architectures if the @var{index} +alternative does not exist then the value is treated as an absolute +number to be stored in the e_machine field of the ELF header. + +@item --writable-text +Mark the output text as writable. This option isn't meaningful for all +object file formats. + +@item --readonly-text +Make the output text write protected. This option isn't meaningful for all +object file formats. + +@item --pure +Mark the output file as demand paged. This option isn't meaningful for all +object file formats. + +@item --impure +Mark the output file as impure. This option isn't meaningful for all +object file formats. + +@item --prefix-symbols=@var{string} +Prefix all symbols in the output file with @var{string}. + +@item --prefix-sections=@var{string} +Prefix all section names in the output file with @var{string}. + +@item --prefix-alloc-sections=@var{string} +Prefix all the names of all allocated sections in the output file with +@var{string}. + +@item --add-gnu-debuglink=@var{path-to-file} +Creates a .gnu_debuglink section which contains a reference to +@var{path-to-file} and adds it to the output file. Note: the file at +@var{path-to-file} must exist. Part of the process of adding the +.gnu_debuglink section involves embedding a checksum of the contents +of the debug info file into the section. + +If the debug info file is built in one location but it is going to be +installed at a later time into a different location then do not use +the path to the installed location. The @option{--add-gnu-debuglink} +option will fail because the installed file does not exist yet. +Instead put the debug info file in the current directory and use the +@option{--add-gnu-debuglink} option without any directory components, +like this: + +@smallexample + objcopy --add-gnu-debuglink=foo.debug +@end smallexample + +At debug time the debugger will attempt to look for the separate debug +info file in a set of known locations. The exact set of these +locations varies depending upon the distribution being used, but it +typically includes: + +@table @code + +@item * The same directory as the executable. + +@item * A sub-directory of the directory containing the executable +called .debug + +@item * A global debug directory such as /usr/lib/debug. +@end table + +As long as the debug info file has been installed into one of these +locations before the debugger is run everything should work +correctly. + +@item --keep-file-symbols +When stripping a file, perhaps with @option{--strip-debug} or +@option{--strip-unneeded}, retain any symbols specifying source file names, +which would otherwise get stripped. + +@item --only-keep-debug +Strip a file, removing contents of any sections that would not be +stripped by @option{--strip-debug} and leaving the debugging sections +intact. In ELF files, this preserves all note sections in the output. + +Note - the section headers of the stripped sections are preserved, +including their sizes, but the contents of the section are discarded. +The section headers are preserved so that other tools can match up the +debuginfo file with the real executable, even if that executable has +been relocated to a different address space. + +The intention is that this option will be used in conjunction with +@option{--add-gnu-debuglink} to create a two part executable. One a +stripped binary which will occupy less space in RAM and in a +distribution and the second a debugging information file which is only +needed if debugging abilities are required. The suggested procedure +to create these files is as follows: + +@enumerate +@item Link the executable as normal. Assuming that is is called +@code{foo} then... +@item Run @code{objcopy --only-keep-debug foo foo.dbg} to +create a file containing the debugging info. +@item Run @code{objcopy --strip-debug foo} to create a +stripped executable. +@item Run @code{objcopy --add-gnu-debuglink=foo.dbg foo} +to add a link to the debugging info into the stripped executable. +@end enumerate + +Note---the choice of @code{.dbg} as an extension for the debug info +file is arbitrary. Also the @code{--only-keep-debug} step is +optional. You could instead do this: + +@enumerate +@item Link the executable as normal. +@item Copy @code{foo} to @code{foo.full} +@item Run @code{objcopy --strip-debug foo} +@item Run @code{objcopy --add-gnu-debuglink=foo.full foo} +@end enumerate + +i.e., the file pointed to by the @option{--add-gnu-debuglink} can be the +full executable. It does not have to be a file created by the +@option{--only-keep-debug} switch. + +Note---this switch is only intended for use on fully linked files. It +does not make sense to use it on object files where the debugging +information may be incomplete. Besides the gnu_debuglink feature +currently only supports the presence of one filename containing +debugging information, not multiple filenames on a one-per-object-file +basis. + +@item --strip-dwo +Remove the contents of all DWARF .dwo sections, leaving the +remaining debugging sections and all symbols intact. +This option is intended for use by the compiler as part of +the @option{-gsplit-dwarf} option, which splits debug information +between the .o file and a separate .dwo file. The compiler +generates all debug information in the same file, then uses +the @option{--extract-dwo} option to copy the .dwo sections to +the .dwo file, then the @option{--strip-dwo} option to remove +those sections from the original .o file. + +@item --extract-dwo +Extract the contents of all DWARF .dwo sections. See the +@option{--strip-dwo} option for more information. + +@item --file-alignment @var{num} +Specify the file alignment. Sections in the file will always begin at +file offsets which are multiples of this number. This defaults to +512. +[This option is specific to PE targets.] + +@item --heap @var{reserve} +@itemx --heap @var{reserve},@var{commit} +Specify the number of bytes of memory to reserve (and optionally commit) +to be used as heap for this program. +[This option is specific to PE targets.] + +@item --image-base @var{value} +Use @var{value} as the base address of your program or dll. This is +the lowest memory location that will be used when your program or dll +is loaded. To reduce the need to relocate and improve performance of +your dlls, each should have a unique base address and not overlap any +other dlls. The default is 0x400000 for executables, and 0x10000000 +for dlls. +[This option is specific to PE targets.] + +@item --section-alignment @var{num} +Sets the section alignment. Sections in memory will always begin at +addresses which are a multiple of this number. Defaults to 0x1000. +[This option is specific to PE targets.] + +@item --stack @var{reserve} +@itemx --stack @var{reserve},@var{commit} +Specify the number of bytes of memory to reserve (and optionally commit) +to be used as stack for this program. +[This option is specific to PE targets.] + +@item --subsystem @var{which} +@itemx --subsystem @var{which}:@var{major} +@itemx --subsystem @var{which}:@var{major}.@var{minor} +Specifies the subsystem under which your program will execute. The +legal values for @var{which} are @code{native}, @code{windows}, +@code{console}, @code{posix}, @code{efi-app}, @code{efi-bsd}, +@code{efi-rtd}, @code{sal-rtd}, and @code{xbox}. You may optionally set +the subsystem version also. Numeric values are also accepted for +@var{which}. +[This option is specific to PE targets.] + +@item --extract-symbol +Keep the file's section flags and symbols but remove all section data. +Specifically, the option: + +@itemize +@item removes the contents of all sections; +@item sets the size of every section to zero; and +@item sets the file's start address to zero. +@end itemize + +This option is used to build a @file{.sym} file for a VxWorks kernel. +It can also be a useful way of reducing the size of a @option{--just-symbols} +linker input file. + +@item --compress-debug-sections +Compress DWARF debug sections using zlib with SHF_COMPRESSED from the +ELF ABI. Note - if compression would actually make a section +@emph{larger}, then it is not compressed. + +@item --compress-debug-sections=none +@itemx --compress-debug-sections=zlib +@itemx --compress-debug-sections=zlib-gnu +@itemx --compress-debug-sections=zlib-gabi +For ELF files, these options control how DWARF debug sections are +compressed. @option{--compress-debug-sections=none} is equivalent +to @option{--decompress-debug-sections}. +@option{--compress-debug-sections=zlib} and +@option{--compress-debug-sections=zlib-gabi} are equivalent to +@option{--compress-debug-sections}. +@option{--compress-debug-sections=zlib-gnu} compresses DWARF debug +sections using zlib. The debug sections are renamed to begin with +@samp{.zdebug} instead of @samp{.debug}. Note - if compression would +actually make a section @emph{larger}, then it is not compressed nor +renamed. + +@item --decompress-debug-sections +Decompress DWARF debug sections using zlib. The original section +names of the compressed sections are restored. + +@item --elf-stt-common=yes +@itemx --elf-stt-common=no +For ELF files, these options control whether common symbols should be +converted to the @code{STT_COMMON} or @code{STT_OBJECT} type. +@option{--elf-stt-common=yes} converts common symbol type to +@code{STT_COMMON}. @option{--elf-stt-common=no} converts common symbol +type to @code{STT_OBJECT}. + +@item --merge-notes +@itemx --no-merge-notes +For ELF files, attempt (or do not attempt) to reduce the size of any +SHT_NOTE type sections by removing duplicate notes. + +@item -V +@itemx --version +Show the version number of @command{objcopy}. + +@item -v +@itemx --verbose +Verbose output: list all object files modified. In the case of +archives, @samp{objcopy -V} lists all members of the archive. + +@item --help +Show a summary of the options to @command{objcopy}. + +@item --info +Display a list showing all architectures and object formats available. +@end table + +@c man end + +@ignore +@c man begin SEEALSO objcopy +ld(1), objdump(1), and the Info entries for @file{binutils}. +@c man end +@end ignore + +@node objdump +@chapter objdump + +@cindex object file information +@kindex objdump + +@c man title objdump display information from object files. + +@smallexample +@c man begin SYNOPSIS objdump +objdump [@option{-a}|@option{--archive-headers}] + [@option{-b} @var{bfdname}|@option{--target=@var{bfdname}}] + [@option{-C}|@option{--demangle}[=@var{style}] ] + [@option{-d}|@option{--disassemble}] + [@option{-D}|@option{--disassemble-all}] + [@option{-z}|@option{--disassemble-zeroes}] + [@option{-EB}|@option{-EL}|@option{--endian=}@{big | little @}] + [@option{-f}|@option{--file-headers}] + [@option{-F}|@option{--file-offsets}] + [@option{--file-start-context}] + [@option{-g}|@option{--debugging}] + [@option{-e}|@option{--debugging-tags}] + [@option{-h}|@option{--section-headers}|@option{--headers}] + [@option{-i}|@option{--info}] + [@option{-j} @var{section}|@option{--section=}@var{section}] + [@option{-l}|@option{--line-numbers}] + [@option{-S}|@option{--source}] + [@option{-m} @var{machine}|@option{--architecture=}@var{machine}] + [@option{-M} @var{options}|@option{--disassembler-options=}@var{options}] + [@option{-p}|@option{--private-headers}] + [@option{-P} @var{options}|@option{--private=}@var{options}] + [@option{-r}|@option{--reloc}] + [@option{-R}|@option{--dynamic-reloc}] + [@option{-s}|@option{--full-contents}] + [@option{-W[lLiaprmfFsoRtUuTgAckK]}| + @option{--dwarf}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links] + [@option{-G}|@option{--stabs}] + [@option{-t}|@option{--syms}] + [@option{-T}|@option{--dynamic-syms}] + [@option{-x}|@option{--all-headers}] + [@option{-w}|@option{--wide}] + [@option{--start-address=}@var{address}] + [@option{--stop-address=}@var{address}] + [@option{--prefix-addresses}] + [@option{--[no-]show-raw-insn}] + [@option{--adjust-vma=}@var{offset}] + [@option{--dwarf-depth=@var{n}}] + [@option{--dwarf-start=@var{n}}] + [@option{--special-syms}] + [@option{--prefix=}@var{prefix}] + [@option{--prefix-strip=}@var{level}] + [@option{--insn-width=}@var{width}] + [@option{-V}|@option{--version}] + [@option{-H}|@option{--help}] + @var{objfile}@dots{} +@c man end +@end smallexample + +@c man begin DESCRIPTION objdump + +@command{objdump} displays information about one or more object files. +The options control what particular information to display. This +information is mostly useful to programmers who are working on the +compilation tools, as opposed to programmers who just want their +program to compile and work. + +@var{objfile}@dots{} are the object files to be examined. When you +specify archives, @command{objdump} shows information on each of the member +object files. + +@c man end + +@c man begin OPTIONS objdump + +The long and short forms of options, shown here as alternatives, are +equivalent. At least one option from the list +@option{-a,-d,-D,-e,-f,-g,-G,-h,-H,-p,-P,-r,-R,-s,-S,-t,-T,-V,-x} must be given. + +@table @env +@item -a +@itemx --archive-header +@cindex archive headers +If any of the @var{objfile} files are archives, display the archive +header information (in a format similar to @samp{ls -l}). Besides the +information you could list with @samp{ar tv}, @samp{objdump -a} shows +the object file format of each archive member. + +@item --adjust-vma=@var{offset} +@cindex section addresses in objdump +@cindex VMA in objdump +When dumping information, first add @var{offset} to all the section +addresses. This is useful if the section addresses do not correspond to +the symbol table, which can happen when putting sections at particular +addresses when using a format which can not represent section addresses, +such as a.out. + +@item -b @var{bfdname} +@itemx --target=@var{bfdname} +@cindex object code format +Specify that the object-code format for the object files is +@var{bfdname}. This option may not be necessary; @var{objdump} can +automatically recognize many formats. + +For example, +@example +objdump -b oasys -m vax -h fu.o +@end example +@noindent +displays summary information from the section headers (@option{-h}) of +@file{fu.o}, which is explicitly identified (@option{-m}) as a VAX object +file in the format produced by Oasys compilers. You can list the +formats available with the @option{-i} option. +@xref{Target Selection}, for more information. + +@item -C +@itemx --demangle[=@var{style}] +@cindex demangling in objdump +Decode (@dfn{demangle}) low-level symbol names into user-level names. +Besides removing any initial underscore prepended by the system, this +makes C++ function names readable. Different compilers have different +mangling styles. The optional demangling style argument can be used to +choose an appropriate demangling style for your compiler. @xref{c++filt}, +for more information on demangling. + +@item -g +@itemx --debugging +Display debugging information. This attempts to parse STABS and IEEE +debugging format information stored in the file and print it out using +a C like syntax. If neither of these formats are found this option +falls back on the @option{-W} option to print any DWARF information in +the file. + +@item -e +@itemx --debugging-tags +Like @option{-g}, but the information is generated in a format compatible +with ctags tool. + +@item -d +@itemx --disassemble +@cindex disassembling object code +@cindex machine instructions +Display the assembler mnemonics for the machine instructions from +@var{objfile}. This option only disassembles those sections which are +expected to contain instructions. + +@item -D +@itemx --disassemble-all +Like @option{-d}, but disassemble the contents of all sections, not just +those expected to contain instructions. + +This option also has a subtle effect on the disassembly of +instructions in code sections. When option @option{-d} is in effect +objdump will assume that any symbols present in a code section occur +on the boundary between instructions and it will refuse to disassemble +across such a boundary. When option @option{-D} is in effect however +this assumption is supressed. This means that it is possible for the +output of @option{-d} and @option{-D} to differ if, for example, data +is stored in code sections. + +If the target is an ARM architecture this switch also has the effect +of forcing the disassembler to decode pieces of data found in code +sections as if they were instructions. + +@item --prefix-addresses +When disassembling, print the complete address on each line. This is +the older disassembly format. + +@item -EB +@itemx -EL +@itemx --endian=@{big|little@} +@cindex endianness +@cindex disassembly endianness +Specify the endianness of the object files. This only affects +disassembly. This can be useful when disassembling a file format which +does not describe endianness information, such as S-records. + +@item -f +@itemx --file-headers +@cindex object file header +Display summary information from the overall header of +each of the @var{objfile} files. + +@item -F +@itemx --file-offsets +@cindex object file offsets +When disassembling sections, whenever a symbol is displayed, also +display the file offset of the region of data that is about to be +dumped. If zeroes are being skipped, then when disassembly resumes, +tell the user how many zeroes were skipped and the file offset of the +location from where the disassembly resumes. When dumping sections, +display the file offset of the location from where the dump starts. + +@item --file-start-context +@cindex source code context +Specify that when displaying interlisted source code/disassembly +(assumes @option{-S}) from a file that has not yet been displayed, extend the +context to the start of the file. + +@item -h +@itemx --section-headers +@itemx --headers +@cindex section headers +Display summary information from the section headers of the +object file. + +File segments may be relocated to nonstandard addresses, for example by +using the @option{-Ttext}, @option{-Tdata}, or @option{-Tbss} options to +@command{ld}. However, some object file formats, such as a.out, do not +store the starting address of the file segments. In those situations, +although @command{ld} relocates the sections correctly, using @samp{objdump +-h} to list the file section headers cannot show the correct addresses. +Instead, it shows the usual addresses, which are implicit for the +target. + +Note, in some cases it is possible for a section to have both the +READONLY and the NOREAD attributes set. In such cases the NOREAD +attribute takes precedence, but @command{objdump} will report both +since the exact setting of the flag bits might be important. + +@item -H +@itemx --help +Print a summary of the options to @command{objdump} and exit. + +@item -i +@itemx --info +@cindex architectures available +@cindex object formats available +Display a list showing all architectures and object formats available +for specification with @option{-b} or @option{-m}. + +@item -j @var{name} +@itemx --section=@var{name} +@cindex section information +Display information only for section @var{name}. + +@item -l +@itemx --line-numbers +@cindex source filenames for object files +Label the display (using debugging information) with the filename and +source line numbers corresponding to the object code or relocs shown. +Only useful with @option{-d}, @option{-D}, or @option{-r}. + +@item -m @var{machine} +@itemx --architecture=@var{machine} +@cindex architecture +@cindex disassembly architecture +Specify the architecture to use when disassembling object files. This +can be useful when disassembling object files which do not describe +architecture information, such as S-records. You can list the available +architectures with the @option{-i} option. + +If the target is an ARM architecture then this switch has an +additional effect. It restricts the disassembly to only those +instructions supported by the architecture specified by @var{machine}. +If it is necessary to use this switch because the input file does not +contain any architecture information, but it is also desired to +disassemble all the instructions use @option{-marm}. + +@item -M @var{options} +@itemx --disassembler-options=@var{options} +Pass target specific information to the disassembler. Only supported on +some targets. If it is necessary to specify more than one +disassembler option then multiple @option{-M} options can be used or +can be placed together into a comma separated list. + +For ARC, @option{dsp} controls the printing of DSP instructions, +@option{spfp} selects the printing of FPX single precision FP +instructions, @option{dpfp} selects the printing of FPX double +precision FP instructions, @option{quarkse_em} selects the printing of +special QuarkSE-EM instructions, @option{fpuda} selects the printing +of double precision assist instructions, @option{fpus} selects the +printing of FPU single precision FP instructions, while @option{fpud} +selects the printing of FPU souble precision FP instructions. +Additionally, one can choose to have all the immediates printed in +hexadecimal using @option{hex}. By default, the short immediates are +printed using the decimal representation, while the long immediate +values are printed as hexadecimal. + +@option{cpu=...} allows to enforce a particular ISA when disassembling +instructions, overriding the @option{-m} value or whatever is in the ELF file. +This might be useful to select ARC EM or HS ISA, because architecture is same +for those and disassembler relies on private ELF header data to decide if code +is for EM or HS. This option might be specified multiple times - only the +latest value will be used. Valid values are same as for the assembler +@option{-mcpu=...} option. + +If the target is an ARM architecture then this switch can be used to +select which register name set is used during disassembler. Specifying +@option{-M reg-names-std} (the default) will select the register names as +used in ARM's instruction set documentation, but with register 13 called +'sp', register 14 called 'lr' and register 15 called 'pc'. Specifying +@option{-M reg-names-apcs} will select the name set used by the ARM +Procedure Call Standard, whilst specifying @option{-M reg-names-raw} will +just use @samp{r} followed by the register number. + +There are also two variants on the APCS register naming scheme enabled +by @option{-M reg-names-atpcs} and @option{-M reg-names-special-atpcs} which +use the ARM/Thumb Procedure Call Standard naming conventions. (Either +with the normal register names or the special register names). + +This option can also be used for ARM architectures to force the +disassembler to interpret all instructions as Thumb instructions by +using the switch @option{--disassembler-options=force-thumb}. This can be +useful when attempting to disassemble thumb code produced by other +compilers. + +For the x86, some of the options duplicate functions of the @option{-m} +switch, but allow finer grained control. Multiple selections from the +following may be specified as a comma separated string. +@table @code +@item x86-64 +@itemx i386 +@itemx i8086 +Select disassembly for the given architecture. + +@item intel +@itemx att +Select between intel syntax mode and AT&T syntax mode. + +@item amd64 +@itemx intel64 +Select between AMD64 ISA and Intel64 ISA. + +@item intel-mnemonic +@itemx att-mnemonic +Select between intel mnemonic mode and AT&T mnemonic mode. +Note: @code{intel-mnemonic} implies @code{intel} and +@code{att-mnemonic} implies @code{att}. + +@item addr64 +@itemx addr32 +@itemx addr16 +@itemx data32 +@itemx data16 +Specify the default address size and operand size. These four options +will be overridden if @code{x86-64}, @code{i386} or @code{i8086} +appear later in the option string. + +@item suffix +When in AT&T mode, instructs the disassembler to print a mnemonic +suffix even when the suffix could be inferred by the operands. +@end table + +For PowerPC, the @option{-M} argument @option{raw} selects +disasssembly of hardware insns rather than aliases. For example, you +will see @code{rlwinm} rather than @code{clrlwi}, and @code{addi} +rather than @code{li}. All of the @option{-m} arguments for +@command{gas} that select a CPU are supported. These are: +@option{403}, @option{405}, @option{440}, @option{464}, @option{476}, +@option{601}, @option{603}, @option{604}, @option{620}, @option{7400}, +@option{7410}, @option{7450}, @option{7455}, @option{750cl}, +@option{821}, @option{850}, @option{860}, @option{a2}, @option{booke}, +@option{booke32}, @option{cell}, @option{com}, @option{e200z4}, +@option{e300}, @option{e500}, @option{e500mc}, @option{e500mc64}, +@option{e500x2}, @option{e5500}, @option{e6500}, @option{efs}, +@option{power4}, @option{power5}, @option{power6}, @option{power7}, +@option{power8}, @option{power9}, @option{ppc}, @option{ppc32}, +@option{ppc64}, @option{ppc64bridge}, @option{ppcps}, @option{pwr}, +@option{pwr2}, @option{pwr4}, @option{pwr5}, @option{pwr5x}, +@option{pwr6}, @option{pwr7}, @option{pwr8}, @option{pwr9}, +@option{pwrx}, @option{titan}, and @option{vle}. +@option{32} and @option{64} modify the default or a prior CPU +selection, disabling and enabling 64-bit insns respectively. In +addition, @option{altivec}, @option{any}, @option{htm}, @option{vsx}, +and @option{spe} add capabilities to a previous @emph{or later} CPU +selection. @option{any} will disassemble any opcode known to +binutils, but in cases where an opcode has two different meanings or +different arguments, you may not see the disassembly you expect. +If you disassemble without giving a CPU selection, a default will be +chosen from information gleaned by BFD from the object files headers, +but the result again may not be as you expect. + +For MIPS, this option controls the printing of instruction mnemonic +names and register names in disassembled instructions. Multiple +selections from the following may be specified as a comma separated +string, and invalid options are ignored: + +@table @code +@item no-aliases +Print the 'raw' instruction mnemonic instead of some pseudo +instruction mnemonic. I.e., print 'daddu' or 'or' instead of 'move', +'sll' instead of 'nop', etc. + +@item msa +Disassemble MSA instructions. + +@item virt +Disassemble the virtualization ASE instructions. + +@item xpa +Disassemble the eXtended Physical Address (XPA) ASE instructions. + +@item gpr-names=@var{ABI} +Print GPR (general-purpose register) names as appropriate +for the specified ABI. By default, GPR names are selected according to +the ABI of the binary being disassembled. + +@item fpr-names=@var{ABI} +Print FPR (floating-point register) names as +appropriate for the specified ABI. By default, FPR numbers are printed +rather than names. + +@item cp0-names=@var{ARCH} +Print CP0 (system control coprocessor; coprocessor 0) register names +as appropriate for the CPU or architecture specified by +@var{ARCH}. By default, CP0 register names are selected according to +the architecture and CPU of the binary being disassembled. + +@item hwr-names=@var{ARCH} +Print HWR (hardware register, used by the @code{rdhwr} instruction) names +as appropriate for the CPU or architecture specified by +@var{ARCH}. By default, HWR names are selected according to +the architecture and CPU of the binary being disassembled. + +@item reg-names=@var{ABI} +Print GPR and FPR names as appropriate for the selected ABI. + +@item reg-names=@var{ARCH} +Print CPU-specific register names (CP0 register and HWR names) +as appropriate for the selected CPU or architecture. +@end table + +For any of the options listed above, @var{ABI} or +@var{ARCH} may be specified as @samp{numeric} to have numbers printed +rather than names, for the selected types of registers. +You can list the available values of @var{ABI} and @var{ARCH} using +the @option{--help} option. + +For VAX, you can specify function entry addresses with @option{-M +entry:0xf00ba}. You can use this multiple times to properly +disassemble VAX binary files that don't contain symbol tables (like +ROM dumps). In these cases, the function entry mask would otherwise +be decoded as VAX instructions, which would probably lead the rest +of the function being wrongly disassembled. + +@item -p +@itemx --private-headers +Print information that is specific to the object file format. The exact +information printed depends upon the object file format. For some +object file formats, no additional information is printed. + +@item -P @var{options} +@itemx --private=@var{options} +Print information that is specific to the object file format. The +argument @var{options} is a comma separated list that depends on the +format (the lists of options is displayed with the help). + +For XCOFF, the available options are: +@table @code +@item header +@item aout +@item sections +@item syms +@item relocs +@item lineno, +@item loader +@item except +@item typchk +@item traceback +@item toc +@item ldinfo +@end table + +Not all object formats support this option. In particular the ELF +format does not use it. + +@item -r +@itemx --reloc +@cindex relocation entries, in object file +Print the relocation entries of the file. If used with @option{-d} or +@option{-D}, the relocations are printed interspersed with the +disassembly. + +@item -R +@itemx --dynamic-reloc +@cindex dynamic relocation entries, in object file +Print the dynamic relocation entries of the file. This is only +meaningful for dynamic objects, such as certain types of shared +libraries. As for @option{-r}, if used with @option{-d} or +@option{-D}, the relocations are printed interspersed with the +disassembly. + +@item -s +@itemx --full-contents +@cindex sections, full contents +@cindex object file sections +Display the full contents of any sections requested. By default all +non-empty sections are displayed. + +@item -S +@itemx --source +@cindex source disassembly +@cindex disassembly, with source +Display source code intermixed with disassembly, if possible. Implies +@option{-d}. + +@item --prefix=@var{prefix} +@cindex Add prefix to absolute paths +Specify @var{prefix} to add to the absolute paths when used with +@option{-S}. + +@item --prefix-strip=@var{level} +@cindex Strip absolute paths +Indicate how many initial directory names to strip off the hardwired +absolute paths. It has no effect without @option{--prefix=}@var{prefix}. + +@item --show-raw-insn +When disassembling instructions, print the instruction in hex as well as +in symbolic form. This is the default except when +@option{--prefix-addresses} is used. + +@item --no-show-raw-insn +When disassembling instructions, do not print the instruction bytes. +This is the default when @option{--prefix-addresses} is used. + +@item --insn-width=@var{width} +@cindex Instruction width +Display @var{width} bytes on a single line when disassembling +instructions. + +@item -W[lLiaprmfFsoRtUuTgAckK] +@itemx --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links] +@include debug.options.texi + +@item --dwarf-check +Enable additional checks for consistency of Dwarf information. + +@item -G +@itemx --stabs +@cindex stab +@cindex .stab +@cindex debug symbols +@cindex ELF object file format +Display the full contents of any sections requested. Display the +contents of the .stab and .stab.index and .stab.excl sections from an +ELF file. This is only useful on systems (such as Solaris 2.0) in which +@code{.stab} debugging symbol-table entries are carried in an ELF +section. In most other file formats, debugging symbol-table entries are +interleaved with linkage symbols, and are visible in the @option{--syms} +output. + +@item --start-address=@var{address} +@cindex start-address +Start displaying data at the specified address. This affects the output +of the @option{-d}, @option{-r} and @option{-s} options. + +@item --stop-address=@var{address} +@cindex stop-address +Stop displaying data at the specified address. This affects the output +of the @option{-d}, @option{-r} and @option{-s} options. + +@item -t +@itemx --syms +@cindex symbol table entries, printing +Print the symbol table entries of the file. +This is similar to the information provided by the @samp{nm} program, +although the display format is different. The format of the output +depends upon the format of the file being dumped, but there are two main +types. One looks like this: + +@smallexample +[ 4](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss +[ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 fred +@end smallexample + +where the number inside the square brackets is the number of the entry +in the symbol table, the @var{sec} number is the section number, the +@var{fl} value are the symbol's flag bits, the @var{ty} number is the +symbol's type, the @var{scl} number is the symbol's storage class and +the @var{nx} value is the number of auxilary entries associated with +the symbol. The last two fields are the symbol's value and its name. + +The other common output format, usually seen with ELF based files, +looks like this: + +@smallexample +00000000 l d .bss 00000000 .bss +00000000 g .text 00000000 fred +@end smallexample + +Here the first number is the symbol's value (sometimes refered to as +its address). The next field is actually a set of characters and +spaces indicating the flag bits that are set on the symbol. These +characters are described below. Next is the section with which the +symbol is associated or @emph{*ABS*} if the section is absolute (ie +not connected with any section), or @emph{*UND*} if the section is +referenced in the file being dumped, but not defined there. + +After the section name comes another field, a number, which for common +symbols is the alignment and for other symbol is the size. Finally +the symbol's name is displayed. + +The flag characters are divided into 7 groups as follows: +@table @code +@item l +@itemx g +@itemx u +@itemx ! +The symbol is a local (l), global (g), unique global (u), neither +global nor local (a space) or both global and local (!). A +symbol can be neither local or global for a variety of reasons, e.g., +because it is used for debugging, but it is probably an indication of +a bug if it is ever both local and global. Unique global symbols are +a GNU extension to the standard set of ELF symbol bindings. For such +a symbol the dynamic linker will make sure that in the entire process +there is just one symbol with this name and type in use. + +@item w +The symbol is weak (w) or strong (a space). + +@item C +The symbol denotes a constructor (C) or an ordinary symbol (a space). + +@item W +The symbol is a warning (W) or a normal symbol (a space). A warning +symbol's name is a message to be displayed if the symbol following the +warning symbol is ever referenced. + +@item I +@item i +The symbol is an indirect reference to another symbol (I), a function +to be evaluated during reloc processing (i) or a normal symbol (a +space). + +@item d +@itemx D +The symbol is a debugging symbol (d) or a dynamic symbol (D) or a +normal symbol (a space). + +@item F +@item f +@item O +The symbol is the name of a function (F) or a file (f) or an object +(O) or just a normal symbol (a space). +@end table + +@item -T +@itemx --dynamic-syms +@cindex dynamic symbol table entries, printing +Print the dynamic symbol table entries of the file. This is only +meaningful for dynamic objects, such as certain types of shared +libraries. This is similar to the information provided by the @samp{nm} +program when given the @option{-D} (@option{--dynamic}) option. + +The output format is similar to that produced by the @option{--syms} +option, except that an extra field is inserted before the symbol's +name, giving the version information associated with the symbol. +If the version is the default version to be used when resolving +unversioned references to the symbol then it's displayed as is, +otherwise it's put into parentheses. + +@item --special-syms +When displaying symbols include those which the target considers to be +special in some way and which would not normally be of interest to the +user. + +@item -V +@itemx --version +Print the version number of @command{objdump} and exit. + +@item -x +@itemx --all-headers +@cindex all header information, object file +@cindex header information, all +Display all available header information, including the symbol table and +relocation entries. Using @option{-x} is equivalent to specifying all of +@option{-a -f -h -p -r -t}. + +@item -w +@itemx --wide +@cindex wide output, printing +Format some lines for output devices that have more than 80 columns. +Also do not truncate symbol names when they are displayed. + +@item -z +@itemx --disassemble-zeroes +Normally the disassembly output will skip blocks of zeroes. This +option directs the disassembler to disassemble those blocks, just like +any other data. +@end table + +@c man end + +@ignore +@c man begin SEEALSO objdump +nm(1), readelf(1), and the Info entries for @file{binutils}. +@c man end +@end ignore + +@node ranlib +@chapter ranlib + +@kindex ranlib +@cindex archive contents +@cindex symbol index + +@c man title ranlib generate index to archive. + +@smallexample +@c man begin SYNOPSIS ranlib +ranlib [@option{--plugin} @var{name}] [@option{-DhHvVt}] @var{archive} +@c man end +@end smallexample + +@c man begin DESCRIPTION ranlib + +@command{ranlib} generates an index to the contents of an archive and +stores it in the archive. The index lists each symbol defined by a +member of an archive that is a relocatable object file. + +You may use @samp{nm -s} or @samp{nm --print-armap} to list this index. + +An archive with such an index speeds up linking to the library and +allows routines in the library to call each other without regard to +their placement in the archive. + +The @sc{gnu} @command{ranlib} program is another form of @sc{gnu} @command{ar}; running +@command{ranlib} is completely equivalent to executing @samp{ar -s}. +@xref{ar}. + +@c man end + +@c man begin OPTIONS ranlib + +@table @env +@item -h +@itemx -H +@itemx --help +Show usage information for @command{ranlib}. + +@item -v +@itemx -V +@itemx --version +Show the version number of @command{ranlib}. + +@item -D +@cindex deterministic archives +@kindex --enable-deterministic-archives +Operate in @emph{deterministic} mode. The symbol map archive member's +header will show zero for the UID, GID, and timestamp. When this +option is used, multiple runs will produce identical output files. + +If @file{binutils} was configured with +@option{--enable-deterministic-archives}, then this mode is on by +default. It can be disabled with the @samp{-U} option, described +below. + +@item -t +Update the timestamp of the symbol map of an archive. + +@item -U +@cindex deterministic archives +@kindex --enable-deterministic-archives +Do @emph{not} operate in @emph{deterministic} mode. This is the +inverse of the @samp{-D} option, above: the archive index will get +actual UID, GID, timestamp, and file mode values. + +If @file{binutils} was configured @emph{without} +@option{--enable-deterministic-archives}, then this mode is on by +default. + +@end table + +@c man end + +@ignore +@c man begin SEEALSO ranlib +ar(1), nm(1), and the Info entries for @file{binutils}. +@c man end +@end ignore + +@node size +@chapter size + +@kindex size +@cindex section sizes + +@c man title size list section sizes and total size. + +@smallexample +@c man begin SYNOPSIS size +size [@option{-A}|@option{-B}|@option{--format=}@var{compatibility}] + [@option{--help}] + [@option{-d}|@option{-o}|@option{-x}|@option{--radix=}@var{number}] + [@option{--common}] + [@option{-t}|@option{--totals}] + [@option{--target=}@var{bfdname}] [@option{-V}|@option{--version}] + [@var{objfile}@dots{}] +@c man end +@end smallexample + +@c man begin DESCRIPTION size + +The @sc{gnu} @command{size} utility lists the section sizes---and the total +size---for each of the object or archive files @var{objfile} in its +argument list. By default, one line of output is generated for each +object file or each module in an archive. + +@var{objfile}@dots{} are the object files to be examined. +If none are specified, the file @code{a.out} will be used. + +@c man end + +@c man begin OPTIONS size + +The command line options have the following meanings: + +@table @env +@item -A +@itemx -B +@itemx --format=@var{compatibility} +@cindex @command{size} display format +Using one of these options, you can choose whether the output from @sc{gnu} +@command{size} resembles output from System V @command{size} (using @option{-A}, +or @option{--format=sysv}), or Berkeley @command{size} (using @option{-B}, or +@option{--format=berkeley}). The default is the one-line format similar to +Berkeley's. +@c Bonus for doc-source readers: you can also say --format=strange (or +@c anything else that starts with 's') for sysv, and --format=boring (or +@c anything else that starts with 'b') for Berkeley. + +Here is an example of the Berkeley (default) format of output from +@command{size}: +@smallexample +$ size --format=Berkeley ranlib size +text data bss dec hex filename +294880 81920 11592 388392 5ed28 ranlib +294880 81920 11888 388688 5ee50 size +@end smallexample + +@noindent +This is the same data, but displayed closer to System V conventions: + +@smallexample +$ size --format=SysV ranlib size +ranlib : +section size addr +.text 294880 8192 +.data 81920 303104 +.bss 11592 385024 +Total 388392 + + +size : +section size addr +.text 294880 8192 +.data 81920 303104 +.bss 11888 385024 +Total 388688 +@end smallexample + +@item --help +Show a summary of acceptable arguments and options. + +@item -d +@itemx -o +@itemx -x +@itemx --radix=@var{number} +@cindex @command{size} number format +@cindex radix for section sizes +Using one of these options, you can control whether the size of each +section is given in decimal (@option{-d}, or @option{--radix=10}); octal +(@option{-o}, or @option{--radix=8}); or hexadecimal (@option{-x}, or +@option{--radix=16}). In @option{--radix=@var{number}}, only the three +values (8, 10, 16) are supported. The total size is always given in two +radices; decimal and hexadecimal for @option{-d} or @option{-x} output, or +octal and hexadecimal if you're using @option{-o}. + +@item --common +Print total size of common symbols in each file. When using Berkeley +format these are included in the bss size. + +@item -t +@itemx --totals +Show totals of all objects listed (Berkeley format listing mode only). + +@item --target=@var{bfdname} +@cindex object code format +Specify that the object-code format for @var{objfile} is +@var{bfdname}. This option may not be necessary; @command{size} can +automatically recognize many formats. +@xref{Target Selection}, for more information. + +@item -V +@itemx --version +Display the version number of @command{size}. +@end table + +@c man end + +@ignore +@c man begin SEEALSO size +ar(1), objdump(1), readelf(1), and the Info entries for @file{binutils}. +@c man end +@end ignore + +@node strings +@chapter strings +@kindex strings +@cindex listings strings +@cindex printing strings +@cindex strings, printing + +@c man title strings print the strings of printable characters in files. + +@smallexample +@c man begin SYNOPSIS strings +strings [@option{-afovV}] [@option{-}@var{min-len}] + [@option{-n} @var{min-len}] [@option{--bytes=}@var{min-len}] + [@option{-t} @var{radix}] [@option{--radix=}@var{radix}] + [@option{-e} @var{encoding}] [@option{--encoding=}@var{encoding}] + [@option{-}] [@option{--all}] [@option{--print-file-name}] + [@option{-T} @var{bfdname}] [@option{--target=}@var{bfdname}] + [@option{-w}] [@option{--include-all-whitespace}] + [@option{-s}] [@option{--output-separator}@var{sep_string}] + [@option{--help}] [@option{--version}] @var{file}@dots{} +@c man end +@end smallexample + +@c man begin DESCRIPTION strings + +For each @var{file} given, @sc{gnu} @command{strings} prints the +printable character sequences that are at least 4 characters long (or +the number given with the options below) and are followed by an +unprintable character. + +Depending upon how the strings program was configured it will default +to either displaying all the printable sequences that it can find in +each file, or only those sequences that are in loadable, initialized +data sections. If the file type in unrecognizable, or if strings is +reading from stdin then it will always display all of the printable +sequences that it can find. + +For backwards compatibility any file that occurs after a command line +option of just @option{-} will also be scanned in full, regardless of +the presence of any @option{-d} option. + +@command{strings} is mainly useful for determining the contents of +non-text files. + +@c man end + +@c man begin OPTIONS strings + +@table @env +@item -a +@itemx --all +@itemx - +Scan the whole file, regardless of what sections it contains or +whether those sections are loaded or initialized. Normally this is +the default behaviour, but strings can be configured so that the +@option{-d} is the default instead. + +The @option{-} option is position dependent and forces strings to +perform full scans of any file that is mentioned after the @option{-} +on the command line, even if the @option{-d} option has been +specified. + +@item -d +@itemx --data +Only print strings from initialized, loaded data sections in the +file. This may reduce the amount of garbage in the output, but it +also exposes the strings program to any security flaws that may be +present in the BFD library used to scan and load sections. Strings +can be configured so that this option is the default behaviour. In +such cases the @option{-a} option can be used to avoid using the BFD +library and instead just print all of the strings found in the file. + +@item -f +@itemx --print-file-name +Print the name of the file before each string. + +@item --help +Print a summary of the program usage on the standard output and exit. + +@item -@var{min-len} +@itemx -n @var{min-len} +@itemx --bytes=@var{min-len} +Print sequences of characters that are at least @var{min-len} characters +long, instead of the default 4. + +@item -o +Like @samp{-t o}. Some other versions of @command{strings} have @option{-o} +act like @samp{-t d} instead. Since we can not be compatible with both +ways, we simply chose one. + +@item -t @var{radix} +@itemx --radix=@var{radix} +Print the offset within the file before each string. The single +character argument specifies the radix of the offset---@samp{o} for +octal, @samp{x} for hexadecimal, or @samp{d} for decimal. + +@item -e @var{encoding} +@itemx --encoding=@var{encoding} +Select the character encoding of the strings that are to be found. +Possible values for @var{encoding} are: @samp{s} = single-7-bit-byte +characters (ASCII, ISO 8859, etc., default), @samp{S} = +single-8-bit-byte characters, @samp{b} = 16-bit bigendian, @samp{l} = +16-bit littleendian, @samp{B} = 32-bit bigendian, @samp{L} = 32-bit +littleendian. Useful for finding wide character strings. (@samp{l} +and @samp{b} apply to, for example, Unicode UTF-16/UCS-2 encodings). + +@item -T @var{bfdname} +@itemx --target=@var{bfdname} +@cindex object code format +Specify an object code format other than your system's default format. +@xref{Target Selection}, for more information. + +@item -v +@itemx -V +@itemx --version +Print the program version number on the standard output and exit. + +@item -w +@itemx --include-all-whitespace +By default tab and space characters are included in the strings that +are displayed, but other whitespace characters, such a newlines and +carriage returns, are not. The @option{-w} option changes this so +that all whitespace characters are considered to be part of a string. + +@item -s +@itemx --output-separator +By default, output strings are delimited by a new-line. This option +allows you to supply any string to be used as the output record +separator. Useful with --include-all-whitespace where strings +may contain new-lines internally. +@end table + +@c man end + +@ignore +@c man begin SEEALSO strings +ar(1), nm(1), objdump(1), ranlib(1), readelf(1) +and the Info entries for @file{binutils}. +@c man end +@end ignore + +@node strip +@chapter strip + +@kindex strip +@cindex removing symbols +@cindex discarding symbols +@cindex symbols, discarding + +@c man title strip Discard symbols from object files. + +@smallexample +@c man begin SYNOPSIS strip +strip [@option{-F} @var{bfdname} |@option{--target=}@var{bfdname}] + [@option{-I} @var{bfdname} |@option{--input-target=}@var{bfdname}] + [@option{-O} @var{bfdname} |@option{--output-target=}@var{bfdname}] + [@option{-s}|@option{--strip-all}] + [@option{-S}|@option{-g}|@option{-d}|@option{--strip-debug}] + [@option{--strip-dwo}] + [@option{-K} @var{symbolname}|@option{--keep-symbol=}@var{symbolname}] + [@option{-M}|@option{--merge-notes}][@option{--no-merge-notes}] + [@option{-N} @var{symbolname} |@option{--strip-symbol=}@var{symbolname}] + [@option{-w}|@option{--wildcard}] + [@option{-x}|@option{--discard-all}] [@option{-X} |@option{--discard-locals}] + [@option{-R} @var{sectionname} |@option{--remove-section=}@var{sectionname}] + [@option{--remove-relocations=}@var{sectionpattern}] + [@option{-o} @var{file}] [@option{-p}|@option{--preserve-dates}] + [@option{-D}|@option{--enable-deterministic-archives}] + [@option{-U}|@option{--disable-deterministic-archives}] + [@option{--keep-file-symbols}] + [@option{--only-keep-debug}] + [@option{-v} |@option{--verbose}] [@option{-V}|@option{--version}] + [@option{--help}] [@option{--info}] + @var{objfile}@dots{} +@c man end +@end smallexample + +@c man begin DESCRIPTION strip + +@sc{gnu} @command{strip} discards all symbols from object files +@var{objfile}. The list of object files may include archives. +At least one object file must be given. + +@command{strip} modifies the files named in its argument, +rather than writing modified copies under different names. + +@c man end + +@c man begin OPTIONS strip + +@table @env +@item -F @var{bfdname} +@itemx --target=@var{bfdname} +Treat the original @var{objfile} as a file with the object +code format @var{bfdname}, and rewrite it in the same format. +@xref{Target Selection}, for more information. + +@item --help +Show a summary of the options to @command{strip} and exit. + +@item --info +Display a list showing all architectures and object formats available. + +@item -I @var{bfdname} +@itemx --input-target=@var{bfdname} +Treat the original @var{objfile} as a file with the object +code format @var{bfdname}. +@xref{Target Selection}, for more information. + +@item -O @var{bfdname} +@itemx --output-target=@var{bfdname} +Replace @var{objfile} with a file in the output format @var{bfdname}. +@xref{Target Selection}, for more information. + +@item -R @var{sectionname} +@itemx --remove-section=@var{sectionname} +Remove any section named @var{sectionname} from the output file, in +addition to whatever sections would otherwise be removed. This +option may be given more than once. Note that using this option +inappropriately may make the output file unusable. The wildcard +character @samp{*} may be given at the end of @var{sectionname}. If +so, then any section starting with @var{sectionname} will be removed. + +If the first character of @var{sectionpattern} is the exclamation +point (!) then matching sections will not be removed even if an +earlier use of @option{--remove-section} on the same command line +would otherwise remove it. For example: + +@smallexample + --remove-section=.text.* --remove-section=!.text.foo +@end smallexample + +will remove all sections matching the pattern '.text.*', but will not +remove the section '.text.foo'. + +@item --remove-relocations=@var{sectionpattern} +Remove relocations from the output file for any section matching +@var{sectionpattern}. This option may be given more than once. Note +that using this option inappropriately may make the output file +unusable. Wildcard characters are accepted in @var{sectionpattern}. +For example: + +@smallexample + --remove-relocations=.text.* +@end smallexample + +will remove the relocations for all sections matching the patter +'.text.*'. + +If the first character of @var{sectionpattern} is the exclamation +point (!) then matching sections will not have their relocation +removed even if an earlier use of @option{--remove-relocations} on the +same command line would otherwise cause the relocations to be removed. +For example: + +@smallexample + --remove-relocations=.text.* --remove-relocations=!.text.foo +@end smallexample + +will remove all relocations for sections matching the pattern +'.text.*', but will not remove relocations for the section +'.text.foo'. + +@item -s +@itemx --strip-all +Remove all symbols. + +@item -g +@itemx -S +@itemx -d +@itemx --strip-debug +Remove debugging symbols only. + +@item --strip-dwo +Remove the contents of all DWARF .dwo sections, leaving the +remaining debugging sections and all symbols intact. +See the description of this option in the @command{objcopy} section +for more information. + +@item --strip-unneeded +Remove all symbols that are not needed for relocation processing. + +@item -K @var{symbolname} +@itemx --keep-symbol=@var{symbolname} +When stripping symbols, keep symbol @var{symbolname} even if it would +normally be stripped. This option may be given more than once. + +@item -M +@itemx --merge-notes +@itemx --no-merge-notes +For ELF files, attempt (or do not attempt) to reduce the size of any +SHT_NOTE type sections by removing duplicate notes. The default is to +attempt this reduction. + +@item -N @var{symbolname} +@itemx --strip-symbol=@var{symbolname} +Remove symbol @var{symbolname} from the source file. This option may be +given more than once, and may be combined with strip options other than +@option{-K}. + +@item -o @var{file} +Put the stripped output in @var{file}, rather than replacing the +existing file. When this argument is used, only one @var{objfile} +argument may be specified. + +@item -p +@itemx --preserve-dates +Preserve the access and modification dates of the file. + +@item -D +@itemx --enable-deterministic-archives +@cindex deterministic archives +@kindex --enable-deterministic-archives +Operate in @emph{deterministic} mode. When copying archive members +and writing the archive index, use zero for UIDs, GIDs, timestamps, +and use consistent file modes for all files. + +If @file{binutils} was configured with +@option{--enable-deterministic-archives}, then this mode is on by default. +It can be disabled with the @samp{-U} option, below. + +@item -U +@itemx --disable-deterministic-archives +@cindex deterministic archives +@kindex --enable-deterministic-archives +Do @emph{not} operate in @emph{deterministic} mode. This is the +inverse of the @option{-D} option, above: when copying archive members +and writing the archive index, use their actual UID, GID, timestamp, +and file mode values. + +This is the default unless @file{binutils} was configured with +@option{--enable-deterministic-archives}. + +@item -w +@itemx --wildcard +Permit regular expressions in @var{symbolname}s used in other command +line options. The question mark (?), asterisk (*), backslash (\) and +square brackets ([]) operators can be used anywhere in the symbol +name. If the first character of the symbol name is the exclamation +point (!) then the sense of the switch is reversed for that symbol. +For example: + +@smallexample + -w -K !foo -K fo* +@end smallexample + +would cause strip to only keep symbols that start with the letters +``fo'', but to discard the symbol ``foo''. + +@item -x +@itemx --discard-all +Remove non-global symbols. + +@item -X +@itemx --discard-locals +Remove compiler-generated local symbols. +(These usually start with @samp{L} or @samp{.}.) + +@item --keep-file-symbols +When stripping a file, perhaps with @option{--strip-debug} or +@option{--strip-unneeded}, retain any symbols specifying source file names, +which would otherwise get stripped. + +@item --only-keep-debug +Strip a file, emptying the contents of any sections that would not be +stripped by @option{--strip-debug} and leaving the debugging sections +intact. In ELF files, this preserves all the note sections in the +output as well. + +Note - the section headers of the stripped sections are preserved, +including their sizes, but the contents of the section are discarded. +The section headers are preserved so that other tools can match up the +debuginfo file with the real executable, even if that executable has +been relocated to a different address space. + +The intention is that this option will be used in conjunction with +@option{--add-gnu-debuglink} to create a two part executable. One a +stripped binary which will occupy less space in RAM and in a +distribution and the second a debugging information file which is only +needed if debugging abilities are required. The suggested procedure +to create these files is as follows: + +@enumerate +@item Link the executable as normal. Assuming that is is called +@code{foo} then... +@item Run @code{objcopy --only-keep-debug foo foo.dbg} to +create a file containing the debugging info. +@item Run @code{objcopy --strip-debug foo} to create a +stripped executable. +@item Run @code{objcopy --add-gnu-debuglink=foo.dbg foo} +to add a link to the debugging info into the stripped executable. +@end enumerate + +Note---the choice of @code{.dbg} as an extension for the debug info +file is arbitrary. Also the @code{--only-keep-debug} step is +optional. You could instead do this: + +@enumerate +@item Link the executable as normal. +@item Copy @code{foo} to @code{foo.full} +@item Run @code{strip --strip-debug foo} +@item Run @code{objcopy --add-gnu-debuglink=foo.full foo} +@end enumerate + +i.e., the file pointed to by the @option{--add-gnu-debuglink} can be the +full executable. It does not have to be a file created by the +@option{--only-keep-debug} switch. + +Note---this switch is only intended for use on fully linked files. It +does not make sense to use it on object files where the debugging +information may be incomplete. Besides the gnu_debuglink feature +currently only supports the presence of one filename containing +debugging information, not multiple filenames on a one-per-object-file +basis. + +@item -V +@itemx --version +Show the version number for @command{strip}. + +@item -v +@itemx --verbose +Verbose output: list all object files modified. In the case of +archives, @samp{strip -v} lists all members of the archive. +@end table + +@c man end + +@ignore +@c man begin SEEALSO strip +the Info entries for @file{binutils}. +@c man end +@end ignore + +@node c++filt, addr2line, strip, Top +@chapter c++filt + +@kindex c++filt +@cindex demangling C++ symbols + +@c man title cxxfilt Demangle C++ and Java symbols. + +@smallexample +@c man begin SYNOPSIS cxxfilt +c++filt [@option{-_}|@option{--strip-underscore}] + [@option{-n}|@option{--no-strip-underscore}] + [@option{-p}|@option{--no-params}] + [@option{-t}|@option{--types}] + [@option{-i}|@option{--no-verbose}] + [@option{-s} @var{format}|@option{--format=}@var{format}] + [@option{--help}] [@option{--version}] [@var{symbol}@dots{}] +@c man end +@end smallexample + +@c man begin DESCRIPTION cxxfilt + +@kindex cxxfilt +The C++ and Java languages provide function overloading, which means +that you can write many functions with the same name, providing that +each function takes parameters of different types. In order to be +able to distinguish these similarly named functions C++ and Java +encode them into a low-level assembler name which uniquely identifies +each different version. This process is known as @dfn{mangling}. The +@command{c++filt} +@footnote{MS-DOS does not allow @kbd{+} characters in file names, so on +MS-DOS this program is named @command{CXXFILT}.} +program does the inverse mapping: it decodes (@dfn{demangles}) low-level +names into user-level names so that they can be read. + +Every alphanumeric word (consisting of letters, digits, underscores, +dollars, or periods) seen in the input is a potential mangled name. +If the name decodes into a C++ name, the C++ name replaces the +low-level name in the output, otherwise the original word is output. +In this way you can pass an entire assembler source file, containing +mangled names, through @command{c++filt} and see the same source file +containing demangled names. + +You can also use @command{c++filt} to decipher individual symbols by +passing them on the command line: + +@example +c++filt @var{symbol} +@end example + +If no @var{symbol} arguments are given, @command{c++filt} reads symbol +names from the standard input instead. All the results are printed on +the standard output. The difference between reading names from the +command line versus reading names from the standard input is that +command line arguments are expected to be just mangled names and no +checking is performed to separate them from surrounding text. Thus +for example: + +@smallexample +c++filt -n _Z1fv +@end smallexample + +will work and demangle the name to ``f()'' whereas: + +@smallexample +c++filt -n _Z1fv, +@end smallexample + +will not work. (Note the extra comma at the end of the mangled +name which makes it invalid). This command however will work: + +@smallexample +echo _Z1fv, | c++filt -n +@end smallexample + +and will display ``f(),'', i.e., the demangled name followed by a +trailing comma. This behaviour is because when the names are read +from the standard input it is expected that they might be part of an +assembler source file where there might be extra, extraneous +characters trailing after a mangled name. For example: + +@smallexample + .type _Z1fv, @@function +@end smallexample + +@c man end + +@c man begin OPTIONS cxxfilt + +@table @env +@item -_ +@itemx --strip-underscore +On some systems, both the C and C++ compilers put an underscore in front +of every name. For example, the C name @code{foo} gets the low-level +name @code{_foo}. This option removes the initial underscore. Whether +@command{c++filt} removes the underscore by default is target dependent. + +@item -n +@itemx --no-strip-underscore +Do not remove the initial underscore. + +@item -p +@itemx --no-params +When demangling the name of a function, do not display the types of +the function's parameters. + +@item -t +@itemx --types +Attempt to demangle types as well as function names. This is disabled +by default since mangled types are normally only used internally in +the compiler, and they can be confused with non-mangled names. For example, +a function called ``a'' treated as a mangled type name would be +demangled to ``signed char''. + +@item -i +@itemx --no-verbose +Do not include implementation details (if any) in the demangled +output. + +@item -s @var{format} +@itemx --format=@var{format} +@command{c++filt} can decode various methods of mangling, used by +different compilers. The argument to this option selects which +method it uses: + +@table @code +@item auto +Automatic selection based on executable (the default method) +@item gnu +the one used by the @sc{gnu} C++ compiler (g++) +@item lucid +the one used by the Lucid compiler (lcc) +@item arm +the one specified by the C++ Annotated Reference Manual +@item hp +the one used by the HP compiler (aCC) +@item edg +the one used by the EDG compiler +@item gnu-v3 +the one used by the @sc{gnu} C++ compiler (g++) with the V3 ABI. +@item java +the one used by the @sc{gnu} Java compiler (gcj) +@item gnat +the one used by the @sc{gnu} Ada compiler (GNAT). +@end table + +@item --help +Print a summary of the options to @command{c++filt} and exit. + +@item --version +Print the version number of @command{c++filt} and exit. +@end table + +@c man end + +@ignore +@c man begin SEEALSO cxxfilt +the Info entries for @file{binutils}. +@c man end +@end ignore + +@quotation +@emph{Warning:} @command{c++filt} is a new utility, and the details of its +user interface are subject to change in future releases. In particular, +a command-line option may be required in the future to decode a name +passed as an argument on the command line; in other words, + +@example +c++filt @var{symbol} +@end example + +@noindent +may in a future release become + +@example +c++filt @var{option} @var{symbol} +@end example +@end quotation + +@node addr2line +@chapter addr2line + +@kindex addr2line +@cindex address to file name and line number + +@c man title addr2line convert addresses into file names and line numbers. + +@smallexample +@c man begin SYNOPSIS addr2line +addr2line [@option{-a}|@option{--addresses}] + [@option{-b} @var{bfdname}|@option{--target=}@var{bfdname}] + [@option{-C}|@option{--demangle}[=@var{style}]] + [@option{-e} @var{filename}|@option{--exe=}@var{filename}] + [@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}] + [@option{-i}|@option{--inlines}] + [@option{-p}|@option{--pretty-print}] + [@option{-j}|@option{--section=}@var{name}] + [@option{-H}|@option{--help}] [@option{-V}|@option{--version}] + [addr addr @dots{}] +@c man end +@end smallexample + +@c man begin DESCRIPTION addr2line + +@command{addr2line} translates addresses into file names and line numbers. +Given an address in an executable or an offset in a section of a relocatable +object, it uses the debugging information to figure out which file name and +line number are associated with it. + +The executable or relocatable object to use is specified with the @option{-e} +option. The default is the file @file{a.out}. The section in the relocatable +object to use is specified with the @option{-j} option. + +@command{addr2line} has two modes of operation. + +In the first, hexadecimal addresses are specified on the command line, +and @command{addr2line} displays the file name and line number for each +address. + +In the second, @command{addr2line} reads hexadecimal addresses from +standard input, and prints the file name and line number for each +address on standard output. In this mode, @command{addr2line} may be used +in a pipe to convert dynamically chosen addresses. + +The format of the output is @samp{FILENAME:LINENO}. By default +each input address generates one line of output. + +Two options can generate additional lines before each +@samp{FILENAME:LINENO} line (in that order). + +If the @option{-a} option is used then a line with the input address +is displayed. + +If the @option{-f} option is used, then a line with the +@samp{FUNCTIONNAME} is displayed. This is the name of the function +containing the address. + +One option can generate additional lines after the +@samp{FILENAME:LINENO} line. + +If the @option{-i} option is used and the code at the given address is +present there because of inlining by the compiler then additional +lines are displayed afterwards. One or two extra lines (if the +@option{-f} option is used) are displayed for each inlined function. + +Alternatively if the @option{-p} option is used then each input +address generates a single, long, output line containing the address, +the function name, the file name and the line number. If the +@option{-i} option has also been used then any inlined functions will +be displayed in the same manner, but on separate lines, and prefixed +by the text @samp{(inlined by)}. + +If the file name or function name can not be determined, +@command{addr2line} will print two question marks in their place. If the +line number can not be determined, @command{addr2line} will print 0. + +@c man end + +@c man begin OPTIONS addr2line + +The long and short forms of options, shown here as alternatives, are +equivalent. + +@table @env +@item -a +@itemx --addresses +Display the address before the function name, file and line number +information. The address is printed with a @samp{0x} prefix to easily +identify it. + +@item -b @var{bfdname} +@itemx --target=@var{bfdname} +@cindex object code format +Specify that the object-code format for the object files is +@var{bfdname}. + +@item -C +@itemx --demangle[=@var{style}] +@cindex demangling in objdump +Decode (@dfn{demangle}) low-level symbol names into user-level names. +Besides removing any initial underscore prepended by the system, this +makes C++ function names readable. Different compilers have different +mangling styles. The optional demangling style argument can be used to +choose an appropriate demangling style for your compiler. @xref{c++filt}, +for more information on demangling. + +@item -e @var{filename} +@itemx --exe=@var{filename} +Specify the name of the executable for which addresses should be +translated. The default file is @file{a.out}. + +@item -f +@itemx --functions +Display function names as well as file and line number information. + +@item -s +@itemx --basenames +Display only the base of each file name. + +@item -i +@itemx --inlines +If the address belongs to a function that was inlined, the source +information for all enclosing scopes back to the first non-inlined +function will also be printed. For example, if @code{main} inlines +@code{callee1} which inlines @code{callee2}, and address is from +@code{callee2}, the source information for @code{callee1} and @code{main} +will also be printed. + +@item -j +@itemx --section +Read offsets relative to the specified section instead of absolute addresses. + +@item -p +@itemx --pretty-print +Make the output more human friendly: each location are printed on one line. +If option @option{-i} is specified, lines for all enclosing scopes are +prefixed with @samp{(inlined by)}. +@end table + +@c man end + +@ignore +@c man begin SEEALSO addr2line +Info entries for @file{binutils}. +@c man end +@end ignore + +@node nlmconv +@chapter nlmconv + +@command{nlmconv} converts a relocatable object file into a NetWare +Loadable Module. + +@ignore +@command{nlmconv} currently works with @samp{i386} object +files in @code{coff}, @sc{elf}, or @code{a.out} format, and @sc{SPARC} +object files in @sc{elf}, or @code{a.out} format@footnote{ +@command{nlmconv} should work with any @samp{i386} or @sc{sparc} object +format in the Binary File Descriptor library. It has only been tested +with the above formats.}. +@end ignore + +@quotation +@emph{Warning:} @command{nlmconv} is not always built as part of the binary +utilities, since it is only useful for NLM targets. +@end quotation + +@c man title nlmconv converts object code into an NLM. + +@smallexample +@c man begin SYNOPSIS nlmconv +nlmconv [@option{-I} @var{bfdname}|@option{--input-target=}@var{bfdname}] + [@option{-O} @var{bfdname}|@option{--output-target=}@var{bfdname}] + [@option{-T} @var{headerfile}|@option{--header-file=}@var{headerfile}] + [@option{-d}|@option{--debug}] [@option{-l} @var{linker}|@option{--linker=}@var{linker}] + [@option{-h}|@option{--help}] [@option{-V}|@option{--version}] + @var{infile} @var{outfile} +@c man end +@end smallexample + +@c man begin DESCRIPTION nlmconv + +@command{nlmconv} converts the relocatable @samp{i386} object file +@var{infile} into the NetWare Loadable Module @var{outfile}, optionally +reading @var{headerfile} for NLM header information. For instructions +on writing the NLM command file language used in header files, see the +@samp{linkers} section, @samp{NLMLINK} in particular, of the @cite{NLM +Development and Tools Overview}, which is part of the NLM Software +Developer's Kit (``NLM SDK''), available from Novell, Inc. +@command{nlmconv} uses the @sc{gnu} Binary File Descriptor library to read +@var{infile}; +@ifclear man +see @ref{BFD,,BFD,ld.info,Using LD}, for more information. +@end ifclear + +@command{nlmconv} can perform a link step. In other words, you can list +more than one object file for input if you list them in the definitions +file (rather than simply specifying one input file on the command line). +In this case, @command{nlmconv} calls the linker for you. + +@c man end + +@c man begin OPTIONS nlmconv + +@table @env +@item -I @var{bfdname} +@itemx --input-target=@var{bfdname} +Object format of the input file. @command{nlmconv} can usually determine +the format of a given file (so no default is necessary). +@xref{Target Selection}, for more information. + +@item -O @var{bfdname} +@itemx --output-target=@var{bfdname} +Object format of the output file. @command{nlmconv} infers the output +format based on the input format, e.g. for a @samp{i386} input file the +output format is @samp{nlm32-i386}. +@xref{Target Selection}, for more information. + +@item -T @var{headerfile} +@itemx --header-file=@var{headerfile} +Reads @var{headerfile} for NLM header information. For instructions on +writing the NLM command file language used in header files, see@ see the +@samp{linkers} section, of the @cite{NLM Development and Tools +Overview}, which is part of the NLM Software Developer's Kit, available +from Novell, Inc. + +@item -d +@itemx --debug +Displays (on standard error) the linker command line used by @command{nlmconv}. + +@item -l @var{linker} +@itemx --linker=@var{linker} +Use @var{linker} for any linking. @var{linker} can be an absolute or a +relative pathname. + +@item -h +@itemx --help +Prints a usage summary. + +@item -V +@itemx --version +Prints the version number for @command{nlmconv}. +@end table + +@c man end + +@ignore +@c man begin SEEALSO nlmconv +the Info entries for @file{binutils}. +@c man end +@end ignore + +@node windmc +@chapter windmc + +@command{windmc} may be used to generator Windows message resources. + +@quotation +@emph{Warning:} @command{windmc} is not always built as part of the binary +utilities, since it is only useful for Windows targets. +@end quotation + +@c man title windmc generates Windows message resources. + +@smallexample +@c man begin SYNOPSIS windmc +windmc [options] input-file +@c man end +@end smallexample + +@c man begin DESCRIPTION windmc + +@command{windmc} reads message definitions from an input file (.mc) and +translate them into a set of output files. The output files may be of +four kinds: + +@table @code +@item h +A C header file containing the message definitions. + +@item rc +A resource file compilable by the @command{windres} tool. + +@item bin +One or more binary files containing the resource data for a specific +message language. + +@item dbg +A C include file that maps message id's to their symbolic name. +@end table + +The exact description of these different formats is available in +documentation from Microsoft. + +When @command{windmc} converts from the @code{mc} format to the @code{bin} +format, @code{rc}, @code{h}, and optional @code{dbg} it is acting like the +Windows Message Compiler. + +@c man end + +@c man begin OPTIONS windmc + +@table @env +@item -a +@itemx --ascii_in +Specifies that the input file specified is ASCII. This is the default +behaviour. + +@item -A +@itemx --ascii_out +Specifies that messages in the output @code{bin} files should be in ASCII +format. + +@item -b +@itemx --binprefix +Specifies that @code{bin} filenames should have to be prefixed by the +basename of the source file. + +@item -c +@itemx --customflag +Sets the customer bit in all message id's. + +@item -C @var{codepage} +@itemx --codepage_in @var{codepage} +Sets the default codepage to be used to convert input file to UTF16. The +default is ocdepage 1252. + +@item -d +@itemx --decimal_values +Outputs the constants in the header file in decimal. Default is using +hexadecimal output. + +@item -e @var{ext} +@itemx --extension @var{ext} +The extension for the header file. The default is .h extension. + +@item -F @var{target} +@itemx --target @var{target} +Specify the BFD format to use for a bin file as output. This +is a BFD target name; you can use the @option{--help} option to see a list +of supported targets. Normally @command{windmc} will use the default +format, which is the first one listed by the @option{--help} option. +@ifclear man +@ref{Target Selection}. +@end ifclear + +@item -h @var{path} +@itemx --headerdir @var{path} +The target directory of the generated header file. The default is the +current directory. + +@item -H +@itemx --help +Displays a list of command line options and then exits. + +@item -m @var{characters} +@itemx --maxlength @var{characters} +Instructs @command{windmc} to generate a warning if the length +of any message exceeds the number specified. + +@item -n +@itemx --nullterminate +Terminate message text in @code{bin} files by zero. By default they are +terminated by CR/LF. + +@item -o +@itemx --hresult_use +Not yet implemented. Instructs @code{windmc} to generate an OLE2 header +file, using HRESULT definitions. Status codes are used if the flag is not +specified. + +@item -O @var{codepage} +@itemx --codepage_out @var{codepage} +Sets the default codepage to be used to output text files. The default +is ocdepage 1252. + +@item -r @var{path} +@itemx --rcdir @var{path} +The target directory for the generated @code{rc} script and the generated +@code{bin} files that the resource compiler script includes. The default +is the current directory. + +@item -u +@itemx --unicode_in +Specifies that the input file is UTF16. + +@item -U +@itemx --unicode_out +Specifies that messages in the output @code{bin} file should be in UTF16 +format. This is the default behaviour. + +@item -v +@item --verbose +Enable verbose mode. + +@item -V +@item --version +Prints the version number for @command{windmc}. + +@item -x @var{path} +@itemx --xdgb @var{path} +The path of the @code{dbg} C include file that maps message id's to the +symbolic name. No such file is generated without specifying the switch. +@end table + +@c man end + +@ignore +@c man begin SEEALSO windmc +the Info entries for @file{binutils}. +@c man end +@end ignore + +@node windres +@chapter windres + +@command{windres} may be used to manipulate Windows resources. + +@quotation +@emph{Warning:} @command{windres} is not always built as part of the binary +utilities, since it is only useful for Windows targets. +@end quotation + +@c man title windres manipulate Windows resources. + +@smallexample +@c man begin SYNOPSIS windres +windres [options] [input-file] [output-file] +@c man end +@end smallexample + +@c man begin DESCRIPTION windres + +@command{windres} reads resources from an input file and copies them into +an output file. Either file may be in one of three formats: + +@table @code +@item rc +A text format read by the Resource Compiler. + +@item res +A binary format generated by the Resource Compiler. + +@item coff +A COFF object or executable. +@end table + +The exact description of these different formats is available in +documentation from Microsoft. + +When @command{windres} converts from the @code{rc} format to the @code{res} +format, it is acting like the Windows Resource Compiler. When +@command{windres} converts from the @code{res} format to the @code{coff} +format, it is acting like the Windows @code{CVTRES} program. + +When @command{windres} generates an @code{rc} file, the output is similar +but not identical to the format expected for the input. When an input +@code{rc} file refers to an external filename, an output @code{rc} file +will instead include the file contents. + +If the input or output format is not specified, @command{windres} will +guess based on the file name, or, for the input file, the file contents. +A file with an extension of @file{.rc} will be treated as an @code{rc} +file, a file with an extension of @file{.res} will be treated as a +@code{res} file, and a file with an extension of @file{.o} or +@file{.exe} will be treated as a @code{coff} file. + +If no output file is specified, @command{windres} will print the resources +in @code{rc} format to standard output. + +The normal use is for you to write an @code{rc} file, use @command{windres} +to convert it to a COFF object file, and then link the COFF file into +your application. This will make the resources described in the +@code{rc} file available to Windows. + +@c man end + +@c man begin OPTIONS windres + +@table @env +@item -i @var{filename} +@itemx --input @var{filename} +The name of the input file. If this option is not used, then +@command{windres} will use the first non-option argument as the input file +name. If there are no non-option arguments, then @command{windres} will +read from standard input. @command{windres} can not read a COFF file from +standard input. + +@item -o @var{filename} +@itemx --output @var{filename} +The name of the output file. If this option is not used, then +@command{windres} will use the first non-option argument, after any used +for the input file name, as the output file name. If there is no +non-option argument, then @command{windres} will write to standard output. +@command{windres} can not write a COFF file to standard output. Note, +for compatibility with @command{rc} the option @option{-fo} is also +accepted, but its use is not recommended. + +@item -J @var{format} +@itemx --input-format @var{format} +The input format to read. @var{format} may be @samp{res}, @samp{rc}, or +@samp{coff}. If no input format is specified, @command{windres} will +guess, as described above. + +@item -O @var{format} +@itemx --output-format @var{format} +The output format to generate. @var{format} may be @samp{res}, +@samp{rc}, or @samp{coff}. If no output format is specified, +@command{windres} will guess, as described above. + +@item -F @var{target} +@itemx --target @var{target} +Specify the BFD format to use for a COFF file as input or output. This +is a BFD target name; you can use the @option{--help} option to see a list +of supported targets. Normally @command{windres} will use the default +format, which is the first one listed by the @option{--help} option. +@ifclear man +@ref{Target Selection}. +@end ifclear + +@item --preprocessor @var{program} +When @command{windres} reads an @code{rc} file, it runs it through the C +preprocessor first. This option may be used to specify the preprocessor +to use, including any leading arguments. The default preprocessor +argument is @code{gcc -E -xc-header -DRC_INVOKED}. + +@item --preprocessor-arg @var{option} +When @command{windres} reads an @code{rc} file, it runs it through +the C preprocessor first. This option may be used to specify additional +text to be passed to preprocessor on its command line. +This option can be used multiple times to add multiple options to the +preprocessor command line. + +@item -I @var{directory} +@itemx --include-dir @var{directory} +Specify an include directory to use when reading an @code{rc} file. +@command{windres} will pass this to the preprocessor as an @option{-I} +option. @command{windres} will also search this directory when looking for +files named in the @code{rc} file. If the argument passed to this command +matches any of the supported @var{formats} (as described in the @option{-J} +option), it will issue a deprecation warning, and behave just like the +@option{-J} option. New programs should not use this behaviour. If a +directory happens to match a @var{format}, simple prefix it with @samp{./} +to disable the backward compatibility. + +@item -D @var{target} +@itemx --define @var{sym}[=@var{val}] +Specify a @option{-D} option to pass to the preprocessor when reading an +@code{rc} file. + +@item -U @var{target} +@itemx --undefine @var{sym} +Specify a @option{-U} option to pass to the preprocessor when reading an +@code{rc} file. + +@item -r +Ignored for compatibility with rc. + +@item -v +Enable verbose mode. This tells you what the preprocessor is if you +didn't specify one. + +@item -c @var{val} +@item --codepage @var{val} +Specify the default codepage to use when reading an @code{rc} file. +@var{val} should be a hexadecimal prefixed by @samp{0x} or decimal +codepage code. The valid range is from zero up to 0xffff, but the +validity of the codepage is host and configuration dependent. + +@item -l @var{val} +@item --language @var{val} +Specify the default language to use when reading an @code{rc} file. +@var{val} should be a hexadecimal language code. The low eight bits are +the language, and the high eight bits are the sublanguage. + +@item --use-temp-file +Use a temporary file to instead of using popen to read the output of +the preprocessor. Use this option if the popen implementation is buggy +on the host (eg., certain non-English language versions of Windows 95 and +Windows 98 are known to have buggy popen where the output will instead +go the console). + +@item --no-use-temp-file +Use popen, not a temporary file, to read the output of the preprocessor. +This is the default behaviour. + +@item -h +@item --help +Prints a usage summary. + +@item -V +@item --version +Prints the version number for @command{windres}. + +@item --yydebug +If @command{windres} is compiled with @code{YYDEBUG} defined as @code{1}, +this will turn on parser debugging. +@end table + +@c man end + +@ignore +@c man begin SEEALSO windres +the Info entries for @file{binutils}. +@c man end +@end ignore + +@node dlltool +@chapter dlltool +@cindex DLL +@kindex dlltool + +@command{dlltool} is used to create the files needed to create dynamic +link libraries (DLLs) on systems which understand PE format image +files such as Windows. A DLL contains an export table which contains +information that the runtime loader needs to resolve references from a +referencing program. + +The export table is generated by this program by reading in a +@file{.def} file or scanning the @file{.a} and @file{.o} files which +will be in the DLL. A @file{.o} file can contain information in +special @samp{.drectve} sections with export information. + +@quotation +@emph{Note:} @command{dlltool} is not always built as part of the +binary utilities, since it is only useful for those targets which +support DLLs. +@end quotation + +@c man title dlltool Create files needed to build and use DLLs. + +@smallexample +@c man begin SYNOPSIS dlltool +dlltool [@option{-d}|@option{--input-def} @var{def-file-name}] + [@option{-b}|@option{--base-file} @var{base-file-name}] + [@option{-e}|@option{--output-exp} @var{exports-file-name}] + [@option{-z}|@option{--output-def} @var{def-file-name}] + [@option{-l}|@option{--output-lib} @var{library-file-name}] + [@option{-y}|@option{--output-delaylib} @var{library-file-name}] + [@option{--export-all-symbols}] [@option{--no-export-all-symbols}] + [@option{--exclude-symbols} @var{list}] + [@option{--no-default-excludes}] + [@option{-S}|@option{--as} @var{path-to-assembler}] [@option{-f}|@option{--as-flags} @var{options}] + [@option{-D}|@option{--dllname} @var{name}] [@option{-m}|@option{--machine} @var{machine}] + [@option{-a}|@option{--add-indirect}] + [@option{-U}|@option{--add-underscore}] [@option{--add-stdcall-underscore}] + [@option{-k}|@option{--kill-at}] [@option{-A}|@option{--add-stdcall-alias}] + [@option{-p}|@option{--ext-prefix-alias} @var{prefix}] + [@option{-x}|@option{--no-idata4}] [@option{-c}|@option{--no-idata5}] + [@option{--use-nul-prefixed-import-tables}] + [@option{-I}|@option{--identify} @var{library-file-name}] [@option{--identify-strict}] + [@option{-i}|@option{--interwork}] + [@option{-n}|@option{--nodelete}] [@option{-t}|@option{--temp-prefix} @var{prefix}] + [@option{-v}|@option{--verbose}] + [@option{-h}|@option{--help}] [@option{-V}|@option{--version}] + [@option{--no-leading-underscore}] [@option{--leading-underscore}] + [object-file @dots{}] +@c man end +@end smallexample + +@c man begin DESCRIPTION dlltool + +@command{dlltool} reads its inputs, which can come from the @option{-d} and +@option{-b} options as well as object files specified on the command +line. It then processes these inputs and if the @option{-e} option has +been specified it creates a exports file. If the @option{-l} option +has been specified it creates a library file and if the @option{-z} option +has been specified it creates a def file. Any or all of the @option{-e}, +@option{-l} and @option{-z} options can be present in one invocation of +dlltool. + +When creating a DLL, along with the source for the DLL, it is necessary +to have three other files. @command{dlltool} can help with the creation of +these files. + +The first file is a @file{.def} file which specifies which functions are +exported from the DLL, which functions the DLL imports, and so on. This +is a text file and can be created by hand, or @command{dlltool} can be used +to create it using the @option{-z} option. In this case @command{dlltool} +will scan the object files specified on its command line looking for +those functions which have been specially marked as being exported and +put entries for them in the @file{.def} file it creates. + +In order to mark a function as being exported from a DLL, it needs to +have an @option{-export:} entry in the @samp{.drectve} +section of the object file. This can be done in C by using the +asm() operator: + +@smallexample + asm (".section .drectve"); + asm (".ascii \"-export:my_func\""); + + int my_func (void) @{ @dots{} @} +@end smallexample + +The second file needed for DLL creation is an exports file. This file +is linked with the object files that make up the body of the DLL and it +handles the interface between the DLL and the outside world. This is a +binary file and it can be created by giving the @option{-e} option to +@command{dlltool} when it is creating or reading in a @file{.def} file. + +The third file needed for DLL creation is the library file that programs +will link with in order to access the functions in the DLL (an `import +library'). This file can be created by giving the @option{-l} option to +dlltool when it is creating or reading in a @file{.def} file. + +If the @option{-y} option is specified, dlltool generates a delay-import +library that can be used instead of the normal import library to allow +a program to link to the dll only as soon as an imported function is +called for the first time. The resulting executable will need to be +linked to the static delayimp library containing __delayLoadHelper2(), +which in turn will import LoadLibraryA and GetProcAddress from kernel32. + +@command{dlltool} builds the library file by hand, but it builds the +exports file by creating temporary files containing assembler statements +and then assembling these. The @option{-S} command line option can be +used to specify the path to the assembler that dlltool will use, +and the @option{-f} option can be used to pass specific flags to that +assembler. The @option{-n} can be used to prevent dlltool from deleting +these temporary assembler files when it is done, and if @option{-n} is +specified twice then this will prevent dlltool from deleting the +temporary object files it used to build the library. + +Here is an example of creating a DLL from a source file @samp{dll.c} and +also creating a program (from an object file called @samp{program.o}) +that uses that DLL: + +@smallexample + gcc -c dll.c + dlltool -e exports.o -l dll.lib dll.o + gcc dll.o exports.o -o dll.dll + gcc program.o dll.lib -o program +@end smallexample + + +@command{dlltool} may also be used to query an existing import library +to determine the name of the DLL to which it is associated. See the +description of the @option{-I} or @option{--identify} option. + +@c man end + +@c man begin OPTIONS dlltool + +The command line options have the following meanings: + +@table @env + +@item -d @var{filename} +@itemx --input-def @var{filename} +@cindex input .def file +Specifies the name of a @file{.def} file to be read in and processed. + +@item -b @var{filename} +@itemx --base-file @var{filename} +@cindex base files +Specifies the name of a base file to be read in and processed. The +contents of this file will be added to the relocation section in the +exports file generated by dlltool. + +@item -e @var{filename} +@itemx --output-exp @var{filename} +Specifies the name of the export file to be created by dlltool. + +@item -z @var{filename} +@itemx --output-def @var{filename} +Specifies the name of the @file{.def} file to be created by dlltool. + +@item -l @var{filename} +@itemx --output-lib @var{filename} +Specifies the name of the library file to be created by dlltool. + +@item -y @var{filename} +@itemx --output-delaylib @var{filename} +Specifies the name of the delay-import library file to be created by dlltool. + +@item --export-all-symbols +Treat all global and weak defined symbols found in the input object +files as symbols to be exported. There is a small list of symbols which +are not exported by default; see the @option{--no-default-excludes} +option. You may add to the list of symbols to not export by using the +@option{--exclude-symbols} option. + +@item --no-export-all-symbols +Only export symbols explicitly listed in an input @file{.def} file or in +@samp{.drectve} sections in the input object files. This is the default +behaviour. The @samp{.drectve} sections are created by @samp{dllexport} +attributes in the source code. + +@item --exclude-symbols @var{list} +Do not export the symbols in @var{list}. This is a list of symbol names +separated by comma or colon characters. The symbol names should not +contain a leading underscore. This is only meaningful when +@option{--export-all-symbols} is used. + +@item --no-default-excludes +When @option{--export-all-symbols} is used, it will by default avoid +exporting certain special symbols. The current list of symbols to avoid +exporting is @samp{DllMain@@12}, @samp{DllEntryPoint@@0}, +@samp{impure_ptr}. You may use the @option{--no-default-excludes} option +to go ahead and export these special symbols. This is only meaningful +when @option{--export-all-symbols} is used. + +@item -S @var{path} +@itemx --as @var{path} +Specifies the path, including the filename, of the assembler to be used +to create the exports file. + +@item -f @var{options} +@itemx --as-flags @var{options} +Specifies any specific command line options to be passed to the +assembler when building the exports file. This option will work even if +the @option{-S} option is not used. This option only takes one argument, +and if it occurs more than once on the command line, then later +occurrences will override earlier occurrences. So if it is necessary to +pass multiple options to the assembler they should be enclosed in +double quotes. + +@item -D @var{name} +@itemx --dll-name @var{name} +Specifies the name to be stored in the @file{.def} file as the name of +the DLL when the @option{-e} option is used. If this option is not +present, then the filename given to the @option{-e} option will be +used as the name of the DLL. + +@item -m @var{machine} +@itemx -machine @var{machine} +Specifies the type of machine for which the library file should be +built. @command{dlltool} has a built in default type, depending upon how +it was created, but this option can be used to override that. This is +normally only useful when creating DLLs for an ARM processor, when the +contents of the DLL are actually encode using Thumb instructions. + +@item -a +@itemx --add-indirect +Specifies that when @command{dlltool} is creating the exports file it +should add a section which allows the exported functions to be +referenced without using the import library. Whatever the hell that +means! + +@item -U +@itemx --add-underscore +Specifies that when @command{dlltool} is creating the exports file it +should prepend an underscore to the names of @emph{all} exported symbols. + +@item --no-leading-underscore +@item --leading-underscore +Specifies whether standard symbol should be forced to be prefixed, or +not. + +@item --add-stdcall-underscore +Specifies that when @command{dlltool} is creating the exports file it +should prepend an underscore to the names of exported @emph{stdcall} +functions. Variable names and non-stdcall function names are not modified. +This option is useful when creating GNU-compatible import libs for third +party DLLs that were built with MS-Windows tools. + +@item -k +@itemx --kill-at +Specifies that @samp{@@} suffixes should be omitted from the names +of stdcall functions that will be imported from the DLL. This is +useful when creating an import library for a DLL which exports stdcall +functions but without the usual @samp{@@} symbol name suffix. + +This does not change the naming of symbols provided by the import library +to programs linked against it, but only the entries in the import table +(ie the .idata section). + +@item -A +@itemx --add-stdcall-alias +Specifies that when @command{dlltool} is creating the exports file it +should add aliases for stdcall symbols without @samp{@@ } +in addition to the symbols with @samp{@@ }. + +@item -p +@itemx --ext-prefix-alias @var{prefix} +Causes @command{dlltool} to create external aliases for all DLL +imports with the specified prefix. The aliases are created for both +external and import symbols with no leading underscore. + +@item -x +@itemx --no-idata4 +Specifies that when @command{dlltool} is creating the exports and library +files it should omit the @code{.idata4} section. This is for compatibility +with certain operating systems. + +@item --use-nul-prefixed-import-tables +Specifies that when @command{dlltool} is creating the exports and library +files it should prefix the @code{.idata4} and @code{.idata5} by zero an +element. This emulates old gnu import library generation of +@code{dlltool}. By default this option is turned off. + +@item -c +@itemx --no-idata5 +Specifies that when @command{dlltool} is creating the exports and library +files it should omit the @code{.idata5} section. This is for compatibility +with certain operating systems. + +@item -I @var{filename} +@itemx --identify @var{filename} +Specifies that @command{dlltool} should inspect the import library +indicated by @var{filename} and report, on @code{stdout}, the name(s) +of the associated DLL(s). This can be performed in addition to any +other operations indicated by the other options and arguments. +@command{dlltool} fails if the import library does not exist or is not +actually an import library. See also @option{--identify-strict}. + +@item --identify-strict +Modifies the behavior of the @option{--identify} option, such +that an error is reported if @var{filename} is associated with +more than one DLL. + +@item -i +@itemx --interwork +Specifies that @command{dlltool} should mark the objects in the library +file and exports file that it produces as supporting interworking +between ARM and Thumb code. + +@item -n +@itemx --nodelete +Makes @command{dlltool} preserve the temporary assembler files it used to +create the exports file. If this option is repeated then dlltool will +also preserve the temporary object files it uses to create the library +file. + +@item -t @var{prefix} +@itemx --temp-prefix @var{prefix} +Makes @command{dlltool} use @var{prefix} when constructing the names of +temporary assembler and object files. By default, the temp file prefix +is generated from the pid. + +@item -v +@itemx --verbose +Make dlltool describe what it is doing. + +@item -h +@itemx --help +Displays a list of command line options and then exits. + +@item -V +@itemx --version +Displays dlltool's version number and then exits. + +@end table + +@c man end + +@menu +* def file format:: The format of the dlltool @file{.def} file +@end menu + +@node def file format +@section The format of the @command{dlltool} @file{.def} file + +A @file{.def} file contains any number of the following commands: + +@table @asis + +@item @code{NAME} @var{name} @code{[ ,} @var{base} @code{]} +The result is going to be named @var{name}@code{.exe}. + +@item @code{LIBRARY} @var{name} @code{[ ,} @var{base} @code{]} +The result is going to be named @var{name}@code{.dll}. +Note: If you want to use LIBRARY as name then you need to quote. Otherwise +this will fail due a necessary hack for libtool (see PR binutils/13710 for more +details). + +@item @code{EXPORTS ( ( (} @var{name1} @code{[ = } @var{name2} @code{] ) | ( } @var{name1} @code{=} @var{module-name} @code{.} @var{external-name} @code{) ) [ == } @var{its_name} @code{]} +@item @code{[} @var{integer} @code{] [ NONAME ] [ CONSTANT ] [ DATA ] [ PRIVATE ] ) *} +Declares @var{name1} as an exported symbol from the DLL, with optional +ordinal number @var{integer}, or declares @var{name1} as an alias +(forward) of the function @var{external-name} in the DLL. +If @var{its_name} is specified, this name is used as string in export table. +@var{module-name}. +Note: The @code{EXPORTS} has to be the last command in .def file, as keywords +are treated - beside @code{LIBRARY} - as simple name-identifiers. +If you want to use LIBRARY as name then you need to quote it. + +@item @code{IMPORTS ( (} @var{internal-name} @code{=} @var{module-name} @code{.} @var{integer} @code{) | [} @var{internal-name} @code{= ]} @var{module-name} @code{.} @var{external-name} @code{) [ == ) @var{its_name} @code{]} *} +Declares that @var{external-name} or the exported function whose +ordinal number is @var{integer} is to be imported from the file +@var{module-name}. If @var{internal-name} is specified then this is +the name that the imported function will be referred to in the body of +the DLL. +If @var{its_name} is specified, this name is used as string in import table. +Note: The @code{IMPORTS} has to be the last command in .def file, as keywords +are treated - beside @code{LIBRARY} - as simple name-identifiers. +If you want to use LIBRARY as name then you need to quote it. + +@item @code{DESCRIPTION} @var{string} +Puts @var{string} into the output @file{.exp} file in the +@code{.rdata} section. + +@item @code{STACKSIZE} @var{number-reserve} @code{[, } @var{number-commit} @code{]} +@item @code{HEAPSIZE} @var{number-reserve} @code{[, } @var{number-commit} @code{]} +Generates @code{--stack} or @code{--heap} +@var{number-reserve},@var{number-commit} in the output @code{.drectve} +section. The linker will see this and act upon it. + +@item @code{CODE} @var{attr} @code{+} +@item @code{DATA} @var{attr} @code{+} +@item @code{SECTIONS (} @var{section-name} @var{attr}@code{ + ) *} +Generates @code{--attr} @var{section-name} @var{attr} in the output +@code{.drectve} section, where @var{attr} is one of @code{READ}, +@code{WRITE}, @code{EXECUTE} or @code{SHARED}. The linker will see +this and act upon it. + +@end table + +@ignore +@c man begin SEEALSO dlltool +The Info pages for @file{binutils}. +@c man end +@end ignore + +@node readelf +@chapter readelf + +@cindex ELF file information +@kindex readelf + +@c man title readelf Displays information about ELF files. + +@smallexample +@c man begin SYNOPSIS readelf +readelf [@option{-a}|@option{--all}] + [@option{-h}|@option{--file-header}] + [@option{-l}|@option{--program-headers}|@option{--segments}] + [@option{-S}|@option{--section-headers}|@option{--sections}] + [@option{-g}|@option{--section-groups}] + [@option{-t}|@option{--section-details}] + [@option{-e}|@option{--headers}] + [@option{-s}|@option{--syms}|@option{--symbols}] + [@option{--dyn-syms}] + [@option{-n}|@option{--notes}] + [@option{-r}|@option{--relocs}] + [@option{-u}|@option{--unwind}] + [@option{-d}|@option{--dynamic}] + [@option{-V}|@option{--version-info}] + [@option{-A}|@option{--arch-specific}] + [@option{-D}|@option{--use-dynamic}] + [@option{-x} |@option{--hex-dump=}] + [@option{-p} |@option{--string-dump=}] + [@option{-R} |@option{--relocated-dump=}] + [@option{-z}|@option{--decompress}] + [@option{-c}|@option{--archive-index}] + [@option{-w[lLiaprmfFsoRtUuTgAckK]}| + @option{--debug-dump}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]] + [@option{--dwarf-depth=@var{n}}] + [@option{--dwarf-start=@var{n}}] + [@option{-I}|@option{--histogram}] + [@option{-v}|@option{--version}] + [@option{-W}|@option{--wide}] + [@option{-H}|@option{--help}] + @var{elffile}@dots{} +@c man end +@end smallexample + +@c man begin DESCRIPTION readelf + +@command{readelf} displays information about one or more ELF format object +files. The options control what particular information to display. + +@var{elffile}@dots{} are the object files to be examined. 32-bit and +64-bit ELF files are supported, as are archives containing ELF files. + +This program performs a similar function to @command{objdump} but it +goes into more detail and it exists independently of the @sc{bfd} +library, so if there is a bug in @sc{bfd} then readelf will not be +affected. + +@c man end + +@c man begin OPTIONS readelf + +The long and short forms of options, shown here as alternatives, are +equivalent. At least one option besides @samp{-v} or @samp{-H} must be +given. + +@table @env +@item -a +@itemx --all +Equivalent to specifying @option{--file-header}, +@option{--program-headers}, @option{--sections}, @option{--symbols}, +@option{--relocs}, @option{--dynamic}, @option{--notes}, +@option{--version-info}, @option{--arch-specific}, @option{--unwind}, +@option{--section-groups} and @option{--histogram}. + +Note - this option does not enable @option{--use-dynamic} itself, so +if that option is not present on the command line then dynamic symbols +and dynamic relocs will not be displayed. + +@item -h +@itemx --file-header +@cindex ELF file header information +Displays the information contained in the ELF header at the start of the +file. + +@item -l +@itemx --program-headers +@itemx --segments +@cindex ELF program header information +@cindex ELF segment information +Displays the information contained in the file's segment headers, if it +has any. + +@item -S +@itemx --sections +@itemx --section-headers +@cindex ELF section information +Displays the information contained in the file's section headers, if it +has any. + +@item -g +@itemx --section-groups +@cindex ELF section group information +Displays the information contained in the file's section groups, if it +has any. + +@item -t +@itemx --section-details +@cindex ELF section information +Displays the detailed section information. Implies @option{-S}. + +@item -s +@itemx --symbols +@itemx --syms +@cindex ELF symbol table information +Displays the entries in symbol table section of the file, if it has one. +If a symbol has version information associated with it then this is +displayed as well. The version string is displayed as a suffix to the +symbol name, preceeded by an @@ character. For example +@samp{foo@@VER_1}. If the version is the default version to be used +when resolving unversioned references to the symbol then it is +displayed as a suffix preceeded by two @@ characters. For example +@samp{foo@@@@VER_2}. + +@item --dyn-syms +@cindex ELF dynamic symbol table information +Displays the entries in dynamic symbol table section of the file, if it +has one. The output format is the same as the format used by the +@option{--syms} option. + +@item -e +@itemx --headers +Display all the headers in the file. Equivalent to @option{-h -l -S}. + +@item -n +@itemx --notes +@cindex ELF notes +Displays the contents of the NOTE segments and/or sections, if any. + +@item -r +@itemx --relocs +@cindex ELF reloc information +Displays the contents of the file's relocation section, if it has one. + +@item -u +@itemx --unwind +@cindex unwind information +Displays the contents of the file's unwind section, if it has one. Only +the unwind sections for IA64 ELF files, as well as ARM unwind tables +(@code{.ARM.exidx} / @code{.ARM.extab}) are currently supported. + +@item -d +@itemx --dynamic +@cindex ELF dynamic section information +Displays the contents of the file's dynamic section, if it has one. + +@item -V +@itemx --version-info +@cindex ELF version sections information +Displays the contents of the version sections in the file, it they +exist. + +@item -A +@itemx --arch-specific +Displays architecture-specific information in the file, if there +is any. + +@item -D +@itemx --use-dynamic +When displaying symbols, this option makes @command{readelf} use the +symbol hash tables in the file's dynamic section, rather than the +symbol table sections. + +When displaying relocations, this option makes @command{readelf} +display the dynamic relocations rather than the static relocations. + +@item -x +@itemx --hex-dump= +Displays the contents of the indicated section as a hexadecimal bytes. +A number identifies a particular section by index in the section table; +any other string identifies all sections with that name in the object file. + +@item -R +@itemx --relocated-dump= +Displays the contents of the indicated section as a hexadecimal +bytes. A number identifies a particular section by index in the +section table; any other string identifies all sections with that name +in the object file. The contents of the section will be relocated +before they are displayed. + +@item -p +@itemx --string-dump= +Displays the contents of the indicated section as printable strings. +A number identifies a particular section by index in the section table; +any other string identifies all sections with that name in the object file. + +@item -z +@itemx --decompress +Requests that the section(s) being dumped by @option{x}, @option{R} or +@option{p} options are decompressed before being displayed. If the +section(s) are not compressed then they are displayed as is. + +@item -c +@itemx --archive-index +@cindex Archive file symbol index information +Displays the file symbol index information contained in the header part +of binary archives. Performs the same function as the @option{t} +command to @command{ar}, but without using the BFD library. @xref{ar}. + +@item -w[lLiaprmfFsoRtUuTgAckK] +@itemx --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links] +@include debug.options.texi + +@item -I +@itemx --histogram +Display a histogram of bucket list lengths when displaying the contents +of the symbol tables. + +@item -v +@itemx --version +Display the version number of readelf. + +@item -W +@itemx --wide +Don't break output lines to fit into 80 columns. By default +@command{readelf} breaks section header and segment listing lines for +64-bit ELF files, so that they fit into 80 columns. This option causes +@command{readelf} to print each section header resp. each segment one a +single line, which is far more readable on terminals wider than 80 columns. + +@item -H +@itemx --help +Display the command line options understood by @command{readelf}. + +@end table + +@c man end + +@ignore +@c man begin SEEALSO readelf +objdump(1), and the Info entries for @file{binutils}. +@c man end +@end ignore + +@node elfedit +@chapter elfedit + +@cindex Update ELF header +@kindex elfedit + +@c man title elfedit Update the ELF header of ELF files. + +@smallexample +@c man begin SYNOPSIS elfedit +elfedit [@option{--input-mach=}@var{machine}] + [@option{--input-type=}@var{type}] + [@option{--input-osabi=}@var{osabi}] + @option{--output-mach=}@var{machine} + @option{--output-type=}@var{type} + @option{--output-osabi=}@var{osabi} + [@option{-v}|@option{--version}] + [@option{-h}|@option{--help}] + @var{elffile}@dots{} +@c man end +@end smallexample + +@c man begin DESCRIPTION elfedit + +@command{elfedit} updates the ELF header of ELF files which have +the matching ELF machine and file types. The options control how and +which fields in the ELF header should be updated. + +@var{elffile}@dots{} are the ELF files to be updated. 32-bit and +64-bit ELF files are supported, as are archives containing ELF files. +@c man end + +@c man begin OPTIONS elfedit + +The long and short forms of options, shown here as alternatives, are +equivalent. At least one of the @option{--output-mach}, +@option{--output-type} and @option{--output-osabi} options must be given. + +@table @env + +@item --input-mach=@var{machine} +Set the matching input ELF machine type to @var{machine}. If +@option{--input-mach} isn't specified, it will match any ELF +machine types. + +The supported ELF machine types are, @var{i386}, @var{IAMCU}, @var{L1OM}, +@var{K1OM} and @var{x86-64}. + +@item --output-mach=@var{machine} +Change the ELF machine type in the ELF header to @var{machine}. The +supported ELF machine types are the same as @option{--input-mach}. + +@item --input-type=@var{type} +Set the matching input ELF file type to @var{type}. If +@option{--input-type} isn't specified, it will match any ELF file types. + +The supported ELF file types are, @var{rel}, @var{exec} and @var{dyn}. + +@item --output-type=@var{type} +Change the ELF file type in the ELF header to @var{type}. The +supported ELF types are the same as @option{--input-type}. + +@item --input-osabi=@var{osabi} +Set the matching input ELF file OSABI to @var{osabi}. If +@option{--input-osabi} isn't specified, it will match any ELF OSABIs. + +The supported ELF OSABIs are, @var{none}, @var{HPUX}, @var{NetBSD}, +@var{GNU}, @var{Linux} (alias for @var{GNU}), +@var{Solaris}, @var{AIX}, @var{Irix}, +@var{FreeBSD}, @var{TRU64}, @var{Modesto}, @var{OpenBSD}, @var{OpenVMS}, +@var{NSK}, @var{AROS} and @var{FenixOS}. + +@item --output-osabi=@var{osabi} +Change the ELF OSABI in the ELF header to @var{osabi}. The +supported ELF OSABI are the same as @option{--input-osabi}. + +@item -v +@itemx --version +Display the version number of @command{elfedit}. + +@item -h +@itemx --help +Display the command line options understood by @command{elfedit}. + +@end table + +@c man end + +@ignore +@c man begin SEEALSO elfedit +readelf(1), and the Info entries for @file{binutils}. +@c man end +@end ignore + +@node Common Options +@chapter Common Options + +The following command-line options are supported by all of the +programs described in this manual. + +@c man begin OPTIONS +@table @env +@include at-file.texi +@c man end + +@item --help +Display the command-line options supported by the program. + +@item --version +Display the version number of the program. + +@c man begin OPTIONS +@end table +@c man end + +@node Selecting the Target System +@chapter Selecting the Target System + +You can specify two aspects of the target system to the @sc{gnu} +binary file utilities, each in several ways: + +@itemize @bullet +@item +the target + +@item +the architecture +@end itemize + +In the following summaries, the lists of ways to specify values are in +order of decreasing precedence. The ways listed first override those +listed later. + +The commands to list valid values only list the values for which the +programs you are running were configured. If they were configured with +@option{--enable-targets=all}, the commands list most of the available +values, but a few are left out; not all targets can be configured in at +once because some of them can only be configured @dfn{native} (on hosts +with the same type as the target system). + +@menu +* Target Selection:: +* Architecture Selection:: +@end menu + +@node Target Selection +@section Target Selection + +A @dfn{target} is an object file format. A given target may be +supported for multiple architectures (@pxref{Architecture Selection}). +A target selection may also have variations for different operating +systems or architectures. + +The command to list valid target values is @samp{objdump -i} +(the first column of output contains the relevant information). + +Some sample values are: @samp{a.out-hp300bsd}, @samp{ecoff-littlemips}, +@samp{a.out-sunos-big}. + +You can also specify a target using a configuration triplet. This is +the same sort of name that is passed to @file{configure} to specify a +target. When you use a configuration triplet as an argument, it must be +fully canonicalized. You can see the canonical version of a triplet by +running the shell script @file{config.sub} which is included with the +sources. + +Some sample configuration triplets are: @samp{m68k-hp-bsd}, +@samp{mips-dec-ultrix}, @samp{sparc-sun-sunos}. + +@subheading @command{objdump} Target + +Ways to specify: + +@enumerate +@item +command line option: @option{-b} or @option{--target} + +@item +environment variable @code{GNUTARGET} + +@item +deduced from the input file +@end enumerate + +@subheading @command{objcopy} and @command{strip} Input Target + +Ways to specify: + +@enumerate +@item +command line options: @option{-I} or @option{--input-target}, or @option{-F} or @option{--target} + +@item +environment variable @code{GNUTARGET} + +@item +deduced from the input file +@end enumerate + +@subheading @command{objcopy} and @command{strip} Output Target + +Ways to specify: + +@enumerate +@item +command line options: @option{-O} or @option{--output-target}, or @option{-F} or @option{--target} + +@item +the input target (see ``@command{objcopy} and @command{strip} Input Target'' above) + +@item +environment variable @code{GNUTARGET} + +@item +deduced from the input file +@end enumerate + +@subheading @command{nm}, @command{size}, and @command{strings} Target + +Ways to specify: + +@enumerate +@item +command line option: @option{--target} + +@item +environment variable @code{GNUTARGET} + +@item +deduced from the input file +@end enumerate + +@node Architecture Selection +@section Architecture Selection + +An @dfn{architecture} is a type of @sc{cpu} on which an object file is +to run. Its name may contain a colon, separating the name of the +processor family from the name of the particular @sc{cpu}. + +The command to list valid architecture values is @samp{objdump -i} (the +second column contains the relevant information). + +Sample values: @samp{m68k:68020}, @samp{mips:3000}, @samp{sparc}. + +@subheading @command{objdump} Architecture + +Ways to specify: + +@enumerate +@item +command line option: @option{-m} or @option{--architecture} + +@item +deduced from the input file +@end enumerate + +@subheading @command{objcopy}, @command{nm}, @command{size}, @command{strings} Architecture + +Ways to specify: + +@enumerate +@item +deduced from the input file +@end enumerate + +@node Reporting Bugs +@chapter Reporting Bugs +@cindex bugs +@cindex reporting bugs + +Your bug reports play an essential role in making the binary utilities +reliable. + +Reporting a bug may help you by bringing a solution to your problem, or +it may not. But in any case the principal function of a bug report is +to help the entire community by making the next version of the binary +utilities work better. Bug reports are your contribution to their +maintenance. + +In order for a bug report to serve its purpose, you must include the +information that enables us to fix the bug. + +@menu +* Bug Criteria:: Have you found a bug? +* Bug Reporting:: How to report bugs +@end menu + +@node Bug Criteria +@section Have You Found a Bug? +@cindex bug criteria + +If you are not sure whether you have found a bug, here are some guidelines: + +@itemize @bullet +@cindex fatal signal +@cindex crash +@item +If a binary utility gets a fatal signal, for any input whatever, that is +a bug. Reliable utilities never crash. + +@cindex error on valid input +@item +If a binary utility produces an error message for valid input, that is a +bug. + +@item +If you are an experienced user of binary utilities, your suggestions for +improvement are welcome in any case. +@end itemize + +@node Bug Reporting +@section How to Report Bugs +@cindex bug reports +@cindex bugs, reporting + +A number of companies and individuals offer support for @sc{gnu} +products. If you obtained the binary utilities from a support +organization, we recommend you contact that organization first. + +You can find contact information for many support companies and +individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs +distribution. + +@ifset BUGURL +In any event, we also recommend that you send bug reports for the binary +utilities to @value{BUGURL}. +@end ifset + +The fundamental principle of reporting bugs usefully is this: +@strong{report all the facts}. If you are not sure whether to state a +fact or leave it out, state it! + +Often people omit facts because they think they know what causes the +problem and assume that some details do not matter. Thus, you might +assume that the name of a file you use in an example does not matter. +Well, probably it does not, but one cannot be sure. Perhaps the bug is +a stray memory reference which happens to fetch from the location where +that pathname is stored in memory; perhaps, if the pathname were +different, the contents of that location would fool the utility into +doing the right thing despite the bug. Play it safe and give a +specific, complete example. That is the easiest thing for you to do, +and the most helpful. + +Keep in mind that the purpose of a bug report is to enable us to fix the bug if +it is new to us. Therefore, always write your bug reports on the assumption +that the bug has not been reported previously. + +Sometimes people give a few sketchy facts and ask, ``Does this ring a +bell?'' This cannot help us fix a bug, so it is basically useless. We +respond by asking for enough details to enable us to investigate. +You might as well expedite matters by sending them to begin with. + +To enable us to fix the bug, you should include all these things: + +@itemize @bullet +@item +The version of the utility. Each utility announces it if you start it +with the @option{--version} argument. + +Without this, we will not know whether there is any point in looking for +the bug in the current version of the binary utilities. + +@item +Any patches you may have applied to the source, including any patches +made to the @code{BFD} library. + +@item +The type of machine you are using, and the operating system name and +version number. + +@item +What compiler (and its version) was used to compile the utilities---e.g. +``@code{gcc-2.7}''. + +@item +The command arguments you gave the utility to observe the bug. To +guarantee you will not omit something important, list them all. A copy +of the Makefile (or the output from make) is sufficient. + +If we were to try to guess the arguments, we would probably guess wrong +and then we might not encounter the bug. + +@item +A complete input file, or set of input files, that will reproduce the +bug. If the utility is reading an object file or files, then it is +generally most helpful to send the actual object files. + +If the source files were produced exclusively using @sc{gnu} programs +(e.g., @command{gcc}, @command{gas}, and/or the @sc{gnu} @command{ld}), then it +may be OK to send the source files rather than the object files. In +this case, be sure to say exactly what version of @command{gcc}, or +whatever, was used to produce the object files. Also say how +@command{gcc}, or whatever, was configured. + +@item +A description of what behavior you observe that you believe is +incorrect. For example, ``It gets a fatal signal.'' + +Of course, if the bug is that the utility gets a fatal signal, then we +will certainly notice it. But if the bug is incorrect output, we might +not notice unless it is glaringly wrong. You might as well not give us +a chance to make a mistake. + +Even if the problem you experience is a fatal signal, you should still +say so explicitly. Suppose something strange is going on, such as your +copy of the utility is out of sync, or you have encountered a bug in +the C library on your system. (This has happened!) Your copy might +crash and ours would not. If you told us to expect a crash, then when +ours fails to crash, we would know that the bug was not happening for +us. If you had not told us to expect a crash, then we would not be able +to draw any conclusion from our observations. + +@item +If you wish to suggest changes to the source, send us context diffs, as +generated by @command{diff} with the @option{-u}, @option{-c}, or @option{-p} +option. Always send diffs from the old file to the new file. If you +wish to discuss something in the @command{ld} source, refer to it by +context, not by line number. + +The line numbers in our development sources will not match those in your +sources. Your line numbers would convey no useful information to us. +@end itemize + +Here are some things that are not necessary: + +@itemize @bullet +@item +A description of the envelope of the bug. + +Often people who encounter a bug spend a lot of time investigating +which changes to the input file will make the bug go away and which +changes will not affect it. + +This is often time consuming and not very useful, because the way we +will find the bug is by running a single example under the debugger +with breakpoints, not by pure deduction from a series of examples. +We recommend that you save your time for something else. + +Of course, if you can find a simpler example to report @emph{instead} +of the original one, that is a convenience for us. Errors in the +output will be easier to spot, running under the debugger will take +less time, and so on. + +However, simplification is not vital; if you do not want to do this, +report the bug anyway and send us the entire test case you used. + +@item +A patch for the bug. + +A patch for the bug does help us if it is a good one. But do not omit +the necessary information, such as the test case, on the assumption that +a patch is all we need. We might see problems with your patch and decide +to fix the problem another way, or we might not understand it at all. + +Sometimes with programs as complicated as the binary utilities it is +very hard to construct an example that will make the program follow a +certain path through the code. If you do not send us the example, we +will not be able to construct one, so we will not be able to verify that +the bug is fixed. + +And if we cannot understand what bug you are trying to fix, or why your +patch should be an improvement, we will not install it. A test case will +help us to understand. + +@item +A guess about what the bug is or what it depends on. + +Such guesses are usually wrong. Even we cannot guess right about such +things without first using the debugger to find the facts. +@end itemize + +@node GNU Free Documentation License +@appendix GNU Free Documentation License + +@include fdl.texi + +@node Binutils Index +@unnumbered Binutils Index + +@printindex cp + +@bye diff --git a/support/sdbinutils/binutils/doc/cxxfilt.man b/support/sdbinutils/binutils/doc/cxxfilt.man new file mode 100644 index 0000000..db8030a --- /dev/null +++ b/support/sdbinutils/binutils/doc/cxxfilt.man @@ -0,0 +1,341 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "C++FILT 1" +.TH C++FILT 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +cxxfilt \- Demangle C++ and Java symbols. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +c++filt [\fB\-_\fR|\fB\-\-strip\-underscore\fR] + [\fB\-n\fR|\fB\-\-no\-strip\-underscore\fR] + [\fB\-p\fR|\fB\-\-no\-params\fR] + [\fB\-t\fR|\fB\-\-types\fR] + [\fB\-i\fR|\fB\-\-no\-verbose\fR] + [\fB\-s\fR \fIformat\fR|\fB\-\-format=\fR\fIformat\fR] + [\fB\-\-help\fR] [\fB\-\-version\fR] [\fIsymbol\fR...] +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +The \*(C+ and Java languages provide function overloading, which means +that you can write many functions with the same name, providing that +each function takes parameters of different types. In order to be +able to distinguish these similarly named functions \*(C+ and Java +encode them into a low-level assembler name which uniquely identifies +each different version. This process is known as \fImangling\fR. The +\&\fBc++filt\fR +[1] +program does the inverse mapping: it decodes (\fIdemangles\fR) low-level +names into user-level names so that they can be read. +.PP +Every alphanumeric word (consisting of letters, digits, underscores, +dollars, or periods) seen in the input is a potential mangled name. +If the name decodes into a \*(C+ name, the \*(C+ name replaces the +low-level name in the output, otherwise the original word is output. +In this way you can pass an entire assembler source file, containing +mangled names, through \fBc++filt\fR and see the same source file +containing demangled names. +.PP +You can also use \fBc++filt\fR to decipher individual symbols by +passing them on the command line: +.PP +.Vb 1 +\& c++filt +.Ve +.PP +If no \fIsymbol\fR arguments are given, \fBc++filt\fR reads symbol +names from the standard input instead. All the results are printed on +the standard output. The difference between reading names from the +command line versus reading names from the standard input is that +command line arguments are expected to be just mangled names and no +checking is performed to separate them from surrounding text. Thus +for example: +.PP +.Vb 1 +\& c++filt \-n _Z1fv +.Ve +.PP +will work and demangle the name to \*(L"f()\*(R" whereas: +.PP +.Vb 1 +\& c++filt \-n _Z1fv, +.Ve +.PP +will not work. (Note the extra comma at the end of the mangled +name which makes it invalid). This command however will work: +.PP +.Vb 1 +\& echo _Z1fv, | c++filt \-n +.Ve +.PP +and will display \*(L"f(),\*(R", i.e., the demangled name followed by a +trailing comma. This behaviour is because when the names are read +from the standard input it is expected that they might be part of an +assembler source file where there might be extra, extraneous +characters trailing after a mangled name. For example: +.PP +.Vb 1 +\& .type _Z1fv, @function +.Ve +.SH "OPTIONS" +.IX Header "OPTIONS" +.IP "\fB\-_\fR" 4 +.IX Item "-_" +.PD 0 +.IP "\fB\-\-strip\-underscore\fR" 4 +.IX Item "--strip-underscore" +.PD +On some systems, both the C and \*(C+ compilers put an underscore in front +of every name. For example, the C name \f(CW\*(C`foo\*(C'\fR gets the low-level +name \f(CW\*(C`_foo\*(C'\fR. This option removes the initial underscore. Whether +\&\fBc++filt\fR removes the underscore by default is target dependent. +.IP "\fB\-n\fR" 4 +.IX Item "-n" +.PD 0 +.IP "\fB\-\-no\-strip\-underscore\fR" 4 +.IX Item "--no-strip-underscore" +.PD +Do not remove the initial underscore. +.IP "\fB\-p\fR" 4 +.IX Item "-p" +.PD 0 +.IP "\fB\-\-no\-params\fR" 4 +.IX Item "--no-params" +.PD +When demangling the name of a function, do not display the types of +the function's parameters. +.IP "\fB\-t\fR" 4 +.IX Item "-t" +.PD 0 +.IP "\fB\-\-types\fR" 4 +.IX Item "--types" +.PD +Attempt to demangle types as well as function names. This is disabled +by default since mangled types are normally only used internally in +the compiler, and they can be confused with non-mangled names. For example, +a function called \*(L"a\*(R" treated as a mangled type name would be +demangled to \*(L"signed char\*(R". +.IP "\fB\-i\fR" 4 +.IX Item "-i" +.PD 0 +.IP "\fB\-\-no\-verbose\fR" 4 +.IX Item "--no-verbose" +.PD +Do not include implementation details (if any) in the demangled +output. +.IP "\fB\-s\fR \fIformat\fR" 4 +.IX Item "-s format" +.PD 0 +.IP "\fB\-\-format=\fR\fIformat\fR" 4 +.IX Item "--format=format" +.PD +\&\fBc++filt\fR can decode various methods of mangling, used by +different compilers. The argument to this option selects which +method it uses: +.RS 4 +.ie n .IP """auto""" 4 +.el .IP "\f(CWauto\fR" 4 +.IX Item "auto" +Automatic selection based on executable (the default method) +.ie n .IP """gnu""" 4 +.el .IP "\f(CWgnu\fR" 4 +.IX Item "gnu" +the one used by the \s-1GNU \*(C+\s0 compiler (g++) +.ie n .IP """lucid""" 4 +.el .IP "\f(CWlucid\fR" 4 +.IX Item "lucid" +the one used by the Lucid compiler (lcc) +.ie n .IP """arm""" 4 +.el .IP "\f(CWarm\fR" 4 +.IX Item "arm" +the one specified by the \*(C+ Annotated Reference Manual +.ie n .IP """hp""" 4 +.el .IP "\f(CWhp\fR" 4 +.IX Item "hp" +the one used by the \s-1HP\s0 compiler (aCC) +.ie n .IP """edg""" 4 +.el .IP "\f(CWedg\fR" 4 +.IX Item "edg" +the one used by the \s-1EDG\s0 compiler +.ie n .IP """gnu\-v3""" 4 +.el .IP "\f(CWgnu\-v3\fR" 4 +.IX Item "gnu-v3" +the one used by the \s-1GNU \*(C+\s0 compiler (g++) with the V3 \s-1ABI.\s0 +.ie n .IP """java""" 4 +.el .IP "\f(CWjava\fR" 4 +.IX Item "java" +the one used by the \s-1GNU\s0 Java compiler (gcj) +.ie n .IP """gnat""" 4 +.el .IP "\f(CWgnat\fR" 4 +.IX Item "gnat" +the one used by the \s-1GNU\s0 Ada compiler (\s-1GNAT\s0). +.RE +.RS 4 +.RE +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +Print a summary of the options to \fBc++filt\fR and exit. +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +Print the version number of \fBc++filt\fR and exit. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "FOOTNOTES" +.IX Header "FOOTNOTES" +.IP "1." 4 +MS-DOS does not allow \f(CW\*(C`+\*(C'\fR characters in file names, so on +MS-DOS this program is named \fB\s-1CXXFILT\s0\fR. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/debug.options.texi b/support/sdbinutils/binutils/doc/debug.options.texi new file mode 100644 index 0000000..5794565 --- /dev/null +++ b/support/sdbinutils/binutils/doc/debug.options.texi @@ -0,0 +1,144 @@ +@c This file contains the entry for the -w/--debug-dump (readelf) and +@c -W/--dwarf (objdump) option that is common to both readelf and objdump. + +Displays the contents of the DWARF debug sections in the file, if any +are present. Compressed debug sections are automatically decompressed +(temporarily) before they are displayed. If one or more of the +optional letters or words follows the switch then only those type(s) +of data will be dumped. The letters and words refer to the following +information: + +@c Please Keep This Table Alpha Sorted. +@table @code +@item a +@itemx =abbrev +Displays the contents of the @samp{.debug_abbrev} section. + +@item A +@itemx =addr +Displays the contents of the @samp{.debug_addr} section. + +@item c +@itemx =cu_index +Displays the contents of the @samp{.debug_cu_index} and/or +@samp{.debug_tu_index} sections. + +@item f +@itemx =frames +Display the raw contents of a @samp{.debug_frame} section. + +@item F +@item =frame-interp +Display the interpreted contents of a @samp{.debug_frame} section. + +@item g +@itemx =gdb_index +Displays the contents of the @samp{.gdb_index} and/or +@samp{.debug_names} sections. + +@item i +@itemx =info +Displays the contents of the @samp{.debug_info} section. Note: the +output from this option can also be restricted by the use of the +@option{--dwarf-depth} and @option{--dwarf-start} options. + +@item k +@itemx =links +Displays the contents of the @samp{.gnu_debuglink} and/or +@samp{.gnu_debugaltlink} sections. Also displays the link to a +separate dwarf object file (dwo), if one is specified by the +DW_AT_GNU_dwo_name or DW_AT_dwo_name attributes in the +@samp{.debug_info} section. + +@item K +@itemx =follow-links +Display the contents of any selected debug sections that are found in +a linked, separate debug info file. This can result in multiple +versions of the same debug section being displayed if both the main +file and the separate debug info file contain sections with the same +name. + +In addition, when displaying DWARF attributes, if a form is found that +references the separate debug info file, then the referenced contents +will also be displayed. + +@item l +@itemx =rawline +Displays the contents of the @samp{.debug_line} section in a raw +format. + +@item L +@item =decodedline +Displays the interpreted contents of the @samp{.debug_line} section. + +@item m +@itemx =macro +Displays the contents of the @samp{.debug_macro} and/or +@samp{.debug_macinfo} sections. + +@item o +@itemx =loc +Displays the contents of the @samp{.debug_loc} and/or +@samp{.debug_loclists} sections. + +@item p +@itemx =pubnames +Displays the contents of the @samp{.debug_pubnames} and/or +@samp{.debug_gnu_pubnames} sections. + +@item r +@itemx =aranges +Displays the contents of the @samp{.debug_aranges} section. + +@item R +@itemx =Ranges +Displays the contents of the @samp{.debug_ranges} and/or +@samp{.debug_rnglists} sections. + +@item s +@itemx =str +Displays the contents of the @samp{.debug_str}, @samp{.debug_line_str} +and/or @samp{.debug_str_offsets} sections. + +@item t +@itemx =pubtype +Displays the contents of the @samp{.debug_pubtypes} and/or +@samp{.debug_gnu_pubtypes} sections. + +@item T +@itemx =trace_aranges +Displays the contents of the @samp{.trace_aranges} section. + +@item u +@itemx =trace_abbrev +Displays the contents of the @samp{.trace_abbrev} section. + +@item U +@itemx =trace_info +Displays the contents of the @samp{.trace_info} section. + +@end table + +Note: displaying the contents of @samp{.debug_static_funcs}, +@samp{.debug_static_vars} and @samp{debug_weaknames} sections is not +currently supported. + +@item --dwarf-depth=@var{n} +Limit the dump of the @code{.debug_info} section to @var{n} children. +This is only useful with @option{--debug-dump=info}. The default is +to print all DIEs; the special value 0 for @var{n} will also have this +effect. + +With a non-zero value for @var{n}, DIEs at or deeper than @var{n} +levels will not be printed. The range for @var{n} is zero-based. + +@item --dwarf-start=@var{n} +Print only DIEs beginning with the DIE numbered @var{n}. This is only +useful with @option{--debug-dump=info}. + +If specified, this option will suppress printing of any header +information and all DIEs before the DIE numbered @var{n}. Only +siblings and children of the specified DIE will be printed. + +This can be used in conjunction with @option{--dwarf-depth}. + diff --git a/support/sdbinutils/binutils/doc/dlltool.1 b/support/sdbinutils/binutils/doc/dlltool.1 new file mode 100644 index 0000000..e8fd74b --- /dev/null +++ b/support/sdbinutils/binutils/doc/dlltool.1 @@ -0,0 +1,538 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "DLLTOOL 1" +.TH DLLTOOL 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +dlltool \- Create files needed to build and use DLLs. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +dlltool [\fB\-d\fR|\fB\-\-input\-def\fR \fIdef-file-name\fR] + [\fB\-b\fR|\fB\-\-base\-file\fR \fIbase-file-name\fR] + [\fB\-e\fR|\fB\-\-output\-exp\fR \fIexports-file-name\fR] + [\fB\-z\fR|\fB\-\-output\-def\fR \fIdef-file-name\fR] + [\fB\-l\fR|\fB\-\-output\-lib\fR \fIlibrary-file-name\fR] + [\fB\-y\fR|\fB\-\-output\-delaylib\fR \fIlibrary-file-name\fR] + [\fB\-\-export\-all\-symbols\fR] [\fB\-\-no\-export\-all\-symbols\fR] + [\fB\-\-exclude\-symbols\fR \fIlist\fR] + [\fB\-\-no\-default\-excludes\fR] + [\fB\-S\fR|\fB\-\-as\fR \fIpath-to-assembler\fR] [\fB\-f\fR|\fB\-\-as\-flags\fR \fIoptions\fR] + [\fB\-D\fR|\fB\-\-dllname\fR \fIname\fR] [\fB\-m\fR|\fB\-\-machine\fR \fImachine\fR] + [\fB\-a\fR|\fB\-\-add\-indirect\fR] + [\fB\-U\fR|\fB\-\-add\-underscore\fR] [\fB\-\-add\-stdcall\-underscore\fR] + [\fB\-k\fR|\fB\-\-kill\-at\fR] [\fB\-A\fR|\fB\-\-add\-stdcall\-alias\fR] + [\fB\-p\fR|\fB\-\-ext\-prefix\-alias\fR \fIprefix\fR] + [\fB\-x\fR|\fB\-\-no\-idata4\fR] [\fB\-c\fR|\fB\-\-no\-idata5\fR] + [\fB\-\-use\-nul\-prefixed\-import\-tables\fR] + [\fB\-I\fR|\fB\-\-identify\fR \fIlibrary-file-name\fR] [\fB\-\-identify\-strict\fR] + [\fB\-i\fR|\fB\-\-interwork\fR] + [\fB\-n\fR|\fB\-\-nodelete\fR] [\fB\-t\fR|\fB\-\-temp\-prefix\fR \fIprefix\fR] + [\fB\-v\fR|\fB\-\-verbose\fR] + [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] + [\fB\-\-no\-leading\-underscore\fR] [\fB\-\-leading\-underscore\fR] + [object\-file ...] +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\fBdlltool\fR reads its inputs, which can come from the \fB\-d\fR and +\&\fB\-b\fR options as well as object files specified on the command +line. It then processes these inputs and if the \fB\-e\fR option has +been specified it creates a exports file. If the \fB\-l\fR option +has been specified it creates a library file and if the \fB\-z\fR option +has been specified it creates a def file. Any or all of the \fB\-e\fR, +\&\fB\-l\fR and \fB\-z\fR options can be present in one invocation of +dlltool. +.PP +When creating a \s-1DLL,\s0 along with the source for the \s-1DLL,\s0 it is necessary +to have three other files. \fBdlltool\fR can help with the creation of +these files. +.PP +The first file is a \fI.def\fR file which specifies which functions are +exported from the \s-1DLL,\s0 which functions the \s-1DLL\s0 imports, and so on. This +is a text file and can be created by hand, or \fBdlltool\fR can be used +to create it using the \fB\-z\fR option. In this case \fBdlltool\fR +will scan the object files specified on its command line looking for +those functions which have been specially marked as being exported and +put entries for them in the \fI.def\fR file it creates. +.PP +In order to mark a function as being exported from a \s-1DLL,\s0 it needs to +have an \fB\-export:\fR entry in the \fB.drectve\fR +section of the object file. This can be done in C by using the +\&\fIasm()\fR operator: +.PP +.Vb 2 +\& asm (".section .drectve"); +\& asm (".ascii \e"\-export:my_func\e""); +\& +\& int my_func (void) { ... } +.Ve +.PP +The second file needed for \s-1DLL\s0 creation is an exports file. This file +is linked with the object files that make up the body of the \s-1DLL\s0 and it +handles the interface between the \s-1DLL\s0 and the outside world. This is a +binary file and it can be created by giving the \fB\-e\fR option to +\&\fBdlltool\fR when it is creating or reading in a \fI.def\fR file. +.PP +The third file needed for \s-1DLL\s0 creation is the library file that programs +will link with in order to access the functions in the \s-1DLL\s0 (an `import +library'). This file can be created by giving the \fB\-l\fR option to +dlltool when it is creating or reading in a \fI.def\fR file. +.PP +If the \fB\-y\fR option is specified, dlltool generates a delay-import +library that can be used instead of the normal import library to allow +a program to link to the dll only as soon as an imported function is +called for the first time. The resulting executable will need to be +linked to the static delayimp library containing _\|\fI_delayLoadHelper2()\fR, +which in turn will import LoadLibraryA and GetProcAddress from kernel32. +.PP +\&\fBdlltool\fR builds the library file by hand, but it builds the +exports file by creating temporary files containing assembler statements +and then assembling these. The \fB\-S\fR command line option can be +used to specify the path to the assembler that dlltool will use, +and the \fB\-f\fR option can be used to pass specific flags to that +assembler. The \fB\-n\fR can be used to prevent dlltool from deleting +these temporary assembler files when it is done, and if \fB\-n\fR is +specified twice then this will prevent dlltool from deleting the +temporary object files it used to build the library. +.PP +Here is an example of creating a \s-1DLL\s0 from a source file \fBdll.c\fR and +also creating a program (from an object file called \fBprogram.o\fR) +that uses that \s-1DLL:\s0 +.PP +.Vb 4 +\& gcc \-c dll.c +\& dlltool \-e exports.o \-l dll.lib dll.o +\& gcc dll.o exports.o \-o dll.dll +\& gcc program.o dll.lib \-o program +.Ve +.PP +\&\fBdlltool\fR may also be used to query an existing import library +to determine the name of the \s-1DLL\s0 to which it is associated. See the +description of the \fB\-I\fR or \fB\-\-identify\fR option. +.SH "OPTIONS" +.IX Header "OPTIONS" +The command line options have the following meanings: +.IP "\fB\-d\fR \fIfilename\fR" 4 +.IX Item "-d filename" +.PD 0 +.IP "\fB\-\-input\-def\fR \fIfilename\fR" 4 +.IX Item "--input-def filename" +.PD +Specifies the name of a \fI.def\fR file to be read in and processed. +.IP "\fB\-b\fR \fIfilename\fR" 4 +.IX Item "-b filename" +.PD 0 +.IP "\fB\-\-base\-file\fR \fIfilename\fR" 4 +.IX Item "--base-file filename" +.PD +Specifies the name of a base file to be read in and processed. The +contents of this file will be added to the relocation section in the +exports file generated by dlltool. +.IP "\fB\-e\fR \fIfilename\fR" 4 +.IX Item "-e filename" +.PD 0 +.IP "\fB\-\-output\-exp\fR \fIfilename\fR" 4 +.IX Item "--output-exp filename" +.PD +Specifies the name of the export file to be created by dlltool. +.IP "\fB\-z\fR \fIfilename\fR" 4 +.IX Item "-z filename" +.PD 0 +.IP "\fB\-\-output\-def\fR \fIfilename\fR" 4 +.IX Item "--output-def filename" +.PD +Specifies the name of the \fI.def\fR file to be created by dlltool. +.IP "\fB\-l\fR \fIfilename\fR" 4 +.IX Item "-l filename" +.PD 0 +.IP "\fB\-\-output\-lib\fR \fIfilename\fR" 4 +.IX Item "--output-lib filename" +.PD +Specifies the name of the library file to be created by dlltool. +.IP "\fB\-y\fR \fIfilename\fR" 4 +.IX Item "-y filename" +.PD 0 +.IP "\fB\-\-output\-delaylib\fR \fIfilename\fR" 4 +.IX Item "--output-delaylib filename" +.PD +Specifies the name of the delay-import library file to be created by dlltool. +.IP "\fB\-\-export\-all\-symbols\fR" 4 +.IX Item "--export-all-symbols" +Treat all global and weak defined symbols found in the input object +files as symbols to be exported. There is a small list of symbols which +are not exported by default; see the \fB\-\-no\-default\-excludes\fR +option. You may add to the list of symbols to not export by using the +\&\fB\-\-exclude\-symbols\fR option. +.IP "\fB\-\-no\-export\-all\-symbols\fR" 4 +.IX Item "--no-export-all-symbols" +Only export symbols explicitly listed in an input \fI.def\fR file or in +\&\fB.drectve\fR sections in the input object files. This is the default +behaviour. The \fB.drectve\fR sections are created by \fBdllexport\fR +attributes in the source code. +.IP "\fB\-\-exclude\-symbols\fR \fIlist\fR" 4 +.IX Item "--exclude-symbols list" +Do not export the symbols in \fIlist\fR. This is a list of symbol names +separated by comma or colon characters. The symbol names should not +contain a leading underscore. This is only meaningful when +\&\fB\-\-export\-all\-symbols\fR is used. +.IP "\fB\-\-no\-default\-excludes\fR" 4 +.IX Item "--no-default-excludes" +When \fB\-\-export\-all\-symbols\fR is used, it will by default avoid +exporting certain special symbols. The current list of symbols to avoid +exporting is \fBDllMain@12\fR, \fBDllEntryPoint@0\fR, +\&\fBimpure_ptr\fR. You may use the \fB\-\-no\-default\-excludes\fR option +to go ahead and export these special symbols. This is only meaningful +when \fB\-\-export\-all\-symbols\fR is used. +.IP "\fB\-S\fR \fIpath\fR" 4 +.IX Item "-S path" +.PD 0 +.IP "\fB\-\-as\fR \fIpath\fR" 4 +.IX Item "--as path" +.PD +Specifies the path, including the filename, of the assembler to be used +to create the exports file. +.IP "\fB\-f\fR \fIoptions\fR" 4 +.IX Item "-f options" +.PD 0 +.IP "\fB\-\-as\-flags\fR \fIoptions\fR" 4 +.IX Item "--as-flags options" +.PD +Specifies any specific command line options to be passed to the +assembler when building the exports file. This option will work even if +the \fB\-S\fR option is not used. This option only takes one argument, +and if it occurs more than once on the command line, then later +occurrences will override earlier occurrences. So if it is necessary to +pass multiple options to the assembler they should be enclosed in +double quotes. +.IP "\fB\-D\fR \fIname\fR" 4 +.IX Item "-D name" +.PD 0 +.IP "\fB\-\-dll\-name\fR \fIname\fR" 4 +.IX Item "--dll-name name" +.PD +Specifies the name to be stored in the \fI.def\fR file as the name of +the \s-1DLL\s0 when the \fB\-e\fR option is used. If this option is not +present, then the filename given to the \fB\-e\fR option will be +used as the name of the \s-1DLL.\s0 +.IP "\fB\-m\fR \fImachine\fR" 4 +.IX Item "-m machine" +.PD 0 +.IP "\fB\-machine\fR \fImachine\fR" 4 +.IX Item "-machine machine" +.PD +Specifies the type of machine for which the library file should be +built. \fBdlltool\fR has a built in default type, depending upon how +it was created, but this option can be used to override that. This is +normally only useful when creating DLLs for an \s-1ARM\s0 processor, when the +contents of the \s-1DLL\s0 are actually encode using Thumb instructions. +.IP "\fB\-a\fR" 4 +.IX Item "-a" +.PD 0 +.IP "\fB\-\-add\-indirect\fR" 4 +.IX Item "--add-indirect" +.PD +Specifies that when \fBdlltool\fR is creating the exports file it +should add a section which allows the exported functions to be +referenced without using the import library. Whatever the hell that +means! +.IP "\fB\-U\fR" 4 +.IX Item "-U" +.PD 0 +.IP "\fB\-\-add\-underscore\fR" 4 +.IX Item "--add-underscore" +.PD +Specifies that when \fBdlltool\fR is creating the exports file it +should prepend an underscore to the names of \fIall\fR exported symbols. +.IP "\fB\-\-no\-leading\-underscore\fR" 4 +.IX Item "--no-leading-underscore" +.PD 0 +.IP "\fB\-\-leading\-underscore\fR" 4 +.IX Item "--leading-underscore" +.PD +Specifies whether standard symbol should be forced to be prefixed, or +not. +.IP "\fB\-\-add\-stdcall\-underscore\fR" 4 +.IX Item "--add-stdcall-underscore" +Specifies that when \fBdlltool\fR is creating the exports file it +should prepend an underscore to the names of exported \fIstdcall\fR +functions. Variable names and non-stdcall function names are not modified. +This option is useful when creating GNU-compatible import libs for third +party DLLs that were built with MS-Windows tools. +.IP "\fB\-k\fR" 4 +.IX Item "-k" +.PD 0 +.IP "\fB\-\-kill\-at\fR" 4 +.IX Item "--kill-at" +.PD +Specifies that \fB@\fR suffixes should be omitted from the names +of stdcall functions that will be imported from the \s-1DLL.\s0 This is +useful when creating an import library for a \s-1DLL\s0 which exports stdcall +functions but without the usual \fB@\fR symbol name suffix. +.Sp +This does not change the naming of symbols provided by the import library +to programs linked against it, but only the entries in the import table +(ie the .idata section). +.IP "\fB\-A\fR" 4 +.IX Item "-A" +.PD 0 +.IP "\fB\-\-add\-stdcall\-alias\fR" 4 +.IX Item "--add-stdcall-alias" +.PD +Specifies that when \fBdlltool\fR is creating the exports file it +should add aliases for stdcall symbols without \fB@ \fR +in addition to the symbols with \fB@ \fR. +.IP "\fB\-p\fR" 4 +.IX Item "-p" +.PD 0 +.IP "\fB\-\-ext\-prefix\-alias\fR \fIprefix\fR" 4 +.IX Item "--ext-prefix-alias prefix" +.PD +Causes \fBdlltool\fR to create external aliases for all \s-1DLL\s0 +imports with the specified prefix. The aliases are created for both +external and import symbols with no leading underscore. +.IP "\fB\-x\fR" 4 +.IX Item "-x" +.PD 0 +.IP "\fB\-\-no\-idata4\fR" 4 +.IX Item "--no-idata4" +.PD +Specifies that when \fBdlltool\fR is creating the exports and library +files it should omit the \f(CW\*(C`.idata4\*(C'\fR section. This is for compatibility +with certain operating systems. +.IP "\fB\-\-use\-nul\-prefixed\-import\-tables\fR" 4 +.IX Item "--use-nul-prefixed-import-tables" +Specifies that when \fBdlltool\fR is creating the exports and library +files it should prefix the \f(CW\*(C`.idata4\*(C'\fR and \f(CW\*(C`.idata5\*(C'\fR by zero an +element. This emulates old gnu import library generation of +\&\f(CW\*(C`dlltool\*(C'\fR. By default this option is turned off. +.IP "\fB\-c\fR" 4 +.IX Item "-c" +.PD 0 +.IP "\fB\-\-no\-idata5\fR" 4 +.IX Item "--no-idata5" +.PD +Specifies that when \fBdlltool\fR is creating the exports and library +files it should omit the \f(CW\*(C`.idata5\*(C'\fR section. This is for compatibility +with certain operating systems. +.IP "\fB\-I\fR \fIfilename\fR" 4 +.IX Item "-I filename" +.PD 0 +.IP "\fB\-\-identify\fR \fIfilename\fR" 4 +.IX Item "--identify filename" +.PD +Specifies that \fBdlltool\fR should inspect the import library +indicated by \fIfilename\fR and report, on \f(CW\*(C`stdout\*(C'\fR, the name(s) +of the associated \s-1DLL\s0(s). This can be performed in addition to any +other operations indicated by the other options and arguments. +\&\fBdlltool\fR fails if the import library does not exist or is not +actually an import library. See also \fB\-\-identify\-strict\fR. +.IP "\fB\-\-identify\-strict\fR" 4 +.IX Item "--identify-strict" +Modifies the behavior of the \fB\-\-identify\fR option, such +that an error is reported if \fIfilename\fR is associated with +more than one \s-1DLL.\s0 +.IP "\fB\-i\fR" 4 +.IX Item "-i" +.PD 0 +.IP "\fB\-\-interwork\fR" 4 +.IX Item "--interwork" +.PD +Specifies that \fBdlltool\fR should mark the objects in the library +file and exports file that it produces as supporting interworking +between \s-1ARM\s0 and Thumb code. +.IP "\fB\-n\fR" 4 +.IX Item "-n" +.PD 0 +.IP "\fB\-\-nodelete\fR" 4 +.IX Item "--nodelete" +.PD +Makes \fBdlltool\fR preserve the temporary assembler files it used to +create the exports file. If this option is repeated then dlltool will +also preserve the temporary object files it uses to create the library +file. +.IP "\fB\-t\fR \fIprefix\fR" 4 +.IX Item "-t prefix" +.PD 0 +.IP "\fB\-\-temp\-prefix\fR \fIprefix\fR" 4 +.IX Item "--temp-prefix prefix" +.PD +Makes \fBdlltool\fR use \fIprefix\fR when constructing the names of +temporary assembler and object files. By default, the temp file prefix +is generated from the pid. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +.PD 0 +.IP "\fB\-\-verbose\fR" 4 +.IX Item "--verbose" +.PD +Make dlltool describe what it is doing. +.IP "\fB\-h\fR" 4 +.IX Item "-h" +.PD 0 +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +.PD +Displays a list of command line options and then exits. +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Displays dlltool's version number and then exits. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +The Info pages for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/elfedit.1 b/support/sdbinutils/binutils/doc/elfedit.1 new file mode 100644 index 0000000..f5d8288 --- /dev/null +++ b/support/sdbinutils/binutils/doc/elfedit.1 @@ -0,0 +1,238 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "ELFEDIT 1" +.TH ELFEDIT 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +elfedit \- Update the ELF header of ELF files. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +elfedit [\fB\-\-input\-mach=\fR\fImachine\fR] + [\fB\-\-input\-type=\fR\fItype\fR] + [\fB\-\-input\-osabi=\fR\fIosabi\fR] + \fB\-\-output\-mach=\fR\fImachine\fR + \fB\-\-output\-type=\fR\fItype\fR + \fB\-\-output\-osabi=\fR\fIosabi\fR + [\fB\-v\fR|\fB\-\-version\fR] + [\fB\-h\fR|\fB\-\-help\fR] + \fIelffile\fR... +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\fBelfedit\fR updates the \s-1ELF\s0 header of \s-1ELF\s0 files which have +the matching \s-1ELF\s0 machine and file types. The options control how and +which fields in the \s-1ELF\s0 header should be updated. +.PP +\&\fIelffile\fR... are the \s-1ELF\s0 files to be updated. 32\-bit and +64\-bit \s-1ELF\s0 files are supported, as are archives containing \s-1ELF\s0 files. +.SH "OPTIONS" +.IX Header "OPTIONS" +The long and short forms of options, shown here as alternatives, are +equivalent. At least one of the \fB\-\-output\-mach\fR, +\&\fB\-\-output\-type\fR and \fB\-\-output\-osabi\fR options must be given. +.IP "\fB\-\-input\-mach=\fR\fImachine\fR" 4 +.IX Item "--input-mach=machine" +Set the matching input \s-1ELF\s0 machine type to \fImachine\fR. If +\&\fB\-\-input\-mach\fR isn't specified, it will match any \s-1ELF\s0 +machine types. +.Sp +The supported \s-1ELF\s0 machine types are, \fIi386\fR, \fI\s-1IAMCU\s0\fR, \fIL1OM\fR, +\&\fIK1OM\fR and \fIx86\-64\fR. +.IP "\fB\-\-output\-mach=\fR\fImachine\fR" 4 +.IX Item "--output-mach=machine" +Change the \s-1ELF\s0 machine type in the \s-1ELF\s0 header to \fImachine\fR. The +supported \s-1ELF\s0 machine types are the same as \fB\-\-input\-mach\fR. +.IP "\fB\-\-input\-type=\fR\fItype\fR" 4 +.IX Item "--input-type=type" +Set the matching input \s-1ELF\s0 file type to \fItype\fR. If +\&\fB\-\-input\-type\fR isn't specified, it will match any \s-1ELF\s0 file types. +.Sp +The supported \s-1ELF\s0 file types are, \fIrel\fR, \fIexec\fR and \fIdyn\fR. +.IP "\fB\-\-output\-type=\fR\fItype\fR" 4 +.IX Item "--output-type=type" +Change the \s-1ELF\s0 file type in the \s-1ELF\s0 header to \fItype\fR. The +supported \s-1ELF\s0 types are the same as \fB\-\-input\-type\fR. +.IP "\fB\-\-input\-osabi=\fR\fIosabi\fR" 4 +.IX Item "--input-osabi=osabi" +Set the matching input \s-1ELF\s0 file \s-1OSABI\s0 to \fIosabi\fR. If +\&\fB\-\-input\-osabi\fR isn't specified, it will match any \s-1ELF\s0 OSABIs. +.Sp +The supported \s-1ELF\s0 OSABIs are, \fInone\fR, \fI\s-1HPUX\s0\fR, \fINetBSD\fR, +\&\fI\s-1GNU\s0\fR, \fILinux\fR (alias for \fI\s-1GNU\s0\fR), +\&\fISolaris\fR, \fI\s-1AIX\s0\fR, \fIIrix\fR, +\&\fIFreeBSD\fR, \fI\s-1TRU64\s0\fR, \fIModesto\fR, \fIOpenBSD\fR, \fIOpenVMS\fR, +\&\fI\s-1NSK\s0\fR, \fI\s-1AROS\s0\fR and \fIFenixOS\fR. +.IP "\fB\-\-output\-osabi=\fR\fIosabi\fR" 4 +.IX Item "--output-osabi=osabi" +Change the \s-1ELF OSABI\s0 in the \s-1ELF\s0 header to \fIosabi\fR. The +supported \s-1ELF OSABI\s0 are the same as \fB\-\-input\-osabi\fR. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Display the version number of \fBelfedit\fR. +.IP "\fB\-h\fR" 4 +.IX Item "-h" +.PD 0 +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +.PD +Display the command line options understood by \fBelfedit\fR. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fIreadelf\fR\|(1), and the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/fdl.texi b/support/sdbinutils/binutils/doc/fdl.texi new file mode 100644 index 0000000..8805f1a --- /dev/null +++ b/support/sdbinutils/binutils/doc/fdl.texi @@ -0,0 +1,506 @@ +@c The GNU Free Documentation License. +@center Version 1.3, 3 November 2008 + +@c This file is intended to be included within another document, +@c hence no sectioning command or @node. + +@display +Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. +@uref{http://fsf.org/} + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +@end display + +@enumerate 0 +@item +PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +functional and useful document @dfn{free} in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of ``copyleft'', which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + +@item +APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The ``Document'', below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as ``you''. You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A ``Modified Version'' of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A ``Secondary Section'' is a named appendix or a front-matter section +of the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall +subject (or to related matters) and contains nothing that could fall +directly within that overall subject. (Thus, if the Document is in +part a textbook of mathematics, a Secondary Section may not explain +any mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The ``Invariant Sections'' are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The ``Cover Texts'' are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A ``Transparent'' copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not ``Transparent'' is called ``Opaque''. + +Examples of suitable formats for Transparent copies include plain +@sc{ascii} without markup, Texinfo input format, La@TeX{} input +format, @acronym{SGML} or @acronym{XML} using a publicly available +@acronym{DTD}, and standard-conforming simple @acronym{HTML}, +PostScript or @acronym{PDF} designed for human modification. Examples +of transparent image formats include @acronym{PNG}, @acronym{XCF} and +@acronym{JPG}. Opaque formats include proprietary formats that can be +read and edited only by proprietary word processors, @acronym{SGML} or +@acronym{XML} for which the @acronym{DTD} and/or processing tools are +not generally available, and the machine-generated @acronym{HTML}, +PostScript or @acronym{PDF} produced by some word processors for +output purposes only. + +The ``Title Page'' means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, ``Title Page'' means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +The ``publisher'' means any person or entity that distributes copies +of the Document to the public. + +A section ``Entitled XYZ'' means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as ``Acknowledgements'', +``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title'' +of such a section when you modify the Document means that it remains a +section ``Entitled XYZ'' according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + +@item +VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + +@item +COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + +@item +MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +@enumerate A +@item +Use in the Title Page (and on the covers, if any) a title distinct +from that of the Document, and from those of previous versions +(which should, if there were any, be listed in the History section +of the Document). You may use the same title as a previous version +if the original publisher of that version gives permission. + +@item +List on the Title Page, as authors, one or more persons or entities +responsible for authorship of the modifications in the Modified +Version, together with at least five of the principal authors of the +Document (all of its principal authors, if it has fewer than five), +unless they release you from this requirement. + +@item +State on the Title page the name of the publisher of the +Modified Version, as the publisher. + +@item +Preserve all the copyright notices of the Document. + +@item +Add an appropriate copyright notice for your modifications +adjacent to the other copyright notices. + +@item +Include, immediately after the copyright notices, a license notice +giving the public permission to use the Modified Version under the +terms of this License, in the form shown in the Addendum below. + +@item +Preserve in that license notice the full lists of Invariant Sections +and required Cover Texts given in the Document's license notice. + +@item +Include an unaltered copy of this License. + +@item +Preserve the section Entitled ``History'', Preserve its Title, and add +to it an item stating at least the title, year, new authors, and +publisher of the Modified Version as given on the Title Page. If +there is no section Entitled ``History'' in the Document, create one +stating the title, year, authors, and publisher of the Document as +given on its Title Page, then add an item describing the Modified +Version as stated in the previous sentence. + +@item +Preserve the network location, if any, given in the Document for +public access to a Transparent copy of the Document, and likewise +the network locations given in the Document for previous versions +it was based on. These may be placed in the ``History'' section. +You may omit a network location for a work that was published at +least four years before the Document itself, or if the original +publisher of the version it refers to gives permission. + +@item +For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve +the Title of the section, and preserve in the section all the +substance and tone of each of the contributor acknowledgements and/or +dedications given therein. + +@item +Preserve all the Invariant Sections of the Document, +unaltered in their text and in their titles. Section numbers +or the equivalent are not considered part of the section titles. + +@item +Delete any section Entitled ``Endorsements''. Such a section +may not be included in the Modified Version. + +@item +Do not retitle any existing section to be Entitled ``Endorsements'' or +to conflict in title with any Invariant Section. + +@item +Preserve any Warranty Disclaimers. +@end enumerate + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled ``Endorsements'', provided it contains +nothing but endorsements of your Modified Version by various +parties---for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + +@item +COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled ``History'' +in the various original documents, forming one section Entitled +``History''; likewise combine any sections Entitled ``Acknowledgements'', +and any sections Entitled ``Dedications''. You must delete all +sections Entitled ``Endorsements.'' + +@item +COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + +@item +AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an ``aggregate'' if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + +@item +TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled ``Acknowledgements'', +``Dedications'', or ``History'', the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + +@item +TERMINATION + +You may not copy, modify, sublicense, or distribute the Document +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense, or distribute it is void, and +will automatically terminate your rights under this License. + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, receipt of a copy of some or all of the same material does +not give you any rights to use it. + +@item +FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. See +@uref{http://www.gnu.org/copyleft/}. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License ``or any later version'' applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. If the Document +specifies that a proxy can decide which future versions of this +License can be used, that proxy's public statement of acceptance of a +version permanently authorizes you to choose that version for the +Document. + +@item +RELICENSING + +``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any +World Wide Web server that publishes copyrightable works and also +provides prominent facilities for anybody to edit those works. A +public wiki that anybody can edit is an example of such a server. A +``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the +site means any set of copyrightable works thus published on the MMC +site. + +``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0 +license published by Creative Commons Corporation, a not-for-profit +corporation with a principal place of business in San Francisco, +California, as well as future copyleft versions of that license +published by that same organization. + +``Incorporate'' means to publish or republish a Document, in whole or +in part, as part of another Document. + +An MMC is ``eligible for relicensing'' if it is licensed under this +License, and if all works that were first published under this License +somewhere other than this MMC, and subsequently incorporated in whole +or in part into the MMC, (1) had no cover texts or invariant sections, +and (2) were thus incorporated prior to November 1, 2008. + +The operator of an MMC Site may republish an MMC contained in the site +under CC-BY-SA on the same site at any time before August 1, 2009, +provided the MMC is eligible for relicensing. + +@end enumerate + +@page +@heading ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + +@smallexample +@group + Copyright (C) @var{year} @var{your name}. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU + Free Documentation License''. +@end group +@end smallexample + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the ``with@dots{}Texts.'' line with this: + +@smallexample +@group + with the Invariant Sections being @var{list their titles}, with + the Front-Cover Texts being @var{list}, and with the Back-Cover Texts + being @var{list}. +@end group +@end smallexample + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. + +@c Local Variables: +@c ispell-local-pdict: "ispell-dict" +@c End: + diff --git a/support/sdbinutils/binutils/doc/nlmconv.1 b/support/sdbinutils/binutils/doc/nlmconv.1 new file mode 100644 index 0000000..24007ab --- /dev/null +++ b/support/sdbinutils/binutils/doc/nlmconv.1 @@ -0,0 +1,247 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "NLMCONV 1" +.TH NLMCONV 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +nlmconv \- converts object code into an NLM. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +nlmconv [\fB\-I\fR \fIbfdname\fR|\fB\-\-input\-target=\fR\fIbfdname\fR] + [\fB\-O\fR \fIbfdname\fR|\fB\-\-output\-target=\fR\fIbfdname\fR] + [\fB\-T\fR \fIheaderfile\fR|\fB\-\-header\-file=\fR\fIheaderfile\fR] + [\fB\-d\fR|\fB\-\-debug\fR] [\fB\-l\fR \fIlinker\fR|\fB\-\-linker=\fR\fIlinker\fR] + [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] + \fIinfile\fR \fIoutfile\fR +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\fBnlmconv\fR converts the relocatable \fBi386\fR object file +\&\fIinfile\fR into the NetWare Loadable Module \fIoutfile\fR, optionally +reading \fIheaderfile\fR for \s-1NLM\s0 header information. For instructions +on writing the \s-1NLM\s0 command file language used in header files, see the +\&\fBlinkers\fR section, \fB\s-1NLMLINK\s0\fR in particular, of the \fI\s-1NLM\s0 +Development and Tools Overview\fR, which is part of the \s-1NLM\s0 Software +Developer's Kit (\*(L"\s-1NLM SDK\*(R"\s0), available from Novell, Inc. +\&\fBnlmconv\fR uses the \s-1GNU\s0 Binary File Descriptor library to read +\&\fIinfile\fR; +.PP +\&\fBnlmconv\fR can perform a link step. In other words, you can list +more than one object file for input if you list them in the definitions +file (rather than simply specifying one input file on the command line). +In this case, \fBnlmconv\fR calls the linker for you. +.SH "OPTIONS" +.IX Header "OPTIONS" +.IP "\fB\-I\fR \fIbfdname\fR" 4 +.IX Item "-I bfdname" +.PD 0 +.IP "\fB\-\-input\-target=\fR\fIbfdname\fR" 4 +.IX Item "--input-target=bfdname" +.PD +Object format of the input file. \fBnlmconv\fR can usually determine +the format of a given file (so no default is necessary). +.IP "\fB\-O\fR \fIbfdname\fR" 4 +.IX Item "-O bfdname" +.PD 0 +.IP "\fB\-\-output\-target=\fR\fIbfdname\fR" 4 +.IX Item "--output-target=bfdname" +.PD +Object format of the output file. \fBnlmconv\fR infers the output +format based on the input format, e.g. for a \fBi386\fR input file the +output format is \fBnlm32\-i386\fR. +.IP "\fB\-T\fR \fIheaderfile\fR" 4 +.IX Item "-T headerfile" +.PD 0 +.IP "\fB\-\-header\-file=\fR\fIheaderfile\fR" 4 +.IX Item "--header-file=headerfile" +.PD +Reads \fIheaderfile\fR for \s-1NLM\s0 header information. For instructions on +writing the \s-1NLM\s0 command file language used in header files, see see the +\&\fBlinkers\fR section, of the \fI\s-1NLM\s0 Development and Tools +Overview\fR, which is part of the \s-1NLM\s0 Software Developer's Kit, available +from Novell, Inc. +.IP "\fB\-d\fR" 4 +.IX Item "-d" +.PD 0 +.IP "\fB\-\-debug\fR" 4 +.IX Item "--debug" +.PD +Displays (on standard error) the linker command line used by \fBnlmconv\fR. +.IP "\fB\-l\fR \fIlinker\fR" 4 +.IX Item "-l linker" +.PD 0 +.IP "\fB\-\-linker=\fR\fIlinker\fR" 4 +.IX Item "--linker=linker" +.PD +Use \fIlinker\fR for any linking. \fIlinker\fR can be an absolute or a +relative pathname. +.IP "\fB\-h\fR" 4 +.IX Item "-h" +.PD 0 +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +.PD +Prints a usage summary. +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Prints the version number for \fBnlmconv\fR. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/nm.1 b/support/sdbinutils/binutils/doc/nm.1 new file mode 100644 index 0000000..38fb5c9 --- /dev/null +++ b/support/sdbinutils/binutils/doc/nm.1 @@ -0,0 +1,568 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "NM 1" +.TH NM 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +nm \- list symbols from object files +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +nm [\fB\-A\fR|\fB\-o\fR|\fB\-\-print\-file\-name\fR] [\fB\-a\fR|\fB\-\-debug\-syms\fR] + [\fB\-B\fR|\fB\-\-format=bsd\fR] [\fB\-C\fR|\fB\-\-demangle\fR[=\fIstyle\fR]] + [\fB\-D\fR|\fB\-\-dynamic\fR] [\fB\-f\fR\fIformat\fR|\fB\-\-format=\fR\fIformat\fR] + [\fB\-g\fR|\fB\-\-extern\-only\fR] [\fB\-h\fR|\fB\-\-help\fR] + [\fB\-l\fR|\fB\-\-line\-numbers\fR] [\fB\-\-inlines\fR] + [\fB\-n\fR|\fB\-v\fR|\fB\-\-numeric\-sort\fR] + [\fB\-P\fR|\fB\-\-portability\fR] [\fB\-p\fR|\fB\-\-no\-sort\fR] + [\fB\-r\fR|\fB\-\-reverse\-sort\fR] [\fB\-S\fR|\fB\-\-print\-size\fR] + [\fB\-s\fR|\fB\-\-print\-armap\fR] [\fB\-t\fR \fIradix\fR|\fB\-\-radix=\fR\fIradix\fR] + [\fB\-u\fR|\fB\-\-undefined\-only\fR] [\fB\-V\fR|\fB\-\-version\fR] + [\fB\-X 32_64\fR] [\fB\-\-defined\-only\fR] [\fB\-\-no\-demangle\fR] + [\fB\-\-plugin\fR \fIname\fR] [\fB\-\-size\-sort\fR] [\fB\-\-special\-syms\fR] + [\fB\-\-synthetic\fR] [\fB\-\-with\-symbol\-versions\fR] [\fB\-\-target=\fR\fIbfdname\fR] + [\fIobjfile\fR...] +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\s-1GNU\s0 \fBnm\fR lists the symbols from object files \fIobjfile\fR.... +If no object files are listed as arguments, \fBnm\fR assumes the file +\&\fIa.out\fR. +.PP +For each symbol, \fBnm\fR shows: +.IP "\(bu" 4 +The symbol value, in the radix selected by options (see below), or +hexadecimal by default. +.IP "\(bu" 4 +The symbol type. At least the following types are used; others are, as +well, depending on the object file format. If lowercase, the symbol is +usually local; if uppercase, the symbol is global (external). There +are however a few lowercase symbols that are shown for special global +symbols (\f(CW\*(C`u\*(C'\fR, \f(CW\*(C`v\*(C'\fR and \f(CW\*(C`w\*(C'\fR). +.RS 4 +.ie n .IP """A""" 4 +.el .IP "\f(CWA\fR" 4 +.IX Item "A" +The symbol's value is absolute, and will not be changed by further +linking. +.ie n .IP """B""" 4 +.el .IP "\f(CWB\fR" 4 +.IX Item "B" +.PD 0 +.ie n .IP """b""" 4 +.el .IP "\f(CWb\fR" 4 +.IX Item "b" +.PD +The symbol is in the uninitialized data section (known as \s-1BSS\s0). +.ie n .IP """C""" 4 +.el .IP "\f(CWC\fR" 4 +.IX Item "C" +The symbol is common. Common symbols are uninitialized data. When +linking, multiple common symbols may appear with the same name. If the +symbol is defined anywhere, the common symbols are treated as undefined +references. +.ie n .IP """D""" 4 +.el .IP "\f(CWD\fR" 4 +.IX Item "D" +.PD 0 +.ie n .IP """d""" 4 +.el .IP "\f(CWd\fR" 4 +.IX Item "d" +.PD +The symbol is in the initialized data section. +.ie n .IP """G""" 4 +.el .IP "\f(CWG\fR" 4 +.IX Item "G" +.PD 0 +.ie n .IP """g""" 4 +.el .IP "\f(CWg\fR" 4 +.IX Item "g" +.PD +The symbol is in an initialized data section for small objects. Some +object file formats permit more efficient access to small data objects, +such as a global int variable as opposed to a large global array. +.ie n .IP """i""" 4 +.el .IP "\f(CWi\fR" 4 +.IX Item "i" +For \s-1PE\s0 format files this indicates that the symbol is in a section +specific to the implementation of DLLs. For \s-1ELF\s0 format files this +indicates that the symbol is an indirect function. This is a \s-1GNU\s0 +extension to the standard set of \s-1ELF\s0 symbol types. It indicates a +symbol which if referenced by a relocation does not evaluate to its +address, but instead must be invoked at runtime. The runtime +execution will then return the value to be used in the relocation. +.ie n .IP """I""" 4 +.el .IP "\f(CWI\fR" 4 +.IX Item "I" +The symbol is an indirect reference to another symbol. +.ie n .IP """N""" 4 +.el .IP "\f(CWN\fR" 4 +.IX Item "N" +The symbol is a debugging symbol. +.ie n .IP """p""" 4 +.el .IP "\f(CWp\fR" 4 +.IX Item "p" +The symbols is in a stack unwind section. +.ie n .IP """R""" 4 +.el .IP "\f(CWR\fR" 4 +.IX Item "R" +.PD 0 +.ie n .IP """r""" 4 +.el .IP "\f(CWr\fR" 4 +.IX Item "r" +.PD +The symbol is in a read only data section. +.ie n .IP """S""" 4 +.el .IP "\f(CWS\fR" 4 +.IX Item "S" +.PD 0 +.ie n .IP """s""" 4 +.el .IP "\f(CWs\fR" 4 +.IX Item "s" +.PD +The symbol is in an uninitialized data section for small objects. +.ie n .IP """T""" 4 +.el .IP "\f(CWT\fR" 4 +.IX Item "T" +.PD 0 +.ie n .IP """t""" 4 +.el .IP "\f(CWt\fR" 4 +.IX Item "t" +.PD +The symbol is in the text (code) section. +.ie n .IP """U""" 4 +.el .IP "\f(CWU\fR" 4 +.IX Item "U" +The symbol is undefined. +.ie n .IP """u""" 4 +.el .IP "\f(CWu\fR" 4 +.IX Item "u" +The symbol is a unique global symbol. This is a \s-1GNU\s0 extension to the +standard set of \s-1ELF\s0 symbol bindings. For such a symbol the dynamic linker +will make sure that in the entire process there is just one symbol with +this name and type in use. +.ie n .IP """V""" 4 +.el .IP "\f(CWV\fR" 4 +.IX Item "V" +.PD 0 +.ie n .IP """v""" 4 +.el .IP "\f(CWv\fR" 4 +.IX Item "v" +.PD +The symbol is a weak object. When a weak defined symbol is linked with +a normal defined symbol, the normal defined symbol is used with no error. +When a weak undefined symbol is linked and the symbol is not defined, +the value of the weak symbol becomes zero with no error. On some +systems, uppercase indicates that a default value has been specified. +.ie n .IP """W""" 4 +.el .IP "\f(CWW\fR" 4 +.IX Item "W" +.PD 0 +.ie n .IP """w""" 4 +.el .IP "\f(CWw\fR" 4 +.IX Item "w" +.PD +The symbol is a weak symbol that has not been specifically tagged as a +weak object symbol. When a weak defined symbol is linked with a normal +defined symbol, the normal defined symbol is used with no error. +When a weak undefined symbol is linked and the symbol is not defined, +the value of the symbol is determined in a system-specific manner without +error. On some systems, uppercase indicates that a default value has been +specified. +.ie n .IP """\-""" 4 +.el .IP "\f(CW\-\fR" 4 +.IX Item "-" +The symbol is a stabs symbol in an a.out object file. In this case, the +next values printed are the stabs other field, the stabs desc field, and +the stab type. Stabs symbols are used to hold debugging information. +.ie n .IP """?""" 4 +.el .IP "\f(CW?\fR" 4 +.IX Item "?" +The symbol type is unknown, or object file format specific. +.RE +.RS 4 +.RE +.IP "\(bu" 4 +The symbol name. +.SH "OPTIONS" +.IX Header "OPTIONS" +The long and short forms of options, shown here as alternatives, are +equivalent. +.IP "\fB\-A\fR" 4 +.IX Item "-A" +.PD 0 +.IP "\fB\-o\fR" 4 +.IX Item "-o" +.IP "\fB\-\-print\-file\-name\fR" 4 +.IX Item "--print-file-name" +.PD +Precede each symbol by the name of the input file (or archive member) +in which it was found, rather than identifying the input file once only, +before all of its symbols. +.IP "\fB\-a\fR" 4 +.IX Item "-a" +.PD 0 +.IP "\fB\-\-debug\-syms\fR" 4 +.IX Item "--debug-syms" +.PD +Display all symbols, even debugger-only symbols; normally these are not +listed. +.IP "\fB\-B\fR" 4 +.IX Item "-B" +The same as \fB\-\-format=bsd\fR (for compatibility with the \s-1MIPS\s0 \fBnm\fR). +.IP "\fB\-C\fR" 4 +.IX Item "-C" +.PD 0 +.IP "\fB\-\-demangle[=\fR\fIstyle\fR\fB]\fR" 4 +.IX Item "--demangle[=style]" +.PD +Decode (\fIdemangle\fR) low-level symbol names into user-level names. +Besides removing any initial underscore prepended by the system, this +makes \*(C+ function names readable. Different compilers have different +mangling styles. The optional demangling style argument can be used to +choose an appropriate demangling style for your compiler. +.IP "\fB\-\-no\-demangle\fR" 4 +.IX Item "--no-demangle" +Do not demangle low-level symbol names. This is the default. +.IP "\fB\-D\fR" 4 +.IX Item "-D" +.PD 0 +.IP "\fB\-\-dynamic\fR" 4 +.IX Item "--dynamic" +.PD +Display the dynamic symbols rather than the normal symbols. This is +only meaningful for dynamic objects, such as certain types of shared +libraries. +.IP "\fB\-f\fR \fIformat\fR" 4 +.IX Item "-f format" +.PD 0 +.IP "\fB\-\-format=\fR\fIformat\fR" 4 +.IX Item "--format=format" +.PD +Use the output format \fIformat\fR, which can be \f(CW\*(C`bsd\*(C'\fR, +\&\f(CW\*(C`sysv\*(C'\fR, or \f(CW\*(C`posix\*(C'\fR. The default is \f(CW\*(C`bsd\*(C'\fR. +Only the first character of \fIformat\fR is significant; it can be +either upper or lower case. +.IP "\fB\-g\fR" 4 +.IX Item "-g" +.PD 0 +.IP "\fB\-\-extern\-only\fR" 4 +.IX Item "--extern-only" +.PD +Display only external symbols. +.IP "\fB\-h\fR" 4 +.IX Item "-h" +.PD 0 +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +.PD +Show a summary of the options to \fBnm\fR and exit. +.IP "\fB\-l\fR" 4 +.IX Item "-l" +.PD 0 +.IP "\fB\-\-line\-numbers\fR" 4 +.IX Item "--line-numbers" +.PD +For each symbol, use debugging information to try to find a filename and +line number. For a defined symbol, look for the line number of the +address of the symbol. For an undefined symbol, look for the line +number of a relocation entry which refers to the symbol. If line number +information can be found, print it after the other symbol information. +.IP "\fB\-\-inlines\fR" 4 +.IX Item "--inlines" +When option \fB\-l\fR is active, if the address belongs to a +function that was inlined, then this option causes the source +information for all enclosing scopes back to the first non-inlined +function to be printed as well. For example, if \f(CW\*(C`main\*(C'\fR inlines +\&\f(CW\*(C`callee1\*(C'\fR which inlines \f(CW\*(C`callee2\*(C'\fR, and address is from +\&\f(CW\*(C`callee2\*(C'\fR, the source information for \f(CW\*(C`callee1\*(C'\fR and \f(CW\*(C`main\*(C'\fR +will also be printed. +.IP "\fB\-n\fR" 4 +.IX Item "-n" +.PD 0 +.IP "\fB\-v\fR" 4 +.IX Item "-v" +.IP "\fB\-\-numeric\-sort\fR" 4 +.IX Item "--numeric-sort" +.PD +Sort symbols numerically by their addresses, rather than alphabetically +by their names. +.IP "\fB\-p\fR" 4 +.IX Item "-p" +.PD 0 +.IP "\fB\-\-no\-sort\fR" 4 +.IX Item "--no-sort" +.PD +Do not bother to sort the symbols in any order; print them in the order +encountered. +.IP "\fB\-P\fR" 4 +.IX Item "-P" +.PD 0 +.IP "\fB\-\-portability\fR" 4 +.IX Item "--portability" +.PD +Use the \s-1POSIX.2\s0 standard output format instead of the default format. +Equivalent to \fB\-f posix\fR. +.IP "\fB\-r\fR" 4 +.IX Item "-r" +.PD 0 +.IP "\fB\-\-reverse\-sort\fR" 4 +.IX Item "--reverse-sort" +.PD +Reverse the order of the sort (whether numeric or alphabetic); let the +last come first. +.IP "\fB\-S\fR" 4 +.IX Item "-S" +.PD 0 +.IP "\fB\-\-print\-size\fR" 4 +.IX Item "--print-size" +.PD +Print both value and size of defined symbols for the \f(CW\*(C`bsd\*(C'\fR output style. +This option has no effect for object formats that do not record symbol +sizes, unless \fB\-\-size\-sort\fR is also used in which case a +calculated size is displayed. +.IP "\fB\-s\fR" 4 +.IX Item "-s" +.PD 0 +.IP "\fB\-\-print\-armap\fR" 4 +.IX Item "--print-armap" +.PD +When listing symbols from archive members, include the index: a mapping +(stored in the archive by \fBar\fR or \fBranlib\fR) of which modules +contain definitions for which names. +.IP "\fB\-t\fR \fIradix\fR" 4 +.IX Item "-t radix" +.PD 0 +.IP "\fB\-\-radix=\fR\fIradix\fR" 4 +.IX Item "--radix=radix" +.PD +Use \fIradix\fR as the radix for printing the symbol values. It must be +\&\fBd\fR for decimal, \fBo\fR for octal, or \fBx\fR for hexadecimal. +.IP "\fB\-u\fR" 4 +.IX Item "-u" +.PD 0 +.IP "\fB\-\-undefined\-only\fR" 4 +.IX Item "--undefined-only" +.PD +Display only undefined symbols (those external to each object file). +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Show the version number of \fBnm\fR and exit. +.IP "\fB\-X\fR" 4 +.IX Item "-X" +This option is ignored for compatibility with the \s-1AIX\s0 version of +\&\fBnm\fR. It takes one parameter which must be the string +\&\fB32_64\fR. The default mode of \s-1AIX\s0 \fBnm\fR corresponds +to \fB\-X 32\fR, which is not supported by \s-1GNU\s0 \fBnm\fR. +.IP "\fB\-\-defined\-only\fR" 4 +.IX Item "--defined-only" +Display only defined symbols for each object file. +.IP "\fB\-\-plugin\fR \fIname\fR" 4 +.IX Item "--plugin name" +Load the plugin called \fIname\fR to add support for extra target +types. This option is only available if the toolchain has been built +with plugin support enabled. +.Sp +If \fB\-\-plugin\fR is not provided, but plugin support has been +enabled then \fBnm\fR iterates over the files in +\&\fI${libdir}/bfd\-plugins\fR in alphabetic order and the first +plugin that claims the object in question is used. +.Sp +Please note that this plugin search directory is \fInot\fR the one +used by \fBld\fR's \fB\-plugin\fR option. In order to make +\&\fBnm\fR use the linker plugin it must be copied into the +\&\fI${libdir}/bfd\-plugins\fR directory. For \s-1GCC\s0 based compilations +the linker plugin is called \fIliblto_plugin.so.0.0.0\fR. For Clang +based compilations it is called \fILLVMgold.so\fR. The \s-1GCC\s0 plugin +is always backwards compatible with earlier versions, so it is +sufficient to just copy the newest one. +.IP "\fB\-\-size\-sort\fR" 4 +.IX Item "--size-sort" +Sort symbols by size. For \s-1ELF\s0 objects symbol sizes are read from the +\&\s-1ELF,\s0 for other object types the symbol sizes are computed as the +difference between the value of the symbol and the value of the symbol +with the next higher value. If the \f(CW\*(C`bsd\*(C'\fR output format is used +the size of the symbol is printed, rather than the value, and +\&\fB\-S\fR must be used in order both size and value to be printed. +.IP "\fB\-\-special\-syms\fR" 4 +.IX Item "--special-syms" +Display symbols which have a target-specific special meaning. These +symbols are usually used by the target for some special processing and +are not normally helpful when included in the normal symbol lists. +For example for \s-1ARM\s0 targets this option would skip the mapping symbols +used to mark transitions between \s-1ARM\s0 code, \s-1THUMB\s0 code and data. +.IP "\fB\-\-synthetic\fR" 4 +.IX Item "--synthetic" +Include synthetic symbols in the output. These are special symbols +created by the linker for various purposes. They are not shown by +default since they are not part of the binary's original source code. +.IP "\fB\-\-with\-symbol\-versions\fR" 4 +.IX Item "--with-symbol-versions" +Enables the display of symbol version information if any exists. The +version string is displayed as a suffix to the symbol name, preceeded by +an @ character. For example \fBfoo@VER_1\fR. If the version is +the default version to be used when resolving unversioned references +to the symbol then it is displayed as a suffix preceeded by two @ +characters. For example \fBfoo@@VER_2\fR. +.IP "\fB\-\-target=\fR\fIbfdname\fR" 4 +.IX Item "--target=bfdname" +Specify an object code format other than your system's default format. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fIar\fR\|(1), \fIobjdump\fR\|(1), \fIranlib\fR\|(1), and the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/objcopy.1 b/support/sdbinutils/binutils/doc/objcopy.1 new file mode 100644 index 0000000..5fc914f --- /dev/null +++ b/support/sdbinutils/binutils/doc/objcopy.1 @@ -0,0 +1,1203 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "OBJCOPY 1" +.TH OBJCOPY 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +objcopy \- copy and translate object files +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +objcopy [\fB\-F\fR \fIbfdname\fR|\fB\-\-target=\fR\fIbfdname\fR] + [\fB\-I\fR \fIbfdname\fR|\fB\-\-input\-target=\fR\fIbfdname\fR] + [\fB\-O\fR \fIbfdname\fR|\fB\-\-output\-target=\fR\fIbfdname\fR] + [\fB\-B\fR \fIbfdarch\fR|\fB\-\-binary\-architecture=\fR\fIbfdarch\fR] + [\fB\-S\fR|\fB\-\-strip\-all\fR] + [\fB\-g\fR|\fB\-\-strip\-debug\fR] + [\fB\-\-strip\-unneeded\fR] + [\fB\-K\fR \fIsymbolname\fR|\fB\-\-keep\-symbol=\fR\fIsymbolname\fR] + [\fB\-N\fR \fIsymbolname\fR|\fB\-\-strip\-symbol=\fR\fIsymbolname\fR] + [\fB\-\-strip\-unneeded\-symbol=\fR\fIsymbolname\fR] + [\fB\-G\fR \fIsymbolname\fR|\fB\-\-keep\-global\-symbol=\fR\fIsymbolname\fR] + [\fB\-\-localize\-hidden\fR] + [\fB\-L\fR \fIsymbolname\fR|\fB\-\-localize\-symbol=\fR\fIsymbolname\fR] + [\fB\-\-globalize\-symbol=\fR\fIsymbolname\fR] + [\fB\-W\fR \fIsymbolname\fR|\fB\-\-weaken\-symbol=\fR\fIsymbolname\fR] + [\fB\-w\fR|\fB\-\-wildcard\fR] + [\fB\-x\fR|\fB\-\-discard\-all\fR] + [\fB\-X\fR|\fB\-\-discard\-locals\fR] + [\fB\-b\fR \fIbyte\fR|\fB\-\-byte=\fR\fIbyte\fR] + [\fB\-i\fR [\fIbreadth\fR]|\fB\-\-interleave\fR[=\fIbreadth\fR]] + [\fB\-\-interleave\-width=\fR\fIwidth\fR] + [\fB\-j\fR \fIsectionpattern\fR|\fB\-\-only\-section=\fR\fIsectionpattern\fR] + [\fB\-R\fR \fIsectionpattern\fR|\fB\-\-remove\-section=\fR\fIsectionpattern\fR] + [\fB\-\-remove\-relocations=\fR\fIsectionpattern\fR] + [\fB\-p\fR|\fB\-\-preserve\-dates\fR] + [\fB\-D\fR|\fB\-\-enable\-deterministic\-archives\fR] + [\fB\-U\fR|\fB\-\-disable\-deterministic\-archives\fR] + [\fB\-\-debugging\fR] + [\fB\-\-gap\-fill=\fR\fIval\fR] + [\fB\-\-pad\-to=\fR\fIaddress\fR] + [\fB\-\-set\-start=\fR\fIval\fR] + [\fB\-\-adjust\-start=\fR\fIincr\fR] + [\fB\-\-change\-addresses=\fR\fIincr\fR] + [\fB\-\-change\-section\-address\fR \fIsectionpattern\fR{=,+,\-}\fIval\fR] + [\fB\-\-change\-section\-lma\fR \fIsectionpattern\fR{=,+,\-}\fIval\fR] + [\fB\-\-change\-section\-vma\fR \fIsectionpattern\fR{=,+,\-}\fIval\fR] + [\fB\-\-change\-warnings\fR] [\fB\-\-no\-change\-warnings\fR] + [\fB\-\-set\-section\-flags\fR \fIsectionpattern\fR=\fIflags\fR] + [\fB\-\-add\-section\fR \fIsectionname\fR=\fIfilename\fR] + [\fB\-\-dump\-section\fR \fIsectionname\fR=\fIfilename\fR] + [\fB\-\-update\-section\fR \fIsectionname\fR=\fIfilename\fR] + [\fB\-\-rename\-section\fR \fIoldname\fR=\fInewname\fR[,\fIflags\fR]] + [\fB\-\-long\-section\-names\fR {enable,disable,keep}] + [\fB\-\-change\-leading\-char\fR] [\fB\-\-remove\-leading\-char\fR] + [\fB\-\-reverse\-bytes=\fR\fInum\fR] + [\fB\-\-srec\-len=\fR\fIival\fR] [\fB\-\-srec\-forceS3\fR] + [\fB\-\-redefine\-sym\fR \fIold\fR=\fInew\fR] + [\fB\-\-redefine\-syms=\fR\fIfilename\fR] + [\fB\-\-weaken\fR] + [\fB\-\-keep\-symbols=\fR\fIfilename\fR] + [\fB\-\-strip\-symbols=\fR\fIfilename\fR] + [\fB\-\-strip\-unneeded\-symbols=\fR\fIfilename\fR] + [\fB\-\-keep\-global\-symbols=\fR\fIfilename\fR] + [\fB\-\-localize\-symbols=\fR\fIfilename\fR] + [\fB\-\-globalize\-symbols=\fR\fIfilename\fR] + [\fB\-\-weaken\-symbols=\fR\fIfilename\fR] + [\fB\-\-add\-symbol\fR \fIname\fR=[\fIsection\fR:]\fIvalue\fR[,\fIflags\fR] + [\fB\-\-alt\-machine\-code=\fR\fIindex\fR] + [\fB\-\-prefix\-symbols=\fR\fIstring\fR] + [\fB\-\-prefix\-sections=\fR\fIstring\fR] + [\fB\-\-prefix\-alloc\-sections=\fR\fIstring\fR] + [\fB\-\-add\-gnu\-debuglink=\fR\fIpath-to-file\fR] + [\fB\-\-keep\-file\-symbols\fR] + [\fB\-\-only\-keep\-debug\fR] + [\fB\-\-strip\-dwo\fR] + [\fB\-\-extract\-dwo\fR] + [\fB\-\-extract\-symbol\fR] + [\fB\-\-writable\-text\fR] + [\fB\-\-readonly\-text\fR] + [\fB\-\-pure\fR] + [\fB\-\-impure\fR] + [\fB\-\-file\-alignment=\fR\fInum\fR] + [\fB\-\-heap=\fR\fIsize\fR] + [\fB\-\-image\-base=\fR\fIaddress\fR] + [\fB\-\-section\-alignment=\fR\fInum\fR] + [\fB\-\-stack=\fR\fIsize\fR] + [\fB\-\-subsystem=\fR\fIwhich\fR:\fImajor\fR.\fIminor\fR] + [\fB\-\-compress\-debug\-sections\fR] + [\fB\-\-decompress\-debug\-sections\fR] + [\fB\-\-elf\-stt\-common=\fR\fIval\fR] + [\fB\-\-merge\-notes\fR] + [\fB\-\-no\-merge\-notes\fR] + [\fB\-v\fR|\fB\-\-verbose\fR] + [\fB\-V\fR|\fB\-\-version\fR] + [\fB\-\-help\fR] [\fB\-\-info\fR] + \fIinfile\fR [\fIoutfile\fR] +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +The \s-1GNU\s0 \fBobjcopy\fR utility copies the contents of an object +file to another. \fBobjcopy\fR uses the \s-1GNU BFD\s0 Library to +read and write the object files. It can write the destination object +file in a format different from that of the source object file. The +exact behavior of \fBobjcopy\fR is controlled by command-line options. +Note that \fBobjcopy\fR should be able to copy a fully linked file +between any two formats. However, copying a relocatable object file +between any two formats may not work as expected. +.PP +\&\fBobjcopy\fR creates temporary files to do its translations and +deletes them afterward. \fBobjcopy\fR uses \s-1BFD\s0 to do all its +translation work; it has access to all the formats described in \s-1BFD\s0 +and thus is able to recognize most formats without being told +explicitly. +.PP +\&\fBobjcopy\fR can be used to generate S\-records by using an output +target of \fBsrec\fR (e.g., use \fB\-O srec\fR). +.PP +\&\fBobjcopy\fR can be used to generate a raw binary file by using an +output target of \fBbinary\fR (e.g., use \fB\-O binary\fR). When +\&\fBobjcopy\fR generates a raw binary file, it will essentially produce +a memory dump of the contents of the input object file. All symbols and +relocation information will be discarded. The memory dump will start at +the load address of the lowest section copied into the output file. +.PP +When generating an S\-record or a raw binary file, it may be helpful to +use \fB\-S\fR to remove sections containing debugging information. In +some cases \fB\-R\fR will be useful to remove sections which contain +information that is not needed by the binary file. +.PP +Note\-\-\-\fBobjcopy\fR is not able to change the endianness of its input +files. If the input format has an endianness (some formats do not), +\&\fBobjcopy\fR can only copy the inputs into file formats that have the +same endianness or which have no endianness (e.g., \fBsrec\fR). +(However, see the \fB\-\-reverse\-bytes\fR option.) +.SH "OPTIONS" +.IX Header "OPTIONS" +.IP "\fIinfile\fR" 4 +.IX Item "infile" +.PD 0 +.IP "\fIoutfile\fR" 4 +.IX Item "outfile" +.PD +The input and output files, respectively. +If you do not specify \fIoutfile\fR, \fBobjcopy\fR creates a +temporary file and destructively renames the result with +the name of \fIinfile\fR. +.IP "\fB\-I\fR \fIbfdname\fR" 4 +.IX Item "-I bfdname" +.PD 0 +.IP "\fB\-\-input\-target=\fR\fIbfdname\fR" 4 +.IX Item "--input-target=bfdname" +.PD +Consider the source file's object format to be \fIbfdname\fR, rather than +attempting to deduce it. +.IP "\fB\-O\fR \fIbfdname\fR" 4 +.IX Item "-O bfdname" +.PD 0 +.IP "\fB\-\-output\-target=\fR\fIbfdname\fR" 4 +.IX Item "--output-target=bfdname" +.PD +Write the output file using the object format \fIbfdname\fR. +.IP "\fB\-F\fR \fIbfdname\fR" 4 +.IX Item "-F bfdname" +.PD 0 +.IP "\fB\-\-target=\fR\fIbfdname\fR" 4 +.IX Item "--target=bfdname" +.PD +Use \fIbfdname\fR as the object format for both the input and the output +file; i.e., simply transfer data from source to destination with no +translation. +.IP "\fB\-B\fR \fIbfdarch\fR" 4 +.IX Item "-B bfdarch" +.PD 0 +.IP "\fB\-\-binary\-architecture=\fR\fIbfdarch\fR" 4 +.IX Item "--binary-architecture=bfdarch" +.PD +Useful when transforming a architecture-less input file into an object file. +In this case the output architecture can be set to \fIbfdarch\fR. This +option will be ignored if the input file has a known \fIbfdarch\fR. You +can access this binary data inside a program by referencing the special +symbols that are created by the conversion process. These symbols are +called _binary_\fIobjfile\fR_start, _binary_\fIobjfile\fR_end and +_binary_\fIobjfile\fR_size. e.g. you can transform a picture file into +an object file and then access it in your code using these symbols. +.IP "\fB\-j\fR \fIsectionpattern\fR" 4 +.IX Item "-j sectionpattern" +.PD 0 +.IP "\fB\-\-only\-section=\fR\fIsectionpattern\fR" 4 +.IX Item "--only-section=sectionpattern" +.PD +Copy only the indicated sections from the input file to the output file. +This option may be given more than once. Note that using this option +inappropriately may make the output file unusable. Wildcard +characters are accepted in \fIsectionpattern\fR. +.Sp +If the first character of \fIsectionpattern\fR is the exclamation +point (!) then matching sections will not be copied, even if earlier +use of \fB\-\-only\-section\fR on the same command line would +otherwise copy it. For example: +.Sp +.Vb 1 +\& \-\-only\-section=.text.* \-\-only\-section=!.text.foo +.Ve +.Sp +will copy all sectinos maching '.text.*' but not the section +\&'.text.foo'. +.IP "\fB\-R\fR \fIsectionpattern\fR" 4 +.IX Item "-R sectionpattern" +.PD 0 +.IP "\fB\-\-remove\-section=\fR\fIsectionpattern\fR" 4 +.IX Item "--remove-section=sectionpattern" +.PD +Remove any section matching \fIsectionpattern\fR from the output file. +This option may be given more than once. Note that using this option +inappropriately may make the output file unusable. Wildcard +characters are accepted in \fIsectionpattern\fR. Using both the +\&\fB\-j\fR and \fB\-R\fR options together results in undefined +behaviour. +.Sp +If the first character of \fIsectionpattern\fR is the exclamation +point (!) then matching sections will not be removed even if an +earlier use of \fB\-\-remove\-section\fR on the same command line +would otherwise remove it. For example: +.Sp +.Vb 1 +\& \-\-remove\-section=.text.* \-\-remove\-section=!.text.foo +.Ve +.Sp +will remove all sections matching the pattern '.text.*', but will not +remove the section '.text.foo'. +.IP "\fB\-\-remove\-relocations=\fR\fIsectionpattern\fR" 4 +.IX Item "--remove-relocations=sectionpattern" +Remove relocations from the output file for any section matching +\&\fIsectionpattern\fR. This option may be given more than once. Note +that using this option inappropriately may make the output file +unusable. Wildcard characters are accepted in \fIsectionpattern\fR. +For example: +.Sp +.Vb 1 +\& \-\-remove\-relocations=.text.* +.Ve +.Sp +will remove the relocations for all sections matching the patter +\&'.text.*'. +.Sp +If the first character of \fIsectionpattern\fR is the exclamation +point (!) then matching sections will not have their relocation +removed even if an earlier use of \fB\-\-remove\-relocations\fR on the +same command line would otherwise cause the relocations to be removed. +For example: +.Sp +.Vb 1 +\& \-\-remove\-relocations=.text.* \-\-remove\-relocations=!.text.foo +.Ve +.Sp +will remove all relocations for sections matching the pattern +\&'.text.*', but will not remove relocations for the section +\&'.text.foo'. +.IP "\fB\-S\fR" 4 +.IX Item "-S" +.PD 0 +.IP "\fB\-\-strip\-all\fR" 4 +.IX Item "--strip-all" +.PD +Do not copy relocation and symbol information from the source file. +.IP "\fB\-g\fR" 4 +.IX Item "-g" +.PD 0 +.IP "\fB\-\-strip\-debug\fR" 4 +.IX Item "--strip-debug" +.PD +Do not copy debugging symbols or sections from the source file. +.IP "\fB\-\-strip\-unneeded\fR" 4 +.IX Item "--strip-unneeded" +Strip all symbols that are not needed for relocation processing. +.IP "\fB\-K\fR \fIsymbolname\fR" 4 +.IX Item "-K symbolname" +.PD 0 +.IP "\fB\-\-keep\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--keep-symbol=symbolname" +.PD +When stripping symbols, keep symbol \fIsymbolname\fR even if it would +normally be stripped. This option may be given more than once. +.IP "\fB\-N\fR \fIsymbolname\fR" 4 +.IX Item "-N symbolname" +.PD 0 +.IP "\fB\-\-strip\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--strip-symbol=symbolname" +.PD +Do not copy symbol \fIsymbolname\fR from the source file. This option +may be given more than once. +.IP "\fB\-\-strip\-unneeded\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--strip-unneeded-symbol=symbolname" +Do not copy symbol \fIsymbolname\fR from the source file unless it is needed +by a relocation. This option may be given more than once. +.IP "\fB\-G\fR \fIsymbolname\fR" 4 +.IX Item "-G symbolname" +.PD 0 +.IP "\fB\-\-keep\-global\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--keep-global-symbol=symbolname" +.PD +Keep only symbol \fIsymbolname\fR global. Make all other symbols local +to the file, so that they are not visible externally. This option may +be given more than once. +.IP "\fB\-\-localize\-hidden\fR" 4 +.IX Item "--localize-hidden" +In an \s-1ELF\s0 object, mark all symbols that have hidden or internal visibility +as local. This option applies on top of symbol-specific localization options +such as \fB\-L\fR. +.IP "\fB\-L\fR \fIsymbolname\fR" 4 +.IX Item "-L symbolname" +.PD 0 +.IP "\fB\-\-localize\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--localize-symbol=symbolname" +.PD +Convert a global or weak symbol called \fIsymbolname\fR into a local +symbol, so that it is not visible externally. This option may be +given more than once. Note \- unique symbols are not converted. +.IP "\fB\-W\fR \fIsymbolname\fR" 4 +.IX Item "-W symbolname" +.PD 0 +.IP "\fB\-\-weaken\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--weaken-symbol=symbolname" +.PD +Make symbol \fIsymbolname\fR weak. This option may be given more than once. +.IP "\fB\-\-globalize\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--globalize-symbol=symbolname" +Give symbol \fIsymbolname\fR global scoping so that it is visible +outside of the file in which it is defined. This option may be given +more than once. +.IP "\fB\-w\fR" 4 +.IX Item "-w" +.PD 0 +.IP "\fB\-\-wildcard\fR" 4 +.IX Item "--wildcard" +.PD +Permit regular expressions in \fIsymbolname\fRs used in other command +line options. The question mark (?), asterisk (*), backslash (\e) and +square brackets ([]) operators can be used anywhere in the symbol +name. If the first character of the symbol name is the exclamation +point (!) then the sense of the switch is reversed for that symbol. +For example: +.Sp +.Vb 1 +\& \-w \-W !foo \-W fo* +.Ve +.Sp +would cause objcopy to weaken all symbols that start with \*(L"fo\*(R" +except for the symbol \*(L"foo\*(R". +.IP "\fB\-x\fR" 4 +.IX Item "-x" +.PD 0 +.IP "\fB\-\-discard\-all\fR" 4 +.IX Item "--discard-all" +.PD +Do not copy non-global symbols from the source file. +.IP "\fB\-X\fR" 4 +.IX Item "-X" +.PD 0 +.IP "\fB\-\-discard\-locals\fR" 4 +.IX Item "--discard-locals" +.PD +Do not copy compiler-generated local symbols. +(These usually start with \fBL\fR or \fB.\fR.) +.IP "\fB\-b\fR \fIbyte\fR" 4 +.IX Item "-b byte" +.PD 0 +.IP "\fB\-\-byte=\fR\fIbyte\fR" 4 +.IX Item "--byte=byte" +.PD +If interleaving has been enabled via the \fB\-\-interleave\fR option +then start the range of bytes to keep at the \fIbyte\fRth byte. +\&\fIbyte\fR can be in the range from 0 to \fIbreadth\fR\-1, where +\&\fIbreadth\fR is the value given by the \fB\-\-interleave\fR option. +.IP "\fB\-i [\fR\fIbreadth\fR\fB]\fR" 4 +.IX Item "-i [breadth]" +.PD 0 +.IP "\fB\-\-interleave[=\fR\fIbreadth\fR\fB]\fR" 4 +.IX Item "--interleave[=breadth]" +.PD +Only copy a range out of every \fIbreadth\fR bytes. (Header data is +not affected). Select which byte in the range begins the copy with +the \fB\-\-byte\fR option. Select the width of the range with the +\&\fB\-\-interleave\-width\fR option. +.Sp +This option is useful for creating files to program \s-1ROM.\s0 It is +typically used with an \f(CW\*(C`srec\*(C'\fR output target. Note that +\&\fBobjcopy\fR will complain if you do not specify the +\&\fB\-\-byte\fR option as well. +.Sp +The default interleave breadth is 4, so with \fB\-\-byte\fR set to 0, +\&\fBobjcopy\fR would copy the first byte out of every four bytes +from the input to the output. +.IP "\fB\-\-interleave\-width=\fR\fIwidth\fR" 4 +.IX Item "--interleave-width=width" +When used with the \fB\-\-interleave\fR option, copy \fIwidth\fR +bytes at a time. The start of the range of bytes to be copied is set +by the \fB\-\-byte\fR option, and the extent of the range is set with +the \fB\-\-interleave\fR option. +.Sp +The default value for this option is 1. The value of \fIwidth\fR plus +the \fIbyte\fR value set by the \fB\-\-byte\fR option must not exceed +the interleave breadth set by the \fB\-\-interleave\fR option. +.Sp +This option can be used to create images for two 16\-bit flashes interleaved +in a 32\-bit bus by passing \fB\-b 0 \-i 4 \-\-interleave\-width=2\fR +and \fB\-b 2 \-i 4 \-\-interleave\-width=2\fR to two \fBobjcopy\fR +commands. If the input was '12345678' then the outputs would be +\&'1256' and '3478' respectively. +.IP "\fB\-p\fR" 4 +.IX Item "-p" +.PD 0 +.IP "\fB\-\-preserve\-dates\fR" 4 +.IX Item "--preserve-dates" +.PD +Set the access and modification dates of the output file to be the same +as those of the input file. +.IP "\fB\-D\fR" 4 +.IX Item "-D" +.PD 0 +.IP "\fB\-\-enable\-deterministic\-archives\fR" 4 +.IX Item "--enable-deterministic-archives" +.PD +Operate in \fIdeterministic\fR mode. When copying archive members +and writing the archive index, use zero for UIDs, GIDs, timestamps, +and use consistent file modes for all files. +.Sp +If \fIbinutils\fR was configured with +\&\fB\-\-enable\-deterministic\-archives\fR, then this mode is on by default. +It can be disabled with the \fB\-U\fR option, below. +.IP "\fB\-U\fR" 4 +.IX Item "-U" +.PD 0 +.IP "\fB\-\-disable\-deterministic\-archives\fR" 4 +.IX Item "--disable-deterministic-archives" +.PD +Do \fInot\fR operate in \fIdeterministic\fR mode. This is the +inverse of the \fB\-D\fR option, above: when copying archive members +and writing the archive index, use their actual \s-1UID, GID,\s0 timestamp, +and file mode values. +.Sp +This is the default unless \fIbinutils\fR was configured with +\&\fB\-\-enable\-deterministic\-archives\fR. +.IP "\fB\-\-debugging\fR" 4 +.IX Item "--debugging" +Convert debugging information, if possible. This is not the default +because only certain debugging formats are supported, and the +conversion process can be time consuming. +.IP "\fB\-\-gap\-fill\fR \fIval\fR" 4 +.IX Item "--gap-fill val" +Fill gaps between sections with \fIval\fR. This operation applies to +the \fIload address\fR (\s-1LMA\s0) of the sections. It is done by increasing +the size of the section with the lower address, and filling in the extra +space created with \fIval\fR. +.IP "\fB\-\-pad\-to\fR \fIaddress\fR" 4 +.IX Item "--pad-to address" +Pad the output file up to the load address \fIaddress\fR. This is +done by increasing the size of the last section. The extra space is +filled in with the value specified by \fB\-\-gap\-fill\fR (default zero). +.IP "\fB\-\-set\-start\fR \fIval\fR" 4 +.IX Item "--set-start val" +Set the start address of the new file to \fIval\fR. Not all object file +formats support setting the start address. +.IP "\fB\-\-change\-start\fR \fIincr\fR" 4 +.IX Item "--change-start incr" +.PD 0 +.IP "\fB\-\-adjust\-start\fR \fIincr\fR" 4 +.IX Item "--adjust-start incr" +.PD +Change the start address by adding \fIincr\fR. Not all object file +formats support setting the start address. +.IP "\fB\-\-change\-addresses\fR \fIincr\fR" 4 +.IX Item "--change-addresses incr" +.PD 0 +.IP "\fB\-\-adjust\-vma\fR \fIincr\fR" 4 +.IX Item "--adjust-vma incr" +.PD +Change the \s-1VMA\s0 and \s-1LMA\s0 addresses of all sections, as well as the start +address, by adding \fIincr\fR. Some object file formats do not permit +section addresses to be changed arbitrarily. Note that this does not +relocate the sections; if the program expects sections to be loaded at a +certain address, and this option is used to change the sections such +that they are loaded at a different address, the program may fail. +.IP "\fB\-\-change\-section\-address\fR \fIsectionpattern\fR\fB{=,+,\-}\fR\fIval\fR" 4 +.IX Item "--change-section-address sectionpattern{=,+,-}val" +.PD 0 +.IP "\fB\-\-adjust\-section\-vma\fR \fIsectionpattern\fR\fB{=,+,\-}\fR\fIval\fR" 4 +.IX Item "--adjust-section-vma sectionpattern{=,+,-}val" +.PD +Set or change both the \s-1VMA\s0 address and the \s-1LMA\s0 address of any section +matching \fIsectionpattern\fR. If \fB=\fR is used, the section +address is set to \fIval\fR. Otherwise, \fIval\fR is added to or +subtracted from the section address. See the comments under +\&\fB\-\-change\-addresses\fR, above. If \fIsectionpattern\fR does not +match any sections in the input file, a warning will be issued, unless +\&\fB\-\-no\-change\-warnings\fR is used. +.IP "\fB\-\-change\-section\-lma\fR \fIsectionpattern\fR\fB{=,+,\-}\fR\fIval\fR" 4 +.IX Item "--change-section-lma sectionpattern{=,+,-}val" +Set or change the \s-1LMA\s0 address of any sections matching +\&\fIsectionpattern\fR. The \s-1LMA\s0 address is the address where the +section will be loaded into memory at program load time. Normally +this is the same as the \s-1VMA\s0 address, which is the address of the +section at program run time, but on some systems, especially those +where a program is held in \s-1ROM,\s0 the two can be different. If \fB=\fR +is used, the section address is set to \fIval\fR. Otherwise, +\&\fIval\fR is added to or subtracted from the section address. See the +comments under \fB\-\-change\-addresses\fR, above. If +\&\fIsectionpattern\fR does not match any sections in the input file, a +warning will be issued, unless \fB\-\-no\-change\-warnings\fR is used. +.IP "\fB\-\-change\-section\-vma\fR \fIsectionpattern\fR\fB{=,+,\-}\fR\fIval\fR" 4 +.IX Item "--change-section-vma sectionpattern{=,+,-}val" +Set or change the \s-1VMA\s0 address of any section matching +\&\fIsectionpattern\fR. The \s-1VMA\s0 address is the address where the +section will be located once the program has started executing. +Normally this is the same as the \s-1LMA\s0 address, which is the address +where the section will be loaded into memory, but on some systems, +especially those where a program is held in \s-1ROM,\s0 the two can be +different. If \fB=\fR is used, the section address is set to +\&\fIval\fR. Otherwise, \fIval\fR is added to or subtracted from the +section address. See the comments under \fB\-\-change\-addresses\fR, +above. If \fIsectionpattern\fR does not match any sections in the +input file, a warning will be issued, unless +\&\fB\-\-no\-change\-warnings\fR is used. +.IP "\fB\-\-change\-warnings\fR" 4 +.IX Item "--change-warnings" +.PD 0 +.IP "\fB\-\-adjust\-warnings\fR" 4 +.IX Item "--adjust-warnings" +.PD +If \fB\-\-change\-section\-address\fR or \fB\-\-change\-section\-lma\fR or +\&\fB\-\-change\-section\-vma\fR is used, and the section pattern does not +match any sections, issue a warning. This is the default. +.IP "\fB\-\-no\-change\-warnings\fR" 4 +.IX Item "--no-change-warnings" +.PD 0 +.IP "\fB\-\-no\-adjust\-warnings\fR" 4 +.IX Item "--no-adjust-warnings" +.PD +Do not issue a warning if \fB\-\-change\-section\-address\fR or +\&\fB\-\-adjust\-section\-lma\fR or \fB\-\-adjust\-section\-vma\fR is used, even +if the section pattern does not match any sections. +.IP "\fB\-\-set\-section\-flags\fR \fIsectionpattern\fR\fB=\fR\fIflags\fR" 4 +.IX Item "--set-section-flags sectionpattern=flags" +Set the flags for any sections matching \fIsectionpattern\fR. The +\&\fIflags\fR argument is a comma separated string of flag names. The +recognized names are \fBalloc\fR, \fBcontents\fR, \fBload\fR, +\&\fBnoload\fR, \fBreadonly\fR, \fBcode\fR, \fBdata\fR, \fBrom\fR, +\&\fBshare\fR, and \fBdebug\fR. You can set the \fBcontents\fR flag +for a section which does not have contents, but it is not meaningful +to clear the \fBcontents\fR flag of a section which does have +contents\*(--just remove the section instead. Not all flags are +meaningful for all object file formats. +.IP "\fB\-\-add\-section\fR \fIsectionname\fR\fB=\fR\fIfilename\fR" 4 +.IX Item "--add-section sectionname=filename" +Add a new section named \fIsectionname\fR while copying the file. The +contents of the new section are taken from the file \fIfilename\fR. The +size of the section will be the size of the file. This option only +works on file formats which can support sections with arbitrary names. +Note \- it may be necessary to use the \fB\-\-set\-section\-flags\fR +option to set the attributes of the newly created section. +.IP "\fB\-\-dump\-section\fR \fIsectionname\fR\fB=\fR\fIfilename\fR" 4 +.IX Item "--dump-section sectionname=filename" +Place the contents of section named \fIsectionname\fR into the file +\&\fIfilename\fR, overwriting any contents that may have been there +previously. This option is the inverse of \fB\-\-add\-section\fR. +This option is similar to the \fB\-\-only\-section\fR option except +that it does not create a formatted file, it just dumps the contents +as raw binary data, without applying any relocations. The option can +be specified more than once. +.IP "\fB\-\-update\-section\fR \fIsectionname\fR\fB=\fR\fIfilename\fR" 4 +.IX Item "--update-section sectionname=filename" +Replace the existing contents of a section named \fIsectionname\fR +with the contents of file \fIfilename\fR. The size of the section +will be adjusted to the size of the file. The section flags for +\&\fIsectionname\fR will be unchanged. For \s-1ELF\s0 format files the section +to segment mapping will also remain unchanged, something which is not +possible using \fB\-\-remove\-section\fR followed by +\&\fB\-\-add\-section\fR. The option can be specified more than once. +.Sp +Note \- it is possible to use \fB\-\-rename\-section\fR and +\&\fB\-\-update\-section\fR to both update and rename a section from one +command line. In this case, pass the original section name to +\&\fB\-\-update\-section\fR, and the original and new section names to +\&\fB\-\-rename\-section\fR. +.IP "\fB\-\-add\-symbol\fR \fIname\fR\fB=[\fR\fIsection\fR\fB:]\fR\fIvalue\fR\fB[,\fR\fIflags\fR\fB]\fR" 4 +.IX Item "--add-symbol name=[section:]value[,flags]" +Add a new symbol named \fIname\fR while copying the file. This option may be +specified multiple times. If the \fIsection\fR is given, the symbol will be +associated with and relative to that section, otherwise it will be an \s-1ABS\s0 +symbol. Specifying an undefined section will result in a fatal error. There +is no check for the value, it will be taken as specified. Symbol flags can +be specified and not all flags will be meaningful for all object file +formats. By default, the symbol will be global. The special flag +\&'before=\fIothersym\fR' will insert the new symbol in front of the specified +\&\fIothersym\fR, otherwise the symbol(s) will be added at the end of the +symbol table in the order they appear. +.IP "\fB\-\-rename\-section\fR \fIoldname\fR\fB=\fR\fInewname\fR\fB[,\fR\fIflags\fR\fB]\fR" 4 +.IX Item "--rename-section oldname=newname[,flags]" +Rename a section from \fIoldname\fR to \fInewname\fR, optionally +changing the section's flags to \fIflags\fR in the process. This has +the advantage over using a linker script to perform the rename in that +the output stays as an object file and does not become a linked +executable. +.Sp +This option is particularly helpful when the input format is binary, +since this will always create a section called .data. If for example, +you wanted instead to create a section called .rodata containing binary +data you could use the following command line to achieve it: +.Sp +.Vb 3 +\& objcopy \-I binary \-O \-B \e +\& \-\-rename\-section .data=.rodata,alloc,load,readonly,data,contents \e +\& +.Ve +.IP "\fB\-\-long\-section\-names {enable,disable,keep}\fR" 4 +.IX Item "--long-section-names {enable,disable,keep}" +Controls the handling of long section names when processing \f(CW\*(C`COFF\*(C'\fR +and \f(CW\*(C`PE\-COFF\*(C'\fR object formats. The default behaviour, \fBkeep\fR, +is to preserve long section names if any are present in the input file. +The \fBenable\fR and \fBdisable\fR options forcibly enable or disable +the use of long section names in the output object; when \fBdisable\fR +is in effect, any long section names in the input object will be truncated. +The \fBenable\fR option will only emit long section names if any are +present in the inputs; this is mostly the same as \fBkeep\fR, but it +is left undefined whether the \fBenable\fR option might force the +creation of an empty string table in the output file. +.IP "\fB\-\-change\-leading\-char\fR" 4 +.IX Item "--change-leading-char" +Some object file formats use special characters at the start of +symbols. The most common such character is underscore, which compilers +often add before every symbol. This option tells \fBobjcopy\fR to +change the leading character of every symbol when it converts between +object file formats. If the object file formats use the same leading +character, this option has no effect. Otherwise, it will add a +character, or remove a character, or change a character, as +appropriate. +.IP "\fB\-\-remove\-leading\-char\fR" 4 +.IX Item "--remove-leading-char" +If the first character of a global symbol is a special symbol leading +character used by the object file format, remove the character. The +most common symbol leading character is underscore. This option will +remove a leading underscore from all global symbols. This can be useful +if you want to link together objects of different file formats with +different conventions for symbol names. This is different from +\&\fB\-\-change\-leading\-char\fR because it always changes the symbol name +when appropriate, regardless of the object file format of the output +file. +.IP "\fB\-\-reverse\-bytes=\fR\fInum\fR" 4 +.IX Item "--reverse-bytes=num" +Reverse the bytes in a section with output contents. A section length must +be evenly divisible by the value given in order for the swap to be able to +take place. Reversing takes place before the interleaving is performed. +.Sp +This option is used typically in generating \s-1ROM\s0 images for problematic +target systems. For example, on some target boards, the 32\-bit words +fetched from 8\-bit ROMs are re-assembled in little-endian byte order +regardless of the \s-1CPU\s0 byte order. Depending on the programming model, the +endianness of the \s-1ROM\s0 may need to be modified. +.Sp +Consider a simple file with a section containing the following eight +bytes: \f(CW12345678\fR. +.Sp +Using \fB\-\-reverse\-bytes=2\fR for the above example, the bytes in the +output file would be ordered \f(CW21436587\fR. +.Sp +Using \fB\-\-reverse\-bytes=4\fR for the above example, the bytes in the +output file would be ordered \f(CW43218765\fR. +.Sp +By using \fB\-\-reverse\-bytes=2\fR for the above example, followed by +\&\fB\-\-reverse\-bytes=4\fR on the output file, the bytes in the second +output file would be ordered \f(CW34127856\fR. +.IP "\fB\-\-srec\-len=\fR\fIival\fR" 4 +.IX Item "--srec-len=ival" +Meaningful only for srec output. Set the maximum length of the Srecords +being produced to \fIival\fR. This length covers both address, data and +crc fields. +.IP "\fB\-\-srec\-forceS3\fR" 4 +.IX Item "--srec-forceS3" +Meaningful only for srec output. Avoid generation of S1/S2 records, +creating S3\-only record format. +.IP "\fB\-\-redefine\-sym\fR \fIold\fR\fB=\fR\fInew\fR" 4 +.IX Item "--redefine-sym old=new" +Change the name of a symbol \fIold\fR, to \fInew\fR. This can be useful +when one is trying link two things together for which you have no +source, and there are name collisions. +.IP "\fB\-\-redefine\-syms=\fR\fIfilename\fR" 4 +.IX Item "--redefine-syms=filename" +Apply \fB\-\-redefine\-sym\fR to each symbol pair "\fIold\fR \fInew\fR" +listed in the file \fIfilename\fR. \fIfilename\fR is simply a flat file, +with one symbol pair per line. Line comments may be introduced by the hash +character. This option may be given more than once. +.IP "\fB\-\-weaken\fR" 4 +.IX Item "--weaken" +Change all global symbols in the file to be weak. This can be useful +when building an object which will be linked against other objects using +the \fB\-R\fR option to the linker. This option is only effective when +using an object file format which supports weak symbols. +.IP "\fB\-\-keep\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--keep-symbols=filename" +Apply \fB\-\-keep\-symbol\fR option to each symbol listed in the file +\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. +.IP "\fB\-\-strip\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--strip-symbols=filename" +Apply \fB\-\-strip\-symbol\fR option to each symbol listed in the file +\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. +.IP "\fB\-\-strip\-unneeded\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--strip-unneeded-symbols=filename" +Apply \fB\-\-strip\-unneeded\-symbol\fR option to each symbol listed in +the file \fIfilename\fR. \fIfilename\fR is simply a flat file, with one +symbol name per line. Line comments may be introduced by the hash +character. This option may be given more than once. +.IP "\fB\-\-keep\-global\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--keep-global-symbols=filename" +Apply \fB\-\-keep\-global\-symbol\fR option to each symbol listed in the +file \fIfilename\fR. \fIfilename\fR is simply a flat file, with one +symbol name per line. Line comments may be introduced by the hash +character. This option may be given more than once. +.IP "\fB\-\-localize\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--localize-symbols=filename" +Apply \fB\-\-localize\-symbol\fR option to each symbol listed in the file +\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. +.IP "\fB\-\-globalize\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--globalize-symbols=filename" +Apply \fB\-\-globalize\-symbol\fR option to each symbol listed in the file +\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. +.IP "\fB\-\-weaken\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--weaken-symbols=filename" +Apply \fB\-\-weaken\-symbol\fR option to each symbol listed in the file +\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. +.IP "\fB\-\-alt\-machine\-code=\fR\fIindex\fR" 4 +.IX Item "--alt-machine-code=index" +If the output architecture has alternate machine codes, use the +\&\fIindex\fRth code instead of the default one. This is useful in case +a machine is assigned an official code and the tool-chain adopts the +new code, but other applications still depend on the original code +being used. For \s-1ELF\s0 based architectures if the \fIindex\fR +alternative does not exist then the value is treated as an absolute +number to be stored in the e_machine field of the \s-1ELF\s0 header. +.IP "\fB\-\-writable\-text\fR" 4 +.IX Item "--writable-text" +Mark the output text as writable. This option isn't meaningful for all +object file formats. +.IP "\fB\-\-readonly\-text\fR" 4 +.IX Item "--readonly-text" +Make the output text write protected. This option isn't meaningful for all +object file formats. +.IP "\fB\-\-pure\fR" 4 +.IX Item "--pure" +Mark the output file as demand paged. This option isn't meaningful for all +object file formats. +.IP "\fB\-\-impure\fR" 4 +.IX Item "--impure" +Mark the output file as impure. This option isn't meaningful for all +object file formats. +.IP "\fB\-\-prefix\-symbols=\fR\fIstring\fR" 4 +.IX Item "--prefix-symbols=string" +Prefix all symbols in the output file with \fIstring\fR. +.IP "\fB\-\-prefix\-sections=\fR\fIstring\fR" 4 +.IX Item "--prefix-sections=string" +Prefix all section names in the output file with \fIstring\fR. +.IP "\fB\-\-prefix\-alloc\-sections=\fR\fIstring\fR" 4 +.IX Item "--prefix-alloc-sections=string" +Prefix all the names of all allocated sections in the output file with +\&\fIstring\fR. +.IP "\fB\-\-add\-gnu\-debuglink=\fR\fIpath-to-file\fR" 4 +.IX Item "--add-gnu-debuglink=path-to-file" +Creates a .gnu_debuglink section which contains a reference to +\&\fIpath-to-file\fR and adds it to the output file. Note: the file at +\&\fIpath-to-file\fR must exist. Part of the process of adding the +\&.gnu_debuglink section involves embedding a checksum of the contents +of the debug info file into the section. +.Sp +If the debug info file is built in one location but it is going to be +installed at a later time into a different location then do not use +the path to the installed location. The \fB\-\-add\-gnu\-debuglink\fR +option will fail because the installed file does not exist yet. +Instead put the debug info file in the current directory and use the +\&\fB\-\-add\-gnu\-debuglink\fR option without any directory components, +like this: +.Sp +.Vb 1 +\& objcopy \-\-add\-gnu\-debuglink=foo.debug +.Ve +.Sp +At debug time the debugger will attempt to look for the separate debug +info file in a set of known locations. The exact set of these +locations varies depending upon the distribution being used, but it +typically includes: +.RS 4 +.ie n .IP """* The same directory as the executable.""" 4 +.el .IP "\f(CW* The same directory as the executable.\fR" 4 +.IX Item "* The same directory as the executable." +.PD 0 +.ie n .IP """* A sub\-directory of the directory containing the executable""" 4 +.el .IP "\f(CW* A sub\-directory of the directory containing the executable\fR" 4 +.IX Item "* A sub-directory of the directory containing the executable" +.PD +called .debug +.ie n .IP """* A global debug directory such as /usr/lib/debug.""" 4 +.el .IP "\f(CW* A global debug directory such as /usr/lib/debug.\fR" 4 +.IX Item "* A global debug directory such as /usr/lib/debug." +.RE +.RS 4 +.Sp +As long as the debug info file has been installed into one of these +locations before the debugger is run everything should work +correctly. +.RE +.IP "\fB\-\-keep\-file\-symbols\fR" 4 +.IX Item "--keep-file-symbols" +When stripping a file, perhaps with \fB\-\-strip\-debug\fR or +\&\fB\-\-strip\-unneeded\fR, retain any symbols specifying source file names, +which would otherwise get stripped. +.IP "\fB\-\-only\-keep\-debug\fR" 4 +.IX Item "--only-keep-debug" +Strip a file, removing contents of any sections that would not be +stripped by \fB\-\-strip\-debug\fR and leaving the debugging sections +intact. In \s-1ELF\s0 files, this preserves all note sections in the output. +.Sp +Note \- the section headers of the stripped sections are preserved, +including their sizes, but the contents of the section are discarded. +The section headers are preserved so that other tools can match up the +debuginfo file with the real executable, even if that executable has +been relocated to a different address space. +.Sp +The intention is that this option will be used in conjunction with +\&\fB\-\-add\-gnu\-debuglink\fR to create a two part executable. One a +stripped binary which will occupy less space in \s-1RAM\s0 and in a +distribution and the second a debugging information file which is only +needed if debugging abilities are required. The suggested procedure +to create these files is as follows: +.RS 4 +.IP "1." 4 +.IX Item "1." +\&\f(CW\*(C`foo\*(C'\fR then... +.ie n .IP "1." 4 +.el .IP "1." 4 +.IX Item "1." +create a file containing the debugging info. +.ie n .IP "1." 4 +.el .IP "1." 4 +.IX Item "1." +stripped executable. +.ie n .IP "1." 4 +.el .IP "1." 4 +.IX Item "1." +to add a link to the debugging info into the stripped executable. +.RE +.RS 4 +.Sp +Note\-\-\-the choice of \f(CW\*(C`.dbg\*(C'\fR as an extension for the debug info +file is arbitrary. Also the \f(CW\*(C`\-\-only\-keep\-debug\*(C'\fR step is +optional. You could instead do this: +.IP "1." 4 +.IX Item "1." +.PD 0 +.ie n .IP "1." 4 +.el .IP "1." 4 +.IX Item "1." +.ie n .IP "1." 4 +.el .IP "1." 4 +.IX Item "1." +.ie n .IP "1." 4 +.el .IP "1." 4 +.IX Item "1." +.RE +.RS 4 +.PD +.Sp +i.e., the file pointed to by the \fB\-\-add\-gnu\-debuglink\fR can be the +full executable. It does not have to be a file created by the +\&\fB\-\-only\-keep\-debug\fR switch. +.Sp +Note\-\-\-this switch is only intended for use on fully linked files. It +does not make sense to use it on object files where the debugging +information may be incomplete. Besides the gnu_debuglink feature +currently only supports the presence of one filename containing +debugging information, not multiple filenames on a one-per-object-file +basis. +.RE +.IP "\fB\-\-strip\-dwo\fR" 4 +.IX Item "--strip-dwo" +Remove the contents of all \s-1DWARF\s0 .dwo sections, leaving the +remaining debugging sections and all symbols intact. +This option is intended for use by the compiler as part of +the \fB\-gsplit\-dwarf\fR option, which splits debug information +between the .o file and a separate .dwo file. The compiler +generates all debug information in the same file, then uses +the \fB\-\-extract\-dwo\fR option to copy the .dwo sections to +the .dwo file, then the \fB\-\-strip\-dwo\fR option to remove +those sections from the original .o file. +.IP "\fB\-\-extract\-dwo\fR" 4 +.IX Item "--extract-dwo" +Extract the contents of all \s-1DWARF\s0 .dwo sections. See the +\&\fB\-\-strip\-dwo\fR option for more information. +.IP "\fB\-\-file\-alignment\fR \fInum\fR" 4 +.IX Item "--file-alignment num" +Specify the file alignment. Sections in the file will always begin at +file offsets which are multiples of this number. This defaults to +512. +[This option is specific to \s-1PE\s0 targets.] +.IP "\fB\-\-heap\fR \fIreserve\fR" 4 +.IX Item "--heap reserve" +.PD 0 +.IP "\fB\-\-heap\fR \fIreserve\fR\fB,\fR\fIcommit\fR" 4 +.IX Item "--heap reserve,commit" +.PD +Specify the number of bytes of memory to reserve (and optionally commit) +to be used as heap for this program. +[This option is specific to \s-1PE\s0 targets.] +.IP "\fB\-\-image\-base\fR \fIvalue\fR" 4 +.IX Item "--image-base value" +Use \fIvalue\fR as the base address of your program or dll. This is +the lowest memory location that will be used when your program or dll +is loaded. To reduce the need to relocate and improve performance of +your dlls, each should have a unique base address and not overlap any +other dlls. The default is 0x400000 for executables, and 0x10000000 +for dlls. +[This option is specific to \s-1PE\s0 targets.] +.IP "\fB\-\-section\-alignment\fR \fInum\fR" 4 +.IX Item "--section-alignment num" +Sets the section alignment. Sections in memory will always begin at +addresses which are a multiple of this number. Defaults to 0x1000. +[This option is specific to \s-1PE\s0 targets.] +.IP "\fB\-\-stack\fR \fIreserve\fR" 4 +.IX Item "--stack reserve" +.PD 0 +.IP "\fB\-\-stack\fR \fIreserve\fR\fB,\fR\fIcommit\fR" 4 +.IX Item "--stack reserve,commit" +.PD +Specify the number of bytes of memory to reserve (and optionally commit) +to be used as stack for this program. +[This option is specific to \s-1PE\s0 targets.] +.IP "\fB\-\-subsystem\fR \fIwhich\fR" 4 +.IX Item "--subsystem which" +.PD 0 +.IP "\fB\-\-subsystem\fR \fIwhich\fR\fB:\fR\fImajor\fR" 4 +.IX Item "--subsystem which:major" +.IP "\fB\-\-subsystem\fR \fIwhich\fR\fB:\fR\fImajor\fR\fB.\fR\fIminor\fR" 4 +.IX Item "--subsystem which:major.minor" +.PD +Specifies the subsystem under which your program will execute. The +legal values for \fIwhich\fR are \f(CW\*(C`native\*(C'\fR, \f(CW\*(C`windows\*(C'\fR, +\&\f(CW\*(C`console\*(C'\fR, \f(CW\*(C`posix\*(C'\fR, \f(CW\*(C`efi\-app\*(C'\fR, \f(CW\*(C`efi\-bsd\*(C'\fR, +\&\f(CW\*(C`efi\-rtd\*(C'\fR, \f(CW\*(C`sal\-rtd\*(C'\fR, and \f(CW\*(C`xbox\*(C'\fR. You may optionally set +the subsystem version also. Numeric values are also accepted for +\&\fIwhich\fR. +[This option is specific to \s-1PE\s0 targets.] +.IP "\fB\-\-extract\-symbol\fR" 4 +.IX Item "--extract-symbol" +Keep the file's section flags and symbols but remove all section data. +Specifically, the option: +.RS 4 +.IP "*" 4 +.IX Item "*" +.PD 0 +.IP "*" 4 +.IX Item "*" +.IP "*" 4 +.IX Item "*" +.RE +.RS 4 +.PD +.Sp +This option is used to build a \fI.sym\fR file for a VxWorks kernel. +It can also be a useful way of reducing the size of a \fB\-\-just\-symbols\fR +linker input file. +.RE +.IP "\fB\-\-compress\-debug\-sections\fR" 4 +.IX Item "--compress-debug-sections" +Compress \s-1DWARF\s0 debug sections using zlib with \s-1SHF_COMPRESSED\s0 from the +\&\s-1ELF ABI.\s0 Note \- if compression would actually make a section +\&\fIlarger\fR, then it is not compressed. +.IP "\fB\-\-compress\-debug\-sections=none\fR" 4 +.IX Item "--compress-debug-sections=none" +.PD 0 +.IP "\fB\-\-compress\-debug\-sections=zlib\fR" 4 +.IX Item "--compress-debug-sections=zlib" +.IP "\fB\-\-compress\-debug\-sections=zlib\-gnu\fR" 4 +.IX Item "--compress-debug-sections=zlib-gnu" +.IP "\fB\-\-compress\-debug\-sections=zlib\-gabi\fR" 4 +.IX Item "--compress-debug-sections=zlib-gabi" +.PD +For \s-1ELF\s0 files, these options control how \s-1DWARF\s0 debug sections are +compressed. \fB\-\-compress\-debug\-sections=none\fR is equivalent +to \fB\-\-decompress\-debug\-sections\fR. +\&\fB\-\-compress\-debug\-sections=zlib\fR and +\&\fB\-\-compress\-debug\-sections=zlib\-gabi\fR are equivalent to +\&\fB\-\-compress\-debug\-sections\fR. +\&\fB\-\-compress\-debug\-sections=zlib\-gnu\fR compresses \s-1DWARF\s0 debug +sections using zlib. The debug sections are renamed to begin with +\&\fB.zdebug\fR instead of \fB.debug\fR. Note \- if compression would +actually make a section \fIlarger\fR, then it is not compressed nor +renamed. +.IP "\fB\-\-decompress\-debug\-sections\fR" 4 +.IX Item "--decompress-debug-sections" +Decompress \s-1DWARF\s0 debug sections using zlib. The original section +names of the compressed sections are restored. +.IP "\fB\-\-elf\-stt\-common=yes\fR" 4 +.IX Item "--elf-stt-common=yes" +.PD 0 +.IP "\fB\-\-elf\-stt\-common=no\fR" 4 +.IX Item "--elf-stt-common=no" +.PD +For \s-1ELF\s0 files, these options control whether common symbols should be +converted to the \f(CW\*(C`STT_COMMON\*(C'\fR or \f(CW\*(C`STT_OBJECT\*(C'\fR type. +\&\fB\-\-elf\-stt\-common=yes\fR converts common symbol type to +\&\f(CW\*(C`STT_COMMON\*(C'\fR. \fB\-\-elf\-stt\-common=no\fR converts common symbol +type to \f(CW\*(C`STT_OBJECT\*(C'\fR. +.IP "\fB\-\-merge\-notes\fR" 4 +.IX Item "--merge-notes" +.PD 0 +.IP "\fB\-\-no\-merge\-notes\fR" 4 +.IX Item "--no-merge-notes" +.PD +For \s-1ELF\s0 files, attempt (or do not attempt) to reduce the size of any +\&\s-1SHT_NOTE\s0 type sections by removing duplicate notes. +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Show the version number of \fBobjcopy\fR. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +.PD 0 +.IP "\fB\-\-verbose\fR" 4 +.IX Item "--verbose" +.PD +Verbose output: list all object files modified. In the case of +archives, \fBobjcopy \-V\fR lists all members of the archive. +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +Show a summary of the options to \fBobjcopy\fR. +.IP "\fB\-\-info\fR" 4 +.IX Item "--info" +Display a list showing all architectures and object formats available. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fIld\fR\|(1), \fIobjdump\fR\|(1), and the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/objdump.1 b/support/sdbinutils/binutils/doc/objdump.1 new file mode 100644 index 0000000..6cf76da --- /dev/null +++ b/support/sdbinutils/binutils/doc/objdump.1 @@ -0,0 +1,1234 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "OBJDUMP 1" +.TH OBJDUMP 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +objdump \- display information from object files. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +objdump [\fB\-a\fR|\fB\-\-archive\-headers\fR] + [\fB\-b\fR \fIbfdname\fR|\fB\-\-target=\fR\fIbfdname\fR] + [\fB\-C\fR|\fB\-\-demangle\fR[=\fIstyle\fR] ] + [\fB\-d\fR|\fB\-\-disassemble\fR] + [\fB\-D\fR|\fB\-\-disassemble\-all\fR] + [\fB\-z\fR|\fB\-\-disassemble\-zeroes\fR] + [\fB\-EB\fR|\fB\-EL\fR|\fB\-\-endian=\fR{big | little }] + [\fB\-f\fR|\fB\-\-file\-headers\fR] + [\fB\-F\fR|\fB\-\-file\-offsets\fR] + [\fB\-\-file\-start\-context\fR] + [\fB\-g\fR|\fB\-\-debugging\fR] + [\fB\-e\fR|\fB\-\-debugging\-tags\fR] + [\fB\-h\fR|\fB\-\-section\-headers\fR|\fB\-\-headers\fR] + [\fB\-i\fR|\fB\-\-info\fR] + [\fB\-j\fR \fIsection\fR|\fB\-\-section=\fR\fIsection\fR] + [\fB\-l\fR|\fB\-\-line\-numbers\fR] + [\fB\-S\fR|\fB\-\-source\fR] + [\fB\-m\fR \fImachine\fR|\fB\-\-architecture=\fR\fImachine\fR] + [\fB\-M\fR \fIoptions\fR|\fB\-\-disassembler\-options=\fR\fIoptions\fR] + [\fB\-p\fR|\fB\-\-private\-headers\fR] + [\fB\-P\fR \fIoptions\fR|\fB\-\-private=\fR\fIoptions\fR] + [\fB\-r\fR|\fB\-\-reloc\fR] + [\fB\-R\fR|\fB\-\-dynamic\-reloc\fR] + [\fB\-s\fR|\fB\-\-full\-contents\fR] + [\fB\-W[lLiaprmfFsoRtUuTgAckK]\fR| + \fB\-\-dwarf\fR[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames\-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow\-links] + [\fB\-G\fR|\fB\-\-stabs\fR] + [\fB\-t\fR|\fB\-\-syms\fR] + [\fB\-T\fR|\fB\-\-dynamic\-syms\fR] + [\fB\-x\fR|\fB\-\-all\-headers\fR] + [\fB\-w\fR|\fB\-\-wide\fR] + [\fB\-\-start\-address=\fR\fIaddress\fR] + [\fB\-\-stop\-address=\fR\fIaddress\fR] + [\fB\-\-prefix\-addresses\fR] + [\fB\-\-[no\-]show\-raw\-insn\fR] + [\fB\-\-adjust\-vma=\fR\fIoffset\fR] + [\fB\-\-dwarf\-depth=\fR\fIn\fR] + [\fB\-\-dwarf\-start=\fR\fIn\fR] + [\fB\-\-special\-syms\fR] + [\fB\-\-prefix=\fR\fIprefix\fR] + [\fB\-\-prefix\-strip=\fR\fIlevel\fR] + [\fB\-\-insn\-width=\fR\fIwidth\fR] + [\fB\-V\fR|\fB\-\-version\fR] + [\fB\-H\fR|\fB\-\-help\fR] + \fIobjfile\fR... +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\fBobjdump\fR displays information about one or more object files. +The options control what particular information to display. This +information is mostly useful to programmers who are working on the +compilation tools, as opposed to programmers who just want their +program to compile and work. +.PP +\&\fIobjfile\fR... are the object files to be examined. When you +specify archives, \fBobjdump\fR shows information on each of the member +object files. +.SH "OPTIONS" +.IX Header "OPTIONS" +The long and short forms of options, shown here as alternatives, are +equivalent. At least one option from the list +\&\fB\-a,\-d,\-D,\-e,\-f,\-g,\-G,\-h,\-H,\-p,\-P,\-r,\-R,\-s,\-S,\-t,\-T,\-V,\-x\fR must be given. +.IP "\fB\-a\fR" 4 +.IX Item "-a" +.PD 0 +.IP "\fB\-\-archive\-header\fR" 4 +.IX Item "--archive-header" +.PD +If any of the \fIobjfile\fR files are archives, display the archive +header information (in a format similar to \fBls \-l\fR). Besides the +information you could list with \fBar tv\fR, \fBobjdump \-a\fR shows +the object file format of each archive member. +.IP "\fB\-\-adjust\-vma=\fR\fIoffset\fR" 4 +.IX Item "--adjust-vma=offset" +When dumping information, first add \fIoffset\fR to all the section +addresses. This is useful if the section addresses do not correspond to +the symbol table, which can happen when putting sections at particular +addresses when using a format which can not represent section addresses, +such as a.out. +.IP "\fB\-b\fR \fIbfdname\fR" 4 +.IX Item "-b bfdname" +.PD 0 +.IP "\fB\-\-target=\fR\fIbfdname\fR" 4 +.IX Item "--target=bfdname" +.PD +Specify that the object-code format for the object files is +\&\fIbfdname\fR. This option may not be necessary; \fIobjdump\fR can +automatically recognize many formats. +.Sp +For example, +.Sp +.Vb 1 +\& objdump \-b oasys \-m vax \-h fu.o +.Ve +.Sp +displays summary information from the section headers (\fB\-h\fR) of +\&\fIfu.o\fR, which is explicitly identified (\fB\-m\fR) as a \s-1VAX\s0 object +file in the format produced by Oasys compilers. You can list the +formats available with the \fB\-i\fR option. +.IP "\fB\-C\fR" 4 +.IX Item "-C" +.PD 0 +.IP "\fB\-\-demangle[=\fR\fIstyle\fR\fB]\fR" 4 +.IX Item "--demangle[=style]" +.PD +Decode (\fIdemangle\fR) low-level symbol names into user-level names. +Besides removing any initial underscore prepended by the system, this +makes \*(C+ function names readable. Different compilers have different +mangling styles. The optional demangling style argument can be used to +choose an appropriate demangling style for your compiler. +.IP "\fB\-g\fR" 4 +.IX Item "-g" +.PD 0 +.IP "\fB\-\-debugging\fR" 4 +.IX Item "--debugging" +.PD +Display debugging information. This attempts to parse \s-1STABS\s0 and \s-1IEEE\s0 +debugging format information stored in the file and print it out using +a C like syntax. If neither of these formats are found this option +falls back on the \fB\-W\fR option to print any \s-1DWARF\s0 information in +the file. +.IP "\fB\-e\fR" 4 +.IX Item "-e" +.PD 0 +.IP "\fB\-\-debugging\-tags\fR" 4 +.IX Item "--debugging-tags" +.PD +Like \fB\-g\fR, but the information is generated in a format compatible +with ctags tool. +.IP "\fB\-d\fR" 4 +.IX Item "-d" +.PD 0 +.IP "\fB\-\-disassemble\fR" 4 +.IX Item "--disassemble" +.PD +Display the assembler mnemonics for the machine instructions from +\&\fIobjfile\fR. This option only disassembles those sections which are +expected to contain instructions. +.IP "\fB\-D\fR" 4 +.IX Item "-D" +.PD 0 +.IP "\fB\-\-disassemble\-all\fR" 4 +.IX Item "--disassemble-all" +.PD +Like \fB\-d\fR, but disassemble the contents of all sections, not just +those expected to contain instructions. +.Sp +This option also has a subtle effect on the disassembly of +instructions in code sections. When option \fB\-d\fR is in effect +objdump will assume that any symbols present in a code section occur +on the boundary between instructions and it will refuse to disassemble +across such a boundary. When option \fB\-D\fR is in effect however +this assumption is supressed. This means that it is possible for the +output of \fB\-d\fR and \fB\-D\fR to differ if, for example, data +is stored in code sections. +.Sp +If the target is an \s-1ARM\s0 architecture this switch also has the effect +of forcing the disassembler to decode pieces of data found in code +sections as if they were instructions. +.IP "\fB\-\-prefix\-addresses\fR" 4 +.IX Item "--prefix-addresses" +When disassembling, print the complete address on each line. This is +the older disassembly format. +.IP "\fB\-EB\fR" 4 +.IX Item "-EB" +.PD 0 +.IP "\fB\-EL\fR" 4 +.IX Item "-EL" +.IP "\fB\-\-endian={big|little}\fR" 4 +.IX Item "--endian={big|little}" +.PD +Specify the endianness of the object files. This only affects +disassembly. This can be useful when disassembling a file format which +does not describe endianness information, such as S\-records. +.IP "\fB\-f\fR" 4 +.IX Item "-f" +.PD 0 +.IP "\fB\-\-file\-headers\fR" 4 +.IX Item "--file-headers" +.PD +Display summary information from the overall header of +each of the \fIobjfile\fR files. +.IP "\fB\-F\fR" 4 +.IX Item "-F" +.PD 0 +.IP "\fB\-\-file\-offsets\fR" 4 +.IX Item "--file-offsets" +.PD +When disassembling sections, whenever a symbol is displayed, also +display the file offset of the region of data that is about to be +dumped. If zeroes are being skipped, then when disassembly resumes, +tell the user how many zeroes were skipped and the file offset of the +location from where the disassembly resumes. When dumping sections, +display the file offset of the location from where the dump starts. +.IP "\fB\-\-file\-start\-context\fR" 4 +.IX Item "--file-start-context" +Specify that when displaying interlisted source code/disassembly +(assumes \fB\-S\fR) from a file that has not yet been displayed, extend the +context to the start of the file. +.IP "\fB\-h\fR" 4 +.IX Item "-h" +.PD 0 +.IP "\fB\-\-section\-headers\fR" 4 +.IX Item "--section-headers" +.IP "\fB\-\-headers\fR" 4 +.IX Item "--headers" +.PD +Display summary information from the section headers of the +object file. +.Sp +File segments may be relocated to nonstandard addresses, for example by +using the \fB\-Ttext\fR, \fB\-Tdata\fR, or \fB\-Tbss\fR options to +\&\fBld\fR. However, some object file formats, such as a.out, do not +store the starting address of the file segments. In those situations, +although \fBld\fR relocates the sections correctly, using \fBobjdump +\&\-h\fR to list the file section headers cannot show the correct addresses. +Instead, it shows the usual addresses, which are implicit for the +target. +.Sp +Note, in some cases it is possible for a section to have both the +\&\s-1READONLY\s0 and the \s-1NOREAD\s0 attributes set. In such cases the \s-1NOREAD\s0 +attribute takes precedence, but \fBobjdump\fR will report both +since the exact setting of the flag bits might be important. +.IP "\fB\-H\fR" 4 +.IX Item "-H" +.PD 0 +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +.PD +Print a summary of the options to \fBobjdump\fR and exit. +.IP "\fB\-i\fR" 4 +.IX Item "-i" +.PD 0 +.IP "\fB\-\-info\fR" 4 +.IX Item "--info" +.PD +Display a list showing all architectures and object formats available +for specification with \fB\-b\fR or \fB\-m\fR. +.IP "\fB\-j\fR \fIname\fR" 4 +.IX Item "-j name" +.PD 0 +.IP "\fB\-\-section=\fR\fIname\fR" 4 +.IX Item "--section=name" +.PD +Display information only for section \fIname\fR. +.IP "\fB\-l\fR" 4 +.IX Item "-l" +.PD 0 +.IP "\fB\-\-line\-numbers\fR" 4 +.IX Item "--line-numbers" +.PD +Label the display (using debugging information) with the filename and +source line numbers corresponding to the object code or relocs shown. +Only useful with \fB\-d\fR, \fB\-D\fR, or \fB\-r\fR. +.IP "\fB\-m\fR \fImachine\fR" 4 +.IX Item "-m machine" +.PD 0 +.IP "\fB\-\-architecture=\fR\fImachine\fR" 4 +.IX Item "--architecture=machine" +.PD +Specify the architecture to use when disassembling object files. This +can be useful when disassembling object files which do not describe +architecture information, such as S\-records. You can list the available +architectures with the \fB\-i\fR option. +.Sp +If the target is an \s-1ARM\s0 architecture then this switch has an +additional effect. It restricts the disassembly to only those +instructions supported by the architecture specified by \fImachine\fR. +If it is necessary to use this switch because the input file does not +contain any architecture information, but it is also desired to +disassemble all the instructions use \fB\-marm\fR. +.IP "\fB\-M\fR \fIoptions\fR" 4 +.IX Item "-M options" +.PD 0 +.IP "\fB\-\-disassembler\-options=\fR\fIoptions\fR" 4 +.IX Item "--disassembler-options=options" +.PD +Pass target specific information to the disassembler. Only supported on +some targets. If it is necessary to specify more than one +disassembler option then multiple \fB\-M\fR options can be used or +can be placed together into a comma separated list. +.Sp +For \s-1ARC,\s0 \fBdsp\fR controls the printing of \s-1DSP\s0 instructions, +\&\fBspfp\fR selects the printing of \s-1FPX\s0 single precision \s-1FP\s0 +instructions, \fBdpfp\fR selects the printing of \s-1FPX\s0 double +precision \s-1FP\s0 instructions, \fBquarkse_em\fR selects the printing of +special QuarkSE-EM instructions, \fBfpuda\fR selects the printing +of double precision assist instructions, \fBfpus\fR selects the +printing of \s-1FPU\s0 single precision \s-1FP\s0 instructions, while \fBfpud\fR +selects the printing of \s-1FPU\s0 souble precision \s-1FP\s0 instructions. +Additionally, one can choose to have all the immediates printed in +hexadecimal using \fBhex\fR. By default, the short immediates are +printed using the decimal representation, while the long immediate +values are printed as hexadecimal. +.Sp +\&\fBcpu=...\fR allows to enforce a particular \s-1ISA\s0 when disassembling +instructions, overriding the \fB\-m\fR value or whatever is in the \s-1ELF\s0 file. +This might be useful to select \s-1ARC EM\s0 or \s-1HS ISA,\s0 because architecture is same +for those and disassembler relies on private \s-1ELF\s0 header data to decide if code +is for \s-1EM\s0 or \s-1HS.\s0 This option might be specified multiple times \- only the +latest value will be used. Valid values are same as for the assembler +\&\fB\-mcpu=...\fR option. +.Sp +If the target is an \s-1ARM\s0 architecture then this switch can be used to +select which register name set is used during disassembler. Specifying +\&\fB\-M reg-names-std\fR (the default) will select the register names as +used in \s-1ARM\s0's instruction set documentation, but with register 13 called +\&'sp', register 14 called 'lr' and register 15 called 'pc'. Specifying +\&\fB\-M reg-names-apcs\fR will select the name set used by the \s-1ARM\s0 +Procedure Call Standard, whilst specifying \fB\-M reg-names-raw\fR will +just use \fBr\fR followed by the register number. +.Sp +There are also two variants on the \s-1APCS\s0 register naming scheme enabled +by \fB\-M reg-names-atpcs\fR and \fB\-M reg-names-special-atpcs\fR which +use the ARM/Thumb Procedure Call Standard naming conventions. (Either +with the normal register names or the special register names). +.Sp +This option can also be used for \s-1ARM\s0 architectures to force the +disassembler to interpret all instructions as Thumb instructions by +using the switch \fB\-\-disassembler\-options=force\-thumb\fR. This can be +useful when attempting to disassemble thumb code produced by other +compilers. +.Sp +For the x86, some of the options duplicate functions of the \fB\-m\fR +switch, but allow finer grained control. Multiple selections from the +following may be specified as a comma separated string. +.RS 4 +.ie n .IP """x86\-64""" 4 +.el .IP "\f(CWx86\-64\fR" 4 +.IX Item "x86-64" +.PD 0 +.ie n .IP """i386""" 4 +.el .IP "\f(CWi386\fR" 4 +.IX Item "i386" +.ie n .IP """i8086""" 4 +.el .IP "\f(CWi8086\fR" 4 +.IX Item "i8086" +.PD +Select disassembly for the given architecture. +.ie n .IP """intel""" 4 +.el .IP "\f(CWintel\fR" 4 +.IX Item "intel" +.PD 0 +.ie n .IP """att""" 4 +.el .IP "\f(CWatt\fR" 4 +.IX Item "att" +.PD +Select between intel syntax mode and \s-1AT&T\s0 syntax mode. +.ie n .IP """amd64""" 4 +.el .IP "\f(CWamd64\fR" 4 +.IX Item "amd64" +.PD 0 +.ie n .IP """intel64""" 4 +.el .IP "\f(CWintel64\fR" 4 +.IX Item "intel64" +.PD +Select between \s-1AMD64 ISA\s0 and Intel64 \s-1ISA.\s0 +.ie n .IP """intel\-mnemonic""" 4 +.el .IP "\f(CWintel\-mnemonic\fR" 4 +.IX Item "intel-mnemonic" +.PD 0 +.ie n .IP """att\-mnemonic""" 4 +.el .IP "\f(CWatt\-mnemonic\fR" 4 +.IX Item "att-mnemonic" +.PD +Select between intel mnemonic mode and \s-1AT&T\s0 mnemonic mode. +Note: \f(CW\*(C`intel\-mnemonic\*(C'\fR implies \f(CW\*(C`intel\*(C'\fR and +\&\f(CW\*(C`att\-mnemonic\*(C'\fR implies \f(CW\*(C`att\*(C'\fR. +.ie n .IP """addr64""" 4 +.el .IP "\f(CWaddr64\fR" 4 +.IX Item "addr64" +.PD 0 +.ie n .IP """addr32""" 4 +.el .IP "\f(CWaddr32\fR" 4 +.IX Item "addr32" +.ie n .IP """addr16""" 4 +.el .IP "\f(CWaddr16\fR" 4 +.IX Item "addr16" +.ie n .IP """data32""" 4 +.el .IP "\f(CWdata32\fR" 4 +.IX Item "data32" +.ie n .IP """data16""" 4 +.el .IP "\f(CWdata16\fR" 4 +.IX Item "data16" +.PD +Specify the default address size and operand size. These four options +will be overridden if \f(CW\*(C`x86\-64\*(C'\fR, \f(CW\*(C`i386\*(C'\fR or \f(CW\*(C`i8086\*(C'\fR +appear later in the option string. +.ie n .IP """suffix""" 4 +.el .IP "\f(CWsuffix\fR" 4 +.IX Item "suffix" +When in \s-1AT&T\s0 mode, instructs the disassembler to print a mnemonic +suffix even when the suffix could be inferred by the operands. +.RE +.RS 4 +.Sp +For PowerPC, the \fB\-M\fR argument \fBraw\fR selects +disasssembly of hardware insns rather than aliases. For example, you +will see \f(CW\*(C`rlwinm\*(C'\fR rather than \f(CW\*(C`clrlwi\*(C'\fR, and \f(CW\*(C`addi\*(C'\fR +rather than \f(CW\*(C`li\*(C'\fR. All of the \fB\-m\fR arguments for +\&\fBgas\fR that select a \s-1CPU\s0 are supported. These are: +\&\fB403\fR, \fB405\fR, \fB440\fR, \fB464\fR, \fB476\fR, +\&\fB601\fR, \fB603\fR, \fB604\fR, \fB620\fR, \fB7400\fR, +\&\fB7410\fR, \fB7450\fR, \fB7455\fR, \fB750cl\fR, +\&\fB821\fR, \fB850\fR, \fB860\fR, \fBa2\fR, \fBbooke\fR, +\&\fBbooke32\fR, \fBcell\fR, \fBcom\fR, \fBe200z4\fR, +\&\fBe300\fR, \fBe500\fR, \fBe500mc\fR, \fBe500mc64\fR, +\&\fBe500x2\fR, \fBe5500\fR, \fBe6500\fR, \fBefs\fR, +\&\fBpower4\fR, \fBpower5\fR, \fBpower6\fR, \fBpower7\fR, +\&\fBpower8\fR, \fBpower9\fR, \fBppc\fR, \fBppc32\fR, +\&\fBppc64\fR, \fBppc64bridge\fR, \fBppcps\fR, \fBpwr\fR, +\&\fBpwr2\fR, \fBpwr4\fR, \fBpwr5\fR, \fBpwr5x\fR, +\&\fBpwr6\fR, \fBpwr7\fR, \fBpwr8\fR, \fBpwr9\fR, +\&\fBpwrx\fR, \fBtitan\fR, and \fBvle\fR. +\&\fB32\fR and \fB64\fR modify the default or a prior \s-1CPU\s0 +selection, disabling and enabling 64\-bit insns respectively. In +addition, \fBaltivec\fR, \fBany\fR, \fBhtm\fR, \fBvsx\fR, +and \fBspe\fR add capabilities to a previous \fIor later\fR \s-1CPU\s0 +selection. \fBany\fR will disassemble any opcode known to +binutils, but in cases where an opcode has two different meanings or +different arguments, you may not see the disassembly you expect. +If you disassemble without giving a \s-1CPU\s0 selection, a default will be +chosen from information gleaned by \s-1BFD\s0 from the object files headers, +but the result again may not be as you expect. +.Sp +For \s-1MIPS,\s0 this option controls the printing of instruction mnemonic +names and register names in disassembled instructions. Multiple +selections from the following may be specified as a comma separated +string, and invalid options are ignored: +.ie n .IP """no\-aliases""" 4 +.el .IP "\f(CWno\-aliases\fR" 4 +.IX Item "no-aliases" +Print the 'raw' instruction mnemonic instead of some pseudo +instruction mnemonic. I.e., print 'daddu' or 'or' instead of 'move', +\&'sll' instead of 'nop', etc. +.ie n .IP """msa""" 4 +.el .IP "\f(CWmsa\fR" 4 +.IX Item "msa" +Disassemble \s-1MSA\s0 instructions. +.ie n .IP """virt""" 4 +.el .IP "\f(CWvirt\fR" 4 +.IX Item "virt" +Disassemble the virtualization \s-1ASE\s0 instructions. +.ie n .IP """xpa""" 4 +.el .IP "\f(CWxpa\fR" 4 +.IX Item "xpa" +Disassemble the eXtended Physical Address (\s-1XPA\s0) \s-1ASE\s0 instructions. +.ie n .IP """gpr\-names=\fIABI\fP""" 4 +.el .IP "\f(CWgpr\-names=\f(CIABI\f(CW\fR" 4 +.IX Item "gpr-names=ABI" +Print \s-1GPR\s0 (general-purpose register) names as appropriate +for the specified \s-1ABI.\s0 By default, \s-1GPR\s0 names are selected according to +the \s-1ABI\s0 of the binary being disassembled. +.ie n .IP """fpr\-names=\fIABI\fP""" 4 +.el .IP "\f(CWfpr\-names=\f(CIABI\f(CW\fR" 4 +.IX Item "fpr-names=ABI" +Print \s-1FPR\s0 (floating-point register) names as +appropriate for the specified \s-1ABI.\s0 By default, \s-1FPR\s0 numbers are printed +rather than names. +.ie n .IP """cp0\-names=\fIARCH\fP""" 4 +.el .IP "\f(CWcp0\-names=\f(CIARCH\f(CW\fR" 4 +.IX Item "cp0-names=ARCH" +Print \s-1CP0\s0 (system control coprocessor; coprocessor 0) register names +as appropriate for the \s-1CPU\s0 or architecture specified by +\&\fI\s-1ARCH\s0\fR. By default, \s-1CP0\s0 register names are selected according to +the architecture and \s-1CPU\s0 of the binary being disassembled. +.ie n .IP """hwr\-names=\fIARCH\fP""" 4 +.el .IP "\f(CWhwr\-names=\f(CIARCH\f(CW\fR" 4 +.IX Item "hwr-names=ARCH" +Print \s-1HWR\s0 (hardware register, used by the \f(CW\*(C`rdhwr\*(C'\fR instruction) names +as appropriate for the \s-1CPU\s0 or architecture specified by +\&\fI\s-1ARCH\s0\fR. By default, \s-1HWR\s0 names are selected according to +the architecture and \s-1CPU\s0 of the binary being disassembled. +.ie n .IP """reg\-names=\fIABI\fP""" 4 +.el .IP "\f(CWreg\-names=\f(CIABI\f(CW\fR" 4 +.IX Item "reg-names=ABI" +Print \s-1GPR\s0 and \s-1FPR\s0 names as appropriate for the selected \s-1ABI.\s0 +.ie n .IP """reg\-names=\fIARCH\fP""" 4 +.el .IP "\f(CWreg\-names=\f(CIARCH\f(CW\fR" 4 +.IX Item "reg-names=ARCH" +Print CPU-specific register names (\s-1CP0\s0 register and \s-1HWR\s0 names) +as appropriate for the selected \s-1CPU\s0 or architecture. +.RE +.RS 4 +.Sp +For any of the options listed above, \fI\s-1ABI\s0\fR or +\&\fI\s-1ARCH\s0\fR may be specified as \fBnumeric\fR to have numbers printed +rather than names, for the selected types of registers. +You can list the available values of \fI\s-1ABI\s0\fR and \fI\s-1ARCH\s0\fR using +the \fB\-\-help\fR option. +.Sp +For \s-1VAX,\s0 you can specify function entry addresses with \fB\-M +entry:0xf00ba\fR. You can use this multiple times to properly +disassemble \s-1VAX\s0 binary files that don't contain symbol tables (like +\&\s-1ROM\s0 dumps). In these cases, the function entry mask would otherwise +be decoded as \s-1VAX\s0 instructions, which would probably lead the rest +of the function being wrongly disassembled. +.RE +.IP "\fB\-p\fR" 4 +.IX Item "-p" +.PD 0 +.IP "\fB\-\-private\-headers\fR" 4 +.IX Item "--private-headers" +.PD +Print information that is specific to the object file format. The exact +information printed depends upon the object file format. For some +object file formats, no additional information is printed. +.IP "\fB\-P\fR \fIoptions\fR" 4 +.IX Item "-P options" +.PD 0 +.IP "\fB\-\-private=\fR\fIoptions\fR" 4 +.IX Item "--private=options" +.PD +Print information that is specific to the object file format. The +argument \fIoptions\fR is a comma separated list that depends on the +format (the lists of options is displayed with the help). +.Sp +For \s-1XCOFF,\s0 the available options are: +.RS 4 +.ie n .IP """header""" 4 +.el .IP "\f(CWheader\fR" 4 +.IX Item "header" +.PD 0 +.ie n .IP """aout""" 4 +.el .IP "\f(CWaout\fR" 4 +.IX Item "aout" +.ie n .IP """sections""" 4 +.el .IP "\f(CWsections\fR" 4 +.IX Item "sections" +.ie n .IP """syms""" 4 +.el .IP "\f(CWsyms\fR" 4 +.IX Item "syms" +.ie n .IP """relocs""" 4 +.el .IP "\f(CWrelocs\fR" 4 +.IX Item "relocs" +.ie n .IP """lineno,""" 4 +.el .IP "\f(CWlineno,\fR" 4 +.IX Item "lineno," +.ie n .IP """loader""" 4 +.el .IP "\f(CWloader\fR" 4 +.IX Item "loader" +.ie n .IP """except""" 4 +.el .IP "\f(CWexcept\fR" 4 +.IX Item "except" +.ie n .IP """typchk""" 4 +.el .IP "\f(CWtypchk\fR" 4 +.IX Item "typchk" +.ie n .IP """traceback""" 4 +.el .IP "\f(CWtraceback\fR" 4 +.IX Item "traceback" +.ie n .IP """toc""" 4 +.el .IP "\f(CWtoc\fR" 4 +.IX Item "toc" +.ie n .IP """ldinfo""" 4 +.el .IP "\f(CWldinfo\fR" 4 +.IX Item "ldinfo" +.RE +.RS 4 +.PD +.Sp +Not all object formats support this option. In particular the \s-1ELF\s0 +format does not use it. +.RE +.IP "\fB\-r\fR" 4 +.IX Item "-r" +.PD 0 +.IP "\fB\-\-reloc\fR" 4 +.IX Item "--reloc" +.PD +Print the relocation entries of the file. If used with \fB\-d\fR or +\&\fB\-D\fR, the relocations are printed interspersed with the +disassembly. +.IP "\fB\-R\fR" 4 +.IX Item "-R" +.PD 0 +.IP "\fB\-\-dynamic\-reloc\fR" 4 +.IX Item "--dynamic-reloc" +.PD +Print the dynamic relocation entries of the file. This is only +meaningful for dynamic objects, such as certain types of shared +libraries. As for \fB\-r\fR, if used with \fB\-d\fR or +\&\fB\-D\fR, the relocations are printed interspersed with the +disassembly. +.IP "\fB\-s\fR" 4 +.IX Item "-s" +.PD 0 +.IP "\fB\-\-full\-contents\fR" 4 +.IX Item "--full-contents" +.PD +Display the full contents of any sections requested. By default all +non-empty sections are displayed. +.IP "\fB\-S\fR" 4 +.IX Item "-S" +.PD 0 +.IP "\fB\-\-source\fR" 4 +.IX Item "--source" +.PD +Display source code intermixed with disassembly, if possible. Implies +\&\fB\-d\fR. +.IP "\fB\-\-prefix=\fR\fIprefix\fR" 4 +.IX Item "--prefix=prefix" +Specify \fIprefix\fR to add to the absolute paths when used with +\&\fB\-S\fR. +.IP "\fB\-\-prefix\-strip=\fR\fIlevel\fR" 4 +.IX Item "--prefix-strip=level" +Indicate how many initial directory names to strip off the hardwired +absolute paths. It has no effect without \fB\-\-prefix=\fR\fIprefix\fR. +.IP "\fB\-\-show\-raw\-insn\fR" 4 +.IX Item "--show-raw-insn" +When disassembling instructions, print the instruction in hex as well as +in symbolic form. This is the default except when +\&\fB\-\-prefix\-addresses\fR is used. +.IP "\fB\-\-no\-show\-raw\-insn\fR" 4 +.IX Item "--no-show-raw-insn" +When disassembling instructions, do not print the instruction bytes. +This is the default when \fB\-\-prefix\-addresses\fR is used. +.IP "\fB\-\-insn\-width=\fR\fIwidth\fR" 4 +.IX Item "--insn-width=width" +Display \fIwidth\fR bytes on a single line when disassembling +instructions. +.IP "\fB\-W[lLiaprmfFsoRtUuTgAckK]\fR" 4 +.IX Item "-W[lLiaprmfFsoRtUuTgAckK]" +.PD 0 +.IP "\fB\-\-dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames\-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow\-links]\fR" 4 +.IX Item "--dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]" +.PD +Displays the contents of the \s-1DWARF\s0 debug sections in the file, if any +are present. Compressed debug sections are automatically decompressed +(temporarily) before they are displayed. If one or more of the +optional letters or words follows the switch then only those type(s) +of data will be dumped. The letters and words refer to the following +information: +.RS 4 +.ie n .IP """a""" 4 +.el .IP "\f(CWa\fR" 4 +.IX Item "a" +.PD 0 +.ie n .IP """=abbrev""" 4 +.el .IP "\f(CW=abbrev\fR" 4 +.IX Item "=abbrev" +.PD +Displays the contents of the \fB.debug_abbrev\fR section. +.ie n .IP """A""" 4 +.el .IP "\f(CWA\fR" 4 +.IX Item "A" +.PD 0 +.ie n .IP """=addr""" 4 +.el .IP "\f(CW=addr\fR" 4 +.IX Item "=addr" +.PD +Displays the contents of the \fB.debug_addr\fR section. +.ie n .IP """c""" 4 +.el .IP "\f(CWc\fR" 4 +.IX Item "c" +.PD 0 +.ie n .IP """=cu_index""" 4 +.el .IP "\f(CW=cu_index\fR" 4 +.IX Item "=cu_index" +.PD +Displays the contents of the \fB.debug_cu_index\fR and/or +\&\fB.debug_tu_index\fR sections. +.ie n .IP """f""" 4 +.el .IP "\f(CWf\fR" 4 +.IX Item "f" +.PD 0 +.ie n .IP """=frames""" 4 +.el .IP "\f(CW=frames\fR" 4 +.IX Item "=frames" +.PD +Display the raw contents of a \fB.debug_frame\fR section. +.ie n .IP """F""" 4 +.el .IP "\f(CWF\fR" 4 +.IX Item "F" +.PD 0 +.ie n .IP """=frame\-interp""" 4 +.el .IP "\f(CW=frame\-interp\fR" 4 +.IX Item "=frame-interp" +.PD +Display the interpreted contents of a \fB.debug_frame\fR section. +.ie n .IP """g""" 4 +.el .IP "\f(CWg\fR" 4 +.IX Item "g" +.PD 0 +.ie n .IP """=gdb_index""" 4 +.el .IP "\f(CW=gdb_index\fR" 4 +.IX Item "=gdb_index" +.PD +Displays the contents of the \fB.gdb_index\fR and/or +\&\fB.debug_names\fR sections. +.ie n .IP """i""" 4 +.el .IP "\f(CWi\fR" 4 +.IX Item "i" +.PD 0 +.ie n .IP """=info""" 4 +.el .IP "\f(CW=info\fR" 4 +.IX Item "=info" +.PD +Displays the contents of the \fB.debug_info\fR section. Note: the +output from this option can also be restricted by the use of the +\&\fB\-\-dwarf\-depth\fR and \fB\-\-dwarf\-start\fR options. +.ie n .IP """k""" 4 +.el .IP "\f(CWk\fR" 4 +.IX Item "k" +.PD 0 +.ie n .IP """=links""" 4 +.el .IP "\f(CW=links\fR" 4 +.IX Item "=links" +.PD +Displays the contents of the \fB.gnu_debuglink\fR and/or +\&\fB.gnu_debugaltlink\fR sections. Also displays the link to a +separate dwarf object file (dwo), if one is specified by the +DW_AT_GNU_dwo_name or DW_AT_dwo_name attributes in the +\&\fB.debug_info\fR section. +.ie n .IP """K""" 4 +.el .IP "\f(CWK\fR" 4 +.IX Item "K" +.PD 0 +.ie n .IP """=follow\-links""" 4 +.el .IP "\f(CW=follow\-links\fR" 4 +.IX Item "=follow-links" +.PD +Display the contents of any selected debug sections that are found in +a linked, separate debug info file. This can result in multiple +versions of the same debug section being displayed if both the main +file and the separate debug info file contain sections with the same +name. +.Sp +In addition, when displaying \s-1DWARF\s0 attributes, if a form is found that +references the separate debug info file, then the referenced contents +will also be displayed. +.ie n .IP """l""" 4 +.el .IP "\f(CWl\fR" 4 +.IX Item "l" +.PD 0 +.ie n .IP """=rawline""" 4 +.el .IP "\f(CW=rawline\fR" 4 +.IX Item "=rawline" +.PD +Displays the contents of the \fB.debug_line\fR section in a raw +format. +.ie n .IP """L""" 4 +.el .IP "\f(CWL\fR" 4 +.IX Item "L" +.PD 0 +.ie n .IP """=decodedline""" 4 +.el .IP "\f(CW=decodedline\fR" 4 +.IX Item "=decodedline" +.PD +Displays the interpreted contents of the \fB.debug_line\fR section. +.ie n .IP """m""" 4 +.el .IP "\f(CWm\fR" 4 +.IX Item "m" +.PD 0 +.ie n .IP """=macro""" 4 +.el .IP "\f(CW=macro\fR" 4 +.IX Item "=macro" +.PD +Displays the contents of the \fB.debug_macro\fR and/or +\&\fB.debug_macinfo\fR sections. +.ie n .IP """o""" 4 +.el .IP "\f(CWo\fR" 4 +.IX Item "o" +.PD 0 +.ie n .IP """=loc""" 4 +.el .IP "\f(CW=loc\fR" 4 +.IX Item "=loc" +.PD +Displays the contents of the \fB.debug_loc\fR and/or +\&\fB.debug_loclists\fR sections. +.ie n .IP """p""" 4 +.el .IP "\f(CWp\fR" 4 +.IX Item "p" +.PD 0 +.ie n .IP """=pubnames""" 4 +.el .IP "\f(CW=pubnames\fR" 4 +.IX Item "=pubnames" +.PD +Displays the contents of the \fB.debug_pubnames\fR and/or +\&\fB.debug_gnu_pubnames\fR sections. +.ie n .IP """r""" 4 +.el .IP "\f(CWr\fR" 4 +.IX Item "r" +.PD 0 +.ie n .IP """=aranges""" 4 +.el .IP "\f(CW=aranges\fR" 4 +.IX Item "=aranges" +.PD +Displays the contents of the \fB.debug_aranges\fR section. +.ie n .IP """R""" 4 +.el .IP "\f(CWR\fR" 4 +.IX Item "R" +.PD 0 +.ie n .IP """=Ranges""" 4 +.el .IP "\f(CW=Ranges\fR" 4 +.IX Item "=Ranges" +.PD +Displays the contents of the \fB.debug_ranges\fR and/or +\&\fB.debug_rnglists\fR sections. +.ie n .IP """s""" 4 +.el .IP "\f(CWs\fR" 4 +.IX Item "s" +.PD 0 +.ie n .IP """=str""" 4 +.el .IP "\f(CW=str\fR" 4 +.IX Item "=str" +.PD +Displays the contents of the \fB.debug_str\fR, \fB.debug_line_str\fR +and/or \fB.debug_str_offsets\fR sections. +.ie n .IP """t""" 4 +.el .IP "\f(CWt\fR" 4 +.IX Item "t" +.PD 0 +.ie n .IP """=pubtype""" 4 +.el .IP "\f(CW=pubtype\fR" 4 +.IX Item "=pubtype" +.PD +Displays the contents of the \fB.debug_pubtypes\fR and/or +\&\fB.debug_gnu_pubtypes\fR sections. +.ie n .IP """T""" 4 +.el .IP "\f(CWT\fR" 4 +.IX Item "T" +.PD 0 +.ie n .IP """=trace_aranges""" 4 +.el .IP "\f(CW=trace_aranges\fR" 4 +.IX Item "=trace_aranges" +.PD +Displays the contents of the \fB.trace_aranges\fR section. +.ie n .IP """u""" 4 +.el .IP "\f(CWu\fR" 4 +.IX Item "u" +.PD 0 +.ie n .IP """=trace_abbrev""" 4 +.el .IP "\f(CW=trace_abbrev\fR" 4 +.IX Item "=trace_abbrev" +.PD +Displays the contents of the \fB.trace_abbrev\fR section. +.ie n .IP """U""" 4 +.el .IP "\f(CWU\fR" 4 +.IX Item "U" +.PD 0 +.ie n .IP """=trace_info""" 4 +.el .IP "\f(CW=trace_info\fR" 4 +.IX Item "=trace_info" +.PD +Displays the contents of the \fB.trace_info\fR section. +.RE +.RS 4 +.Sp +Note: displaying the contents of \fB.debug_static_funcs\fR, +\&\fB.debug_static_vars\fR and \fBdebug_weaknames\fR sections is not +currently supported. +.RE +.IP "\fB\-\-dwarf\-depth=\fR\fIn\fR" 4 +.IX Item "--dwarf-depth=n" +Limit the dump of the \f(CW\*(C`.debug_info\*(C'\fR section to \fIn\fR children. +This is only useful with \fB\-\-debug\-dump=info\fR. The default is +to print all DIEs; the special value 0 for \fIn\fR will also have this +effect. +.Sp +With a non-zero value for \fIn\fR, DIEs at or deeper than \fIn\fR +levels will not be printed. The range for \fIn\fR is zero-based. +.IP "\fB\-\-dwarf\-start=\fR\fIn\fR" 4 +.IX Item "--dwarf-start=n" +Print only DIEs beginning with the \s-1DIE\s0 numbered \fIn\fR. This is only +useful with \fB\-\-debug\-dump=info\fR. +.Sp +If specified, this option will suppress printing of any header +information and all DIEs before the \s-1DIE\s0 numbered \fIn\fR. Only +siblings and children of the specified \s-1DIE\s0 will be printed. +.Sp +This can be used in conjunction with \fB\-\-dwarf\-depth\fR. +.IP "\fB\-\-dwarf\-check\fR" 4 +.IX Item "--dwarf-check" +Enable additional checks for consistency of Dwarf information. +.IP "\fB\-G\fR" 4 +.IX Item "-G" +.PD 0 +.IP "\fB\-\-stabs\fR" 4 +.IX Item "--stabs" +.PD +Display the full contents of any sections requested. Display the +contents of the .stab and .stab.index and .stab.excl sections from an +\&\s-1ELF\s0 file. This is only useful on systems (such as Solaris 2.0) in which +\&\f(CW\*(C`.stab\*(C'\fR debugging symbol-table entries are carried in an \s-1ELF\s0 +section. In most other file formats, debugging symbol-table entries are +interleaved with linkage symbols, and are visible in the \fB\-\-syms\fR +output. +.IP "\fB\-\-start\-address=\fR\fIaddress\fR" 4 +.IX Item "--start-address=address" +Start displaying data at the specified address. This affects the output +of the \fB\-d\fR, \fB\-r\fR and \fB\-s\fR options. +.IP "\fB\-\-stop\-address=\fR\fIaddress\fR" 4 +.IX Item "--stop-address=address" +Stop displaying data at the specified address. This affects the output +of the \fB\-d\fR, \fB\-r\fR and \fB\-s\fR options. +.IP "\fB\-t\fR" 4 +.IX Item "-t" +.PD 0 +.IP "\fB\-\-syms\fR" 4 +.IX Item "--syms" +.PD +Print the symbol table entries of the file. +This is similar to the information provided by the \fBnm\fR program, +although the display format is different. The format of the output +depends upon the format of the file being dumped, but there are two main +types. One looks like this: +.Sp +.Vb 2 +\& [ 4](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss +\& [ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 fred +.Ve +.Sp +where the number inside the square brackets is the number of the entry +in the symbol table, the \fIsec\fR number is the section number, the +\&\fIfl\fR value are the symbol's flag bits, the \fIty\fR number is the +symbol's type, the \fIscl\fR number is the symbol's storage class and +the \fInx\fR value is the number of auxilary entries associated with +the symbol. The last two fields are the symbol's value and its name. +.Sp +The other common output format, usually seen with \s-1ELF\s0 based files, +looks like this: +.Sp +.Vb 2 +\& 00000000 l d .bss 00000000 .bss +\& 00000000 g .text 00000000 fred +.Ve +.Sp +Here the first number is the symbol's value (sometimes refered to as +its address). The next field is actually a set of characters and +spaces indicating the flag bits that are set on the symbol. These +characters are described below. Next is the section with which the +symbol is associated or \fI*ABS*\fR if the section is absolute (ie +not connected with any section), or \fI*UND*\fR if the section is +referenced in the file being dumped, but not defined there. +.Sp +After the section name comes another field, a number, which for common +symbols is the alignment and for other symbol is the size. Finally +the symbol's name is displayed. +.Sp +The flag characters are divided into 7 groups as follows: +.RS 4 +.ie n .IP """l""" 4 +.el .IP "\f(CWl\fR" 4 +.IX Item "l" +.PD 0 +.ie n .IP """g""" 4 +.el .IP "\f(CWg\fR" 4 +.IX Item "g" +.ie n .IP """u""" 4 +.el .IP "\f(CWu\fR" 4 +.IX Item "u" +.ie n .IP """!""" 4 +.el .IP "\f(CW!\fR" 4 +.IX Item "!" +.PD +The symbol is a local (l), global (g), unique global (u), neither +global nor local (a space) or both global and local (!). A +symbol can be neither local or global for a variety of reasons, e.g., +because it is used for debugging, but it is probably an indication of +a bug if it is ever both local and global. Unique global symbols are +a \s-1GNU\s0 extension to the standard set of \s-1ELF\s0 symbol bindings. For such +a symbol the dynamic linker will make sure that in the entire process +there is just one symbol with this name and type in use. +.ie n .IP """w""" 4 +.el .IP "\f(CWw\fR" 4 +.IX Item "w" +The symbol is weak (w) or strong (a space). +.ie n .IP """C""" 4 +.el .IP "\f(CWC\fR" 4 +.IX Item "C" +The symbol denotes a constructor (C) or an ordinary symbol (a space). +.ie n .IP """W""" 4 +.el .IP "\f(CWW\fR" 4 +.IX Item "W" +The symbol is a warning (W) or a normal symbol (a space). A warning +symbol's name is a message to be displayed if the symbol following the +warning symbol is ever referenced. +.ie n .IP """I""" 4 +.el .IP "\f(CWI\fR" 4 +.IX Item "I" +.PD 0 +.ie n .IP """i""" 4 +.el .IP "\f(CWi\fR" 4 +.IX Item "i" +.PD +The symbol is an indirect reference to another symbol (I), a function +to be evaluated during reloc processing (i) or a normal symbol (a +space). +.ie n .IP """d""" 4 +.el .IP "\f(CWd\fR" 4 +.IX Item "d" +.PD 0 +.ie n .IP """D""" 4 +.el .IP "\f(CWD\fR" 4 +.IX Item "D" +.PD +The symbol is a debugging symbol (d) or a dynamic symbol (D) or a +normal symbol (a space). +.ie n .IP """F""" 4 +.el .IP "\f(CWF\fR" 4 +.IX Item "F" +.PD 0 +.ie n .IP """f""" 4 +.el .IP "\f(CWf\fR" 4 +.IX Item "f" +.ie n .IP """O""" 4 +.el .IP "\f(CWO\fR" 4 +.IX Item "O" +.PD +The symbol is the name of a function (F) or a file (f) or an object +(O) or just a normal symbol (a space). +.RE +.RS 4 +.RE +.IP "\fB\-T\fR" 4 +.IX Item "-T" +.PD 0 +.IP "\fB\-\-dynamic\-syms\fR" 4 +.IX Item "--dynamic-syms" +.PD +Print the dynamic symbol table entries of the file. This is only +meaningful for dynamic objects, such as certain types of shared +libraries. This is similar to the information provided by the \fBnm\fR +program when given the \fB\-D\fR (\fB\-\-dynamic\fR) option. +.Sp +The output format is similar to that produced by the \fB\-\-syms\fR +option, except that an extra field is inserted before the symbol's +name, giving the version information associated with the symbol. +If the version is the default version to be used when resolving +unversioned references to the symbol then it's displayed as is, +otherwise it's put into parentheses. +.IP "\fB\-\-special\-syms\fR" 4 +.IX Item "--special-syms" +When displaying symbols include those which the target considers to be +special in some way and which would not normally be of interest to the +user. +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Print the version number of \fBobjdump\fR and exit. +.IP "\fB\-x\fR" 4 +.IX Item "-x" +.PD 0 +.IP "\fB\-\-all\-headers\fR" 4 +.IX Item "--all-headers" +.PD +Display all available header information, including the symbol table and +relocation entries. Using \fB\-x\fR is equivalent to specifying all of +\&\fB\-a \-f \-h \-p \-r \-t\fR. +.IP "\fB\-w\fR" 4 +.IX Item "-w" +.PD 0 +.IP "\fB\-\-wide\fR" 4 +.IX Item "--wide" +.PD +Format some lines for output devices that have more than 80 columns. +Also do not truncate symbol names when they are displayed. +.IP "\fB\-z\fR" 4 +.IX Item "-z" +.PD 0 +.IP "\fB\-\-disassemble\-zeroes\fR" 4 +.IX Item "--disassemble-zeroes" +.PD +Normally the disassembly output will skip blocks of zeroes. This +option directs the disassembler to disassemble those blocks, just like +any other data. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fInm\fR\|(1), \fIreadelf\fR\|(1), and the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/ranlib.1 b/support/sdbinutils/binutils/doc/ranlib.1 new file mode 100644 index 0000000..e058a88 --- /dev/null +++ b/support/sdbinutils/binutils/doc/ranlib.1 @@ -0,0 +1,223 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "RANLIB 1" +.TH RANLIB 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +ranlib \- generate index to archive. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +ranlib [\fB\-\-plugin\fR \fIname\fR] [\fB\-DhHvVt\fR] \fIarchive\fR +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\fBranlib\fR generates an index to the contents of an archive and +stores it in the archive. The index lists each symbol defined by a +member of an archive that is a relocatable object file. +.PP +You may use \fBnm \-s\fR or \fBnm \-\-print\-armap\fR to list this index. +.PP +An archive with such an index speeds up linking to the library and +allows routines in the library to call each other without regard to +their placement in the archive. +.PP +The \s-1GNU\s0 \fBranlib\fR program is another form of \s-1GNU\s0 \fBar\fR; running +\&\fBranlib\fR is completely equivalent to executing \fBar \-s\fR. +.SH "OPTIONS" +.IX Header "OPTIONS" +.IP "\fB\-h\fR" 4 +.IX Item "-h" +.PD 0 +.IP "\fB\-H\fR" 4 +.IX Item "-H" +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +.PD +Show usage information for \fBranlib\fR. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +.PD 0 +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Show the version number of \fBranlib\fR. +.IP "\fB\-D\fR" 4 +.IX Item "-D" +Operate in \fIdeterministic\fR mode. The symbol map archive member's +header will show zero for the \s-1UID, GID,\s0 and timestamp. When this +option is used, multiple runs will produce identical output files. +.Sp +If \fIbinutils\fR was configured with +\&\fB\-\-enable\-deterministic\-archives\fR, then this mode is on by +default. It can be disabled with the \fB\-U\fR option, described +below. +.IP "\fB\-t\fR" 4 +.IX Item "-t" +Update the timestamp of the symbol map of an archive. +.IP "\fB\-U\fR" 4 +.IX Item "-U" +Do \fInot\fR operate in \fIdeterministic\fR mode. This is the +inverse of the \fB\-D\fR option, above: the archive index will get +actual \s-1UID, GID,\s0 timestamp, and file mode values. +.Sp +If \fIbinutils\fR was configured \fIwithout\fR +\&\fB\-\-enable\-deterministic\-archives\fR, then this mode is on by +default. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fIar\fR\|(1), \fInm\fR\|(1), and the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/readelf.1 b/support/sdbinutils/binutils/doc/readelf.1 new file mode 100644 index 0000000..f1ad95a --- /dev/null +++ b/support/sdbinutils/binutils/doc/readelf.1 @@ -0,0 +1,688 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "READELF 1" +.TH READELF 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +readelf \- Displays information about ELF files. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +readelf [\fB\-a\fR|\fB\-\-all\fR] + [\fB\-h\fR|\fB\-\-file\-header\fR] + [\fB\-l\fR|\fB\-\-program\-headers\fR|\fB\-\-segments\fR] + [\fB\-S\fR|\fB\-\-section\-headers\fR|\fB\-\-sections\fR] + [\fB\-g\fR|\fB\-\-section\-groups\fR] + [\fB\-t\fR|\fB\-\-section\-details\fR] + [\fB\-e\fR|\fB\-\-headers\fR] + [\fB\-s\fR|\fB\-\-syms\fR|\fB\-\-symbols\fR] + [\fB\-\-dyn\-syms\fR] + [\fB\-n\fR|\fB\-\-notes\fR] + [\fB\-r\fR|\fB\-\-relocs\fR] + [\fB\-u\fR|\fB\-\-unwind\fR] + [\fB\-d\fR|\fB\-\-dynamic\fR] + [\fB\-V\fR|\fB\-\-version\-info\fR] + [\fB\-A\fR|\fB\-\-arch\-specific\fR] + [\fB\-D\fR|\fB\-\-use\-dynamic\fR] + [\fB\-x\fR |\fB\-\-hex\-dump=\fR] + [\fB\-p\fR |\fB\-\-string\-dump=\fR] + [\fB\-R\fR |\fB\-\-relocated\-dump=\fR] + [\fB\-z\fR|\fB\-\-decompress\fR] + [\fB\-c\fR|\fB\-\-archive\-index\fR] + [\fB\-w[lLiaprmfFsoRtUuTgAckK]\fR| + \fB\-\-debug\-dump\fR[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames\-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow\-links]] + [\fB\-\-dwarf\-depth=\fR\fIn\fR] + [\fB\-\-dwarf\-start=\fR\fIn\fR] + [\fB\-I\fR|\fB\-\-histogram\fR] + [\fB\-v\fR|\fB\-\-version\fR] + [\fB\-W\fR|\fB\-\-wide\fR] + [\fB\-H\fR|\fB\-\-help\fR] + \fIelffile\fR... +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\fBreadelf\fR displays information about one or more \s-1ELF\s0 format object +files. The options control what particular information to display. +.PP +\&\fIelffile\fR... are the object files to be examined. 32\-bit and +64\-bit \s-1ELF\s0 files are supported, as are archives containing \s-1ELF\s0 files. +.PP +This program performs a similar function to \fBobjdump\fR but it +goes into more detail and it exists independently of the \s-1BFD\s0 +library, so if there is a bug in \s-1BFD\s0 then readelf will not be +affected. +.SH "OPTIONS" +.IX Header "OPTIONS" +The long and short forms of options, shown here as alternatives, are +equivalent. At least one option besides \fB\-v\fR or \fB\-H\fR must be +given. +.IP "\fB\-a\fR" 4 +.IX Item "-a" +.PD 0 +.IP "\fB\-\-all\fR" 4 +.IX Item "--all" +.PD +Equivalent to specifying \fB\-\-file\-header\fR, +\&\fB\-\-program\-headers\fR, \fB\-\-sections\fR, \fB\-\-symbols\fR, +\&\fB\-\-relocs\fR, \fB\-\-dynamic\fR, \fB\-\-notes\fR, +\&\fB\-\-version\-info\fR, \fB\-\-arch\-specific\fR, \fB\-\-unwind\fR, +\&\fB\-\-section\-groups\fR and \fB\-\-histogram\fR. +.Sp +Note \- this option does not enable \fB\-\-use\-dynamic\fR itself, so +if that option is not present on the command line then dynamic symbols +and dynamic relocs will not be displayed. +.IP "\fB\-h\fR" 4 +.IX Item "-h" +.PD 0 +.IP "\fB\-\-file\-header\fR" 4 +.IX Item "--file-header" +.PD +Displays the information contained in the \s-1ELF\s0 header at the start of the +file. +.IP "\fB\-l\fR" 4 +.IX Item "-l" +.PD 0 +.IP "\fB\-\-program\-headers\fR" 4 +.IX Item "--program-headers" +.IP "\fB\-\-segments\fR" 4 +.IX Item "--segments" +.PD +Displays the information contained in the file's segment headers, if it +has any. +.IP "\fB\-S\fR" 4 +.IX Item "-S" +.PD 0 +.IP "\fB\-\-sections\fR" 4 +.IX Item "--sections" +.IP "\fB\-\-section\-headers\fR" 4 +.IX Item "--section-headers" +.PD +Displays the information contained in the file's section headers, if it +has any. +.IP "\fB\-g\fR" 4 +.IX Item "-g" +.PD 0 +.IP "\fB\-\-section\-groups\fR" 4 +.IX Item "--section-groups" +.PD +Displays the information contained in the file's section groups, if it +has any. +.IP "\fB\-t\fR" 4 +.IX Item "-t" +.PD 0 +.IP "\fB\-\-section\-details\fR" 4 +.IX Item "--section-details" +.PD +Displays the detailed section information. Implies \fB\-S\fR. +.IP "\fB\-s\fR" 4 +.IX Item "-s" +.PD 0 +.IP "\fB\-\-symbols\fR" 4 +.IX Item "--symbols" +.IP "\fB\-\-syms\fR" 4 +.IX Item "--syms" +.PD +Displays the entries in symbol table section of the file, if it has one. +If a symbol has version information associated with it then this is +displayed as well. The version string is displayed as a suffix to the +symbol name, preceeded by an @ character. For example +\&\fBfoo@VER_1\fR. If the version is the default version to be used +when resolving unversioned references to the symbol then it is +displayed as a suffix preceeded by two @ characters. For example +\&\fBfoo@@VER_2\fR. +.IP "\fB\-\-dyn\-syms\fR" 4 +.IX Item "--dyn-syms" +Displays the entries in dynamic symbol table section of the file, if it +has one. The output format is the same as the format used by the +\&\fB\-\-syms\fR option. +.IP "\fB\-e\fR" 4 +.IX Item "-e" +.PD 0 +.IP "\fB\-\-headers\fR" 4 +.IX Item "--headers" +.PD +Display all the headers in the file. Equivalent to \fB\-h \-l \-S\fR. +.IP "\fB\-n\fR" 4 +.IX Item "-n" +.PD 0 +.IP "\fB\-\-notes\fR" 4 +.IX Item "--notes" +.PD +Displays the contents of the \s-1NOTE\s0 segments and/or sections, if any. +.IP "\fB\-r\fR" 4 +.IX Item "-r" +.PD 0 +.IP "\fB\-\-relocs\fR" 4 +.IX Item "--relocs" +.PD +Displays the contents of the file's relocation section, if it has one. +.IP "\fB\-u\fR" 4 +.IX Item "-u" +.PD 0 +.IP "\fB\-\-unwind\fR" 4 +.IX Item "--unwind" +.PD +Displays the contents of the file's unwind section, if it has one. Only +the unwind sections for \s-1IA64 ELF\s0 files, as well as \s-1ARM\s0 unwind tables +(\f(CW\*(C`.ARM.exidx\*(C'\fR / \f(CW\*(C`.ARM.extab\*(C'\fR) are currently supported. +.IP "\fB\-d\fR" 4 +.IX Item "-d" +.PD 0 +.IP "\fB\-\-dynamic\fR" 4 +.IX Item "--dynamic" +.PD +Displays the contents of the file's dynamic section, if it has one. +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD 0 +.IP "\fB\-\-version\-info\fR" 4 +.IX Item "--version-info" +.PD +Displays the contents of the version sections in the file, it they +exist. +.IP "\fB\-A\fR" 4 +.IX Item "-A" +.PD 0 +.IP "\fB\-\-arch\-specific\fR" 4 +.IX Item "--arch-specific" +.PD +Displays architecture-specific information in the file, if there +is any. +.IP "\fB\-D\fR" 4 +.IX Item "-D" +.PD 0 +.IP "\fB\-\-use\-dynamic\fR" 4 +.IX Item "--use-dynamic" +.PD +When displaying symbols, this option makes \fBreadelf\fR use the +symbol hash tables in the file's dynamic section, rather than the +symbol table sections. +.Sp +When displaying relocations, this option makes \fBreadelf\fR +display the dynamic relocations rather than the static relocations. +.IP "\fB\-x \fR" 4 +.IX Item "-x " +.PD 0 +.IP "\fB\-\-hex\-dump=\fR" 4 +.IX Item "--hex-dump=" +.PD +Displays the contents of the indicated section as a hexadecimal bytes. +A number identifies a particular section by index in the section table; +any other string identifies all sections with that name in the object file. +.IP "\fB\-R \fR" 4 +.IX Item "-R " +.PD 0 +.IP "\fB\-\-relocated\-dump=\fR" 4 +.IX Item "--relocated-dump=" +.PD +Displays the contents of the indicated section as a hexadecimal +bytes. A number identifies a particular section by index in the +section table; any other string identifies all sections with that name +in the object file. The contents of the section will be relocated +before they are displayed. +.IP "\fB\-p \fR" 4 +.IX Item "-p " +.PD 0 +.IP "\fB\-\-string\-dump=\fR" 4 +.IX Item "--string-dump=" +.PD +Displays the contents of the indicated section as printable strings. +A number identifies a particular section by index in the section table; +any other string identifies all sections with that name in the object file. +.IP "\fB\-z\fR" 4 +.IX Item "-z" +.PD 0 +.IP "\fB\-\-decompress\fR" 4 +.IX Item "--decompress" +.PD +Requests that the section(s) being dumped by \fBx\fR, \fBR\fR or +\&\fBp\fR options are decompressed before being displayed. If the +section(s) are not compressed then they are displayed as is. +.IP "\fB\-c\fR" 4 +.IX Item "-c" +.PD 0 +.IP "\fB\-\-archive\-index\fR" 4 +.IX Item "--archive-index" +.PD +Displays the file symbol index information contained in the header part +of binary archives. Performs the same function as the \fBt\fR +command to \fBar\fR, but without using the \s-1BFD\s0 library. +.IP "\fB\-w[lLiaprmfFsoRtUuTgAckK]\fR" 4 +.IX Item "-w[lLiaprmfFsoRtUuTgAckK]" +.PD 0 +.IP "\fB\-\-debug\-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames\-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow\-links]\fR" 4 +.IX Item "--debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]" +.PD +Displays the contents of the \s-1DWARF\s0 debug sections in the file, if any +are present. Compressed debug sections are automatically decompressed +(temporarily) before they are displayed. If one or more of the +optional letters or words follows the switch then only those type(s) +of data will be dumped. The letters and words refer to the following +information: +.RS 4 +.ie n .IP """a""" 4 +.el .IP "\f(CWa\fR" 4 +.IX Item "a" +.PD 0 +.ie n .IP """=abbrev""" 4 +.el .IP "\f(CW=abbrev\fR" 4 +.IX Item "=abbrev" +.PD +Displays the contents of the \fB.debug_abbrev\fR section. +.ie n .IP """A""" 4 +.el .IP "\f(CWA\fR" 4 +.IX Item "A" +.PD 0 +.ie n .IP """=addr""" 4 +.el .IP "\f(CW=addr\fR" 4 +.IX Item "=addr" +.PD +Displays the contents of the \fB.debug_addr\fR section. +.ie n .IP """c""" 4 +.el .IP "\f(CWc\fR" 4 +.IX Item "c" +.PD 0 +.ie n .IP """=cu_index""" 4 +.el .IP "\f(CW=cu_index\fR" 4 +.IX Item "=cu_index" +.PD +Displays the contents of the \fB.debug_cu_index\fR and/or +\&\fB.debug_tu_index\fR sections. +.ie n .IP """f""" 4 +.el .IP "\f(CWf\fR" 4 +.IX Item "f" +.PD 0 +.ie n .IP """=frames""" 4 +.el .IP "\f(CW=frames\fR" 4 +.IX Item "=frames" +.PD +Display the raw contents of a \fB.debug_frame\fR section. +.ie n .IP """F""" 4 +.el .IP "\f(CWF\fR" 4 +.IX Item "F" +.PD 0 +.ie n .IP """=frame\-interp""" 4 +.el .IP "\f(CW=frame\-interp\fR" 4 +.IX Item "=frame-interp" +.PD +Display the interpreted contents of a \fB.debug_frame\fR section. +.ie n .IP """g""" 4 +.el .IP "\f(CWg\fR" 4 +.IX Item "g" +.PD 0 +.ie n .IP """=gdb_index""" 4 +.el .IP "\f(CW=gdb_index\fR" 4 +.IX Item "=gdb_index" +.PD +Displays the contents of the \fB.gdb_index\fR and/or +\&\fB.debug_names\fR sections. +.ie n .IP """i""" 4 +.el .IP "\f(CWi\fR" 4 +.IX Item "i" +.PD 0 +.ie n .IP """=info""" 4 +.el .IP "\f(CW=info\fR" 4 +.IX Item "=info" +.PD +Displays the contents of the \fB.debug_info\fR section. Note: the +output from this option can also be restricted by the use of the +\&\fB\-\-dwarf\-depth\fR and \fB\-\-dwarf\-start\fR options. +.ie n .IP """k""" 4 +.el .IP "\f(CWk\fR" 4 +.IX Item "k" +.PD 0 +.ie n .IP """=links""" 4 +.el .IP "\f(CW=links\fR" 4 +.IX Item "=links" +.PD +Displays the contents of the \fB.gnu_debuglink\fR and/or +\&\fB.gnu_debugaltlink\fR sections. Also displays the link to a +separate dwarf object file (dwo), if one is specified by the +DW_AT_GNU_dwo_name or DW_AT_dwo_name attributes in the +\&\fB.debug_info\fR section. +.ie n .IP """K""" 4 +.el .IP "\f(CWK\fR" 4 +.IX Item "K" +.PD 0 +.ie n .IP """=follow\-links""" 4 +.el .IP "\f(CW=follow\-links\fR" 4 +.IX Item "=follow-links" +.PD +Display the contents of any selected debug sections that are found in +a linked, separate debug info file. This can result in multiple +versions of the same debug section being displayed if both the main +file and the separate debug info file contain sections with the same +name. +.Sp +In addition, when displaying \s-1DWARF\s0 attributes, if a form is found that +references the separate debug info file, then the referenced contents +will also be displayed. +.ie n .IP """l""" 4 +.el .IP "\f(CWl\fR" 4 +.IX Item "l" +.PD 0 +.ie n .IP """=rawline""" 4 +.el .IP "\f(CW=rawline\fR" 4 +.IX Item "=rawline" +.PD +Displays the contents of the \fB.debug_line\fR section in a raw +format. +.ie n .IP """L""" 4 +.el .IP "\f(CWL\fR" 4 +.IX Item "L" +.PD 0 +.ie n .IP """=decodedline""" 4 +.el .IP "\f(CW=decodedline\fR" 4 +.IX Item "=decodedline" +.PD +Displays the interpreted contents of the \fB.debug_line\fR section. +.ie n .IP """m""" 4 +.el .IP "\f(CWm\fR" 4 +.IX Item "m" +.PD 0 +.ie n .IP """=macro""" 4 +.el .IP "\f(CW=macro\fR" 4 +.IX Item "=macro" +.PD +Displays the contents of the \fB.debug_macro\fR and/or +\&\fB.debug_macinfo\fR sections. +.ie n .IP """o""" 4 +.el .IP "\f(CWo\fR" 4 +.IX Item "o" +.PD 0 +.ie n .IP """=loc""" 4 +.el .IP "\f(CW=loc\fR" 4 +.IX Item "=loc" +.PD +Displays the contents of the \fB.debug_loc\fR and/or +\&\fB.debug_loclists\fR sections. +.ie n .IP """p""" 4 +.el .IP "\f(CWp\fR" 4 +.IX Item "p" +.PD 0 +.ie n .IP """=pubnames""" 4 +.el .IP "\f(CW=pubnames\fR" 4 +.IX Item "=pubnames" +.PD +Displays the contents of the \fB.debug_pubnames\fR and/or +\&\fB.debug_gnu_pubnames\fR sections. +.ie n .IP """r""" 4 +.el .IP "\f(CWr\fR" 4 +.IX Item "r" +.PD 0 +.ie n .IP """=aranges""" 4 +.el .IP "\f(CW=aranges\fR" 4 +.IX Item "=aranges" +.PD +Displays the contents of the \fB.debug_aranges\fR section. +.ie n .IP """R""" 4 +.el .IP "\f(CWR\fR" 4 +.IX Item "R" +.PD 0 +.ie n .IP """=Ranges""" 4 +.el .IP "\f(CW=Ranges\fR" 4 +.IX Item "=Ranges" +.PD +Displays the contents of the \fB.debug_ranges\fR and/or +\&\fB.debug_rnglists\fR sections. +.ie n .IP """s""" 4 +.el .IP "\f(CWs\fR" 4 +.IX Item "s" +.PD 0 +.ie n .IP """=str""" 4 +.el .IP "\f(CW=str\fR" 4 +.IX Item "=str" +.PD +Displays the contents of the \fB.debug_str\fR, \fB.debug_line_str\fR +and/or \fB.debug_str_offsets\fR sections. +.ie n .IP """t""" 4 +.el .IP "\f(CWt\fR" 4 +.IX Item "t" +.PD 0 +.ie n .IP """=pubtype""" 4 +.el .IP "\f(CW=pubtype\fR" 4 +.IX Item "=pubtype" +.PD +Displays the contents of the \fB.debug_pubtypes\fR and/or +\&\fB.debug_gnu_pubtypes\fR sections. +.ie n .IP """T""" 4 +.el .IP "\f(CWT\fR" 4 +.IX Item "T" +.PD 0 +.ie n .IP """=trace_aranges""" 4 +.el .IP "\f(CW=trace_aranges\fR" 4 +.IX Item "=trace_aranges" +.PD +Displays the contents of the \fB.trace_aranges\fR section. +.ie n .IP """u""" 4 +.el .IP "\f(CWu\fR" 4 +.IX Item "u" +.PD 0 +.ie n .IP """=trace_abbrev""" 4 +.el .IP "\f(CW=trace_abbrev\fR" 4 +.IX Item "=trace_abbrev" +.PD +Displays the contents of the \fB.trace_abbrev\fR section. +.ie n .IP """U""" 4 +.el .IP "\f(CWU\fR" 4 +.IX Item "U" +.PD 0 +.ie n .IP """=trace_info""" 4 +.el .IP "\f(CW=trace_info\fR" 4 +.IX Item "=trace_info" +.PD +Displays the contents of the \fB.trace_info\fR section. +.RE +.RS 4 +.Sp +Note: displaying the contents of \fB.debug_static_funcs\fR, +\&\fB.debug_static_vars\fR and \fBdebug_weaknames\fR sections is not +currently supported. +.RE +.IP "\fB\-\-dwarf\-depth=\fR\fIn\fR" 4 +.IX Item "--dwarf-depth=n" +Limit the dump of the \f(CW\*(C`.debug_info\*(C'\fR section to \fIn\fR children. +This is only useful with \fB\-\-debug\-dump=info\fR. The default is +to print all DIEs; the special value 0 for \fIn\fR will also have this +effect. +.Sp +With a non-zero value for \fIn\fR, DIEs at or deeper than \fIn\fR +levels will not be printed. The range for \fIn\fR is zero-based. +.IP "\fB\-\-dwarf\-start=\fR\fIn\fR" 4 +.IX Item "--dwarf-start=n" +Print only DIEs beginning with the \s-1DIE\s0 numbered \fIn\fR. This is only +useful with \fB\-\-debug\-dump=info\fR. +.Sp +If specified, this option will suppress printing of any header +information and all DIEs before the \s-1DIE\s0 numbered \fIn\fR. Only +siblings and children of the specified \s-1DIE\s0 will be printed. +.Sp +This can be used in conjunction with \fB\-\-dwarf\-depth\fR. +.IP "\fB\-I\fR" 4 +.IX Item "-I" +.PD 0 +.IP "\fB\-\-histogram\fR" 4 +.IX Item "--histogram" +.PD +Display a histogram of bucket list lengths when displaying the contents +of the symbol tables. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Display the version number of readelf. +.IP "\fB\-W\fR" 4 +.IX Item "-W" +.PD 0 +.IP "\fB\-\-wide\fR" 4 +.IX Item "--wide" +.PD +Don't break output lines to fit into 80 columns. By default +\&\fBreadelf\fR breaks section header and segment listing lines for +64\-bit \s-1ELF\s0 files, so that they fit into 80 columns. This option causes +\&\fBreadelf\fR to print each section header resp. each segment one a +single line, which is far more readable on terminals wider than 80 columns. +.IP "\fB\-H\fR" 4 +.IX Item "-H" +.PD 0 +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +.PD +Display the command line options understood by \fBreadelf\fR. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fIobjdump\fR\|(1), and the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/size.1 b/support/sdbinutils/binutils/doc/size.1 new file mode 100644 index 0000000..03ca09c --- /dev/null +++ b/support/sdbinutils/binutils/doc/size.1 @@ -0,0 +1,271 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "SIZE 1" +.TH SIZE 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +size \- list section sizes and total size. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +size [\fB\-A\fR|\fB\-B\fR|\fB\-\-format=\fR\fIcompatibility\fR] + [\fB\-\-help\fR] + [\fB\-d\fR|\fB\-o\fR|\fB\-x\fR|\fB\-\-radix=\fR\fInumber\fR] + [\fB\-\-common\fR] + [\fB\-t\fR|\fB\-\-totals\fR] + [\fB\-\-target=\fR\fIbfdname\fR] [\fB\-V\fR|\fB\-\-version\fR] + [\fIobjfile\fR...] +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +The \s-1GNU\s0 \fBsize\fR utility lists the section sizes\-\-\-and the total +size\-\-\-for each of the object or archive files \fIobjfile\fR in its +argument list. By default, one line of output is generated for each +object file or each module in an archive. +.PP +\&\fIobjfile\fR... are the object files to be examined. +If none are specified, the file \f(CW\*(C`a.out\*(C'\fR will be used. +.SH "OPTIONS" +.IX Header "OPTIONS" +The command line options have the following meanings: +.IP "\fB\-A\fR" 4 +.IX Item "-A" +.PD 0 +.IP "\fB\-B\fR" 4 +.IX Item "-B" +.IP "\fB\-\-format=\fR\fIcompatibility\fR" 4 +.IX Item "--format=compatibility" +.PD +Using one of these options, you can choose whether the output from \s-1GNU\s0 +\&\fBsize\fR resembles output from System V \fBsize\fR (using \fB\-A\fR, +or \fB\-\-format=sysv\fR), or Berkeley \fBsize\fR (using \fB\-B\fR, or +\&\fB\-\-format=berkeley\fR). The default is the one-line format similar to +Berkeley's. +.Sp +Here is an example of the Berkeley (default) format of output from +\&\fBsize\fR: +.Sp +.Vb 4 +\& $ size \-\-format=Berkeley ranlib size +\& text data bss dec hex filename +\& 294880 81920 11592 388392 5ed28 ranlib +\& 294880 81920 11888 388688 5ee50 size +.Ve +.Sp +This is the same data, but displayed closer to System V conventions: +.Sp +.Vb 7 +\& $ size \-\-format=SysV ranlib size +\& ranlib : +\& section size addr +\& .text 294880 8192 +\& .data 81920 303104 +\& .bss 11592 385024 +\& Total 388392 +\& +\& +\& size : +\& section size addr +\& .text 294880 8192 +\& .data 81920 303104 +\& .bss 11888 385024 +\& Total 388688 +.Ve +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +Show a summary of acceptable arguments and options. +.IP "\fB\-d\fR" 4 +.IX Item "-d" +.PD 0 +.IP "\fB\-o\fR" 4 +.IX Item "-o" +.IP "\fB\-x\fR" 4 +.IX Item "-x" +.IP "\fB\-\-radix=\fR\fInumber\fR" 4 +.IX Item "--radix=number" +.PD +Using one of these options, you can control whether the size of each +section is given in decimal (\fB\-d\fR, or \fB\-\-radix=10\fR); octal +(\fB\-o\fR, or \fB\-\-radix=8\fR); or hexadecimal (\fB\-x\fR, or +\&\fB\-\-radix=16\fR). In \fB\-\-radix=\fR\fInumber\fR, only the three +values (8, 10, 16) are supported. The total size is always given in two +radices; decimal and hexadecimal for \fB\-d\fR or \fB\-x\fR output, or +octal and hexadecimal if you're using \fB\-o\fR. +.IP "\fB\-\-common\fR" 4 +.IX Item "--common" +Print total size of common symbols in each file. When using Berkeley +format these are included in the bss size. +.IP "\fB\-t\fR" 4 +.IX Item "-t" +.PD 0 +.IP "\fB\-\-totals\fR" 4 +.IX Item "--totals" +.PD +Show totals of all objects listed (Berkeley format listing mode only). +.IP "\fB\-\-target=\fR\fIbfdname\fR" 4 +.IX Item "--target=bfdname" +Specify that the object-code format for \fIobjfile\fR is +\&\fIbfdname\fR. This option may not be necessary; \fBsize\fR can +automatically recognize many formats. +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Display the version number of \fBsize\fR. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fIar\fR\|(1), \fIobjdump\fR\|(1), \fIreadelf\fR\|(1), and the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/strings.1 b/support/sdbinutils/binutils/doc/strings.1 new file mode 100644 index 0000000..946b779 --- /dev/null +++ b/support/sdbinutils/binutils/doc/strings.1 @@ -0,0 +1,311 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "STRINGS 1" +.TH STRINGS 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +strings \- print the strings of printable characters in files. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +strings [\fB\-afovV\fR] [\fB\-\fR\fImin-len\fR] + [\fB\-n\fR \fImin-len\fR] [\fB\-\-bytes=\fR\fImin-len\fR] + [\fB\-t\fR \fIradix\fR] [\fB\-\-radix=\fR\fIradix\fR] + [\fB\-e\fR \fIencoding\fR] [\fB\-\-encoding=\fR\fIencoding\fR] + [\fB\-\fR] [\fB\-\-all\fR] [\fB\-\-print\-file\-name\fR] + [\fB\-T\fR \fIbfdname\fR] [\fB\-\-target=\fR\fIbfdname\fR] + [\fB\-w\fR] [\fB\-\-include\-all\-whitespace\fR] + [\fB\-s\fR] [\fB\-\-output\-separator\fR\fIsep_string\fR] + [\fB\-\-help\fR] [\fB\-\-version\fR] \fIfile\fR... +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +For each \fIfile\fR given, \s-1GNU\s0 \fBstrings\fR prints the +printable character sequences that are at least 4 characters long (or +the number given with the options below) and are followed by an +unprintable character. +.PP +Depending upon how the strings program was configured it will default +to either displaying all the printable sequences that it can find in +each file, or only those sequences that are in loadable, initialized +data sections. If the file type in unrecognizable, or if strings is +reading from stdin then it will always display all of the printable +sequences that it can find. +.PP +For backwards compatibility any file that occurs after a command line +option of just \fB\-\fR will also be scanned in full, regardless of +the presence of any \fB\-d\fR option. +.PP +\&\fBstrings\fR is mainly useful for determining the contents of +non-text files. +.SH "OPTIONS" +.IX Header "OPTIONS" +.IP "\fB\-a\fR" 4 +.IX Item "-a" +.PD 0 +.IP "\fB\-\-all\fR" 4 +.IX Item "--all" +.IP "\fB\-\fR" 4 +.IX Item "-" +.PD +Scan the whole file, regardless of what sections it contains or +whether those sections are loaded or initialized. Normally this is +the default behaviour, but strings can be configured so that the +\&\fB\-d\fR is the default instead. +.Sp +The \fB\-\fR option is position dependent and forces strings to +perform full scans of any file that is mentioned after the \fB\-\fR +on the command line, even if the \fB\-d\fR option has been +specified. +.IP "\fB\-d\fR" 4 +.IX Item "-d" +.PD 0 +.IP "\fB\-\-data\fR" 4 +.IX Item "--data" +.PD +Only print strings from initialized, loaded data sections in the +file. This may reduce the amount of garbage in the output, but it +also exposes the strings program to any security flaws that may be +present in the \s-1BFD\s0 library used to scan and load sections. Strings +can be configured so that this option is the default behaviour. In +such cases the \fB\-a\fR option can be used to avoid using the \s-1BFD\s0 +library and instead just print all of the strings found in the file. +.IP "\fB\-f\fR" 4 +.IX Item "-f" +.PD 0 +.IP "\fB\-\-print\-file\-name\fR" 4 +.IX Item "--print-file-name" +.PD +Print the name of the file before each string. +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +Print a summary of the program usage on the standard output and exit. +.IP "\fB\-\fR\fImin-len\fR" 4 +.IX Item "-min-len" +.PD 0 +.IP "\fB\-n\fR \fImin-len\fR" 4 +.IX Item "-n min-len" +.IP "\fB\-\-bytes=\fR\fImin-len\fR" 4 +.IX Item "--bytes=min-len" +.PD +Print sequences of characters that are at least \fImin-len\fR characters +long, instead of the default 4. +.IP "\fB\-o\fR" 4 +.IX Item "-o" +Like \fB\-t o\fR. Some other versions of \fBstrings\fR have \fB\-o\fR +act like \fB\-t d\fR instead. Since we can not be compatible with both +ways, we simply chose one. +.IP "\fB\-t\fR \fIradix\fR" 4 +.IX Item "-t radix" +.PD 0 +.IP "\fB\-\-radix=\fR\fIradix\fR" 4 +.IX Item "--radix=radix" +.PD +Print the offset within the file before each string. The single +character argument specifies the radix of the offset\-\-\-\fBo\fR for +octal, \fBx\fR for hexadecimal, or \fBd\fR for decimal. +.IP "\fB\-e\fR \fIencoding\fR" 4 +.IX Item "-e encoding" +.PD 0 +.IP "\fB\-\-encoding=\fR\fIencoding\fR" 4 +.IX Item "--encoding=encoding" +.PD +Select the character encoding of the strings that are to be found. +Possible values for \fIencoding\fR are: \fBs\fR = single\-7\-bit\-byte +characters (\s-1ASCII, ISO 8859,\s0 etc., default), \fBS\fR = +single\-8\-bit\-byte characters, \fBb\fR = 16\-bit bigendian, \fBl\fR = +16\-bit littleendian, \fBB\fR = 32\-bit bigendian, \fBL\fR = 32\-bit +littleendian. Useful for finding wide character strings. (\fBl\fR +and \fBb\fR apply to, for example, Unicode \s-1UTF\-16/UCS\-2\s0 encodings). +.IP "\fB\-T\fR \fIbfdname\fR" 4 +.IX Item "-T bfdname" +.PD 0 +.IP "\fB\-\-target=\fR\fIbfdname\fR" 4 +.IX Item "--target=bfdname" +.PD +Specify an object code format other than your system's default format. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +.PD 0 +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Print the program version number on the standard output and exit. +.IP "\fB\-w\fR" 4 +.IX Item "-w" +.PD 0 +.IP "\fB\-\-include\-all\-whitespace\fR" 4 +.IX Item "--include-all-whitespace" +.PD +By default tab and space characters are included in the strings that +are displayed, but other whitespace characters, such a newlines and +carriage returns, are not. The \fB\-w\fR option changes this so +that all whitespace characters are considered to be part of a string. +.IP "\fB\-s\fR" 4 +.IX Item "-s" +.PD 0 +.IP "\fB\-\-output\-separator\fR" 4 +.IX Item "--output-separator" +.PD +By default, output strings are delimited by a new-line. This option +allows you to supply any string to be used as the output record +separator. Useful with \-\-include\-all\-whitespace where strings +may contain new-lines internally. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fIar\fR\|(1), \fInm\fR\|(1), \fIobjdump\fR\|(1), \fIranlib\fR\|(1), \fIreadelf\fR\|(1) +and the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/strip.1 b/support/sdbinutils/binutils/doc/strip.1 new file mode 100644 index 0000000..23f930b --- /dev/null +++ b/support/sdbinutils/binutils/doc/strip.1 @@ -0,0 +1,493 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "STRIP 1" +.TH STRIP 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +strip \- Discard symbols from object files. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +strip [\fB\-F\fR \fIbfdname\fR |\fB\-\-target=\fR\fIbfdname\fR] + [\fB\-I\fR \fIbfdname\fR |\fB\-\-input\-target=\fR\fIbfdname\fR] + [\fB\-O\fR \fIbfdname\fR |\fB\-\-output\-target=\fR\fIbfdname\fR] + [\fB\-s\fR|\fB\-\-strip\-all\fR] + [\fB\-S\fR|\fB\-g\fR|\fB\-d\fR|\fB\-\-strip\-debug\fR] + [\fB\-\-strip\-dwo\fR] + [\fB\-K\fR \fIsymbolname\fR|\fB\-\-keep\-symbol=\fR\fIsymbolname\fR] + [\fB\-M\fR|\fB\-\-merge\-notes\fR][\fB\-\-no\-merge\-notes\fR] + [\fB\-N\fR \fIsymbolname\fR |\fB\-\-strip\-symbol=\fR\fIsymbolname\fR] + [\fB\-w\fR|\fB\-\-wildcard\fR] + [\fB\-x\fR|\fB\-\-discard\-all\fR] [\fB\-X\fR |\fB\-\-discard\-locals\fR] + [\fB\-R\fR \fIsectionname\fR |\fB\-\-remove\-section=\fR\fIsectionname\fR] + [\fB\-\-remove\-relocations=\fR\fIsectionpattern\fR] + [\fB\-o\fR \fIfile\fR] [\fB\-p\fR|\fB\-\-preserve\-dates\fR] + [\fB\-D\fR|\fB\-\-enable\-deterministic\-archives\fR] + [\fB\-U\fR|\fB\-\-disable\-deterministic\-archives\fR] + [\fB\-\-keep\-file\-symbols\fR] + [\fB\-\-only\-keep\-debug\fR] + [\fB\-v\fR |\fB\-\-verbose\fR] [\fB\-V\fR|\fB\-\-version\fR] + [\fB\-\-help\fR] [\fB\-\-info\fR] + \fIobjfile\fR... +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\s-1GNU\s0 \fBstrip\fR discards all symbols from object files +\&\fIobjfile\fR. The list of object files may include archives. +At least one object file must be given. +.PP +\&\fBstrip\fR modifies the files named in its argument, +rather than writing modified copies under different names. +.SH "OPTIONS" +.IX Header "OPTIONS" +.IP "\fB\-F\fR \fIbfdname\fR" 4 +.IX Item "-F bfdname" +.PD 0 +.IP "\fB\-\-target=\fR\fIbfdname\fR" 4 +.IX Item "--target=bfdname" +.PD +Treat the original \fIobjfile\fR as a file with the object +code format \fIbfdname\fR, and rewrite it in the same format. +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +Show a summary of the options to \fBstrip\fR and exit. +.IP "\fB\-\-info\fR" 4 +.IX Item "--info" +Display a list showing all architectures and object formats available. +.IP "\fB\-I\fR \fIbfdname\fR" 4 +.IX Item "-I bfdname" +.PD 0 +.IP "\fB\-\-input\-target=\fR\fIbfdname\fR" 4 +.IX Item "--input-target=bfdname" +.PD +Treat the original \fIobjfile\fR as a file with the object +code format \fIbfdname\fR. +.IP "\fB\-O\fR \fIbfdname\fR" 4 +.IX Item "-O bfdname" +.PD 0 +.IP "\fB\-\-output\-target=\fR\fIbfdname\fR" 4 +.IX Item "--output-target=bfdname" +.PD +Replace \fIobjfile\fR with a file in the output format \fIbfdname\fR. +.IP "\fB\-R\fR \fIsectionname\fR" 4 +.IX Item "-R sectionname" +.PD 0 +.IP "\fB\-\-remove\-section=\fR\fIsectionname\fR" 4 +.IX Item "--remove-section=sectionname" +.PD +Remove any section named \fIsectionname\fR from the output file, in +addition to whatever sections would otherwise be removed. This +option may be given more than once. Note that using this option +inappropriately may make the output file unusable. The wildcard +character \fB*\fR may be given at the end of \fIsectionname\fR. If +so, then any section starting with \fIsectionname\fR will be removed. +.Sp +If the first character of \fIsectionpattern\fR is the exclamation +point (!) then matching sections will not be removed even if an +earlier use of \fB\-\-remove\-section\fR on the same command line +would otherwise remove it. For example: +.Sp +.Vb 1 +\& \-\-remove\-section=.text.* \-\-remove\-section=!.text.foo +.Ve +.Sp +will remove all sections matching the pattern '.text.*', but will not +remove the section '.text.foo'. +.IP "\fB\-\-remove\-relocations=\fR\fIsectionpattern\fR" 4 +.IX Item "--remove-relocations=sectionpattern" +Remove relocations from the output file for any section matching +\&\fIsectionpattern\fR. This option may be given more than once. Note +that using this option inappropriately may make the output file +unusable. Wildcard characters are accepted in \fIsectionpattern\fR. +For example: +.Sp +.Vb 1 +\& \-\-remove\-relocations=.text.* +.Ve +.Sp +will remove the relocations for all sections matching the patter +\&'.text.*'. +.Sp +If the first character of \fIsectionpattern\fR is the exclamation +point (!) then matching sections will not have their relocation +removed even if an earlier use of \fB\-\-remove\-relocations\fR on the +same command line would otherwise cause the relocations to be removed. +For example: +.Sp +.Vb 1 +\& \-\-remove\-relocations=.text.* \-\-remove\-relocations=!.text.foo +.Ve +.Sp +will remove all relocations for sections matching the pattern +\&'.text.*', but will not remove relocations for the section +\&'.text.foo'. +.IP "\fB\-s\fR" 4 +.IX Item "-s" +.PD 0 +.IP "\fB\-\-strip\-all\fR" 4 +.IX Item "--strip-all" +.PD +Remove all symbols. +.IP "\fB\-g\fR" 4 +.IX Item "-g" +.PD 0 +.IP "\fB\-S\fR" 4 +.IX Item "-S" +.IP "\fB\-d\fR" 4 +.IX Item "-d" +.IP "\fB\-\-strip\-debug\fR" 4 +.IX Item "--strip-debug" +.PD +Remove debugging symbols only. +.IP "\fB\-\-strip\-dwo\fR" 4 +.IX Item "--strip-dwo" +Remove the contents of all \s-1DWARF\s0 .dwo sections, leaving the +remaining debugging sections and all symbols intact. +See the description of this option in the \fBobjcopy\fR section +for more information. +.IP "\fB\-\-strip\-unneeded\fR" 4 +.IX Item "--strip-unneeded" +Remove all symbols that are not needed for relocation processing. +.IP "\fB\-K\fR \fIsymbolname\fR" 4 +.IX Item "-K symbolname" +.PD 0 +.IP "\fB\-\-keep\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--keep-symbol=symbolname" +.PD +When stripping symbols, keep symbol \fIsymbolname\fR even if it would +normally be stripped. This option may be given more than once. +.IP "\fB\-M\fR" 4 +.IX Item "-M" +.PD 0 +.IP "\fB\-\-merge\-notes\fR" 4 +.IX Item "--merge-notes" +.IP "\fB\-\-no\-merge\-notes\fR" 4 +.IX Item "--no-merge-notes" +.PD +For \s-1ELF\s0 files, attempt (or do not attempt) to reduce the size of any +\&\s-1SHT_NOTE\s0 type sections by removing duplicate notes. The default is to +attempt this reduction. +.IP "\fB\-N\fR \fIsymbolname\fR" 4 +.IX Item "-N symbolname" +.PD 0 +.IP "\fB\-\-strip\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--strip-symbol=symbolname" +.PD +Remove symbol \fIsymbolname\fR from the source file. This option may be +given more than once, and may be combined with strip options other than +\&\fB\-K\fR. +.IP "\fB\-o\fR \fIfile\fR" 4 +.IX Item "-o file" +Put the stripped output in \fIfile\fR, rather than replacing the +existing file. When this argument is used, only one \fIobjfile\fR +argument may be specified. +.IP "\fB\-p\fR" 4 +.IX Item "-p" +.PD 0 +.IP "\fB\-\-preserve\-dates\fR" 4 +.IX Item "--preserve-dates" +.PD +Preserve the access and modification dates of the file. +.IP "\fB\-D\fR" 4 +.IX Item "-D" +.PD 0 +.IP "\fB\-\-enable\-deterministic\-archives\fR" 4 +.IX Item "--enable-deterministic-archives" +.PD +Operate in \fIdeterministic\fR mode. When copying archive members +and writing the archive index, use zero for UIDs, GIDs, timestamps, +and use consistent file modes for all files. +.Sp +If \fIbinutils\fR was configured with +\&\fB\-\-enable\-deterministic\-archives\fR, then this mode is on by default. +It can be disabled with the \fB\-U\fR option, below. +.IP "\fB\-U\fR" 4 +.IX Item "-U" +.PD 0 +.IP "\fB\-\-disable\-deterministic\-archives\fR" 4 +.IX Item "--disable-deterministic-archives" +.PD +Do \fInot\fR operate in \fIdeterministic\fR mode. This is the +inverse of the \fB\-D\fR option, above: when copying archive members +and writing the archive index, use their actual \s-1UID, GID,\s0 timestamp, +and file mode values. +.Sp +This is the default unless \fIbinutils\fR was configured with +\&\fB\-\-enable\-deterministic\-archives\fR. +.IP "\fB\-w\fR" 4 +.IX Item "-w" +.PD 0 +.IP "\fB\-\-wildcard\fR" 4 +.IX Item "--wildcard" +.PD +Permit regular expressions in \fIsymbolname\fRs used in other command +line options. The question mark (?), asterisk (*), backslash (\e) and +square brackets ([]) operators can be used anywhere in the symbol +name. If the first character of the symbol name is the exclamation +point (!) then the sense of the switch is reversed for that symbol. +For example: +.Sp +.Vb 1 +\& \-w \-K !foo \-K fo* +.Ve +.Sp +would cause strip to only keep symbols that start with the letters +\&\*(L"fo\*(R", but to discard the symbol \*(L"foo\*(R". +.IP "\fB\-x\fR" 4 +.IX Item "-x" +.PD 0 +.IP "\fB\-\-discard\-all\fR" 4 +.IX Item "--discard-all" +.PD +Remove non-global symbols. +.IP "\fB\-X\fR" 4 +.IX Item "-X" +.PD 0 +.IP "\fB\-\-discard\-locals\fR" 4 +.IX Item "--discard-locals" +.PD +Remove compiler-generated local symbols. +(These usually start with \fBL\fR or \fB.\fR.) +.IP "\fB\-\-keep\-file\-symbols\fR" 4 +.IX Item "--keep-file-symbols" +When stripping a file, perhaps with \fB\-\-strip\-debug\fR or +\&\fB\-\-strip\-unneeded\fR, retain any symbols specifying source file names, +which would otherwise get stripped. +.IP "\fB\-\-only\-keep\-debug\fR" 4 +.IX Item "--only-keep-debug" +Strip a file, emptying the contents of any sections that would not be +stripped by \fB\-\-strip\-debug\fR and leaving the debugging sections +intact. In \s-1ELF\s0 files, this preserves all the note sections in the +output as well. +.Sp +Note \- the section headers of the stripped sections are preserved, +including their sizes, but the contents of the section are discarded. +The section headers are preserved so that other tools can match up the +debuginfo file with the real executable, even if that executable has +been relocated to a different address space. +.Sp +The intention is that this option will be used in conjunction with +\&\fB\-\-add\-gnu\-debuglink\fR to create a two part executable. One a +stripped binary which will occupy less space in \s-1RAM\s0 and in a +distribution and the second a debugging information file which is only +needed if debugging abilities are required. The suggested procedure +to create these files is as follows: +.RS 4 +.IP "1." 4 +.IX Item "1." +\&\f(CW\*(C`foo\*(C'\fR then... +.ie n .IP "1." 4 +.el .IP "1." 4 +.IX Item "1." +create a file containing the debugging info. +.ie n .IP "1." 4 +.el .IP "1." 4 +.IX Item "1." +stripped executable. +.ie n .IP "1." 4 +.el .IP "1." 4 +.IX Item "1." +to add a link to the debugging info into the stripped executable. +.RE +.RS 4 +.Sp +Note\-\-\-the choice of \f(CW\*(C`.dbg\*(C'\fR as an extension for the debug info +file is arbitrary. Also the \f(CW\*(C`\-\-only\-keep\-debug\*(C'\fR step is +optional. You could instead do this: +.IP "1." 4 +.IX Item "1." +.PD 0 +.ie n .IP "1." 4 +.el .IP "1." 4 +.IX Item "1." +.ie n .IP "1." 4 +.el .IP "1." 4 +.IX Item "1." +.ie n .IP "1." 4 +.el .IP "1." 4 +.IX Item "1." +.RE +.RS 4 +.PD +.Sp +i.e., the file pointed to by the \fB\-\-add\-gnu\-debuglink\fR can be the +full executable. It does not have to be a file created by the +\&\fB\-\-only\-keep\-debug\fR switch. +.Sp +Note\-\-\-this switch is only intended for use on fully linked files. It +does not make sense to use it on object files where the debugging +information may be incomplete. Besides the gnu_debuglink feature +currently only supports the presence of one filename containing +debugging information, not multiple filenames on a one-per-object-file +basis. +.RE +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Show the version number for \fBstrip\fR. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +.PD 0 +.IP "\fB\-\-verbose\fR" 4 +.IX Item "--verbose" +.PD +Verbose output: list all object files modified. In the case of +archives, \fBstrip \-v\fR lists all members of the archive. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/windmc.1 b/support/sdbinutils/binutils/doc/windmc.1 new file mode 100644 index 0000000..eec35ac --- /dev/null +++ b/support/sdbinutils/binutils/doc/windmc.1 @@ -0,0 +1,356 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "WINDMC 1" +.TH WINDMC 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +windmc \- generates Windows message resources. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +windmc [options] input-file +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\fBwindmc\fR reads message definitions from an input file (.mc) and +translate them into a set of output files. The output files may be of +four kinds: +.ie n .IP """h""" 4 +.el .IP "\f(CWh\fR" 4 +.IX Item "h" +A C header file containing the message definitions. +.ie n .IP """rc""" 4 +.el .IP "\f(CWrc\fR" 4 +.IX Item "rc" +A resource file compilable by the \fBwindres\fR tool. +.ie n .IP """bin""" 4 +.el .IP "\f(CWbin\fR" 4 +.IX Item "bin" +One or more binary files containing the resource data for a specific +message language. +.ie n .IP """dbg""" 4 +.el .IP "\f(CWdbg\fR" 4 +.IX Item "dbg" +A C include file that maps message id's to their symbolic name. +.PP +The exact description of these different formats is available in +documentation from Microsoft. +.PP +When \fBwindmc\fR converts from the \f(CW\*(C`mc\*(C'\fR format to the \f(CW\*(C`bin\*(C'\fR +format, \f(CW\*(C`rc\*(C'\fR, \f(CW\*(C`h\*(C'\fR, and optional \f(CW\*(C`dbg\*(C'\fR it is acting like the +Windows Message Compiler. +.SH "OPTIONS" +.IX Header "OPTIONS" +.IP "\fB\-a\fR" 4 +.IX Item "-a" +.PD 0 +.IP "\fB\-\-ascii_in\fR" 4 +.IX Item "--ascii_in" +.PD +Specifies that the input file specified is \s-1ASCII.\s0 This is the default +behaviour. +.IP "\fB\-A\fR" 4 +.IX Item "-A" +.PD 0 +.IP "\fB\-\-ascii_out\fR" 4 +.IX Item "--ascii_out" +.PD +Specifies that messages in the output \f(CW\*(C`bin\*(C'\fR files should be in \s-1ASCII\s0 +format. +.IP "\fB\-b\fR" 4 +.IX Item "-b" +.PD 0 +.IP "\fB\-\-binprefix\fR" 4 +.IX Item "--binprefix" +.PD +Specifies that \f(CW\*(C`bin\*(C'\fR filenames should have to be prefixed by the +basename of the source file. +.IP "\fB\-c\fR" 4 +.IX Item "-c" +.PD 0 +.IP "\fB\-\-customflag\fR" 4 +.IX Item "--customflag" +.PD +Sets the customer bit in all message id's. +.IP "\fB\-C\fR \fIcodepage\fR" 4 +.IX Item "-C codepage" +.PD 0 +.IP "\fB\-\-codepage_in\fR \fIcodepage\fR" 4 +.IX Item "--codepage_in codepage" +.PD +Sets the default codepage to be used to convert input file to \s-1UTF16.\s0 The +default is ocdepage 1252. +.IP "\fB\-d\fR" 4 +.IX Item "-d" +.PD 0 +.IP "\fB\-\-decimal_values\fR" 4 +.IX Item "--decimal_values" +.PD +Outputs the constants in the header file in decimal. Default is using +hexadecimal output. +.IP "\fB\-e\fR \fIext\fR" 4 +.IX Item "-e ext" +.PD 0 +.IP "\fB\-\-extension\fR \fIext\fR" 4 +.IX Item "--extension ext" +.PD +The extension for the header file. The default is .h extension. +.IP "\fB\-F\fR \fItarget\fR" 4 +.IX Item "-F target" +.PD 0 +.IP "\fB\-\-target\fR \fItarget\fR" 4 +.IX Item "--target target" +.PD +Specify the \s-1BFD\s0 format to use for a bin file as output. This +is a \s-1BFD\s0 target name; you can use the \fB\-\-help\fR option to see a list +of supported targets. Normally \fBwindmc\fR will use the default +format, which is the first one listed by the \fB\-\-help\fR option. +.IP "\fB\-h\fR \fIpath\fR" 4 +.IX Item "-h path" +.PD 0 +.IP "\fB\-\-headerdir\fR \fIpath\fR" 4 +.IX Item "--headerdir path" +.PD +The target directory of the generated header file. The default is the +current directory. +.IP "\fB\-H\fR" 4 +.IX Item "-H" +.PD 0 +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +.PD +Displays a list of command line options and then exits. +.IP "\fB\-m\fR \fIcharacters\fR" 4 +.IX Item "-m characters" +.PD 0 +.IP "\fB\-\-maxlength\fR \fIcharacters\fR" 4 +.IX Item "--maxlength characters" +.PD +Instructs \fBwindmc\fR to generate a warning if the length +of any message exceeds the number specified. +.IP "\fB\-n\fR" 4 +.IX Item "-n" +.PD 0 +.IP "\fB\-\-nullterminate\fR" 4 +.IX Item "--nullterminate" +.PD +Terminate message text in \f(CW\*(C`bin\*(C'\fR files by zero. By default they are +terminated by \s-1CR/LF.\s0 +.IP "\fB\-o\fR" 4 +.IX Item "-o" +.PD 0 +.IP "\fB\-\-hresult_use\fR" 4 +.IX Item "--hresult_use" +.PD +Not yet implemented. Instructs \f(CW\*(C`windmc\*(C'\fR to generate an \s-1OLE2\s0 header +file, using \s-1HRESULT\s0 definitions. Status codes are used if the flag is not +specified. +.IP "\fB\-O\fR \fIcodepage\fR" 4 +.IX Item "-O codepage" +.PD 0 +.IP "\fB\-\-codepage_out\fR \fIcodepage\fR" 4 +.IX Item "--codepage_out codepage" +.PD +Sets the default codepage to be used to output text files. The default +is ocdepage 1252. +.IP "\fB\-r\fR \fIpath\fR" 4 +.IX Item "-r path" +.PD 0 +.IP "\fB\-\-rcdir\fR \fIpath\fR" 4 +.IX Item "--rcdir path" +.PD +The target directory for the generated \f(CW\*(C`rc\*(C'\fR script and the generated +\&\f(CW\*(C`bin\*(C'\fR files that the resource compiler script includes. The default +is the current directory. +.IP "\fB\-u\fR" 4 +.IX Item "-u" +.PD 0 +.IP "\fB\-\-unicode_in\fR" 4 +.IX Item "--unicode_in" +.PD +Specifies that the input file is \s-1UTF16.\s0 +.IP "\fB\-U\fR" 4 +.IX Item "-U" +.PD 0 +.IP "\fB\-\-unicode_out\fR" 4 +.IX Item "--unicode_out" +.PD +Specifies that messages in the output \f(CW\*(C`bin\*(C'\fR file should be in \s-1UTF16\s0 +format. This is the default behaviour. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +.PD 0 +.IP "\fB\-\-verbose\fR" 4 +.IX Item "--verbose" +.PD +Enable verbose mode. +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Prints the version number for \fBwindmc\fR. +.IP "\fB\-x\fR \fIpath\fR" 4 +.IX Item "-x path" +.PD 0 +.IP "\fB\-\-xdgb\fR \fIpath\fR" 4 +.IX Item "--xdgb path" +.PD +The path of the \f(CW\*(C`dbg\*(C'\fR C include file that maps message id's to the +symbolic name. No such file is generated without specifying the switch. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/doc/windres.1 b/support/sdbinutils/binutils/doc/windres.1 new file mode 100644 index 0000000..4f87d4e --- /dev/null +++ b/support/sdbinutils/binutils/doc/windres.1 @@ -0,0 +1,364 @@ +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "WINDRES 1" +.TH WINDRES 1 "2018-01-27" "binutils-2.30" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +windres \- manipulate Windows resources. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +windres [options] [input\-file] [output\-file] +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\fBwindres\fR reads resources from an input file and copies them into +an output file. Either file may be in one of three formats: +.ie n .IP """rc""" 4 +.el .IP "\f(CWrc\fR" 4 +.IX Item "rc" +A text format read by the Resource Compiler. +.ie n .IP """res""" 4 +.el .IP "\f(CWres\fR" 4 +.IX Item "res" +A binary format generated by the Resource Compiler. +.ie n .IP """coff""" 4 +.el .IP "\f(CWcoff\fR" 4 +.IX Item "coff" +A \s-1COFF\s0 object or executable. +.PP +The exact description of these different formats is available in +documentation from Microsoft. +.PP +When \fBwindres\fR converts from the \f(CW\*(C`rc\*(C'\fR format to the \f(CW\*(C`res\*(C'\fR +format, it is acting like the Windows Resource Compiler. When +\&\fBwindres\fR converts from the \f(CW\*(C`res\*(C'\fR format to the \f(CW\*(C`coff\*(C'\fR +format, it is acting like the Windows \f(CW\*(C`CVTRES\*(C'\fR program. +.PP +When \fBwindres\fR generates an \f(CW\*(C`rc\*(C'\fR file, the output is similar +but not identical to the format expected for the input. When an input +\&\f(CW\*(C`rc\*(C'\fR file refers to an external filename, an output \f(CW\*(C`rc\*(C'\fR file +will instead include the file contents. +.PP +If the input or output format is not specified, \fBwindres\fR will +guess based on the file name, or, for the input file, the file contents. +A file with an extension of \fI.rc\fR will be treated as an \f(CW\*(C`rc\*(C'\fR +file, a file with an extension of \fI.res\fR will be treated as a +\&\f(CW\*(C`res\*(C'\fR file, and a file with an extension of \fI.o\fR or +\&\fI.exe\fR will be treated as a \f(CW\*(C`coff\*(C'\fR file. +.PP +If no output file is specified, \fBwindres\fR will print the resources +in \f(CW\*(C`rc\*(C'\fR format to standard output. +.PP +The normal use is for you to write an \f(CW\*(C`rc\*(C'\fR file, use \fBwindres\fR +to convert it to a \s-1COFF\s0 object file, and then link the \s-1COFF\s0 file into +your application. This will make the resources described in the +\&\f(CW\*(C`rc\*(C'\fR file available to Windows. +.SH "OPTIONS" +.IX Header "OPTIONS" +.IP "\fB\-i\fR \fIfilename\fR" 4 +.IX Item "-i filename" +.PD 0 +.IP "\fB\-\-input\fR \fIfilename\fR" 4 +.IX Item "--input filename" +.PD +The name of the input file. If this option is not used, then +\&\fBwindres\fR will use the first non-option argument as the input file +name. If there are no non-option arguments, then \fBwindres\fR will +read from standard input. \fBwindres\fR can not read a \s-1COFF\s0 file from +standard input. +.IP "\fB\-o\fR \fIfilename\fR" 4 +.IX Item "-o filename" +.PD 0 +.IP "\fB\-\-output\fR \fIfilename\fR" 4 +.IX Item "--output filename" +.PD +The name of the output file. If this option is not used, then +\&\fBwindres\fR will use the first non-option argument, after any used +for the input file name, as the output file name. If there is no +non-option argument, then \fBwindres\fR will write to standard output. +\&\fBwindres\fR can not write a \s-1COFF\s0 file to standard output. Note, +for compatibility with \fBrc\fR the option \fB\-fo\fR is also +accepted, but its use is not recommended. +.IP "\fB\-J\fR \fIformat\fR" 4 +.IX Item "-J format" +.PD 0 +.IP "\fB\-\-input\-format\fR \fIformat\fR" 4 +.IX Item "--input-format format" +.PD +The input format to read. \fIformat\fR may be \fBres\fR, \fBrc\fR, or +\&\fBcoff\fR. If no input format is specified, \fBwindres\fR will +guess, as described above. +.IP "\fB\-O\fR \fIformat\fR" 4 +.IX Item "-O format" +.PD 0 +.IP "\fB\-\-output\-format\fR \fIformat\fR" 4 +.IX Item "--output-format format" +.PD +The output format to generate. \fIformat\fR may be \fBres\fR, +\&\fBrc\fR, or \fBcoff\fR. If no output format is specified, +\&\fBwindres\fR will guess, as described above. +.IP "\fB\-F\fR \fItarget\fR" 4 +.IX Item "-F target" +.PD 0 +.IP "\fB\-\-target\fR \fItarget\fR" 4 +.IX Item "--target target" +.PD +Specify the \s-1BFD\s0 format to use for a \s-1COFF\s0 file as input or output. This +is a \s-1BFD\s0 target name; you can use the \fB\-\-help\fR option to see a list +of supported targets. Normally \fBwindres\fR will use the default +format, which is the first one listed by the \fB\-\-help\fR option. +.IP "\fB\-\-preprocessor\fR \fIprogram\fR" 4 +.IX Item "--preprocessor program" +When \fBwindres\fR reads an \f(CW\*(C`rc\*(C'\fR file, it runs it through the C +preprocessor first. This option may be used to specify the preprocessor +to use, including any leading arguments. The default preprocessor +argument is \f(CW\*(C`gcc \-E \-xc\-header \-DRC_INVOKED\*(C'\fR. +.IP "\fB\-\-preprocessor\-arg\fR \fIoption\fR" 4 +.IX Item "--preprocessor-arg option" +When \fBwindres\fR reads an \f(CW\*(C`rc\*(C'\fR file, it runs it through +the C preprocessor first. This option may be used to specify additional +text to be passed to preprocessor on its command line. +This option can be used multiple times to add multiple options to the +preprocessor command line. +.IP "\fB\-I\fR \fIdirectory\fR" 4 +.IX Item "-I directory" +.PD 0 +.IP "\fB\-\-include\-dir\fR \fIdirectory\fR" 4 +.IX Item "--include-dir directory" +.PD +Specify an include directory to use when reading an \f(CW\*(C`rc\*(C'\fR file. +\&\fBwindres\fR will pass this to the preprocessor as an \fB\-I\fR +option. \fBwindres\fR will also search this directory when looking for +files named in the \f(CW\*(C`rc\*(C'\fR file. If the argument passed to this command +matches any of the supported \fIformats\fR (as described in the \fB\-J\fR +option), it will issue a deprecation warning, and behave just like the +\&\fB\-J\fR option. New programs should not use this behaviour. If a +directory happens to match a \fIformat\fR, simple prefix it with \fB./\fR +to disable the backward compatibility. +.IP "\fB\-D\fR \fItarget\fR" 4 +.IX Item "-D target" +.PD 0 +.IP "\fB\-\-define\fR \fIsym\fR\fB[=\fR\fIval\fR\fB]\fR" 4 +.IX Item "--define sym[=val]" +.PD +Specify a \fB\-D\fR option to pass to the preprocessor when reading an +\&\f(CW\*(C`rc\*(C'\fR file. +.IP "\fB\-U\fR \fItarget\fR" 4 +.IX Item "-U target" +.PD 0 +.IP "\fB\-\-undefine\fR \fIsym\fR" 4 +.IX Item "--undefine sym" +.PD +Specify a \fB\-U\fR option to pass to the preprocessor when reading an +\&\f(CW\*(C`rc\*(C'\fR file. +.IP "\fB\-r\fR" 4 +.IX Item "-r" +Ignored for compatibility with rc. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +Enable verbose mode. This tells you what the preprocessor is if you +didn't specify one. +.IP "\fB\-c\fR \fIval\fR" 4 +.IX Item "-c val" +.PD 0 +.IP "\fB\-\-codepage\fR \fIval\fR" 4 +.IX Item "--codepage val" +.PD +Specify the default codepage to use when reading an \f(CW\*(C`rc\*(C'\fR file. +\&\fIval\fR should be a hexadecimal prefixed by \fB0x\fR or decimal +codepage code. The valid range is from zero up to 0xffff, but the +validity of the codepage is host and configuration dependent. +.IP "\fB\-l\fR \fIval\fR" 4 +.IX Item "-l val" +.PD 0 +.IP "\fB\-\-language\fR \fIval\fR" 4 +.IX Item "--language val" +.PD +Specify the default language to use when reading an \f(CW\*(C`rc\*(C'\fR file. +\&\fIval\fR should be a hexadecimal language code. The low eight bits are +the language, and the high eight bits are the sublanguage. +.IP "\fB\-\-use\-temp\-file\fR" 4 +.IX Item "--use-temp-file" +Use a temporary file to instead of using popen to read the output of +the preprocessor. Use this option if the popen implementation is buggy +on the host (eg., certain non-English language versions of Windows 95 and +Windows 98 are known to have buggy popen where the output will instead +go the console). +.IP "\fB\-\-no\-use\-temp\-file\fR" 4 +.IX Item "--no-use-temp-file" +Use popen, not a temporary file, to read the output of the preprocessor. +This is the default behaviour. +.IP "\fB\-h\fR" 4 +.IX Item "-h" +.PD 0 +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +.PD +Prints a usage summary. +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Prints the version number for \fBwindres\fR. +.IP "\fB\-\-yydebug\fR" 4 +.IX Item "--yydebug" +If \fBwindres\fR is compiled with \f(CW\*(C`YYDEBUG\*(C'\fR defined as \f(CW1\fR, +this will turn on parser debugging. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991\-2018 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, with no Front-Cover Texts, and with no +Back-Cover Texts. A copy of the license is included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/support/sdbinutils/binutils/dwarf-mode.el b/support/sdbinutils/binutils/dwarf-mode.el new file mode 100644 index 0000000..8eed1b7 --- /dev/null +++ b/support/sdbinutils/binutils/dwarf-mode.el @@ -0,0 +1,218 @@ +;;; dwarf-mode.el --- Browser for DWARF information. -*-lexical-binding:t-*- + +;; Version: 1.4 + +;; Copyright (C) 2012-2018 Free Software Foundation, Inc. + +;; This file is not part of GNU Emacs, but is distributed under the +;; same terms: + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs 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 GNU Emacs. If not, see . + +;;; Code: + +(defvar dwarf-objdump-program "objdump") + +(defconst dwarf-font-lock-keywords + '( + ;; Name and linkage name. + ("DW_AT_[a-z_]*name\\s *: .*:\\(.*\\)\\s *$" + (1 font-lock-function-name-face)) + + ("Compilation Unit @ offset 0x[0-9a-f]+" + (0 font-lock-string-face)) + )) + +(defvar dwarf-file nil + "Buffer-local variable holding the file name passed to objdump.") + +(defvar dwarf--process nil + "Running objdump process, or nil.") + +(defvar dwarf--deletion-region nil + "Region to delete before inserting text in `dwarf--filter'.") + +(defun dwarf--check-running () + "Throw an exception if an objdump process is already running." + (when dwarf--process + (error "An objdump process is still running in this buffer"))) + +(defun dwarf--filter (proc string) + "Filter function for objdump processes." + (when (buffer-live-p (process-buffer proc)) + (with-current-buffer (process-buffer proc) + (save-excursion + (let ((inhibit-read-only t)) + (when dwarf--deletion-region + (apply #'delete-region dwarf--deletion-region) + (setq dwarf--deletion-region nil)) + (goto-char (process-mark proc)) + (insert string) + (set-marker (process-mark proc) (point)) + (set-buffer-modified-p nil)))))) + +(defun dwarf--sentinel (_proc _status) + (setq mode-line-process nil) + (setq dwarf--process nil)) + +(defun dwarf--invoke (start end &rest command) + "Invoke a command and arrange to insert output into the current buffer." + (setq mode-line-process "[Running]") + (setq dwarf--deletion-region (list start end)) + (setq dwarf--process (make-process :name "objdump" + :buffer (current-buffer) + :command command + :connection-type 'pipe + :noquery t + :filter #'dwarf--filter + :sentinel #'dwarf--sentinel)) + (set-marker (process-mark dwarf--process) (point))) + +;; Expand a "..." to show all the child DIES. NEW-DEPTH controls how +;; deep to display the new dies; `nil' means display all of them. +(defun dwarf-do-insert-substructure (new-depth die) + (dwarf--check-running) + (let ((inhibit-read-only t)) + (beginning-of-line) + (apply #'dwarf--invoke + (point) (save-excursion + (end-of-line) + (forward-char) + (point)) + dwarf-objdump-program "-Wi" (concat "--dwarf-start=0x" die) + (expand-file-name dwarf-file) + (if new-depth (list (concat "--dwarf-depth=" + (int-to-string new-depth))))) + (set-buffer-modified-p nil))) + +(defun dwarf-insert-substructure-button (die) + (beginning-of-line) + (unless (looking-at "^ <\\([0-9]+\\)>") + (error "Unrecognized line.")) + (let ((new-depth (1+ (string-to-number (match-string 1))))) + (dwarf-do-insert-substructure new-depth die))) + +(defun dwarf-insert-substructure (arg) + "Expand a `...' to show children of the current DIE. +By default, expands just one level of children. +A prefix argument means expand all children." + (interactive "P") + (beginning-of-line) + (unless (looking-at "^ <\\([0-9]+\\)><\\([0-9a-f]+\\)>") + (error "Unrecognized line.")) + (let ((die (match-string 2))) + (if arg + (dwarf-do-insert-substructure nil die) + (dwarf-insert-substructure-button die)))) + +;; Called when a button is pressed. +;; Either follows a DIE reference, or expands a "...". +(defun dwarf-die-button-action (button) + (let* ((die (button-get button 'die)) + ;; Note that the first number can only be decimal. + (die-rx (concat "^\\s *\\(<[0-9]+>\\)?<" + die ">[^<]")) + (old (point)) + (is-ref (button-get button 'die-ref))) + (if is-ref + (progn + (goto-char (point-min)) + (if (re-search-forward die-rx nil 'move) + (push-mark old) + (goto-char old) + (error "Could not find DIE <0x%s>" die))) + (dwarf-insert-substructure-button die)))) + +;; Button definition. +(define-button-type 'dwarf-die-button + 'follow-link t + 'action #'dwarf-die-button-action) + +;; Helper regexp to match a DIE reference. +(defconst dwarf-die-reference "\\(<0x\\([0-9a-f]+\\)>\\)") + +;; Helper regexp to match a `...' indicating that there are hidden +;; children. +(defconst dwarf-die-more "^ <[0-9]+><\\([0-9a-z]+\\)>: \\([.][.][.]\\)") + +;; jit-lock callback function to fontify a region. This applies the +;; buttons, since AFAICT there is no good way to apply buttons via +;; font-lock. +(defun dwarf-fontify-region (start end) + (save-excursion + (let ((beg-line (progn (goto-char start) (line-beginning-position))) + (end-line (progn (goto-char end) (line-end-position)))) + (goto-char beg-line) + (while (re-search-forward dwarf-die-reference end-line 'move) + (let ((b-start (match-beginning 1)) + (b-end (match-end 1)) + (hex (match-string-no-properties 2))) + (make-text-button b-start b-end :type 'dwarf-die-button + 'die hex 'die-ref t))) + ;; This is a bogus approach. Why can't we make buttons from the + ;; font-lock defaults? + (goto-char beg-line) + (while (re-search-forward dwarf-die-more end-line 'move) + (let ((hex (match-string-no-properties 1)) + (b-start (match-beginning 2)) + (b-end (match-end 2))) + (make-text-button b-start b-end :type 'dwarf-die-button + 'die hex 'die-ref nil)))))) + +;; Run objdump and insert the contents into the buffer. The arguments +;; are the way they are because this is also called as a +;; revert-buffer-function. +(defun dwarf-do-refresh (&rest ignore) + (dwarf--check-running) + (let ((inhibit-read-only t)) + (dwarf--invoke (point-min) (point-max) + dwarf-objdump-program "-Wi" "--dwarf-depth=1" + (expand-file-name dwarf-file)) + (set-buffer-modified-p nil))) + +(defvar dwarf-mode-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map special-mode-map) + (define-key map [(control ?m)] #'dwarf-insert-substructure) + map) + "Keymap for dwarf-mode buffers.") + +(define-derived-mode dwarf-mode special-mode "DWARF" + "Major mode for browsing DWARF output. + +\\{dwarf-mode-map}" + + (set (make-local-variable 'font-lock-defaults) '(dwarf-font-lock-keywords)) + ;; FIXME: we could be smarter and check the file time. + (set (make-local-variable 'revert-buffer-function) #'dwarf-do-refresh) + (jit-lock-register #'dwarf-fontify-region)) + +;;;###autoload +(defun dwarf-browse (file) + "Invoke `objdump' and put output into a `dwarf-mode' buffer. +This is the main interface to `dwarf-mode'." + (interactive "fFile name: ") + (let* ((base-name (file-name-nondirectory file)) + (buffer (generate-new-buffer (concat "*DWARF for " base-name "*")))) + (pop-to-buffer buffer) + (dwarf-mode) + (setq default-directory (file-name-directory file)) + (set (make-local-variable 'dwarf-file) file) + (set (make-local-variable 'dwarf--process) nil) + (set (make-local-variable 'dwarf--deletion-region) nil) + (dwarf-do-refresh))) + +(provide 'dwarf-mode) + +;;; dwarf-mode.el ends here diff --git a/support/sdbinutils/binutils/dwarf.c b/support/sdbinutils/binutils/dwarf.c new file mode 100644 index 0000000..6dee8aa --- /dev/null +++ b/support/sdbinutils/binutils/dwarf.c @@ -0,0 +1,10160 @@ +/* dwarf.c -- display DWARF contents of a BFD binary file + Copyright (C) 2005-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "sysdep.h" +#include "libiberty.h" +#include "bfd.h" +#include "bfd_stdint.h" +#include "bucomm.h" +#include "elfcomm.h" +#include "elf/common.h" +#include "dwarf2.h" +#include "dwarf.h" +#include "gdb/gdb-index.h" +#include "filenames.h" +#include + +#undef MAX +#undef MIN +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +static const char *regname (unsigned int regno, int row); + +static int have_frame_base; +static int need_base_address; + +static unsigned int num_debug_info_entries = 0; +static unsigned int alloc_num_debug_info_entries = 0; +static debug_info *debug_information = NULL; +/* Special value for num_debug_info_entries to indicate + that the .debug_info section could not be loaded/parsed. */ +#define DEBUG_INFO_UNAVAILABLE (unsigned int) -1 + +static const char * dwo_name; +static const char * dwo_dir; +static const unsigned char * dwo_id; +static bfd_size_type dwo_id_len; +static bfd_boolean need_dwo_info; + +unsigned int eh_addr_size; + +int do_debug_info; +int do_debug_abbrevs; +int do_debug_lines; +int do_debug_pubnames; +int do_debug_pubtypes; +int do_debug_aranges; +int do_debug_ranges; +int do_debug_frames; +int do_debug_frames_interp; +int do_debug_macinfo; +int do_debug_str; +int do_debug_loc; +int do_gdb_index; +int do_trace_info; +int do_trace_abbrevs; +int do_trace_aranges; +int do_debug_addr; +int do_debug_cu_index; +int do_wide; +int do_debug_links; +int do_follow_links; + +int dwarf_cutoff_level = -1; +unsigned long dwarf_start_die; + +int dwarf_check = 0; + +/* Convenient constant, to avoid having to cast -1 to dwarf_vma when + testing whether e.g. a locview list is present. */ +static const dwarf_vma vm1 = -1; + +/* Collection of CU/TU section sets from .debug_cu_index and .debug_tu_index + sections. For version 1 package files, each set is stored in SHNDX_POOL + as a zero-terminated list of section indexes comprising one set of debug + sections from a .dwo file. */ + +static unsigned int *shndx_pool = NULL; +static unsigned int shndx_pool_size = 0; +static unsigned int shndx_pool_used = 0; + +/* Pointer to a separate file containing extra debug information. */ +static void * separate_debug_file = NULL; +static const char * separate_debug_filename = NULL; + +/* For version 2 package files, each set contains an array of section offsets + and an array of section sizes, giving the offset and size of the + contribution from a CU or TU within one of the debug sections. + When displaying debug info from a package file, we need to use these + tables to locate the corresponding contributions to each section. */ + +struct cu_tu_set +{ + uint64_t signature; + dwarf_vma section_offsets[DW_SECT_MAX]; + size_t section_sizes[DW_SECT_MAX]; +}; + +static int cu_count = 0; +static int tu_count = 0; +static struct cu_tu_set *cu_sets = NULL; +static struct cu_tu_set *tu_sets = NULL; + +static bfd_boolean load_cu_tu_indexes (void *); + +/* Values for do_debug_lines. */ +#define FLAG_DEBUG_LINES_RAW 1 +#define FLAG_DEBUG_LINES_DECODED 2 + +static unsigned int +size_of_encoded_value (int encoding) +{ + switch (encoding & 0x7) + { + default: /* ??? */ + case 0: return eh_addr_size; + case 2: return 2; + case 3: return 4; + case 4: return 8; + } +} + +static dwarf_vma +get_encoded_value (unsigned char **pdata, + int encoding, + struct dwarf_section *section, + unsigned char * end) +{ + unsigned char * data = * pdata; + unsigned int size = size_of_encoded_value (encoding); + dwarf_vma val; + + if (data + size >= end) + { + warn (_("Encoded value extends past end of section\n")); + * pdata = end; + return 0; + } + + /* PR 17512: file: 002-829853-0.004. */ + if (size > 8) + { + warn (_("Encoded size of %d is too large to read\n"), size); + * pdata = end; + return 0; + } + + /* PR 17512: file: 1085-5603-0.004. */ + if (size == 0) + { + warn (_("Encoded size of 0 is too small to read\n")); + * pdata = end; + return 0; + } + + if (encoding & DW_EH_PE_signed) + val = byte_get_signed (data, size); + else + val = byte_get (data, size); + + if ((encoding & 0x70) == DW_EH_PE_pcrel) + val += section->address + (data - section->start); + + * pdata = data + size; + return val; +} + +#if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG +# ifndef __MINGW32__ +# define DWARF_VMA_FMT "ll" +# define DWARF_VMA_FMT_LONG "%16.16llx" +# else +# define DWARF_VMA_FMT "I64" +# define DWARF_VMA_FMT_LONG "%016I64x" +# endif +#else +# define DWARF_VMA_FMT "l" +# define DWARF_VMA_FMT_LONG "%16.16lx" +#endif + +/* Convert a dwarf vma value into a string. Returns a pointer to a static + buffer containing the converted VALUE. The value is converted according + to the printf formating character FMTCH. If NUM_BYTES is non-zero then + it specifies the maximum number of bytes to be displayed in the converted + value and FMTCH is ignored - hex is always used. */ + +static const char * +dwarf_vmatoa_1 (const char *fmtch, dwarf_vma value, unsigned num_bytes) +{ + /* As dwarf_vmatoa is used more then once in a printf call + for output, we are cycling through an fixed array of pointers + for return address. */ + static int buf_pos = 0; + static struct dwarf_vmatoa_buf + { + char place[64]; + } buf[16]; + char *ret; + + ret = buf[buf_pos++].place; + buf_pos %= ARRAY_SIZE (buf); + + if (num_bytes) + { + /* Printf does not have a way of specifying a maximum field width for an + integer value, so we print the full value into a buffer and then select + the precision we need. */ + snprintf (ret, sizeof (buf[0].place), DWARF_VMA_FMT_LONG, value); + if (num_bytes > 8) + num_bytes = 8; + return ret + (16 - 2 * num_bytes); + } + else + { + char fmt[32]; + + if (fmtch) + sprintf (fmt, "%%%s%s", DWARF_VMA_FMT, fmtch); + else + sprintf (fmt, "%%%s", DWARF_VMA_FMT); + snprintf (ret, sizeof (buf[0].place), fmt, value); + return ret; + } +} + +static inline const char * +dwarf_vmatoa (const char * fmtch, dwarf_vma value) +{ + return dwarf_vmatoa_1 (fmtch, value, 0); +} + +/* Print a dwarf_vma value (typically an address, offset or length) in + hexadecimal format, followed by a space. The length of the VALUE (and + hence the precision displayed) is determined by the NUM_BYTES parameter. */ + +static void +print_dwarf_vma (dwarf_vma value, unsigned num_bytes) +{ + printf ("%s ", dwarf_vmatoa_1 (NULL, value, num_bytes)); +} + +/* Print a view number in hexadecimal value, with the same width + print_dwarf_vma would have printed it with the same num_bytes. + Print blanks for zero view, unless force is nonzero. */ + +static void +print_dwarf_view (dwarf_vma value, unsigned num_bytes, int force) +{ + int len; + if (!num_bytes) + len = 4; + else + len = num_bytes * 2; + + assert (value == (unsigned long) value); + if (value || force) + printf ("v%0*lx ", len - 1, (unsigned long) value); + else + printf ("%*s", len + 1, ""); +} + +/* Format a 64-bit value, given as two 32-bit values, in hex. + For reentrancy, this uses a buffer provided by the caller. */ + +static const char * +dwarf_vmatoa64 (dwarf_vma hvalue, dwarf_vma lvalue, char *buf, + unsigned int buf_len) +{ + int len = 0; + + if (hvalue == 0) + snprintf (buf, buf_len, "%" DWARF_VMA_FMT "x", lvalue); + else + { + len = snprintf (buf, buf_len, "%" DWARF_VMA_FMT "x", hvalue); + snprintf (buf + len, buf_len - len, + "%08" DWARF_VMA_FMT "x", lvalue); + } + + return buf; +} + +/* Read in a LEB128 encoded value starting at address DATA. + If SIGN is true, return a signed LEB128 value. + If LENGTH_RETURN is not NULL, return in it the number of bytes read. + No bytes will be read at address END or beyond. */ + +dwarf_vma +read_leb128 (unsigned char *data, + unsigned int *length_return, + bfd_boolean sign, + const unsigned char * const end) +{ + dwarf_vma result = 0; + unsigned int num_read = 0; + unsigned int shift = 0; + unsigned char byte = 0; + + while (data < end) + { + byte = *data++; + num_read++; + + result |= ((dwarf_vma) (byte & 0x7f)) << shift; + + shift += 7; + if ((byte & 0x80) == 0) + break; + + /* PR 17512: file: 0ca183b8. + FIXME: Should we signal this error somehow ? */ + if (shift >= sizeof (result) * 8) + break; + } + + if (length_return != NULL) + *length_return = num_read; + + if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40)) + result |= -((dwarf_vma) 1 << shift); + + return result; +} + +/* Create a signed version to avoid painful typecasts. */ +static inline dwarf_signed_vma +read_sleb128 (unsigned char * data, + unsigned int * length_return, + const unsigned char * const end) +{ + return (dwarf_signed_vma) read_leb128 (data, length_return, TRUE, end); +} + +static inline dwarf_vma +read_uleb128 (unsigned char * data, + unsigned int * length_return, + const unsigned char * const end) +{ + return read_leb128 (data, length_return, FALSE, end); +} + +#define SKIP_ULEB() read_uleb128 (start, & length_return, end); start += length_return +#define SKIP_SLEB() read_sleb128 (start, & length_return, end); start += length_return + +#define READ_ULEB(var) \ + do \ + { \ + dwarf_vma _val; \ + \ + (var) = _val = read_uleb128 (start, &length_return, end); \ + if ((var) != _val) \ + error (_("Internal error: %s:%d: LEB value (%s) " \ + "too large for containing variable\n"), \ + __FILE__, __LINE__, dwarf_vmatoa ("u", _val)); \ + start += length_return; \ + } \ + while (0) + +#define READ_SLEB(var) \ + do \ + { \ + dwarf_signed_vma _val; \ + \ + (var) = _val = read_sleb128 (start, &length_return, end); \ + if ((var) != _val) \ + error (_("Internal error: %s:%d: LEB value (%s) " \ + "too large for containing variable\n"), \ + __FILE__, __LINE__, dwarf_vmatoa ("d", _val)); \ + start += length_return; \ + } \ + while (0) + +#define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \ + do \ + { \ + unsigned int amount = (AMOUNT); \ + if (sizeof (VAL) < amount) \ + { \ + error (ngettext ("internal error: attempt to read %d byte " \ + "of data in to %d sized variable", \ + "internal error: attempt to read %d bytes " \ + "of data in to %d sized variable", \ + amount), \ + amount, (int) sizeof (VAL)); \ + amount = sizeof (VAL); \ + } \ + if (((PTR) + amount) >= (END)) \ + { \ + if ((PTR) < (END)) \ + amount = (END) - (PTR); \ + else \ + amount = 0; \ + } \ + if (amount == 0 || amount > 8) \ + VAL = 0; \ + else \ + VAL = byte_get ((PTR), amount); \ + } \ + while (0) + +#define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \ + do \ + { \ + SAFE_BYTE_GET (VAL, PTR, AMOUNT, END); \ + PTR += AMOUNT; \ + } \ + while (0) + +#define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END) \ + do \ + { \ + unsigned int amount = (AMOUNT); \ + if (((PTR) + amount) >= (END)) \ + { \ + if ((PTR) < (END)) \ + amount = (END) - (PTR); \ + else \ + amount = 0; \ + } \ + if (amount) \ + VAL = byte_get_signed ((PTR), amount); \ + else \ + VAL = 0; \ + } \ + while (0) + +#define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \ + do \ + { \ + SAFE_SIGNED_BYTE_GET (VAL, PTR, AMOUNT, END); \ + PTR += AMOUNT; \ + } \ + while (0) + +#define SAFE_BYTE_GET64(PTR, HIGH, LOW, END) \ + do \ + { \ + if (((PTR) + 8) <= (END)) \ + { \ + byte_get_64 ((PTR), (HIGH), (LOW)); \ + } \ + else \ + { \ + * (LOW) = * (HIGH) = 0; \ + } \ + } \ + while (0) + +typedef struct State_Machine_Registers +{ + dwarf_vma address; + unsigned int view; + unsigned int file; + unsigned int line; + unsigned int column; + int is_stmt; + int basic_block; + unsigned char op_index; + unsigned char end_sequence; + /* This variable hold the number of the last entry seen + in the File Table. */ + unsigned int last_file_entry; +} SMR; + +static SMR state_machine_regs; + +static void +reset_state_machine (int is_stmt) +{ + state_machine_regs.address = 0; + state_machine_regs.view = 0; + state_machine_regs.op_index = 0; + state_machine_regs.file = 1; + state_machine_regs.line = 1; + state_machine_regs.column = 0; + state_machine_regs.is_stmt = is_stmt; + state_machine_regs.basic_block = 0; + state_machine_regs.end_sequence = 0; + state_machine_regs.last_file_entry = 0; +} + +/* Handled an extend line op. + Returns the number of bytes read. */ + +static int +process_extended_line_op (unsigned char * data, + int is_stmt, + unsigned char * end) +{ + unsigned char op_code; + unsigned int bytes_read; + unsigned int len; + unsigned char *name; + unsigned char *orig_data = data; + dwarf_vma adr; + + len = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + + if (len == 0 || data == end || len > (uintptr_t) (end - data)) + { + warn (_("Badly formed extended line op encountered!\n")); + return bytes_read; + } + + len += bytes_read; + op_code = *data++; + + printf (_(" Extended opcode %d: "), op_code); + + switch (op_code) + { + case DW_LNE_end_sequence: + printf (_("End of Sequence\n\n")); + reset_state_machine (is_stmt); + break; + + case DW_LNE_set_address: + /* PR 17512: file: 002-100480-0.004. */ + if (len - bytes_read - 1 > 8) + { + warn (_("Length (%d) of DW_LNE_set_address op is too long\n"), + len - bytes_read - 1); + adr = 0; + } + else + SAFE_BYTE_GET (adr, data, len - bytes_read - 1, end); + printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr)); + state_machine_regs.address = adr; + state_machine_regs.view = 0; + state_machine_regs.op_index = 0; + break; + + case DW_LNE_define_file: + printf (_("define new File Table entry\n")); + printf (_(" Entry\tDir\tTime\tSize\tName\n")); + printf (" %d\t", ++state_machine_regs.last_file_entry); + + { + size_t l; + + name = data; + l = strnlen ((char *) data, end - data); + data += len + 1; + printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + data += bytes_read; + printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + data += bytes_read; + printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + data += bytes_read; + printf ("%.*s\n\n", (int) l, name); + } + + if (((unsigned int) (data - orig_data) != len) || data == end) + warn (_("DW_LNE_define_file: Bad opcode length\n")); + break; + + case DW_LNE_set_discriminator: + printf (_("set Discriminator to %s\n"), + dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + break; + + /* HP extensions. */ + case DW_LNE_HP_negate_is_UV_update: + printf ("DW_LNE_HP_negate_is_UV_update\n"); + break; + case DW_LNE_HP_push_context: + printf ("DW_LNE_HP_push_context\n"); + break; + case DW_LNE_HP_pop_context: + printf ("DW_LNE_HP_pop_context\n"); + break; + case DW_LNE_HP_set_file_line_column: + printf ("DW_LNE_HP_set_file_line_column\n"); + break; + case DW_LNE_HP_set_routine_name: + printf ("DW_LNE_HP_set_routine_name\n"); + break; + case DW_LNE_HP_set_sequence: + printf ("DW_LNE_HP_set_sequence\n"); + break; + case DW_LNE_HP_negate_post_semantics: + printf ("DW_LNE_HP_negate_post_semantics\n"); + break; + case DW_LNE_HP_negate_function_exit: + printf ("DW_LNE_HP_negate_function_exit\n"); + break; + case DW_LNE_HP_negate_front_end_logical: + printf ("DW_LNE_HP_negate_front_end_logical\n"); + break; + case DW_LNE_HP_define_proc: + printf ("DW_LNE_HP_define_proc\n"); + break; + case DW_LNE_HP_source_file_correlation: + { + unsigned char *edata = data + len - bytes_read - 1; + + printf ("DW_LNE_HP_source_file_correlation\n"); + + while (data < edata) + { + unsigned int opc; + + opc = read_uleb128 (data, & bytes_read, edata); + data += bytes_read; + + switch (opc) + { + case DW_LNE_HP_SFC_formfeed: + printf (" DW_LNE_HP_SFC_formfeed\n"); + break; + case DW_LNE_HP_SFC_set_listing_line: + printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n", + dwarf_vmatoa ("u", + read_uleb128 (data, & bytes_read, edata))); + data += bytes_read; + break; + case DW_LNE_HP_SFC_associate: + printf (" DW_LNE_HP_SFC_associate "); + printf ("(%s", + dwarf_vmatoa ("u", + read_uleb128 (data, & bytes_read, edata))); + data += bytes_read; + printf (",%s", + dwarf_vmatoa ("u", + read_uleb128 (data, & bytes_read, edata))); + data += bytes_read; + printf (",%s)\n", + dwarf_vmatoa ("u", + read_uleb128 (data, & bytes_read, edata))); + data += bytes_read; + break; + default: + printf (_(" UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc); + data = edata; + break; + } + } + } + break; + + default: + { + unsigned int rlen = len - bytes_read - 1; + + if (op_code >= DW_LNE_lo_user + /* The test against DW_LNW_hi_user is redundant due to + the limited range of the unsigned char data type used + for op_code. */ + /*&& op_code <= DW_LNE_hi_user*/) + printf (_("user defined: ")); + else + printf (_("UNKNOWN: ")); + printf (_("length %d ["), rlen); + for (; rlen; rlen--) + printf (" %02x", *data++); + printf ("]\n"); + } + break; + } + + return len; +} + +static const unsigned char * +fetch_indirect_string (dwarf_vma offset) +{ + struct dwarf_section *section = &debug_displays [str].section; + const unsigned char * ret; + + if (section->start == NULL) + return (const unsigned char *) _(""); + + if (offset >= section->size) + { + warn (_("DW_FORM_strp offset too big: %s\n"), + dwarf_vmatoa ("x", offset)); + return (const unsigned char *) _(""); + } + + ret = section->start + offset; + /* Unfortunately we cannot rely upon the .debug_str section ending with a + NUL byte. Since our caller is expecting to receive a well formed C + string we test for the lack of a terminating byte here. */ + if (strnlen ((const char *) ret, section->size - offset) + == section->size - offset) + ret = (const unsigned char *) + _(""); + + return ret; +} + +static const unsigned char * +fetch_indirect_line_string (dwarf_vma offset) +{ + struct dwarf_section *section = &debug_displays [line_str].section; + const unsigned char * ret; + + if (section->start == NULL) + return (const unsigned char *) _(""); + + if (offset >= section->size) + { + warn (_("DW_FORM_line_strp offset too big: %s\n"), + dwarf_vmatoa ("x", offset)); + return (const unsigned char *) _(""); + } + + ret = section->start + offset; + /* Unfortunately we cannot rely upon the .debug_line_str section ending + with a NUL byte. Since our caller is expecting to receive a well formed + C string we test for the lack of a terminating byte here. */ + if (strnlen ((const char *) ret, section->size - offset) + == section->size - offset) + ret = (const unsigned char *) + _(""); + + return ret; +} + +static const char * +fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set, + dwarf_vma offset_size, bfd_boolean dwo) +{ + enum dwarf_section_display_enum str_sec_idx = dwo ? str_dwo : str; + enum dwarf_section_display_enum idx_sec_idx = dwo ? str_index_dwo : str_index; + struct dwarf_section *index_section = &debug_displays [idx_sec_idx].section; + struct dwarf_section *str_section = &debug_displays [str_sec_idx].section; + dwarf_vma index_offset = idx * offset_size; + dwarf_vma str_offset; + const char * ret; + + if (index_section->start == NULL) + return (dwo ? _("") + : _("")); + + if (this_set != NULL) + index_offset += this_set->section_offsets [DW_SECT_STR_OFFSETS]; + if (index_offset >= index_section->size) + { + warn (_("DW_FORM_GNU_str_index offset too big: %s\n"), + dwarf_vmatoa ("x", index_offset)); + return _(""); + } + + if (str_section->start == NULL) + return (dwo ? _("") + : _("")); + + str_offset = byte_get (index_section->start + index_offset, offset_size); + str_offset -= str_section->address; + if (str_offset >= str_section->size) + { + warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"), + dwarf_vmatoa ("x", str_offset)); + return _(""); + } + + ret = (const char *) str_section->start + str_offset; + /* Unfortunately we cannot rely upon str_section ending with a NUL byte. + Since our caller is expecting to receive a well formed C string we test + for the lack of a terminating byte here. */ + if (strnlen (ret, str_section->size - str_offset) + == str_section->size - str_offset) + ret = (const char *) _(""); + + return ret; +} + +static const char * +fetch_indexed_value (dwarf_vma offset, dwarf_vma bytes) +{ + struct dwarf_section *section = &debug_displays [debug_addr].section; + + if (section->start == NULL) + return (_("")); + + if (offset + bytes > section->size) + { + warn (_("Offset into section %s too big: %s\n"), + section->name, dwarf_vmatoa ("x", offset)); + return ""; + } + + return dwarf_vmatoa ("x", byte_get (section->start + offset, bytes)); +} + + +/* FIXME: There are better and more efficient ways to handle + these structures. For now though, I just want something that + is simple to implement. */ +typedef struct abbrev_attr +{ + unsigned long attribute; + unsigned long form; + bfd_signed_vma implicit_const; + struct abbrev_attr *next; +} +abbrev_attr; + +typedef struct abbrev_entry +{ + unsigned long entry; + unsigned long tag; + int children; + struct abbrev_attr *first_attr; + struct abbrev_attr *last_attr; + struct abbrev_entry *next; +} +abbrev_entry; + +static abbrev_entry *first_abbrev = NULL; +static abbrev_entry *last_abbrev = NULL; + +static void +free_abbrevs (void) +{ + abbrev_entry *abbrv; + + for (abbrv = first_abbrev; abbrv;) + { + abbrev_entry *next_abbrev = abbrv->next; + abbrev_attr *attr; + + for (attr = abbrv->first_attr; attr;) + { + abbrev_attr *next_attr = attr->next; + + free (attr); + attr = next_attr; + } + + free (abbrv); + abbrv = next_abbrev; + } + + last_abbrev = first_abbrev = NULL; +} + +static void +add_abbrev (unsigned long number, unsigned long tag, int children) +{ + abbrev_entry *entry; + + entry = (abbrev_entry *) malloc (sizeof (*entry)); + if (entry == NULL) + /* ugg */ + return; + + entry->entry = number; + entry->tag = tag; + entry->children = children; + entry->first_attr = NULL; + entry->last_attr = NULL; + entry->next = NULL; + + if (first_abbrev == NULL) + first_abbrev = entry; + else + last_abbrev->next = entry; + + last_abbrev = entry; +} + +static void +add_abbrev_attr (unsigned long attribute, unsigned long form, + bfd_signed_vma implicit_const) +{ + abbrev_attr *attr; + + attr = (abbrev_attr *) malloc (sizeof (*attr)); + if (attr == NULL) + /* ugg */ + return; + + attr->attribute = attribute; + attr->form = form; + attr->implicit_const = implicit_const; + attr->next = NULL; + + if (last_abbrev->first_attr == NULL) + last_abbrev->first_attr = attr; + else + last_abbrev->last_attr->next = attr; + + last_abbrev->last_attr = attr; +} + +/* Processes the (partial) contents of a .debug_abbrev section. + Returns NULL if the end of the section was encountered. + Returns the address after the last byte read if the end of + an abbreviation set was found. */ + +static unsigned char * +process_abbrev_section (unsigned char *start, unsigned char *end) +{ + if (first_abbrev != NULL) + return NULL; + + while (start < end) + { + unsigned int bytes_read; + unsigned long entry; + unsigned long tag; + unsigned long attribute; + int children; + + entry = read_uleb128 (start, & bytes_read, end); + start += bytes_read; + + /* A single zero is supposed to end the section according + to the standard. If there's more, then signal that to + the caller. */ + if (start == end) + return NULL; + if (entry == 0) + return start; + + tag = read_uleb128 (start, & bytes_read, end); + start += bytes_read; + if (start == end) + return NULL; + + children = *start++; + + add_abbrev (entry, tag, children); + + do + { + unsigned long form; + /* Initialize it due to a false compiler warning. */ + bfd_signed_vma implicit_const = -1; + + attribute = read_uleb128 (start, & bytes_read, end); + start += bytes_read; + if (start == end) + break; + + form = read_uleb128 (start, & bytes_read, end); + start += bytes_read; + if (start == end) + break; + + if (form == DW_FORM_implicit_const) + { + implicit_const = read_sleb128 (start, & bytes_read, end); + start += bytes_read; + if (start == end) + break; + } + + add_abbrev_attr (attribute, form, implicit_const); + } + while (attribute != 0); + } + + /* Report the missing single zero which ends the section. */ + error (_(".debug_abbrev section not zero terminated\n")); + + return NULL; +} + +static const char * +get_TAG_name (unsigned long tag) +{ + const char *name = get_DW_TAG_name ((unsigned int) tag); + + if (name == NULL) + { + static char buffer[100]; + + if (tag >= DW_TAG_lo_user && tag <= DW_TAG_hi_user) + snprintf (buffer, sizeof (buffer), _("User TAG value: %#lx"), tag); + else + snprintf (buffer, sizeof (buffer), _("Unknown TAG value: %#lx"), tag); + return buffer; + } + + return name; +} + +static const char * +get_FORM_name (unsigned long form) +{ + const char *name; + + if (form == 0) + return "DW_FORM value: 0"; + + name = get_DW_FORM_name (form); + if (name == NULL) + { + static char buffer[100]; + + snprintf (buffer, sizeof (buffer), _("Unknown FORM value: %lx"), form); + return buffer; + } + + return name; +} + +static const char * +get_IDX_name (unsigned long idx) +{ + const char *name = get_DW_IDX_name ((unsigned int) idx); + + if (name == NULL) + { + static char buffer[100]; + + snprintf (buffer, sizeof (buffer), _("Unknown IDX value: %lx"), idx); + return buffer; + } + + return name; +} + +static unsigned char * +display_block (unsigned char *data, + dwarf_vma length, + const unsigned char * const end, char delimiter) +{ + dwarf_vma maxlen; + + printf (_("%c%s byte block: "), delimiter, dwarf_vmatoa ("u", length)); + if (data > end) + return (unsigned char *) end; + + maxlen = (dwarf_vma) (end - data); + length = length > maxlen ? maxlen : length; + + while (length --) + printf ("%lx ", (unsigned long) byte_get (data++, 1)); + + return data; +} + +static int +decode_location_expression (unsigned char * data, + unsigned int pointer_size, + unsigned int offset_size, + int dwarf_version, + dwarf_vma length, + dwarf_vma cu_offset, + struct dwarf_section * section) +{ + unsigned op; + unsigned int bytes_read; + dwarf_vma uvalue; + dwarf_signed_vma svalue; + unsigned char *end = data + length; + int need_frame_base = 0; + + while (data < end) + { + op = *data++; + + switch (op) + { + case DW_OP_addr: + SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); + printf ("DW_OP_addr: %s", dwarf_vmatoa ("x", uvalue)); + break; + case DW_OP_deref: + printf ("DW_OP_deref"); + break; + case DW_OP_const1u: + SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); + printf ("DW_OP_const1u: %lu", (unsigned long) uvalue); + break; + case DW_OP_const1s: + SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 1, end); + printf ("DW_OP_const1s: %ld", (long) svalue); + break; + case DW_OP_const2u: + SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end); + printf ("DW_OP_const2u: %lu", (unsigned long) uvalue); + break; + case DW_OP_const2s: + SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); + printf ("DW_OP_const2s: %ld", (long) svalue); + break; + case DW_OP_const4u: + SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); + printf ("DW_OP_const4u: %lu", (unsigned long) uvalue); + break; + case DW_OP_const4s: + SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); + printf ("DW_OP_const4s: %ld", (long) svalue); + break; + case DW_OP_const8u: + SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); + printf ("DW_OP_const8u: %lu ", (unsigned long) uvalue); + SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); + printf ("%lu", (unsigned long) uvalue); + break; + case DW_OP_const8s: + SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); + printf ("DW_OP_const8s: %ld ", (long) svalue); + SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); + printf ("%ld", (long) svalue); + break; + case DW_OP_constu: + printf ("DW_OP_constu: %s", + dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_consts: + printf ("DW_OP_consts: %s", + dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_dup: + printf ("DW_OP_dup"); + break; + case DW_OP_drop: + printf ("DW_OP_drop"); + break; + case DW_OP_over: + printf ("DW_OP_over"); + break; + case DW_OP_pick: + SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); + printf ("DW_OP_pick: %ld", (unsigned long) uvalue); + break; + case DW_OP_swap: + printf ("DW_OP_swap"); + break; + case DW_OP_rot: + printf ("DW_OP_rot"); + break; + case DW_OP_xderef: + printf ("DW_OP_xderef"); + break; + case DW_OP_abs: + printf ("DW_OP_abs"); + break; + case DW_OP_and: + printf ("DW_OP_and"); + break; + case DW_OP_div: + printf ("DW_OP_div"); + break; + case DW_OP_minus: + printf ("DW_OP_minus"); + break; + case DW_OP_mod: + printf ("DW_OP_mod"); + break; + case DW_OP_mul: + printf ("DW_OP_mul"); + break; + case DW_OP_neg: + printf ("DW_OP_neg"); + break; + case DW_OP_not: + printf ("DW_OP_not"); + break; + case DW_OP_or: + printf ("DW_OP_or"); + break; + case DW_OP_plus: + printf ("DW_OP_plus"); + break; + case DW_OP_plus_uconst: + printf ("DW_OP_plus_uconst: %s", + dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_shl: + printf ("DW_OP_shl"); + break; + case DW_OP_shr: + printf ("DW_OP_shr"); + break; + case DW_OP_shra: + printf ("DW_OP_shra"); + break; + case DW_OP_xor: + printf ("DW_OP_xor"); + break; + case DW_OP_bra: + SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); + printf ("DW_OP_bra: %ld", (long) svalue); + break; + case DW_OP_eq: + printf ("DW_OP_eq"); + break; + case DW_OP_ge: + printf ("DW_OP_ge"); + break; + case DW_OP_gt: + printf ("DW_OP_gt"); + break; + case DW_OP_le: + printf ("DW_OP_le"); + break; + case DW_OP_lt: + printf ("DW_OP_lt"); + break; + case DW_OP_ne: + printf ("DW_OP_ne"); + break; + case DW_OP_skip: + SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); + printf ("DW_OP_skip: %ld", (long) svalue); + break; + + case DW_OP_lit0: + case DW_OP_lit1: + case DW_OP_lit2: + case DW_OP_lit3: + case DW_OP_lit4: + case DW_OP_lit5: + case DW_OP_lit6: + case DW_OP_lit7: + case DW_OP_lit8: + case DW_OP_lit9: + case DW_OP_lit10: + case DW_OP_lit11: + case DW_OP_lit12: + case DW_OP_lit13: + case DW_OP_lit14: + case DW_OP_lit15: + case DW_OP_lit16: + case DW_OP_lit17: + case DW_OP_lit18: + case DW_OP_lit19: + case DW_OP_lit20: + case DW_OP_lit21: + case DW_OP_lit22: + case DW_OP_lit23: + case DW_OP_lit24: + case DW_OP_lit25: + case DW_OP_lit26: + case DW_OP_lit27: + case DW_OP_lit28: + case DW_OP_lit29: + case DW_OP_lit30: + case DW_OP_lit31: + printf ("DW_OP_lit%d", op - DW_OP_lit0); + break; + + case DW_OP_reg0: + case DW_OP_reg1: + case DW_OP_reg2: + case DW_OP_reg3: + case DW_OP_reg4: + case DW_OP_reg5: + case DW_OP_reg6: + case DW_OP_reg7: + case DW_OP_reg8: + case DW_OP_reg9: + case DW_OP_reg10: + case DW_OP_reg11: + case DW_OP_reg12: + case DW_OP_reg13: + case DW_OP_reg14: + case DW_OP_reg15: + case DW_OP_reg16: + case DW_OP_reg17: + case DW_OP_reg18: + case DW_OP_reg19: + case DW_OP_reg20: + case DW_OP_reg21: + case DW_OP_reg22: + case DW_OP_reg23: + case DW_OP_reg24: + case DW_OP_reg25: + case DW_OP_reg26: + case DW_OP_reg27: + case DW_OP_reg28: + case DW_OP_reg29: + case DW_OP_reg30: + case DW_OP_reg31: + printf ("DW_OP_reg%d (%s)", op - DW_OP_reg0, + regname (op - DW_OP_reg0, 1)); + break; + + case DW_OP_breg0: + case DW_OP_breg1: + case DW_OP_breg2: + case DW_OP_breg3: + case DW_OP_breg4: + case DW_OP_breg5: + case DW_OP_breg6: + case DW_OP_breg7: + case DW_OP_breg8: + case DW_OP_breg9: + case DW_OP_breg10: + case DW_OP_breg11: + case DW_OP_breg12: + case DW_OP_breg13: + case DW_OP_breg14: + case DW_OP_breg15: + case DW_OP_breg16: + case DW_OP_breg17: + case DW_OP_breg18: + case DW_OP_breg19: + case DW_OP_breg20: + case DW_OP_breg21: + case DW_OP_breg22: + case DW_OP_breg23: + case DW_OP_breg24: + case DW_OP_breg25: + case DW_OP_breg26: + case DW_OP_breg27: + case DW_OP_breg28: + case DW_OP_breg29: + case DW_OP_breg30: + case DW_OP_breg31: + printf ("DW_OP_breg%d (%s): %s", + op - DW_OP_breg0, + regname (op - DW_OP_breg0, 1), + dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + + case DW_OP_regx: + uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("DW_OP_regx: %s (%s)", + dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); + break; + case DW_OP_fbreg: + need_frame_base = 1; + printf ("DW_OP_fbreg: %s", + dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_bregx: + uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("DW_OP_bregx: %s (%s) %s", + dwarf_vmatoa ("u", uvalue), regname (uvalue, 1), + dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_piece: + printf ("DW_OP_piece: %s", + dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_deref_size: + SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); + printf ("DW_OP_deref_size: %ld", (long) uvalue); + break; + case DW_OP_xderef_size: + SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); + printf ("DW_OP_xderef_size: %ld", (long) uvalue); + break; + case DW_OP_nop: + printf ("DW_OP_nop"); + break; + + /* DWARF 3 extensions. */ + case DW_OP_push_object_address: + printf ("DW_OP_push_object_address"); + break; + case DW_OP_call2: + /* FIXME: Strictly speaking for 64-bit DWARF3 files + this ought to be an 8-byte wide computation. */ + SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); + printf ("DW_OP_call2: <0x%s>", + dwarf_vmatoa ("x", svalue + cu_offset)); + break; + case DW_OP_call4: + /* FIXME: Strictly speaking for 64-bit DWARF3 files + this ought to be an 8-byte wide computation. */ + SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); + printf ("DW_OP_call4: <0x%s>", + dwarf_vmatoa ("x", svalue + cu_offset)); + break; + case DW_OP_call_ref: + /* FIXME: Strictly speaking for 64-bit DWARF3 files + this ought to be an 8-byte wide computation. */ + if (dwarf_version == -1) + { + printf (_("(DW_OP_call_ref in frame info)")); + /* No way to tell where the next op is, so just bail. */ + return need_frame_base; + } + if (dwarf_version == 2) + { + SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); + } + else + { + SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); + } + printf ("DW_OP_call_ref: <0x%s>", dwarf_vmatoa ("x", uvalue)); + break; + case DW_OP_form_tls_address: + printf ("DW_OP_form_tls_address"); + break; + case DW_OP_call_frame_cfa: + printf ("DW_OP_call_frame_cfa"); + break; + case DW_OP_bit_piece: + printf ("DW_OP_bit_piece: "); + printf (_("size: %s "), + dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); + data += bytes_read; + printf (_("offset: %s "), + dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + + /* DWARF 4 extensions. */ + case DW_OP_stack_value: + printf ("DW_OP_stack_value"); + break; + + case DW_OP_implicit_value: + printf ("DW_OP_implicit_value"); + uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + data = display_block (data, uvalue, end, ' '); + break; + + /* GNU extensions. */ + case DW_OP_GNU_push_tls_address: + printf (_("DW_OP_GNU_push_tls_address or DW_OP_HP_unknown")); + break; + case DW_OP_GNU_uninit: + printf ("DW_OP_GNU_uninit"); + /* FIXME: Is there data associated with this OP ? */ + break; + case DW_OP_GNU_encoded_addr: + { + int encoding = 0; + dwarf_vma addr; + + if (data < end) + encoding = *data++; + addr = get_encoded_value (&data, encoding, section, end); + + printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding); + print_dwarf_vma (addr, pointer_size); + } + break; + case DW_OP_implicit_pointer: + case DW_OP_GNU_implicit_pointer: + /* FIXME: Strictly speaking for 64-bit DWARF3 files + this ought to be an 8-byte wide computation. */ + if (dwarf_version == -1) + { + printf (_("(%s in frame info)"), + (op == DW_OP_implicit_pointer + ? "DW_OP_implicit_pointer" + : "DW_OP_GNU_implicit_pointer")); + /* No way to tell where the next op is, so just bail. */ + return need_frame_base; + } + if (dwarf_version == 2) + { + SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); + } + else + { + SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); + } + printf ("%s: <0x%s> %s", + (op == DW_OP_implicit_pointer + ? "DW_OP_implicit_pointer" : "DW_OP_GNU_implicit_pointer"), + dwarf_vmatoa ("x", uvalue), + dwarf_vmatoa ("d", read_sleb128 (data, + &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_entry_value: + case DW_OP_GNU_entry_value: + uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + /* PR 17531: file: 0cc9cd00. */ + if (uvalue > (dwarf_vma) (end - data)) + uvalue = end - data; + printf ("%s: (", (op == DW_OP_entry_value ? "DW_OP_entry_value" + : "DW_OP_GNU_entry_value")); + if (decode_location_expression (data, pointer_size, offset_size, + dwarf_version, uvalue, + cu_offset, section)) + need_frame_base = 1; + putchar (')'); + data += uvalue; + if (data > end) + data = end; + break; + case DW_OP_const_type: + case DW_OP_GNU_const_type: + uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("%s: <0x%s> ", + (op == DW_OP_const_type ? "DW_OP_const_type" + : "DW_OP_GNU_const_type"), + dwarf_vmatoa ("x", cu_offset + uvalue)); + SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); + data = display_block (data, uvalue, end, ' '); + break; + case DW_OP_regval_type: + case DW_OP_GNU_regval_type: + uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("%s: %s (%s)", + (op == DW_OP_regval_type ? "DW_OP_regval_type" + : "DW_OP_GNU_regval_type"), + dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); + uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); + break; + case DW_OP_deref_type: + case DW_OP_GNU_deref_type: + SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); + printf ("%s: %ld", + (op == DW_OP_deref_type ? "DW_OP_deref_type" + : "DW_OP_GNU_deref_type"), + (long) uvalue); + uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); + break; + case DW_OP_convert: + case DW_OP_GNU_convert: + uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("%s <0x%s>", + (op == DW_OP_convert ? "DW_OP_convert" : "DW_OP_GNU_convert"), + dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); + break; + case DW_OP_reinterpret: + case DW_OP_GNU_reinterpret: + uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("%s <0x%s>", + (op == DW_OP_reinterpret ? "DW_OP_reinterpret" + : "DW_OP_GNU_reinterpret"), + dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); + break; + case DW_OP_GNU_parameter_ref: + SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); + printf ("DW_OP_GNU_parameter_ref: <0x%s>", + dwarf_vmatoa ("x", cu_offset + uvalue)); + break; + case DW_OP_GNU_addr_index: + uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue)); + break; + case DW_OP_GNU_const_index: + uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("DW_OP_GNU_const_index <0x%s>", dwarf_vmatoa ("x", uvalue)); + break; + + /* HP extensions. */ + case DW_OP_HP_is_value: + printf ("DW_OP_HP_is_value"); + /* FIXME: Is there data associated with this OP ? */ + break; + case DW_OP_HP_fltconst4: + printf ("DW_OP_HP_fltconst4"); + /* FIXME: Is there data associated with this OP ? */ + break; + case DW_OP_HP_fltconst8: + printf ("DW_OP_HP_fltconst8"); + /* FIXME: Is there data associated with this OP ? */ + break; + case DW_OP_HP_mod_range: + printf ("DW_OP_HP_mod_range"); + /* FIXME: Is there data associated with this OP ? */ + break; + case DW_OP_HP_unmod_range: + printf ("DW_OP_HP_unmod_range"); + /* FIXME: Is there data associated with this OP ? */ + break; + case DW_OP_HP_tls: + printf ("DW_OP_HP_tls"); + /* FIXME: Is there data associated with this OP ? */ + break; + + /* PGI (STMicroelectronics) extensions. */ + case DW_OP_PGI_omp_thread_num: + /* Pushes the thread number for the current thread as it would be + returned by the standard OpenMP library function: + omp_get_thread_num(). The "current thread" is the thread for + which the expression is being evaluated. */ + printf ("DW_OP_PGI_omp_thread_num"); + break; + + default: + if (op >= DW_OP_lo_user + && op <= DW_OP_hi_user) + printf (_("(User defined location op 0x%x)"), op); + else + printf (_("(Unknown location op 0x%x)"), op); + /* No way to tell where the next op is, so just bail. */ + return need_frame_base; + } + + /* Separate the ops. */ + if (data < end) + printf ("; "); + } + + return need_frame_base; +} + +/* Find the CU or TU set corresponding to the given CU_OFFSET. + This is used for DWARF package files. */ + +static struct cu_tu_set * +find_cu_tu_set_v2 (dwarf_vma cu_offset, int do_types) +{ + struct cu_tu_set *p; + unsigned int nsets; + unsigned int dw_sect; + + if (do_types) + { + p = tu_sets; + nsets = tu_count; + dw_sect = DW_SECT_TYPES; + } + else + { + p = cu_sets; + nsets = cu_count; + dw_sect = DW_SECT_INFO; + } + while (nsets > 0) + { + if (p->section_offsets [dw_sect] == cu_offset) + return p; + p++; + nsets--; + } + return NULL; +} + +/* Add INC to HIGH_BITS:LOW_BITS. */ +static void +add64 (dwarf_vma * high_bits, dwarf_vma * low_bits, dwarf_vma inc) +{ + dwarf_vma tmp = * low_bits; + + tmp += inc; + + /* FIXME: There is probably a better way of handling this: + + We need to cope with dwarf_vma being a 32-bit or 64-bit + type. Plus regardless of its size LOW_BITS is meant to + only hold 32-bits, so if there is overflow or wrap around + we must propagate into HIGH_BITS. */ + if (tmp < * low_bits) + { + ++ * high_bits; + } + else if (sizeof (tmp) > 8 + && (tmp >> 31) > 1) + { + ++ * high_bits; + tmp &= 0xFFFFFFFF; + } + + * low_bits = tmp; +} + +static const char * +fetch_alt_indirect_string (dwarf_vma offset) +{ + struct dwarf_section * section; + const char * ret; + + if (! do_follow_links) + return ""; + + if (separate_debug_file == NULL) + return _(""); + + if (! load_debug_section (separate_debug_str, separate_debug_file)) + return _(""); + + section = &debug_displays [separate_debug_str].section; + if (section->start == NULL) + return _(""); + + if (offset >= section->size) + { + warn (_("DW_FORM_GNU_strp_alt offset too big: %s\n"), dwarf_vmatoa ("x", offset)); + return _(""); + } + + ret = (const char *) (section->start + offset); + /* Unfortunately we cannot rely upon the .debug_str section ending with a + NUL byte. Since our caller is expecting to receive a well formed C + string we test for the lack of a terminating byte here. */ + if (strnlen ((const char *) ret, section->size - offset) + == section->size - offset) + return _(""); + + return ret; +} + +static const char * +get_AT_name (unsigned long attribute) +{ + const char *name; + + if (attribute == 0) + return "DW_AT value: 0"; + + /* One value is shared by the MIPS and HP extensions: */ + if (attribute == DW_AT_MIPS_fde) + return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable"; + + name = get_DW_AT_name (attribute); + + if (name == NULL) + { + static char buffer[100]; + + snprintf (buffer, sizeof (buffer), _("Unknown AT value: %lx"), + attribute); + return buffer; + } + + return name; +} + +static unsigned char * +read_and_display_attr_value (unsigned long attribute, + unsigned long form, + dwarf_signed_vma implicit_const, + unsigned char * data, + unsigned char * end, + dwarf_vma cu_offset, + dwarf_vma pointer_size, + dwarf_vma offset_size, + int dwarf_version, + debug_info * debug_info_p, + int do_loc, + struct dwarf_section * section, + struct cu_tu_set * this_set, + char delimiter) +{ + dwarf_vma uvalue = 0; + unsigned char *block_start = NULL; + unsigned char * orig_data = data; + unsigned int bytes_read; + + if (data > end || (data == end && form != DW_FORM_flag_present)) + { + warn (_("Corrupt attribute\n")); + return data; + } + + switch (form) + { + default: + break; + + case DW_FORM_ref_addr: + if (dwarf_version == 2) + SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); + else if (dwarf_version == 3 || dwarf_version == 4) + SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); + else + error (_("Internal error: DWARF version is not 2, 3 or 4.\n")); + + break; + + case DW_FORM_addr: + SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); + break; + + case DW_FORM_strp: + case DW_FORM_line_strp: + case DW_FORM_sec_offset: + case DW_FORM_GNU_ref_alt: + case DW_FORM_GNU_strp_alt: + SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); + break; + + case DW_FORM_flag_present: + uvalue = 1; + break; + + case DW_FORM_ref1: + case DW_FORM_flag: + case DW_FORM_data1: + SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); + break; + + case DW_FORM_ref2: + case DW_FORM_data2: + SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end); + break; + + case DW_FORM_ref4: + case DW_FORM_data4: + SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); + break; + + case DW_FORM_sdata: + uvalue = read_sleb128 (data, & bytes_read, end); + data += bytes_read; + break; + + case DW_FORM_GNU_str_index: + uvalue = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + break; + + case DW_FORM_ref_udata: + case DW_FORM_udata: + uvalue = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + break; + + case DW_FORM_indirect: + form = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + if (!do_loc) + printf ("%c%s", delimiter, get_FORM_name (form)); + if (form == DW_FORM_implicit_const) + { + implicit_const = read_sleb128 (data, & bytes_read, end); + data += bytes_read; + } + return read_and_display_attr_value (attribute, form, implicit_const, data, + end, cu_offset, pointer_size, + offset_size, dwarf_version, + debug_info_p, do_loc, + section, this_set, delimiter); + case DW_FORM_GNU_addr_index: + uvalue = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + break; + } + + switch (form) + { + case DW_FORM_ref_addr: + if (!do_loc) + printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x",uvalue)); + break; + + case DW_FORM_GNU_ref_alt: + if (!do_loc) + printf ("%c", delimiter, dwarf_vmatoa ("x",uvalue)); + /* FIXME: Follow the reference... */ + break; + + case DW_FORM_ref1: + case DW_FORM_ref2: + case DW_FORM_ref4: + case DW_FORM_ref_udata: + if (!do_loc) + printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue + cu_offset)); + break; + + case DW_FORM_data4: + case DW_FORM_addr: + case DW_FORM_sec_offset: + if (!do_loc) + printf ("%c0x%s", delimiter, dwarf_vmatoa ("x", uvalue)); + break; + + case DW_FORM_flag_present: + case DW_FORM_flag: + case DW_FORM_data1: + case DW_FORM_data2: + case DW_FORM_sdata: + case DW_FORM_udata: + if (!do_loc) + printf ("%c%s", delimiter, dwarf_vmatoa ("d", uvalue)); + break; + + case DW_FORM_implicit_const: + if (!do_loc) + printf ("%c%s", delimiter, dwarf_vmatoa ("d", implicit_const)); + break; + + case DW_FORM_ref8: + case DW_FORM_data8: + if (!do_loc) + { + dwarf_vma high_bits; + dwarf_vma utmp; + char buf[64]; + + SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end); + utmp = uvalue; + if (form == DW_FORM_ref8) + add64 (& high_bits, & utmp, cu_offset); + printf ("%c0x%s", delimiter, + dwarf_vmatoa64 (high_bits, utmp, buf, sizeof (buf))); + } + + if ((do_loc || do_debug_loc || do_debug_ranges) + && num_debug_info_entries == 0) + { + if (sizeof (uvalue) == 8) + SAFE_BYTE_GET (uvalue, data, 8, end); + else + error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n")); + } + + data += 8; + break; + + case DW_FORM_data16: + if (!do_loc) + { + dwarf_vma left_high_bits, left_low_bits; + dwarf_vma right_high_bits, right_low_bits; + + SAFE_BYTE_GET64 (data, &left_high_bits, &left_low_bits, end); + SAFE_BYTE_GET64 (data + 8, &right_high_bits, &right_low_bits, end); + if (byte_get == byte_get_little_endian) + { + /* Swap them. */ + left_high_bits ^= right_high_bits; + right_high_bits ^= left_high_bits; + left_high_bits ^= right_high_bits; + left_low_bits ^= right_low_bits; + right_low_bits ^= left_low_bits; + left_low_bits ^= right_low_bits; + } + printf (" 0x%08" DWARF_VMA_FMT "x%08" DWARF_VMA_FMT "x" + "%08" DWARF_VMA_FMT "x%08" DWARF_VMA_FMT "x", + left_high_bits, left_low_bits, right_high_bits, + right_low_bits); + } + data += 16; + break; + + case DW_FORM_string: + if (!do_loc) + printf ("%c%.*s", delimiter, (int) (end - data), data); + data += strnlen ((char *) data, end - data) + 1; + break; + + case DW_FORM_block: + case DW_FORM_exprloc: + uvalue = read_uleb128 (data, & bytes_read, end); + block_start = data + bytes_read; + if (block_start >= end) + { + warn (_("Block ends prematurely\n")); + uvalue = 0; + block_start = end; + } + /* FIXME: Testing "(block_start + uvalue) < block_start" miscompiles with + gcc 4.8.3 running on an x86_64 host in 32-bit mode. So we pre-compute + block_start + uvalue here. */ + data = block_start + uvalue; + /* PR 17512: file: 008-103549-0.001:0.1. */ + if (block_start + uvalue > end || data < block_start) + { + warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); + uvalue = end - block_start; + } + if (do_loc) + data = block_start + uvalue; + else + data = display_block (block_start, uvalue, end, delimiter); + break; + + case DW_FORM_block1: + SAFE_BYTE_GET (uvalue, data, 1, end); + block_start = data + 1; + if (block_start >= end) + { + warn (_("Block ends prematurely\n")); + uvalue = 0; + block_start = end; + } + data = block_start + uvalue; + if (block_start + uvalue > end || data < block_start) + { + warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); + uvalue = end - block_start; + } + if (do_loc) + data = block_start + uvalue; + else + data = display_block (block_start, uvalue, end, delimiter); + break; + + case DW_FORM_block2: + SAFE_BYTE_GET (uvalue, data, 2, end); + block_start = data + 2; + if (block_start >= end) + { + warn (_("Block ends prematurely\n")); + uvalue = 0; + block_start = end; + } + data = block_start + uvalue; + if (block_start + uvalue > end || data < block_start) + { + warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); + uvalue = end - block_start; + } + if (do_loc) + data = block_start + uvalue; + else + data = display_block (block_start, uvalue, end, delimiter); + break; + + case DW_FORM_block4: + SAFE_BYTE_GET (uvalue, data, 4, end); + block_start = data + 4; + /* PR 17512: file: 3371-3907-0.004. */ + if (block_start >= end) + { + warn (_("Block ends prematurely\n")); + uvalue = 0; + block_start = end; + } + data = block_start + uvalue; + if (block_start + uvalue > end + /* PR 17531: file: 5b5f0592. */ + || data < block_start) + { + warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); + uvalue = end - block_start; + } + if (do_loc) + data = block_start + uvalue; + else + data = display_block (block_start, uvalue, end, delimiter); + break; + + case DW_FORM_strp: + if (!do_loc) + printf (_("%c(indirect string, offset: 0x%s): %s"), delimiter, + dwarf_vmatoa ("x", uvalue), + fetch_indirect_string (uvalue)); + break; + + case DW_FORM_line_strp: + if (!do_loc) + printf (_("%c(indirect line string, offset: 0x%s): %s"), delimiter, + dwarf_vmatoa ("x", uvalue), + fetch_indirect_line_string (uvalue)); + break; + + case DW_FORM_GNU_str_index: + if (!do_loc) + { + const char * suffix = strrchr (section->name, '.'); + bfd_boolean dwo = (suffix && strcmp (suffix, ".dwo") == 0) ? TRUE : FALSE; + + printf (_("%c(indexed string: 0x%s): %s"), delimiter, + dwarf_vmatoa ("x", uvalue), + fetch_indexed_string (uvalue, this_set, offset_size, dwo)); + } + break; + + case DW_FORM_GNU_strp_alt: + if (!do_loc) + { + printf (_("%c(alt indirect string, offset: 0x%s) %s"), delimiter, + dwarf_vmatoa ("x", uvalue), + fetch_alt_indirect_string (uvalue)); + } + break; + + case DW_FORM_indirect: + /* Handled above. */ + break; + + case DW_FORM_ref_sig8: + if (!do_loc) + { + dwarf_vma high_bits; + char buf[64]; + + SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end); + printf ("%csignature: 0x%s", delimiter, + dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf))); + } + data += 8; + break; + + case DW_FORM_GNU_addr_index: + if (!do_loc) + printf (_("%c(addr_index: 0x%s): %s"), delimiter, + dwarf_vmatoa ("x", uvalue), + fetch_indexed_value (uvalue * pointer_size, pointer_size)); + break; + + default: + warn (_("Unrecognized form: %lu\n"), form); + break; + } + + if ((do_loc || do_debug_loc || do_debug_ranges) + && num_debug_info_entries == 0 + && debug_info_p != NULL) + { + switch (attribute) + { + case DW_AT_frame_base: + have_frame_base = 1; + /* Fall through. */ + case DW_AT_location: + case DW_AT_GNU_locviews: + case DW_AT_string_length: + case DW_AT_return_addr: + case DW_AT_data_member_location: + case DW_AT_vtable_elem_location: + case DW_AT_segment: + case DW_AT_static_link: + case DW_AT_use_location: + case DW_AT_call_value: + case DW_AT_GNU_call_site_value: + case DW_AT_call_data_value: + case DW_AT_GNU_call_site_data_value: + case DW_AT_call_target: + case DW_AT_GNU_call_site_target: + case DW_AT_call_target_clobbered: + case DW_AT_GNU_call_site_target_clobbered: + if ((dwarf_version < 4 + && (form == DW_FORM_data4 || form == DW_FORM_data8)) + || form == DW_FORM_sec_offset) + { + /* Process location list. */ + unsigned int lmax = debug_info_p->max_loc_offsets; + unsigned int num = debug_info_p->num_loc_offsets; + + if (lmax == 0 || num >= lmax) + { + lmax += 1024; + debug_info_p->loc_offsets = (dwarf_vma *) + xcrealloc (debug_info_p->loc_offsets, + lmax, sizeof (*debug_info_p->loc_offsets)); + debug_info_p->loc_views = (dwarf_vma *) + xcrealloc (debug_info_p->loc_views, + lmax, sizeof (*debug_info_p->loc_views)); + debug_info_p->have_frame_base = (int *) + xcrealloc (debug_info_p->have_frame_base, + lmax, sizeof (*debug_info_p->have_frame_base)); + debug_info_p->max_loc_offsets = lmax; + } + if (this_set != NULL) + uvalue += this_set->section_offsets [DW_SECT_LOC]; + debug_info_p->have_frame_base [num] = have_frame_base; + if (attribute != DW_AT_GNU_locviews) + { + debug_info_p->loc_offsets [num] = uvalue; + debug_info_p->num_loc_offsets++; + assert (debug_info_p->num_loc_offsets + - debug_info_p->num_loc_views <= 1); + } + else + { + assert (debug_info_p->num_loc_views <= num); + num = debug_info_p->num_loc_views; + debug_info_p->loc_views [num] = uvalue; + debug_info_p->num_loc_views++; + assert (debug_info_p->num_loc_views + - debug_info_p->num_loc_offsets <= 1); + } + } + break; + + case DW_AT_low_pc: + if (need_base_address) + debug_info_p->base_address = uvalue; + break; + + case DW_AT_GNU_addr_base: + debug_info_p->addr_base = uvalue; + break; + + case DW_AT_GNU_ranges_base: + debug_info_p->ranges_base = uvalue; + break; + + case DW_AT_ranges: + if ((dwarf_version < 4 + && (form == DW_FORM_data4 || form == DW_FORM_data8)) + || form == DW_FORM_sec_offset) + { + /* Process range list. */ + unsigned int lmax = debug_info_p->max_range_lists; + unsigned int num = debug_info_p->num_range_lists; + + if (lmax == 0 || num >= lmax) + { + lmax += 1024; + debug_info_p->range_lists = (dwarf_vma *) + xcrealloc (debug_info_p->range_lists, + lmax, sizeof (*debug_info_p->range_lists)); + debug_info_p->max_range_lists = lmax; + } + debug_info_p->range_lists [num] = uvalue; + debug_info_p->num_range_lists++; + } + break; + + case DW_AT_GNU_dwo_name: + case DW_AT_dwo_name: + if (need_dwo_info) + switch (form) + { + case DW_FORM_strp: + dwo_name = (const char *) fetch_indirect_string (uvalue); + break; + case DW_FORM_GNU_str_index: + dwo_name = fetch_indexed_string (uvalue, this_set, offset_size, FALSE); + break; + case DW_FORM_string: + dwo_name = (const char *) orig_data; + break; + default: + warn (_("Unsupported form (%s) for attribute %s\n"), + get_FORM_name (form), get_AT_name (attribute)); + dwo_name = _(""); + break; + } + break; + + case DW_AT_comp_dir: + /* FIXME: Also extract a build-id in a CU/TU. */ + if (need_dwo_info) + switch (form) + { + case DW_FORM_strp: + dwo_dir = (const char *) fetch_indirect_string (uvalue); + break; + case DW_FORM_line_strp: + dwo_dir = (const char *) fetch_indirect_line_string (uvalue); + break; + case DW_FORM_GNU_str_index: + dwo_dir = fetch_indexed_string (uvalue, this_set, offset_size, FALSE); + break; + case DW_FORM_string: + dwo_dir = (const char *) orig_data; + break; + default: + warn (_("Unsupported form (%s) for attribute %s\n"), + get_FORM_name (form), get_AT_name (attribute)); + dwo_dir = _(""); + break; + } + break; + + case DW_AT_GNU_dwo_id: + if (need_dwo_info) + switch (form) + { + case DW_FORM_data8: + dwo_id = data - 8; + dwo_id_len = 8; + break; + default: + warn (_("Unsupported form (%s) for attribute %s\n"), + get_FORM_name (form), get_AT_name (attribute)); + dwo_id = NULL; + break; + } + break; + + default: + break; + } + } + + if (do_loc || attribute == 0) + return data; + + /* For some attributes we can display further information. */ + switch (attribute) + { + case DW_AT_inline: + printf ("\t"); + switch (uvalue) + { + case DW_INL_not_inlined: + printf (_("(not inlined)")); + break; + case DW_INL_inlined: + printf (_("(inlined)")); + break; + case DW_INL_declared_not_inlined: + printf (_("(declared as inline but ignored)")); + break; + case DW_INL_declared_inlined: + printf (_("(declared as inline and inlined)")); + break; + default: + printf (_(" (Unknown inline attribute value: %s)"), + dwarf_vmatoa ("x", uvalue)); + break; + } + break; + + case DW_AT_language: + printf ("\t"); + switch (uvalue) + { + /* Ordered by the numeric value of these constants. */ + case DW_LANG_C89: printf ("(ANSI C)"); break; + case DW_LANG_C: printf ("(non-ANSI C)"); break; + case DW_LANG_Ada83: printf ("(Ada)"); break; + case DW_LANG_C_plus_plus: printf ("(C++)"); break; + case DW_LANG_Cobol74: printf ("(Cobol 74)"); break; + case DW_LANG_Cobol85: printf ("(Cobol 85)"); break; + case DW_LANG_Fortran77: printf ("(FORTRAN 77)"); break; + case DW_LANG_Fortran90: printf ("(Fortran 90)"); break; + case DW_LANG_Pascal83: printf ("(ANSI Pascal)"); break; + case DW_LANG_Modula2: printf ("(Modula 2)"); break; + /* DWARF 2.1 values. */ + case DW_LANG_Java: printf ("(Java)"); break; + case DW_LANG_C99: printf ("(ANSI C99)"); break; + case DW_LANG_Ada95: printf ("(ADA 95)"); break; + case DW_LANG_Fortran95: printf ("(Fortran 95)"); break; + /* DWARF 3 values. */ + case DW_LANG_PLI: printf ("(PLI)"); break; + case DW_LANG_ObjC: printf ("(Objective C)"); break; + case DW_LANG_ObjC_plus_plus: printf ("(Objective C++)"); break; + case DW_LANG_UPC: printf ("(Unified Parallel C)"); break; + case DW_LANG_D: printf ("(D)"); break; + /* DWARF 4 values. */ + case DW_LANG_Python: printf ("(Python)"); break; + /* DWARF 5 values. */ + case DW_LANG_Go: printf ("(Go)"); break; + case DW_LANG_C_plus_plus_11: printf ("(C++11)"); break; + case DW_LANG_C11: printf ("(C11)"); break; + case DW_LANG_C_plus_plus_14: printf ("(C++14)"); break; + case DW_LANG_Fortran03: printf ("(Fortran 03)"); break; + case DW_LANG_Fortran08: printf ("(Fortran 08)"); break; + /* MIPS extension. */ + case DW_LANG_Mips_Assembler: printf ("(MIPS assembler)"); break; + /* UPC extension. */ + case DW_LANG_Upc: printf ("(Unified Parallel C)"); break; + default: + if (uvalue >= DW_LANG_lo_user && uvalue <= DW_LANG_hi_user) + printf (_("(implementation defined: %s)"), + dwarf_vmatoa ("x", uvalue)); + else + printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue)); + break; + } + break; + + case DW_AT_encoding: + printf ("\t"); + switch (uvalue) + { + case DW_ATE_void: printf ("(void)"); break; + case DW_ATE_address: printf ("(machine address)"); break; + case DW_ATE_boolean: printf ("(boolean)"); break; + case DW_ATE_complex_float: printf ("(complex float)"); break; + case DW_ATE_float: printf ("(float)"); break; + case DW_ATE_signed: printf ("(signed)"); break; + case DW_ATE_signed_char: printf ("(signed char)"); break; + case DW_ATE_unsigned: printf ("(unsigned)"); break; + case DW_ATE_unsigned_char: printf ("(unsigned char)"); break; + /* DWARF 2.1 values: */ + case DW_ATE_imaginary_float: printf ("(imaginary float)"); break; + case DW_ATE_decimal_float: printf ("(decimal float)"); break; + /* DWARF 3 values: */ + case DW_ATE_packed_decimal: printf ("(packed_decimal)"); break; + case DW_ATE_numeric_string: printf ("(numeric_string)"); break; + case DW_ATE_edited: printf ("(edited)"); break; + case DW_ATE_signed_fixed: printf ("(signed_fixed)"); break; + case DW_ATE_unsigned_fixed: printf ("(unsigned_fixed)"); break; + /* DWARF 4 values: */ + case DW_ATE_UTF: printf ("(unicode string)"); break; + /* DWARF 5 values: */ + case DW_ATE_UCS: printf ("(UCS)"); break; + case DW_ATE_ASCII: printf ("(ASCII)"); break; + + /* HP extensions: */ + case DW_ATE_HP_float80: printf ("(HP_float80)"); break; + case DW_ATE_HP_complex_float80: printf ("(HP_complex_float80)"); break; + case DW_ATE_HP_float128: printf ("(HP_float128)"); break; + case DW_ATE_HP_complex_float128:printf ("(HP_complex_float128)"); break; + case DW_ATE_HP_floathpintel: printf ("(HP_floathpintel)"); break; + case DW_ATE_HP_imaginary_float80: printf ("(HP_imaginary_float80)"); break; + case DW_ATE_HP_imaginary_float128: printf ("(HP_imaginary_float128)"); break; + + default: + if (uvalue >= DW_ATE_lo_user + && uvalue <= DW_ATE_hi_user) + printf (_("(user defined type)")); + else + printf (_("(unknown type)")); + break; + } + break; + + case DW_AT_accessibility: + printf ("\t"); + switch (uvalue) + { + case DW_ACCESS_public: printf ("(public)"); break; + case DW_ACCESS_protected: printf ("(protected)"); break; + case DW_ACCESS_private: printf ("(private)"); break; + default: + printf (_("(unknown accessibility)")); + break; + } + break; + + case DW_AT_visibility: + printf ("\t"); + switch (uvalue) + { + case DW_VIS_local: printf ("(local)"); break; + case DW_VIS_exported: printf ("(exported)"); break; + case DW_VIS_qualified: printf ("(qualified)"); break; + default: printf (_("(unknown visibility)")); break; + } + break; + + case DW_AT_endianity: + printf ("\t"); + switch (uvalue) + { + case DW_END_default: printf ("(default)"); break; + case DW_END_big: printf ("(big)"); break; + case DW_END_little: printf ("(little)"); break; + default: + if (uvalue >= DW_END_lo_user && uvalue <= DW_END_hi_user) + printf (_("(user specified)")); + else + printf (_("(unknown endianity)")); + break; + } + break; + + case DW_AT_virtuality: + printf ("\t"); + switch (uvalue) + { + case DW_VIRTUALITY_none: printf ("(none)"); break; + case DW_VIRTUALITY_virtual: printf ("(virtual)"); break; + case DW_VIRTUALITY_pure_virtual:printf ("(pure_virtual)"); break; + default: printf (_("(unknown virtuality)")); break; + } + break; + + case DW_AT_identifier_case: + printf ("\t"); + switch (uvalue) + { + case DW_ID_case_sensitive: printf ("(case_sensitive)"); break; + case DW_ID_up_case: printf ("(up_case)"); break; + case DW_ID_down_case: printf ("(down_case)"); break; + case DW_ID_case_insensitive: printf ("(case_insensitive)"); break; + default: printf (_("(unknown case)")); break; + } + break; + + case DW_AT_calling_convention: + printf ("\t"); + switch (uvalue) + { + case DW_CC_normal: printf ("(normal)"); break; + case DW_CC_program: printf ("(program)"); break; + case DW_CC_nocall: printf ("(nocall)"); break; + case DW_CC_pass_by_reference: printf ("(pass by ref)"); break; + case DW_CC_pass_by_value: printf ("(pass by value)"); break; + case DW_CC_GNU_renesas_sh: printf ("(Rensas SH)"); break; + case DW_CC_GNU_borland_fastcall_i386: printf ("(Borland fastcall i386)"); break; + default: + if (uvalue >= DW_CC_lo_user + && uvalue <= DW_CC_hi_user) + printf (_("(user defined)")); + else + printf (_("(unknown convention)")); + } + break; + + case DW_AT_ordering: + printf ("\t"); + switch (uvalue) + { + case 255: + case -1: printf (_("(undefined)")); break; + case 0: printf ("(row major)"); break; + case 1: printf ("(column major)"); break; + } + break; + + case DW_AT_decimal_sign: + printf ("\t"); + switch (uvalue) + { + case DW_DS_unsigned: printf (_("(unsigned)")); break; + case DW_DS_leading_overpunch: printf (_("(leading overpunch)")); break; + case DW_DS_trailing_overpunch: printf (_("(trailing overpunch)")); break; + case DW_DS_leading_separate: printf (_("(leading separate)")); break; + case DW_DS_trailing_separate: printf (_("(trailing separate)")); break; + default: printf (_("(unrecognised)")); break; + } + break; + + case DW_AT_defaulted: + printf ("\t"); + switch (uvalue) + { + case DW_DEFAULTED_no: printf (_("(no)")); break; + case DW_DEFAULTED_in_class: printf (_("(in class)")); break; + case DW_DEFAULTED_out_of_class: printf (_("(out of class)")); break; + default: printf (_("(unrecognised)")); break; + } + break; + + case DW_AT_discr_list: + printf ("\t"); + switch (uvalue) + { + case DW_DSC_label: printf (_("(label)")); break; + case DW_DSC_range: printf (_("(range)")); break; + default: printf (_("(unrecognised)")); break; + } + break; + + case DW_AT_frame_base: + have_frame_base = 1; + /* Fall through. */ + case DW_AT_location: + case DW_AT_string_length: + case DW_AT_return_addr: + case DW_AT_data_member_location: + case DW_AT_vtable_elem_location: + case DW_AT_segment: + case DW_AT_static_link: + case DW_AT_use_location: + case DW_AT_call_value: + case DW_AT_GNU_call_site_value: + case DW_AT_call_data_value: + case DW_AT_GNU_call_site_data_value: + case DW_AT_call_target: + case DW_AT_GNU_call_site_target: + case DW_AT_call_target_clobbered: + case DW_AT_GNU_call_site_target_clobbered: + if ((dwarf_version < 4 + && (form == DW_FORM_data4 || form == DW_FORM_data8)) + || form == DW_FORM_sec_offset) + printf (_(" (location list)")); + /* Fall through. */ + case DW_AT_allocated: + case DW_AT_associated: + case DW_AT_data_location: + case DW_AT_stride: + case DW_AT_upper_bound: + case DW_AT_lower_bound: + if (block_start) + { + int need_frame_base; + + printf ("\t("); + need_frame_base = decode_location_expression (block_start, + pointer_size, + offset_size, + dwarf_version, + uvalue, + cu_offset, section); + printf (")"); + if (need_frame_base && !have_frame_base) + printf (_(" [without DW_AT_frame_base]")); + } + break; + + case DW_AT_data_bit_offset: + case DW_AT_byte_size: + case DW_AT_bit_size: + case DW_AT_string_length_byte_size: + case DW_AT_string_length_bit_size: + case DW_AT_bit_stride: + if (form == DW_FORM_exprloc) + { + printf ("\t("); + (void) decode_location_expression (block_start, pointer_size, + offset_size, dwarf_version, + uvalue, cu_offset, section); + printf (")"); + } + break; + + case DW_AT_import: + { + if (form == DW_FORM_ref_sig8 + || form == DW_FORM_GNU_ref_alt) + break; + + if (form == DW_FORM_ref1 + || form == DW_FORM_ref2 + || form == DW_FORM_ref4 + || form == DW_FORM_ref_udata) + uvalue += cu_offset; + + if (uvalue >= section->size) + warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset 0x%lx is too big.\n"), + dwarf_vmatoa ("x", uvalue), + (unsigned long) (orig_data - section->start)); + else + { + unsigned long abbrev_number; + abbrev_entry * entry; + + abbrev_number = read_uleb128 (section->start + uvalue, NULL, end); + + printf (_("\t[Abbrev Number: %ld"), abbrev_number); + /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will + use different abbrev table, and we don't track .debug_info chunks + yet. */ + if (form != DW_FORM_ref_addr) + { + for (entry = first_abbrev; entry != NULL; entry = entry->next) + if (entry->entry == abbrev_number) + break; + if (entry != NULL) + printf (" (%s)", get_TAG_name (entry->tag)); + } + printf ("]"); + } + } + break; + + default: + break; + } + + return data; +} + +static unsigned char * +read_and_display_attr (unsigned long attribute, + unsigned long form, + dwarf_signed_vma implicit_const, + unsigned char * data, + unsigned char * end, + dwarf_vma cu_offset, + dwarf_vma pointer_size, + dwarf_vma offset_size, + int dwarf_version, + debug_info * debug_info_p, + int do_loc, + struct dwarf_section * section, + struct cu_tu_set * this_set) +{ + if (!do_loc) + printf (" %-18s:", get_AT_name (attribute)); + data = read_and_display_attr_value (attribute, form, implicit_const, data, end, + cu_offset, pointer_size, offset_size, + dwarf_version, debug_info_p, + do_loc, section, this_set, ' '); + if (!do_loc) + printf ("\n"); + return data; +} + +/* Like load_debug_section, but if the ordinary call fails, and we are + following debug links, and we have been able to load a separate debug + info file, then attempt to load the requested section from the separate + file. */ + +static bfd_boolean +load_debug_section_with_follow (enum dwarf_section_display_enum sec_enum, + void * data) +{ + if (load_debug_section (sec_enum, data)) + { + if (data == separate_debug_file) + debug_displays[sec_enum].section.filename = separate_debug_filename; + + /* FIXME: We should check to see if there is a separate debug info file + that also contains this section, and if so, issue a warning. */ + return TRUE; + } + + if (do_follow_links && separate_debug_file != NULL) + if (load_debug_section (sec_enum, separate_debug_file)) + { + debug_displays[sec_enum].section.filename = separate_debug_filename; + return TRUE; + } + + return FALSE; +} + +static void +introduce (struct dwarf_section * section, bfd_boolean raw) +{ + if (raw) + { + if (do_follow_links && section->filename) + printf (_("Raw dump of debug contents of section %s (loaded from %s):\n\n"), + section->name, section->filename); + else + printf (_("Raw dump of debug contents of section %s:\n\n"), section->name); + } + else + { + if (do_follow_links && section->filename) + printf (_("Contents of the %s section (loaded from %s):\n\n"), + section->name, section->filename); + else + printf (_("Contents of the %s section:\n\n"), section->name); + } +} + +/* Process the contents of a .debug_info section. + If do_loc is TRUE then we are scanning for location lists and dwo tags + and we do not want to display anything to the user. + If do_types is TRUE, we are processing a .debug_types section instead of + a .debug_info section. + The information displayed is restricted by the values in DWARF_START_DIE + and DWARF_CUTOFF_LEVEL. + Returns TRUE upon success. Otherwise an error or warning message is + printed and FALSE is returned. */ + +static bfd_boolean +process_debug_info (struct dwarf_section * section, + void * file, + enum dwarf_section_display_enum abbrev_sec, + bfd_boolean do_loc, + bfd_boolean do_types) +{ + unsigned char *start = section->start; + unsigned char *end = start + section->size; + unsigned char *section_begin; + unsigned int unit; + unsigned int num_units = 0; + + if ((do_loc || do_debug_loc || do_debug_ranges) + && num_debug_info_entries == 0 + && ! do_types) + { + dwarf_vma length; + + /* First scan the section to get the number of comp units. */ + for (section_begin = start, num_units = 0; section_begin < end; + num_units ++) + { + /* Read the first 4 bytes. For a 32-bit DWARF section, this + will be the length. For a 64-bit DWARF section, it'll be + the escape code 0xffffffff followed by an 8 byte length. */ + SAFE_BYTE_GET (length, section_begin, 4, end); + + if (length == 0xffffffff) + { + SAFE_BYTE_GET (length, section_begin + 4, 8, end); + section_begin += length + 12; + } + else if (length >= 0xfffffff0 && length < 0xffffffff) + { + warn (_("Reserved length value (0x%s) found in section %s\n"), + dwarf_vmatoa ("x", length), section->name); + return FALSE; + } + else + section_begin += length + 4; + + /* Negative values are illegal, they may even cause infinite + looping. This can happen if we can't accurately apply + relocations to an object file, or if the file is corrupt. */ + if ((signed long) length <= 0 || section_begin < start) + { + warn (_("Corrupt unit length (0x%s) found in section %s\n"), + dwarf_vmatoa ("x", length), section->name); + return FALSE; + } + } + + if (num_units == 0) + { + error (_("No comp units in %s section ?\n"), section->name); + return FALSE; + } + + /* Then allocate an array to hold the information. */ + debug_information = (debug_info *) cmalloc (num_units, + sizeof (* debug_information)); + if (debug_information == NULL) + { + error (_("Not enough memory for a debug info array of %u entries\n"), + num_units); + alloc_num_debug_info_entries = num_debug_info_entries = 0; + return FALSE; + } + + /* PR 17531: file: 92ca3797. + We cannot rely upon the debug_information array being initialised + before it is used. A corrupt file could easily contain references + to a unit for which information has not been made available. So + we ensure that the array is zeroed here. */ + memset (debug_information, 0, num_units * sizeof (*debug_information)); + + alloc_num_debug_info_entries = num_units; + } + + if (!do_loc) + { + load_debug_section_with_follow (str, file); + load_debug_section_with_follow (line_str, file); + load_debug_section_with_follow (str_dwo, file); + load_debug_section_with_follow (str_index, file); + load_debug_section_with_follow (str_index_dwo, file); + load_debug_section_with_follow (debug_addr, file); + } + + load_debug_section_with_follow (abbrev_sec, file); + if (debug_displays [abbrev_sec].section.start == NULL) + { + warn (_("Unable to locate %s section!\n"), + debug_displays [abbrev_sec].section.uncompressed_name); + return FALSE; + } + + if (!do_loc && dwarf_start_die == 0) + introduce (section, FALSE); + + for (section_begin = start, unit = 0; start < end; unit++) + { + DWARF2_Internal_CompUnit compunit; + unsigned char *hdrptr; + unsigned char *tags; + int level, last_level, saved_level; + dwarf_vma cu_offset; + unsigned long sec_off; + unsigned int offset_size; + unsigned int initial_length_size; + dwarf_vma signature_high = 0; + dwarf_vma signature_low = 0; + dwarf_vma type_offset = 0; + struct cu_tu_set *this_set; + dwarf_vma abbrev_base; + size_t abbrev_size; + + hdrptr = start; + + SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 4, end); + + if (compunit.cu_length == 0xffffffff) + { + SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 8, end); + offset_size = 8; + initial_length_size = 12; + } + else + { + offset_size = 4; + initial_length_size = 4; + } + + SAFE_BYTE_GET_AND_INC (compunit.cu_version, hdrptr, 2, end); + + cu_offset = start - section_begin; + + this_set = find_cu_tu_set_v2 (cu_offset, do_types); + + if (compunit.cu_version < 5) + { + compunit.cu_unit_type = DW_UT_compile; + /* Initialize it due to a false compiler warning. */ + compunit.cu_pointer_size = -1; + } + else + { + SAFE_BYTE_GET_AND_INC (compunit.cu_unit_type, hdrptr, 1, end); + do_types = (compunit.cu_unit_type == DW_UT_type); + + SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end); + } + + SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size, end); + + if (this_set == NULL) + { + abbrev_base = 0; + abbrev_size = debug_displays [abbrev_sec].section.size; + } + else + { + abbrev_base = this_set->section_offsets [DW_SECT_ABBREV]; + abbrev_size = this_set->section_sizes [DW_SECT_ABBREV]; + } + + if (compunit.cu_version < 5) + SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end); + + /* PR 17512: file: 001-108546-0.001:0.1. */ + if (compunit.cu_pointer_size < 2 || compunit.cu_pointer_size > 8) + { + warn (_("Invalid pointer size (%d) in compunit header, using %d instead\n"), + compunit.cu_pointer_size, offset_size); + compunit.cu_pointer_size = offset_size; + } + + if (do_types) + { + SAFE_BYTE_GET64 (hdrptr, &signature_high, &signature_low, end); + hdrptr += 8; + SAFE_BYTE_GET_AND_INC (type_offset, hdrptr, offset_size, end); + } + + if (dwarf_start_die > (cu_offset + compunit.cu_length + + initial_length_size)) + { + start = section_begin + cu_offset + compunit.cu_length + + initial_length_size; + continue; + } + + if ((do_loc || do_debug_loc || do_debug_ranges) + && num_debug_info_entries == 0 + && ! do_types) + { + debug_information [unit].cu_offset = cu_offset; + debug_information [unit].pointer_size + = compunit.cu_pointer_size; + debug_information [unit].offset_size = offset_size; + debug_information [unit].dwarf_version = compunit.cu_version; + debug_information [unit].base_address = 0; + debug_information [unit].addr_base = DEBUG_INFO_UNAVAILABLE; + debug_information [unit].ranges_base = DEBUG_INFO_UNAVAILABLE; + debug_information [unit].loc_offsets = NULL; + debug_information [unit].have_frame_base = NULL; + debug_information [unit].max_loc_offsets = 0; + debug_information [unit].num_loc_offsets = 0; + debug_information [unit].range_lists = NULL; + debug_information [unit].max_range_lists= 0; + debug_information [unit].num_range_lists = 0; + } + + if (!do_loc && dwarf_start_die == 0) + { + printf (_(" Compilation Unit @ offset 0x%s:\n"), + dwarf_vmatoa ("x", cu_offset)); + printf (_(" Length: 0x%s (%s)\n"), + dwarf_vmatoa ("x", compunit.cu_length), + offset_size == 8 ? "64-bit" : "32-bit"); + printf (_(" Version: %d\n"), compunit.cu_version); + printf (_(" Abbrev Offset: 0x%s\n"), + dwarf_vmatoa ("x", compunit.cu_abbrev_offset)); + printf (_(" Pointer Size: %d\n"), compunit.cu_pointer_size); + if (do_types) + { + char buf[64]; + + printf (_(" Signature: 0x%s\n"), + dwarf_vmatoa64 (signature_high, signature_low, + buf, sizeof (buf))); + printf (_(" Type Offset: 0x%s\n"), + dwarf_vmatoa ("x", type_offset)); + } + if (this_set != NULL) + { + dwarf_vma *offsets = this_set->section_offsets; + size_t *sizes = this_set->section_sizes; + + printf (_(" Section contributions:\n")); + printf (_(" .debug_abbrev.dwo: 0x%s 0x%s\n"), + dwarf_vmatoa ("x", offsets [DW_SECT_ABBREV]), + dwarf_vmatoa ("x", sizes [DW_SECT_ABBREV])); + printf (_(" .debug_line.dwo: 0x%s 0x%s\n"), + dwarf_vmatoa ("x", offsets [DW_SECT_LINE]), + dwarf_vmatoa ("x", sizes [DW_SECT_LINE])); + printf (_(" .debug_loc.dwo: 0x%s 0x%s\n"), + dwarf_vmatoa ("x", offsets [DW_SECT_LOC]), + dwarf_vmatoa ("x", sizes [DW_SECT_LOC])); + printf (_(" .debug_str_offsets.dwo: 0x%s 0x%s\n"), + dwarf_vmatoa ("x", offsets [DW_SECT_STR_OFFSETS]), + dwarf_vmatoa ("x", sizes [DW_SECT_STR_OFFSETS])); + } + } + + sec_off = cu_offset + initial_length_size; + if (sec_off + compunit.cu_length < sec_off + || sec_off + compunit.cu_length > section->size) + { + warn (_("Debug info is corrupted, %s header at %#lx has length %s\n"), + section->name, + (unsigned long) cu_offset, + dwarf_vmatoa ("x", compunit.cu_length)); + num_units = unit; + break; + } + + tags = hdrptr; + start += compunit.cu_length + initial_length_size; + + if (compunit.cu_version < 2 || compunit.cu_version > 5) + { + warn (_("CU at offset %s contains corrupt or " + "unsupported version number: %d.\n"), + dwarf_vmatoa ("x", cu_offset), compunit.cu_version); + continue; + } + + if (compunit.cu_unit_type != DW_UT_compile + && compunit.cu_unit_type != DW_UT_type) + { + warn (_("CU at offset %s contains corrupt or " + "unsupported unit type: %d.\n"), + dwarf_vmatoa ("x", cu_offset), compunit.cu_unit_type); + continue; + } + + free_abbrevs (); + + /* Process the abbrevs used by this compilation unit. */ + if (compunit.cu_abbrev_offset >= abbrev_size) + warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"), + (unsigned long) compunit.cu_abbrev_offset, + (unsigned long) abbrev_size); + /* PR 17531: file:4bcd9ce9. */ + else if ((abbrev_base + abbrev_size) + > debug_displays [abbrev_sec].section.size) + warn (_("Debug info is corrupted, abbrev size (%lx) is larger than abbrev section size (%lx)\n"), + (unsigned long) abbrev_base + abbrev_size, + (unsigned long) debug_displays [abbrev_sec].section.size); + else + process_abbrev_section + (((unsigned char *) debug_displays [abbrev_sec].section.start + + abbrev_base + compunit.cu_abbrev_offset), + ((unsigned char *) debug_displays [abbrev_sec].section.start + + abbrev_base + abbrev_size)); + + level = 0; + last_level = level; + saved_level = -1; + while (tags < start) + { + unsigned int bytes_read; + unsigned long abbrev_number; + unsigned long die_offset; + abbrev_entry *entry; + abbrev_attr *attr; + int do_printing = 1; + + die_offset = tags - section_begin; + + abbrev_number = read_uleb128 (tags, & bytes_read, start); + tags += bytes_read; + + /* A null DIE marks the end of a list of siblings or it may also be + a section padding. */ + if (abbrev_number == 0) + { + /* Check if it can be a section padding for the last CU. */ + if (level == 0 && start == end) + { + unsigned char *chk; + + for (chk = tags; chk < start; chk++) + if (*chk != 0) + break; + if (chk == start) + break; + } + + if (!do_loc && die_offset >= dwarf_start_die + && (dwarf_cutoff_level == -1 + || level < dwarf_cutoff_level)) + printf (_(" <%d><%lx>: Abbrev Number: 0\n"), + level, die_offset); + + --level; + if (level < 0) + { + static unsigned num_bogus_warns = 0; + + if (num_bogus_warns < 3) + { + warn (_("Bogus end-of-siblings marker detected at offset %lx in %s section\n"), + die_offset, section->name); + num_bogus_warns ++; + if (num_bogus_warns == 3) + warn (_("Further warnings about bogus end-of-sibling markers suppressed\n")); + } + } + if (dwarf_start_die != 0 && level < saved_level) + return TRUE; + continue; + } + + if (!do_loc) + { + if (dwarf_start_die != 0 && die_offset < dwarf_start_die) + do_printing = 0; + else + { + if (dwarf_start_die != 0 && die_offset == dwarf_start_die) + saved_level = level; + do_printing = (dwarf_cutoff_level == -1 + || level < dwarf_cutoff_level); + if (do_printing) + printf (_(" <%d><%lx>: Abbrev Number: %lu"), + level, die_offset, abbrev_number); + else if (dwarf_cutoff_level == -1 + || last_level < dwarf_cutoff_level) + printf (_(" <%d><%lx>: ...\n"), level, die_offset); + last_level = level; + } + } + + /* Scan through the abbreviation list until we reach the + correct entry. */ + for (entry = first_abbrev; + entry && entry->entry != abbrev_number; + entry = entry->next) + continue; + + if (entry == NULL) + { + if (!do_loc && do_printing) + { + printf ("\n"); + fflush (stdout); + } + warn (_("DIE at offset 0x%lx refers to abbreviation number %lu which does not exist\n"), + die_offset, abbrev_number); + return FALSE; + } + + if (!do_loc && do_printing) + printf (" (%s)\n", get_TAG_name (entry->tag)); + + switch (entry->tag) + { + default: + need_base_address = 0; + break; + case DW_TAG_compile_unit: + need_base_address = 1; + need_dwo_info = do_loc; + break; + case DW_TAG_entry_point: + case DW_TAG_subprogram: + need_base_address = 0; + /* Assuming that there is no DW_AT_frame_base. */ + have_frame_base = 0; + break; + } + + debug_info *debug_info_p = + (debug_information && unit < alloc_num_debug_info_entries) + ? debug_information + unit : NULL; + + assert (!debug_info_p + || (debug_info_p->num_loc_offsets + == debug_info_p->num_loc_views)); + + for (attr = entry->first_attr; + attr && attr->attribute; + attr = attr->next) + { + if (! do_loc && do_printing) + /* Show the offset from where the tag was extracted. */ + printf (" <%lx>", (unsigned long)(tags - section_begin)); + + tags = read_and_display_attr (attr->attribute, + attr->form, + attr->implicit_const, + tags, + end, + cu_offset, + compunit.cu_pointer_size, + offset_size, + compunit.cu_version, + debug_info_p, + do_loc || ! do_printing, + section, + this_set); + } + + /* If a locview attribute appears before a location one, + make sure we don't associate it with an earlier + loclist. */ + if (debug_info_p) + switch (debug_info_p->num_loc_offsets - debug_info_p->num_loc_views) + { + case 1: + debug_info_p->loc_views [debug_info_p->num_loc_views] = vm1; + debug_info_p->num_loc_views++; + assert (debug_info_p->num_loc_views + == debug_info_p->num_loc_offsets); + break; + + case 0: + break; + + case -1: + warn(_("DIE has locviews without loclist\n")); + debug_info_p->num_loc_views--; + break; + + default: + assert (0); + } + + if (entry->children) + ++level; + } + } + + /* Set num_debug_info_entries here so that it can be used to check if + we need to process .debug_loc and .debug_ranges sections. */ + if ((do_loc || do_debug_loc || do_debug_ranges) + && num_debug_info_entries == 0 + && ! do_types) + { + if (num_units > alloc_num_debug_info_entries) + num_debug_info_entries = alloc_num_debug_info_entries; + else + num_debug_info_entries = num_units; + } + + if (!do_loc) + printf ("\n"); + + return TRUE; +} + +/* Locate and scan the .debug_info section in the file and record the pointer + sizes and offsets for the compilation units in it. Usually an executable + will have just one pointer size, but this is not guaranteed, and so we try + not to make any assumptions. Returns zero upon failure, or the number of + compilation units upon success. */ + +static unsigned int +load_debug_info (void * file) +{ + /* If we have already tried and failed to load the .debug_info + section then do not bother to repeat the task. */ + if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE) + return 0; + + /* If we already have the information there is nothing else to do. */ + if (num_debug_info_entries > 0) + return num_debug_info_entries; + + /* If this is a DWARF package file, load the CU and TU indexes. */ + (void) load_cu_tu_indexes (file); + + if (load_debug_section_with_follow (info, file) + && process_debug_info (&debug_displays [info].section, file, abbrev, TRUE, FALSE)) + return num_debug_info_entries; + + if (load_debug_section_with_follow (info_dwo, file) + && process_debug_info (&debug_displays [info_dwo].section, file, + abbrev_dwo, TRUE, FALSE)) + return num_debug_info_entries; + + num_debug_info_entries = DEBUG_INFO_UNAVAILABLE; + return 0; +} + +/* Read a DWARF .debug_line section header starting at DATA. + Upon success returns an updated DATA pointer and the LINFO + structure and the END_OF_SEQUENCE pointer will be filled in. + Otherwise returns NULL. */ + +static unsigned char * +read_debug_line_header (struct dwarf_section * section, + unsigned char * data, + unsigned char * end, + DWARF2_Internal_LineInfo * linfo, + unsigned char ** end_of_sequence) +{ + unsigned char *hdrptr; + unsigned int initial_length_size; + unsigned char address_size, segment_selector_size; + + /* Extract information from the Line Number Program Header. + (section 6.2.4 in the Dwarf3 doc). */ + hdrptr = data; + + /* Get and check the length of the block. */ + SAFE_BYTE_GET_AND_INC (linfo->li_length, hdrptr, 4, end); + + if (linfo->li_length == 0xffffffff) + { + /* This section is 64-bit DWARF 3. */ + SAFE_BYTE_GET_AND_INC (linfo->li_length, hdrptr, 8, end); + linfo->li_offset_size = 8; + initial_length_size = 12; + } + else + { + linfo->li_offset_size = 4; + initial_length_size = 4; + } + + if (linfo->li_length + initial_length_size > section->size) + { + /* If the length field has a relocation against it, then we should + not complain if it is inaccurate (and probably negative). This + happens in object files when the .debug_line section is actually + comprised of several different .debug_line.* sections, (some of + which may be removed by linker garbage collection), and a relocation + is used to compute the correct length once that is done. */ + if (reloc_at (section, (hdrptr - section->start) - linfo->li_offset_size)) + { + linfo->li_length = (end - data) - initial_length_size; + } + else + { + warn (_("The length field (0x%lx) in the debug_line header is wrong - the section is too small\n"), + (long) linfo->li_length); + return NULL; + } + } + + /* Get and check the version number. */ + SAFE_BYTE_GET_AND_INC (linfo->li_version, hdrptr, 2, end); + + if (linfo->li_version != 2 + && linfo->li_version != 3 + && linfo->li_version != 4 + && linfo->li_version != 5) + { + warn (_("Only DWARF version 2, 3, 4 and 5 line info " + "is currently supported.\n")); + return NULL; + } + + if (linfo->li_version >= 5) + { + SAFE_BYTE_GET_AND_INC (address_size, hdrptr, 1, end); + + SAFE_BYTE_GET_AND_INC (segment_selector_size, hdrptr, 1, end); + if (segment_selector_size != 0) + { + warn (_("The %s section contains " + "unsupported segment selector size: %d.\n"), + section->name, segment_selector_size); + return 0; + } + } + + SAFE_BYTE_GET_AND_INC (linfo->li_prologue_length, hdrptr, + linfo->li_offset_size, end); + SAFE_BYTE_GET_AND_INC (linfo->li_min_insn_length, hdrptr, 1, end); + + if (linfo->li_version >= 4) + { + SAFE_BYTE_GET_AND_INC (linfo->li_max_ops_per_insn, hdrptr, 1, end); + + if (linfo->li_max_ops_per_insn == 0) + { + warn (_("Invalid maximum operations per insn.\n")); + return NULL; + } + } + else + linfo->li_max_ops_per_insn = 1; + + SAFE_BYTE_GET_AND_INC (linfo->li_default_is_stmt, hdrptr, 1, end); + SAFE_SIGNED_BYTE_GET_AND_INC (linfo->li_line_base, hdrptr, 1, end); + SAFE_BYTE_GET_AND_INC (linfo->li_line_range, hdrptr, 1, end); + SAFE_BYTE_GET_AND_INC (linfo->li_opcode_base, hdrptr, 1, end); + + * end_of_sequence = data + linfo->li_length + initial_length_size; + /* PR 17512: file:002-117414-0.004. */ + if (* end_of_sequence > end) + { + warn (_("Line length %s extends beyond end of section\n"), + dwarf_vmatoa ("u", linfo->li_length)); + * end_of_sequence = end; + return NULL; + } + + return hdrptr; +} + +static unsigned char * +display_formatted_table (unsigned char * data, + unsigned char * start, + unsigned char * end, + const DWARF2_Internal_LineInfo * linfo, + struct dwarf_section * section, + const char * what) +{ + unsigned char *format_start, format_count, *format, formati; + dwarf_vma data_count, datai; + unsigned int bytes_read, namepass, last_entry = 0; + + SAFE_BYTE_GET_AND_INC (format_count, data, 1, end); + format_start = data; + for (formati = 0; formati < format_count; formati++) + { + read_uleb128 (data, & bytes_read, end); + data += bytes_read; + read_uleb128 (data, & bytes_read, end); + data += bytes_read; + if (data == end) + { + warn (_("Corrupt %s format table entry\n"), what); + return data; + } + } + + data_count = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + if (data == end) + { + warn (_("Corrupt %s list\n"), what); + return data; + } + + if (data_count == 0) + { + printf (_("\n The %s Table is empty.\n"), what); + return data; + } + + printf (_("\n The %s Table (offset 0x%lx):\n"), what, + (long)(data - start)); + + printf (_(" Entry")); + /* Delay displaying name as the last entry for better screen layout. */ + for (namepass = 0; namepass < 2; namepass++) + { + format = format_start; + for (formati = 0; formati < format_count; formati++) + { + dwarf_vma content_type; + + content_type = read_uleb128 (format, & bytes_read, end); + format += bytes_read; + if ((content_type == DW_LNCT_path) == (namepass == 1)) + switch (content_type) + { + case DW_LNCT_path: + printf (_("\tName")); + break; + case DW_LNCT_directory_index: + printf (_("\tDir")); + break; + case DW_LNCT_timestamp: + printf (_("\tTime")); + break; + case DW_LNCT_size: + printf (_("\tSize")); + break; + case DW_LNCT_MD5: + printf (_("\tMD5")); + break; + default: + printf (_("\t(Unknown format content type %s)"), + dwarf_vmatoa ("u", content_type)); + } + read_uleb128 (format, & bytes_read, end); + format += bytes_read; + } + } + putchar ('\n'); + + for (datai = 0; datai < data_count; datai++) + { + unsigned char *datapass = data; + + printf (" %d", last_entry++); + /* Delay displaying name as the last entry for better screen layout. */ + for (namepass = 0; namepass < 2; namepass++) + { + format = format_start; + data = datapass; + for (formati = 0; formati < format_count; formati++) + { + dwarf_vma content_type, form; + + content_type = read_uleb128 (format, & bytes_read, end); + format += bytes_read; + form = read_uleb128 (format, & bytes_read, end); + format += bytes_read; + data = read_and_display_attr_value (0, form, 0, data, end, 0, 0, + linfo->li_offset_size, + linfo->li_version, NULL, + ((content_type == DW_LNCT_path) != (namepass == 1)), + section, NULL, '\t'); + } + } + if (data == end) + { + warn (_("Corrupt %s entries list\n"), what); + return data; + } + putchar ('\n'); + } + return data; +} + +static int +display_debug_lines_raw (struct dwarf_section * section, + unsigned char * data, + unsigned char * end, + void * file) +{ + unsigned char *start = section->start; + int verbose_view = 0; + + introduce (section, TRUE); + + while (data < end) + { + static DWARF2_Internal_LineInfo saved_linfo; + DWARF2_Internal_LineInfo linfo; + unsigned char *standard_opcodes; + unsigned char *end_of_sequence; + int i; + + if (const_strneq (section->name, ".debug_line.") + /* Note: the following does not apply to .debug_line.dwo sections. + These are full debug_line sections. */ + && strcmp (section->name, ".debug_line.dwo") != 0) + { + /* Sections named .debug_line. are fragments of a .debug_line + section containing just the Line Number Statements. They are + created by the assembler and intended to be used alongside gcc's + -ffunction-sections command line option. When the linker's + garbage collection decides to discard a .text. section it + can then also discard the line number information in .debug_line.. + + Since the section is a fragment it does not have the details + needed to fill out a LineInfo structure, so instead we use the + details from the last full debug_line section that we processed. */ + end_of_sequence = end; + standard_opcodes = NULL; + linfo = saved_linfo; + /* PR 17531: file: 0522b371. */ + if (linfo.li_line_range == 0) + { + warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n")); + return 0; + } + reset_state_machine (linfo.li_default_is_stmt); + } + else + { + unsigned char * hdrptr; + + if ((hdrptr = read_debug_line_header (section, data, end, & linfo, + & end_of_sequence)) == NULL) + return 0; + + printf (_(" Offset: 0x%lx\n"), (long)(data - start)); + printf (_(" Length: %ld\n"), (long) linfo.li_length); + printf (_(" DWARF Version: %d\n"), linfo.li_version); + printf (_(" Prologue Length: %d\n"), (int) linfo.li_prologue_length); + printf (_(" Minimum Instruction Length: %d\n"), linfo.li_min_insn_length); + if (linfo.li_version >= 4) + printf (_(" Maximum Ops per Instruction: %d\n"), linfo.li_max_ops_per_insn); + printf (_(" Initial value of 'is_stmt': %d\n"), linfo.li_default_is_stmt); + printf (_(" Line Base: %d\n"), linfo.li_line_base); + printf (_(" Line Range: %d\n"), linfo.li_line_range); + printf (_(" Opcode Base: %d\n"), linfo.li_opcode_base); + + /* PR 17512: file: 1665-6428-0.004. */ + if (linfo.li_line_range == 0) + { + warn (_("Line range of 0 is invalid, using 1 instead\n")); + linfo.li_line_range = 1; + } + + reset_state_machine (linfo.li_default_is_stmt); + + /* Display the contents of the Opcodes table. */ + standard_opcodes = hdrptr; + + /* PR 17512: file: 002-417945-0.004. */ + if (standard_opcodes + linfo.li_opcode_base >= end) + { + warn (_("Line Base extends beyond end of section\n")); + return 0; + } + + printf (_("\n Opcodes:\n")); + + for (i = 1; i < linfo.li_opcode_base; i++) + printf (ngettext (" Opcode %d has %d arg\n", + " Opcode %d has %d args\n", + standard_opcodes[i - 1]), + i, standard_opcodes[i - 1]); + + /* Display the contents of the Directory table. */ + data = standard_opcodes + linfo.li_opcode_base - 1; + + if (linfo.li_version >= 5) + { + load_debug_section_with_follow (line_str, file); + + data = display_formatted_table (data, start, end, &linfo, section, + _("Directory")); + data = display_formatted_table (data, start, end, &linfo, section, + _("File name")); + } + else + { + if (*data == 0) + printf (_("\n The Directory Table is empty.\n")); + else + { + unsigned int last_dir_entry = 0; + + printf (_("\n The Directory Table (offset 0x%lx):\n"), + (long)(data - start)); + + while (data < end && *data != 0) + { + printf (" %d\t%.*s\n", ++last_dir_entry, (int) (end - data), data); + + data += strnlen ((char *) data, end - data) + 1; + } + + /* PR 17512: file: 002-132094-0.004. */ + if (data >= end - 1) + break; + } + + /* Skip the NUL at the end of the table. */ + data++; + + /* Display the contents of the File Name table. */ + if (*data == 0) + printf (_("\n The File Name Table is empty.\n")); + else + { + printf (_("\n The File Name Table (offset 0x%lx):\n"), + (long)(data - start)); + printf (_(" Entry\tDir\tTime\tSize\tName\n")); + + while (data < end && *data != 0) + { + unsigned char *name; + unsigned int bytes_read; + + printf (" %d\t", ++state_machine_regs.last_file_entry); + name = data; + data += strnlen ((char *) data, end - data) + 1; + + printf ("%s\t", + dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + data += bytes_read; + printf ("%s\t", + dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + data += bytes_read; + printf ("%s\t", + dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + data += bytes_read; + printf ("%.*s\n", (int)(end - name), name); + + if (data == end) + { + warn (_("Corrupt file name table entry\n")); + break; + } + } + } + + /* Skip the NUL at the end of the table. */ + data++; + } + + putchar ('\n'); + saved_linfo = linfo; + } + + /* Now display the statements. */ + if (data >= end_of_sequence) + printf (_(" No Line Number Statements.\n")); + else + { + printf (_(" Line Number Statements:\n")); + + while (data < end_of_sequence) + { + unsigned char op_code; + dwarf_signed_vma adv; + dwarf_vma uladv; + unsigned int bytes_read; + + printf (" [0x%08lx]", (long)(data - start)); + + op_code = *data++; + + if (op_code >= linfo.li_opcode_base) + { + op_code -= linfo.li_opcode_base; + uladv = (op_code / linfo.li_line_range); + if (linfo.li_max_ops_per_insn == 1) + { + uladv *= linfo.li_min_insn_length; + state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; + printf (_(" Special opcode %d: " + "advance Address by %s to 0x%s%s"), + op_code, dwarf_vmatoa ("u", uladv), + dwarf_vmatoa ("x", state_machine_regs.address), + verbose_view && uladv + ? _(" (reset view)") : ""); + } + else + { + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) + * linfo.li_min_insn_length; + + state_machine_regs.address += addrdelta; + state_machine_regs.op_index + = (state_machine_regs.op_index + uladv) + % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; + printf (_(" Special opcode %d: " + "advance Address by %s to 0x%s[%d]%s"), + op_code, dwarf_vmatoa ("u", uladv), + dwarf_vmatoa ("x", state_machine_regs.address), + state_machine_regs.op_index, + verbose_view && addrdelta + ? _(" (reset view)") : ""); + } + adv = (op_code % linfo.li_line_range) + linfo.li_line_base; + state_machine_regs.line += adv; + printf (_(" and Line by %s to %d"), + dwarf_vmatoa ("d", adv), state_machine_regs.line); + if (verbose_view || state_machine_regs.view) + printf (_(" (view %u)\n"), state_machine_regs.view); + else + putchar ('\n'); + state_machine_regs.view++; + } + else switch (op_code) + { + case DW_LNS_extended_op: + data += process_extended_line_op (data, linfo.li_default_is_stmt, end); + break; + + case DW_LNS_copy: + printf (_(" Copy")); + if (verbose_view || state_machine_regs.view) + printf (_(" (view %u)\n"), state_machine_regs.view); + else + putchar ('\n'); + state_machine_regs.view++; + break; + + case DW_LNS_advance_pc: + uladv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + if (linfo.li_max_ops_per_insn == 1) + { + uladv *= linfo.li_min_insn_length; + state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; + printf (_(" Advance PC by %s to 0x%s%s\n"), + dwarf_vmatoa ("u", uladv), + dwarf_vmatoa ("x", state_machine_regs.address), + verbose_view && uladv + ? _(" (reset view)") : ""); + } + else + { + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) + * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; + state_machine_regs.op_index + = (state_machine_regs.op_index + uladv) + % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; + printf (_(" Advance PC by %s to 0x%s[%d]%s\n"), + dwarf_vmatoa ("u", uladv), + dwarf_vmatoa ("x", state_machine_regs.address), + state_machine_regs.op_index, + verbose_view && addrdelta + ? _(" (reset view)") : ""); + } + break; + + case DW_LNS_advance_line: + adv = read_sleb128 (data, & bytes_read, end); + data += bytes_read; + state_machine_regs.line += adv; + printf (_(" Advance Line by %s to %d\n"), + dwarf_vmatoa ("d", adv), + state_machine_regs.line); + break; + + case DW_LNS_set_file: + adv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + printf (_(" Set File Name to entry %s in the File Name Table\n"), + dwarf_vmatoa ("d", adv)); + state_machine_regs.file = adv; + break; + + case DW_LNS_set_column: + uladv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + printf (_(" Set column to %s\n"), + dwarf_vmatoa ("u", uladv)); + state_machine_regs.column = uladv; + break; + + case DW_LNS_negate_stmt: + adv = state_machine_regs.is_stmt; + adv = ! adv; + printf (_(" Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv)); + state_machine_regs.is_stmt = adv; + break; + + case DW_LNS_set_basic_block: + printf (_(" Set basic block\n")); + state_machine_regs.basic_block = 1; + break; + + case DW_LNS_const_add_pc: + uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range); + if (linfo.li_max_ops_per_insn) + { + uladv *= linfo.li_min_insn_length; + state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; + printf (_(" Advance PC by constant %s to 0x%s%s\n"), + dwarf_vmatoa ("u", uladv), + dwarf_vmatoa ("x", state_machine_regs.address), + verbose_view && uladv + ? _(" (reset view)") : ""); + } + else + { + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) + * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; + state_machine_regs.op_index + = (state_machine_regs.op_index + uladv) + % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; + printf (_(" Advance PC by constant %s to 0x%s[%d]%s\n"), + dwarf_vmatoa ("u", uladv), + dwarf_vmatoa ("x", state_machine_regs.address), + state_machine_regs.op_index, + verbose_view && addrdelta + ? _(" (reset view)") : ""); + } + break; + + case DW_LNS_fixed_advance_pc: + SAFE_BYTE_GET_AND_INC (uladv, data, 2, end); + state_machine_regs.address += uladv; + state_machine_regs.op_index = 0; + printf (_(" Advance PC by fixed size amount %s to 0x%s\n"), + dwarf_vmatoa ("u", uladv), + dwarf_vmatoa ("x", state_machine_regs.address)); + /* Do NOT reset view. */ + break; + + case DW_LNS_set_prologue_end: + printf (_(" Set prologue_end to true\n")); + break; + + case DW_LNS_set_epilogue_begin: + printf (_(" Set epilogue_begin to true\n")); + break; + + case DW_LNS_set_isa: + uladv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv)); + break; + + default: + printf (_(" Unknown opcode %d with operands: "), op_code); + + if (standard_opcodes != NULL) + for (i = standard_opcodes[op_code - 1]; i > 0 ; --i) + { + printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data, + &bytes_read, end)), + i == 1 ? "" : ", "); + data += bytes_read; + } + putchar ('\n'); + break; + } + } + putchar ('\n'); + } + } + + return 1; +} + +typedef struct +{ + unsigned char *name; + unsigned int directory_index; + unsigned int modification_date; + unsigned int length; +} File_Entry; + +/* Output a decoded representation of the .debug_line section. */ + +static int +display_debug_lines_decoded (struct dwarf_section * section, + unsigned char * data, + unsigned char * end, + void * fileptr) +{ + static DWARF2_Internal_LineInfo saved_linfo; + + introduce (section, FALSE); + + while (data < end) + { + /* This loop amounts to one iteration per compilation unit. */ + DWARF2_Internal_LineInfo linfo; + unsigned char *standard_opcodes; + unsigned char *end_of_sequence; + int i; + File_Entry *file_table = NULL; + unsigned int n_files = 0; + unsigned char **directory_table = NULL; + dwarf_vma n_directories = 0; + + if (const_strneq (section->name, ".debug_line.") + /* Note: the following does not apply to .debug_line.dwo sections. + These are full debug_line sections. */ + && strcmp (section->name, ".debug_line.dwo") != 0) + { + /* See comment in display_debug_lines_raw(). */ + end_of_sequence = end; + standard_opcodes = NULL; + linfo = saved_linfo; + /* PR 17531: file: 0522b371. */ + if (linfo.li_line_range == 0) + { + warn (_("Partial .debug_line. section encountered without a prior full .debug_line section\n")); + return 0; + } + reset_state_machine (linfo.li_default_is_stmt); + } + else + { + unsigned char *hdrptr; + + if ((hdrptr = read_debug_line_header (section, data, end, & linfo, + & end_of_sequence)) == NULL) + return 0; + + /* PR 17531: file: 0522b371. */ + if (linfo.li_line_range == 0) + { + warn (_("Line range of 0 is invalid, using 1 instead\n")); + linfo.li_line_range = 1; + } + reset_state_machine (linfo.li_default_is_stmt); + + /* Save a pointer to the contents of the Opcodes table. */ + standard_opcodes = hdrptr; + + /* Traverse the Directory table just to count entries. */ + data = standard_opcodes + linfo.li_opcode_base - 1; + /* PR 20440 */ + if (data >= end) + { + warn (_("opcode base of %d extends beyond end of section\n"), + linfo.li_opcode_base); + return 0; + } + + if (linfo.li_version >= 5) + { + unsigned char *format_start, format_count, *format; + dwarf_vma formati, entryi; + unsigned int bytes_read; + + load_debug_section_with_follow (line_str, fileptr); + + /* Skip directories format. */ + SAFE_BYTE_GET_AND_INC (format_count, data, 1, end); + format_start = data; + for (formati = 0; formati < format_count; formati++) + { + read_uleb128 (data, & bytes_read, end); + data += bytes_read; + read_uleb128 (data, & bytes_read, end); + data += bytes_read; + } + + n_directories = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + if (data == end) + { + warn (_("Corrupt directories list\n")); + break; + } + + directory_table = (unsigned char **) + xmalloc (n_directories * sizeof (unsigned char *)); + + for (entryi = 0; entryi < n_directories; entryi++) + { + unsigned char **pathp = &directory_table[entryi]; + + format = format_start; + for (formati = 0; formati < format_count; formati++) + { + dwarf_vma content_type, form; + dwarf_vma uvalue; + + content_type = read_uleb128 (format, & bytes_read, end); + format += bytes_read; + form = read_uleb128 (format, & bytes_read, end); + format += bytes_read; + if (data == end) + { + warn (_("Corrupt directories list\n")); + break; + } + switch (content_type) + { + case DW_LNCT_path: + switch (form) + { + case DW_FORM_string: + *pathp = data; + break; + case DW_FORM_line_strp: + SAFE_BYTE_GET (uvalue, data, linfo.li_offset_size, + end); + /* Remove const by the cast. */ + *pathp = (unsigned char *) + fetch_indirect_line_string (uvalue); + break; + } + break; + } + data = read_and_display_attr_value (0, form, 0, data, end, + 0, 0, + linfo.li_offset_size, + linfo.li_version, + NULL, 1, section, + NULL, '\t'); + } + if (data == end) + { + warn (_("Corrupt directories list\n")); + break; + } + } + + /* Skip files format. */ + SAFE_BYTE_GET_AND_INC (format_count, data, 1, end); + format_start = data; + for (formati = 0; formati < format_count; formati++) + { + read_uleb128 (data, & bytes_read, end); + data += bytes_read; + read_uleb128 (data, & bytes_read, end); + data += bytes_read; + } + + n_files = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + if (data == end) + { + warn (_("Corrupt file name list\n")); + break; + } + + file_table = (File_Entry *) xcalloc (1, n_files + * sizeof (File_Entry)); + + for (entryi = 0; entryi < n_files; entryi++) + { + File_Entry *file = &file_table[entryi]; + + format = format_start; + for (formati = 0; formati < format_count; formati++) + { + dwarf_vma content_type, form; + dwarf_vma uvalue; + + content_type = read_uleb128 (format, & bytes_read, end); + format += bytes_read; + form = read_uleb128 (format, & bytes_read, end); + format += bytes_read; + if (data == end) + { + warn (_("Corrupt file name list\n")); + break; + } + switch (content_type) + { + case DW_LNCT_path: + switch (form) + { + case DW_FORM_string: + file->name = data; + break; + case DW_FORM_line_strp: + SAFE_BYTE_GET (uvalue, data, linfo.li_offset_size, + end); + /* Remove const by the cast. */ + file->name = (unsigned char *) + fetch_indirect_line_string (uvalue); + break; + } + break; + case DW_LNCT_directory_index: + switch (form) + { + case DW_FORM_data1: + SAFE_BYTE_GET (file->directory_index, data, 1, + end); + break; + case DW_FORM_data2: + SAFE_BYTE_GET (file->directory_index, data, 2, + end); + break; + case DW_FORM_udata: + file->directory_index = read_uleb128 (data, NULL, + end); + break; + } + break; + } + data = read_and_display_attr_value (0, form, 0, data, end, + 0, 0, + linfo.li_offset_size, + linfo.li_version, + NULL, 1, section, + NULL, '\t'); + } + if (data == end) + { + warn (_("Corrupt file name list\n")); + break; + } + } + } + else + { + if (*data != 0) + { + unsigned char *ptr_directory_table = data; + + while (data < end && *data != 0) + { + data += strnlen ((char *) data, end - data) + 1; + n_directories++; + } + + /* PR 20440 */ + if (data >= end) + { + warn (_("directory table ends unexpectedly\n")); + n_directories = 0; + break; + } + + /* Go through the directory table again to save the directories. */ + directory_table = (unsigned char **) + xmalloc (n_directories * sizeof (unsigned char *)); + + i = 0; + while (*ptr_directory_table != 0) + { + directory_table[i] = ptr_directory_table; + ptr_directory_table += strnlen ((char *) ptr_directory_table, + ptr_directory_table - end) + 1; + i++; + } + } + /* Skip the NUL at the end of the table. */ + data++; + + /* Traverse the File Name table just to count the entries. */ + if (data < end && *data != 0) + { + unsigned char *ptr_file_name_table = data; + + while (data < end && *data != 0) + { + unsigned int bytes_read; + + /* Skip Name, directory index, last modification time and length + of file. */ + data += strnlen ((char *) data, end - data) + 1; + read_uleb128 (data, & bytes_read, end); + data += bytes_read; + read_uleb128 (data, & bytes_read, end); + data += bytes_read; + read_uleb128 (data, & bytes_read, end); + data += bytes_read; + + n_files++; + } + + if (data >= end) + { + warn (_("file table ends unexpectedly\n")); + n_files = 0; + break; + } + + /* Go through the file table again to save the strings. */ + file_table = (File_Entry *) xmalloc (n_files * sizeof (File_Entry)); + + i = 0; + while (*ptr_file_name_table != 0) + { + unsigned int bytes_read; + + file_table[i].name = ptr_file_name_table; + ptr_file_name_table += strnlen ((char *) ptr_file_name_table, + end - ptr_file_name_table) + 1; + + /* We are not interested in directory, time or size. */ + file_table[i].directory_index = read_uleb128 (ptr_file_name_table, + & bytes_read, end); + ptr_file_name_table += bytes_read; + file_table[i].modification_date = read_uleb128 (ptr_file_name_table, + & bytes_read, end); + ptr_file_name_table += bytes_read; + file_table[i].length = read_uleb128 (ptr_file_name_table, & bytes_read, end); + ptr_file_name_table += bytes_read; + i++; + } + i = 0; + } + + /* Skip the NUL at the end of the table. */ + data++; + } + + /* Print the Compilation Unit's name and a header. */ + if (file_table == NULL) + ; + else if (directory_table == NULL) + printf (_("CU: %s:\n"), file_table[0].name); + else + { + unsigned int ix = file_table[0].directory_index; + const char *directory; + + if (ix == 0) + directory = "."; + /* PR 20439 */ + else if (n_directories == 0) + directory = _(""); + else if (ix > n_directories) + { + warn (_("directory index %u > number of directories %s\n"), + ix, dwarf_vmatoa ("u", n_directories)); + directory = _(""); + } + else + directory = (char *) directory_table[ix - 1]; + + if (do_wide || strlen (directory) < 76) + printf (_("CU: %s/%s:\n"), directory, file_table[0].name); + else + printf ("%s:\n", file_table[0].name); + } + + printf (_("File name Line number Starting address View\n")); + saved_linfo = linfo; + } + + /* This loop iterates through the Dwarf Line Number Program. */ + while (data < end_of_sequence) + { + unsigned char op_code; + int xop; + int adv; + unsigned long int uladv; + unsigned int bytes_read; + int is_special_opcode = 0; + + op_code = *data++; + xop = op_code; + + if (op_code >= linfo.li_opcode_base) + { + op_code -= linfo.li_opcode_base; + uladv = (op_code / linfo.li_line_range); + if (linfo.li_max_ops_per_insn == 1) + { + uladv *= linfo.li_min_insn_length; + state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; + } + else + { + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) + * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; + state_machine_regs.op_index + = (state_machine_regs.op_index + uladv) + % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; + } + + adv = (op_code % linfo.li_line_range) + linfo.li_line_base; + state_machine_regs.line += adv; + is_special_opcode = 1; + /* Increment view after printing this row. */ + } + else switch (op_code) + { + case DW_LNS_extended_op: + { + unsigned int ext_op_code_len; + unsigned char ext_op_code; + unsigned char *op_code_data = data; + + ext_op_code_len = read_uleb128 (op_code_data, &bytes_read, + end_of_sequence); + op_code_data += bytes_read; + + if (ext_op_code_len == 0) + { + warn (_("Badly formed extended line op encountered!\n")); + break; + } + ext_op_code_len += bytes_read; + ext_op_code = *op_code_data++; + xop = ext_op_code; + xop = -xop; + + switch (ext_op_code) + { + case DW_LNE_end_sequence: + /* Reset stuff after printing this row. */ + break; + case DW_LNE_set_address: + SAFE_BYTE_GET_AND_INC (state_machine_regs.address, + op_code_data, + ext_op_code_len - bytes_read - 1, + end); + state_machine_regs.op_index = 0; + state_machine_regs.view = 0; + break; + case DW_LNE_define_file: + { + file_table = (File_Entry *) xrealloc + (file_table, (n_files + 1) * sizeof (File_Entry)); + + ++state_machine_regs.last_file_entry; + /* Source file name. */ + file_table[n_files].name = op_code_data; + op_code_data += strlen ((char *) op_code_data) + 1; + /* Directory index. */ + file_table[n_files].directory_index = + read_uleb128 (op_code_data, & bytes_read, + end_of_sequence); + op_code_data += bytes_read; + /* Last modification time. */ + file_table[n_files].modification_date = + read_uleb128 (op_code_data, & bytes_read, + end_of_sequence); + op_code_data += bytes_read; + /* File length. */ + file_table[n_files].length = + read_uleb128 (op_code_data, & bytes_read, + end_of_sequence); + + n_files++; + break; + } + case DW_LNE_set_discriminator: + case DW_LNE_HP_set_sequence: + /* Simply ignored. */ + break; + + default: + printf (_("UNKNOWN (%u): length %d\n"), + ext_op_code, ext_op_code_len - bytes_read); + break; + } + data += ext_op_code_len; + break; + } + case DW_LNS_copy: + /* Increment view after printing this row. */ + break; + + case DW_LNS_advance_pc: + uladv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + if (linfo.li_max_ops_per_insn == 1) + { + uladv *= linfo.li_min_insn_length; + state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; + } + else + { + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) + * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; + state_machine_regs.op_index + = (state_machine_regs.op_index + uladv) + % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; + } + break; + + case DW_LNS_advance_line: + adv = read_sleb128 (data, & bytes_read, end); + data += bytes_read; + state_machine_regs.line += adv; + break; + + case DW_LNS_set_file: + adv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + state_machine_regs.file = adv; + + { + unsigned file = state_machine_regs.file - 1; + unsigned dir; + + if (file_table == NULL || n_files == 0) + printf (_("\n [Use file table entry %d]\n"), file); + /* PR 20439 */ + else if (file >= n_files) + { + warn (_("file index %u > number of files %u\n"), file + 1, n_files); + printf (_("\n "), file); + } + else if ((dir = file_table[file].directory_index) == 0) + /* If directory index is 0, that means current directory. */ + printf ("\n./%s:[++]\n", file_table[file].name); + else if (directory_table == NULL || n_directories == 0) + printf (_("\n [Use file %s in directory table entry %d]\n"), + file_table[file].name, dir); + /* PR 20439 */ + else if (dir > n_directories) + { + warn (_("directory index %u > number of directories %s\n"), + dir, dwarf_vmatoa ("u", n_directories)); + printf (_("\n \n"), dir); + } + else + printf ("\n%s/%s:\n", + /* The directory index starts counting at 1. */ + directory_table[dir - 1], file_table[file].name); + } + break; + + case DW_LNS_set_column: + uladv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + state_machine_regs.column = uladv; + break; + + case DW_LNS_negate_stmt: + adv = state_machine_regs.is_stmt; + adv = ! adv; + state_machine_regs.is_stmt = adv; + break; + + case DW_LNS_set_basic_block: + state_machine_regs.basic_block = 1; + break; + + case DW_LNS_const_add_pc: + uladv = ((255 - linfo.li_opcode_base) / linfo.li_line_range); + if (linfo.li_max_ops_per_insn == 1) + { + uladv *= linfo.li_min_insn_length; + state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; + } + else + { + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) + * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; + state_machine_regs.op_index + = (state_machine_regs.op_index + uladv) + % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; + } + break; + + case DW_LNS_fixed_advance_pc: + SAFE_BYTE_GET_AND_INC (uladv, data, 2, end); + state_machine_regs.address += uladv; + state_machine_regs.op_index = 0; + /* Do NOT reset view. */ + break; + + case DW_LNS_set_prologue_end: + break; + + case DW_LNS_set_epilogue_begin: + break; + + case DW_LNS_set_isa: + uladv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + printf (_(" Set ISA to %lu\n"), uladv); + break; + + default: + printf (_(" Unknown opcode %d with operands: "), op_code); + + if (standard_opcodes != NULL) + for (i = standard_opcodes[op_code - 1]; i > 0 ; --i) + { + printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data, + &bytes_read, end)), + i == 1 ? "" : ", "); + data += bytes_read; + } + putchar ('\n'); + break; + } + + /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row + to the DWARF address/line matrix. */ + if ((is_special_opcode) || (xop == -DW_LNE_end_sequence) + || (xop == DW_LNS_copy)) + { + const unsigned int MAX_FILENAME_LENGTH = 35; + char *fileName; + char *newFileName = NULL; + size_t fileNameLength; + + if (file_table) + { + unsigned indx = state_machine_regs.file - 1; + /* PR 20439 */ + if (indx >= n_files) + { + warn (_("corrupt file index %u encountered\n"), indx); + fileName = _(""); + } + else + fileName = (char *) file_table[indx].name; + } + else + fileName = _(""); + + fileNameLength = strlen (fileName); + + if ((fileNameLength > MAX_FILENAME_LENGTH) && (!do_wide)) + { + newFileName = (char *) xmalloc (MAX_FILENAME_LENGTH + 1); + /* Truncate file name */ + strncpy (newFileName, + fileName + fileNameLength - MAX_FILENAME_LENGTH, + MAX_FILENAME_LENGTH + 1); + } + else + { + newFileName = (char *) xmalloc (fileNameLength + 1); + strncpy (newFileName, fileName, fileNameLength + 1); + } + + if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH)) + { + if (linfo.li_max_ops_per_insn == 1) + printf ("%-35s %11d %#18" DWARF_VMA_FMT "x", + newFileName, state_machine_regs.line, + state_machine_regs.address); + else + printf ("%-35s %11d %#18" DWARF_VMA_FMT "x[%d]", + newFileName, state_machine_regs.line, + state_machine_regs.address, + state_machine_regs.op_index); + } + else + { + if (linfo.li_max_ops_per_insn == 1) + printf ("%s %11d %#18" DWARF_VMA_FMT "x", + newFileName, state_machine_regs.line, + state_machine_regs.address); + else + printf ("%s %11d %#18" DWARF_VMA_FMT "x[%d]", + newFileName, state_machine_regs.line, + state_machine_regs.address, + state_machine_regs.op_index); + } + + if (state_machine_regs.view) + printf (" %6u\n", state_machine_regs.view); + else + putchar ('\n'); + state_machine_regs.view++; + + if (xop == -DW_LNE_end_sequence) + { + reset_state_machine (linfo.li_default_is_stmt); + putchar ('\n'); + } + + free (newFileName); + } + } + + if (file_table) + { + free (file_table); + file_table = NULL; + n_files = 0; + } + + if (directory_table) + { + free (directory_table); + directory_table = NULL; + n_directories = 0; + } + + putchar ('\n'); + } + + return 1; +} + +static int +display_debug_lines (struct dwarf_section *section, void *file) +{ + unsigned char *data = section->start; + unsigned char *end = data + section->size; + int retValRaw = 1; + int retValDecoded = 1; + + if (do_debug_lines == 0) + do_debug_lines |= FLAG_DEBUG_LINES_RAW; + + if (do_debug_lines & FLAG_DEBUG_LINES_RAW) + retValRaw = display_debug_lines_raw (section, data, end, file); + + if (do_debug_lines & FLAG_DEBUG_LINES_DECODED) + retValDecoded = display_debug_lines_decoded (section, data, end, file); + + if (!retValRaw || !retValDecoded) + return 0; + + return 1; +} + +static debug_info * +find_debug_info_for_offset (unsigned long offset) +{ + unsigned int i; + + if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE) + return NULL; + + for (i = 0; i < num_debug_info_entries; i++) + if (debug_information[i].cu_offset == offset) + return debug_information + i; + + return NULL; +} + +static const char * +get_gdb_index_symbol_kind_name (gdb_index_symbol_kind kind) +{ + /* See gdb/gdb-index.h. */ + static const char * const kinds[] = + { + N_ ("no info"), + N_ ("type"), + N_ ("variable"), + N_ ("function"), + N_ ("other"), + N_ ("unused5"), + N_ ("unused6"), + N_ ("unused7") + }; + + return _ (kinds[kind]); +} + +static int +display_debug_pubnames_worker (struct dwarf_section *section, + void *file ATTRIBUTE_UNUSED, + int is_gnu) +{ + DWARF2_Internal_PubNames names; + unsigned char *start = section->start; + unsigned char *end = start + section->size; + + /* It does not matter if this load fails, + we test for that later on. */ + load_debug_info (file); + + introduce (section, FALSE); + + while (start < end) + { + unsigned char *data; + unsigned long sec_off; + unsigned int offset_size, initial_length_size; + + SAFE_BYTE_GET_AND_INC (names.pn_length, start, 4, end); + if (names.pn_length == 0xffffffff) + { + SAFE_BYTE_GET_AND_INC (names.pn_length, start, 8, end); + offset_size = 8; + initial_length_size = 12; + } + else + { + offset_size = 4; + initial_length_size = 4; + } + + sec_off = start - section->start; + if (sec_off + names.pn_length < sec_off + || sec_off + names.pn_length > section->size) + { + warn (_("Debug info is corrupted, %s header at %#lx has length %s\n"), + section->name, + sec_off - initial_length_size, + dwarf_vmatoa ("x", names.pn_length)); + break; + } + + data = start; + start += names.pn_length; + + SAFE_BYTE_GET_AND_INC (names.pn_version, data, 2, end); + SAFE_BYTE_GET_AND_INC (names.pn_offset, data, offset_size, end); + + if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE + && num_debug_info_entries > 0 + && find_debug_info_for_offset (names.pn_offset) == NULL) + warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), + (unsigned long) names.pn_offset, section->name); + + SAFE_BYTE_GET_AND_INC (names.pn_size, data, offset_size, end); + + printf (_(" Length: %ld\n"), + (long) names.pn_length); + printf (_(" Version: %d\n"), + names.pn_version); + printf (_(" Offset into .debug_info section: 0x%lx\n"), + (unsigned long) names.pn_offset); + printf (_(" Size of area in .debug_info section: %ld\n"), + (long) names.pn_size); + + if (names.pn_version != 2 && names.pn_version != 3) + { + static int warned = 0; + + if (! warned) + { + warn (_("Only DWARF 2 and 3 pubnames are currently supported\n")); + warned = 1; + } + + continue; + } + + if (is_gnu) + printf (_("\n Offset Kind Name\n")); + else + printf (_("\n Offset\tName\n")); + + while (1) + { + bfd_size_type maxprint; + dwarf_vma offset; + + SAFE_BYTE_GET (offset, data, offset_size, end); + + if (offset == 0) + break; + + data += offset_size; + if (data >= end) + break; + maxprint = (end - data) - 1; + + if (is_gnu) + { + unsigned int kind_data; + gdb_index_symbol_kind kind; + const char *kind_name; + int is_static; + + SAFE_BYTE_GET (kind_data, data, 1, end); + data++; + maxprint --; + /* GCC computes the kind as the upper byte in the CU index + word, and then right shifts it by the CU index size. + Left shift KIND to where the gdb-index.h accessor macros + can use it. */ + kind_data <<= GDB_INDEX_CU_BITSIZE; + kind = GDB_INDEX_SYMBOL_KIND_VALUE (kind_data); + kind_name = get_gdb_index_symbol_kind_name (kind); + is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (kind_data); + printf (" %-6lx %s,%-10s %.*s\n", + (unsigned long) offset, is_static ? _("s") : _("g"), + kind_name, (int) maxprint, data); + } + else + printf (" %-6lx\t%.*s\n", + (unsigned long) offset, (int) maxprint, data); + + data += strnlen ((char *) data, maxprint) + 1; + if (data >= end) + break; + } + } + + printf ("\n"); + return 1; +} + +static int +display_debug_pubnames (struct dwarf_section *section, void *file) +{ + return display_debug_pubnames_worker (section, file, 0); +} + +static int +display_debug_gnu_pubnames (struct dwarf_section *section, void *file) +{ + return display_debug_pubnames_worker (section, file, 1); +} + +static int +display_debug_macinfo (struct dwarf_section *section, + void *file ATTRIBUTE_UNUSED) +{ + unsigned char *start = section->start; + unsigned char *end = start + section->size; + unsigned char *curr = start; + unsigned int bytes_read; + enum dwarf_macinfo_record_type op; + + introduce (section, FALSE); + + while (curr < end) + { + unsigned int lineno; + const unsigned char *string; + + op = (enum dwarf_macinfo_record_type) *curr; + curr++; + + switch (op) + { + case DW_MACINFO_start_file: + { + unsigned int filenum; + + lineno = read_uleb128 (curr, & bytes_read, end); + curr += bytes_read; + filenum = read_uleb128 (curr, & bytes_read, end); + curr += bytes_read; + + printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"), + lineno, filenum); + } + break; + + case DW_MACINFO_end_file: + printf (_(" DW_MACINFO_end_file\n")); + break; + + case DW_MACINFO_define: + lineno = read_uleb128 (curr, & bytes_read, end); + curr += bytes_read; + string = curr; + curr += strnlen ((char *) string, end - string) + 1; + printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"), + lineno, string); + break; + + case DW_MACINFO_undef: + lineno = read_uleb128 (curr, & bytes_read, end); + curr += bytes_read; + string = curr; + curr += strnlen ((char *) string, end - string) + 1; + printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"), + lineno, string); + break; + + case DW_MACINFO_vendor_ext: + { + unsigned int constant; + + constant = read_uleb128 (curr, & bytes_read, end); + curr += bytes_read; + string = curr; + curr += strnlen ((char *) string, end - string) + 1; + printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"), + constant, string); + } + break; + } + } + + return 1; +} + +/* Given LINE_OFFSET into the .debug_line section, attempt to return + filename and dirname corresponding to file name table entry with index + FILEIDX. Return NULL on failure. */ + +static unsigned char * +get_line_filename_and_dirname (dwarf_vma line_offset, + dwarf_vma fileidx, + unsigned char **dir_name) +{ + struct dwarf_section *section = &debug_displays [line].section; + unsigned char *hdrptr, *dirtable, *file_name; + unsigned int offset_size, initial_length_size; + unsigned int version, opcode_base, bytes_read; + dwarf_vma length, diridx; + const unsigned char * end; + + *dir_name = NULL; + if (section->start == NULL + || line_offset >= section->size + || fileidx == 0) + return NULL; + + hdrptr = section->start + line_offset; + end = section->start + section->size; + + SAFE_BYTE_GET_AND_INC (length, hdrptr, 4, end); + if (length == 0xffffffff) + { + /* This section is 64-bit DWARF 3. */ + SAFE_BYTE_GET_AND_INC (length, hdrptr, 8, end); + offset_size = 8; + initial_length_size = 12; + } + else + { + offset_size = 4; + initial_length_size = 4; + } + if (length + initial_length_size < length + || length + initial_length_size > section->size) + return NULL; + + SAFE_BYTE_GET_AND_INC (version, hdrptr, 2, end); + if (version != 2 && version != 3 && version != 4) + return NULL; + hdrptr += offset_size + 1;/* Skip prologue_length and min_insn_length. */ + if (version >= 4) + hdrptr++; /* Skip max_ops_per_insn. */ + hdrptr += 3; /* Skip default_is_stmt, line_base, line_range. */ + + SAFE_BYTE_GET_AND_INC (opcode_base, hdrptr, 1, end); + if (opcode_base == 0) + return NULL; + + hdrptr += opcode_base - 1; + if (hdrptr >= end) + return NULL; + + dirtable = hdrptr; + /* Skip over dirname table. */ + while (*hdrptr != '\0') + { + hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1; + if (hdrptr >= end) + return NULL; + } + hdrptr++; /* Skip the NUL at the end of the table. */ + + /* Now skip over preceding filename table entries. */ + for (; hdrptr < end && *hdrptr != '\0' && fileidx > 1; fileidx--) + { + hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1; + read_uleb128 (hdrptr, &bytes_read, end); + hdrptr += bytes_read; + read_uleb128 (hdrptr, &bytes_read, end); + hdrptr += bytes_read; + read_uleb128 (hdrptr, &bytes_read, end); + hdrptr += bytes_read; + } + if (hdrptr >= end || *hdrptr == '\0') + return NULL; + + file_name = hdrptr; + hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1; + if (hdrptr >= end) + return NULL; + diridx = read_uleb128 (hdrptr, &bytes_read, end); + if (diridx == 0) + return file_name; + for (; dirtable < end && *dirtable != '\0' && diridx > 1; diridx--) + dirtable += strnlen ((char *) dirtable, end - dirtable) + 1; + if (dirtable >= end || *dirtable == '\0') + return NULL; + *dir_name = dirtable; + return file_name; +} + +static int +display_debug_macro (struct dwarf_section *section, + void *file) +{ + unsigned char *start = section->start; + unsigned char *end = start + section->size; + unsigned char *curr = start; + unsigned char *extended_op_buf[256]; + unsigned int bytes_read; + + load_debug_section_with_follow (str, file); + load_debug_section_with_follow (line, file); + + introduce (section, FALSE); + + while (curr < end) + { + unsigned int lineno, version, flags; + unsigned int offset_size = 4; + const unsigned char *string; + dwarf_vma line_offset = 0, sec_offset = curr - start, offset; + unsigned char **extended_ops = NULL; + + SAFE_BYTE_GET_AND_INC (version, curr, 2, end); + if (version != 4 && version != 5) + { + error (_("Only GNU extension to DWARF 4 or 5 of %s is currently supported.\n"), + section->name); + return 0; + } + + SAFE_BYTE_GET_AND_INC (flags, curr, 1, end); + if (flags & 1) + offset_size = 8; + printf (_(" Offset: 0x%lx\n"), + (unsigned long) sec_offset); + printf (_(" Version: %d\n"), version); + printf (_(" Offset size: %d\n"), offset_size); + if (flags & 2) + { + SAFE_BYTE_GET_AND_INC (line_offset, curr, offset_size, end); + printf (_(" Offset into .debug_line: 0x%lx\n"), + (unsigned long) line_offset); + } + if (flags & 4) + { + unsigned int i, count, op; + dwarf_vma nargs, n; + + SAFE_BYTE_GET_AND_INC (count, curr, 1, end); + + memset (extended_op_buf, 0, sizeof (extended_op_buf)); + extended_ops = extended_op_buf; + if (count) + { + printf (_(" Extension opcode arguments:\n")); + for (i = 0; i < count; i++) + { + SAFE_BYTE_GET_AND_INC (op, curr, 1, end); + extended_ops[op] = curr; + nargs = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; + if (nargs == 0) + printf (_(" DW_MACRO_%02x has no arguments\n"), op); + else + { + printf (_(" DW_MACRO_%02x arguments: "), op); + for (n = 0; n < nargs; n++) + { + unsigned int form; + + SAFE_BYTE_GET_AND_INC (form, curr, 1, end); + printf ("%s%s", get_FORM_name (form), + n == nargs - 1 ? "\n" : ", "); + switch (form) + { + case DW_FORM_data1: + case DW_FORM_data2: + case DW_FORM_data4: + case DW_FORM_data8: + case DW_FORM_sdata: + case DW_FORM_udata: + case DW_FORM_block: + case DW_FORM_block1: + case DW_FORM_block2: + case DW_FORM_block4: + case DW_FORM_flag: + case DW_FORM_string: + case DW_FORM_strp: + case DW_FORM_sec_offset: + break; + default: + error (_("Invalid extension opcode form %s\n"), + get_FORM_name (form)); + return 0; + } + } + } + } + } + } + printf ("\n"); + + while (1) + { + unsigned int op; + + if (curr >= end) + { + error (_(".debug_macro section not zero terminated\n")); + return 0; + } + + SAFE_BYTE_GET_AND_INC (op, curr, 1, end); + if (op == 0) + break; + + switch (op) + { + case DW_MACRO_start_file: + { + unsigned int filenum; + unsigned char *file_name = NULL, *dir_name = NULL; + + lineno = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; + filenum = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; + + if ((flags & 2) == 0) + error (_("DW_MACRO_start_file used, but no .debug_line offset provided.\n")); + else + file_name + = get_line_filename_and_dirname (line_offset, filenum, + &dir_name); + if (file_name == NULL) + printf (_(" DW_MACRO_start_file - lineno: %d filenum: %d\n"), + lineno, filenum); + else + printf (_(" DW_MACRO_start_file - lineno: %d filenum: %d filename: %s%s%s\n"), + lineno, filenum, + dir_name != NULL ? (const char *) dir_name : "", + dir_name != NULL ? "/" : "", file_name); + } + break; + + case DW_MACRO_end_file: + printf (_(" DW_MACRO_end_file\n")); + break; + + case DW_MACRO_define: + lineno = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; + string = curr; + curr += strnlen ((char *) string, end - string) + 1; + printf (_(" DW_MACRO_define - lineno : %d macro : %s\n"), + lineno, string); + break; + + case DW_MACRO_undef: + lineno = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; + string = curr; + curr += strnlen ((char *) string, end - string) + 1; + printf (_(" DW_MACRO_undef - lineno : %d macro : %s\n"), + lineno, string); + break; + + case DW_MACRO_define_strp: + lineno = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; + SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); + string = fetch_indirect_string (offset); + printf (_(" DW_MACRO_define_strp - lineno : %d macro : %s\n"), + lineno, string); + break; + + case DW_MACRO_undef_strp: + lineno = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; + SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); + string = fetch_indirect_string (offset); + printf (_(" DW_MACRO_undef_strp - lineno : %d macro : %s\n"), + lineno, string); + break; + + case DW_MACRO_import: + SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); + printf (_(" DW_MACRO_import - offset : 0x%lx\n"), + (unsigned long) offset); + break; + + case DW_MACRO_define_sup: + lineno = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; + SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); + printf (_(" DW_MACRO_define_sup - lineno : %d macro offset : 0x%lx\n"), + lineno, (unsigned long) offset); + break; + + case DW_MACRO_undef_sup: + lineno = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; + SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); + printf (_(" DW_MACRO_undef_sup - lineno : %d macro offset : 0x%lx\n"), + lineno, (unsigned long) offset); + break; + + case DW_MACRO_import_sup: + SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); + printf (_(" DW_MACRO_import_sup - offset : 0x%lx\n"), + (unsigned long) offset); + break; + + default: + if (extended_ops == NULL || extended_ops[op] == NULL) + { + error (_(" Unknown macro opcode %02x seen\n"), op); + return 0; + } + else + { + /* Skip over unhandled opcodes. */ + dwarf_vma nargs, n; + unsigned char *desc = extended_ops[op]; + nargs = read_uleb128 (desc, &bytes_read, end); + desc += bytes_read; + if (nargs == 0) + { + printf (_(" DW_MACRO_%02x\n"), op); + break; + } + printf (_(" DW_MACRO_%02x -"), op); + for (n = 0; n < nargs; n++) + { + int val; + + /* DW_FORM_implicit_const is not expected here. */ + SAFE_BYTE_GET_AND_INC (val, desc, 1, end); + curr + = read_and_display_attr_value (0, val, 0, + curr, end, 0, 0, offset_size, + version, NULL, 0, NULL, + NULL, ' '); + if (n != nargs - 1) + printf (","); + } + printf ("\n"); + } + break; + } + } + + printf ("\n"); + } + + return 1; +} + +static int +display_debug_abbrev (struct dwarf_section *section, + void *file ATTRIBUTE_UNUSED) +{ + abbrev_entry *entry; + unsigned char *start = section->start; + unsigned char *end = start + section->size; + + introduce (section, FALSE); + + do + { + unsigned char *last; + + free_abbrevs (); + + last = start; + start = process_abbrev_section (start, end); + + if (first_abbrev == NULL) + continue; + + printf (_(" Number TAG (0x%lx)\n"), (long) (last - section->start)); + + for (entry = first_abbrev; entry; entry = entry->next) + { + abbrev_attr *attr; + + printf (" %ld %s [%s]\n", + entry->entry, + get_TAG_name (entry->tag), + entry->children ? _("has children") : _("no children")); + + for (attr = entry->first_attr; attr; attr = attr->next) + { + printf (" %-18s %s", + get_AT_name (attr->attribute), + get_FORM_name (attr->form)); + if (attr->form == DW_FORM_implicit_const) + printf (": %" BFD_VMA_FMT "d", attr->implicit_const); + putchar ('\n'); + } + } + } + while (start); + + printf ("\n"); + + return 1; +} + +/* Return true when ADDR is the maximum address, when addresses are + POINTER_SIZE bytes long. */ + +static bfd_boolean +is_max_address (dwarf_vma addr, unsigned int pointer_size) +{ + dwarf_vma mask = ~(~(dwarf_vma) 1 << (pointer_size * 8 - 1)); + return ((addr & mask) == mask); +} + +/* Display a view pair list starting at *VSTART_PTR and ending at + VLISTEND within SECTION. */ + +static void +display_view_pair_list (struct dwarf_section *section, + unsigned char **vstart_ptr, + unsigned int debug_info_entry, + unsigned char *vlistend) +{ + unsigned char *vstart = *vstart_ptr; + unsigned char *section_end = section->start + section->size; + unsigned int pointer_size = debug_information [debug_info_entry].pointer_size; + + if (vlistend < section_end) + section_end = vlistend; + + putchar ('\n'); + + while (vstart < section_end) + { + dwarf_vma off = vstart - section->start; + dwarf_vma vbegin, vend; + + unsigned int bytes_read; + vbegin = read_uleb128 (vstart, &bytes_read, section_end); + vstart += bytes_read; + if (vstart == section_end) + { + vstart -= bytes_read; + break; + } + + vend = read_uleb128 (vstart, &bytes_read, section_end); + vstart += bytes_read; + + printf (" %8.8lx ", (unsigned long) off); + + print_dwarf_view (vbegin, pointer_size, 1); + print_dwarf_view (vend, pointer_size, 1); + printf (_("location view pair\n")); + } + + putchar ('\n'); + *vstart_ptr = vstart; +} + +/* Display a location list from a normal (ie, non-dwo) .debug_loc section. */ + +static void +display_loc_list (struct dwarf_section *section, + unsigned char **start_ptr, + unsigned int debug_info_entry, + dwarf_vma offset, + dwarf_vma base_address, + unsigned char **vstart_ptr, + int has_frame_base) +{ + unsigned char *start = *start_ptr, *vstart = *vstart_ptr; + unsigned char *section_end = section->start + section->size; + unsigned long cu_offset; + unsigned int pointer_size; + unsigned int offset_size; + int dwarf_version; + + dwarf_vma begin; + dwarf_vma end; + unsigned short length; + int need_frame_base; + + if (debug_info_entry >= num_debug_info_entries) + { + warn (_("No debug information available for loc lists of entry: %u\n"), + debug_info_entry); + return; + } + + cu_offset = debug_information [debug_info_entry].cu_offset; + pointer_size = debug_information [debug_info_entry].pointer_size; + offset_size = debug_information [debug_info_entry].offset_size; + dwarf_version = debug_information [debug_info_entry].dwarf_version; + + if (pointer_size < 2 || pointer_size > 8) + { + warn (_("Invalid pointer size (%d) in debug info for entry %d\n"), + pointer_size, debug_info_entry); + return; + } + + while (1) + { + dwarf_vma off = offset + (start - *start_ptr); + dwarf_vma vbegin = vm1, vend = vm1; + + if (start + 2 * pointer_size > section_end) + { + warn (_("Location list starting at offset 0x%lx is not terminated.\n"), + (unsigned long) offset); + break; + } + + printf (" %8.8lx ", (unsigned long) off); + + SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, section_end); + SAFE_BYTE_GET_AND_INC (end, start, pointer_size, section_end); + + if (begin == 0 && end == 0) + { + /* PR 18374: In a object file we can have a location list that + starts with a begin and end of 0 because there are relocations + that need to be applied to the addresses. Actually applying + the relocations now does not help as they will probably resolve + to 0, since the object file has not been fully linked. Real + end of list markers will not have any relocations against them. */ + if (! reloc_at (section, off) + && ! reloc_at (section, off + pointer_size)) + { + printf (_("\n")); + break; + } + } + + /* Check base address specifiers. */ + if (is_max_address (begin, pointer_size) + && !is_max_address (end, pointer_size)) + { + base_address = end; + print_dwarf_vma (begin, pointer_size); + print_dwarf_vma (end, pointer_size); + printf (_("(base address)\n")); + continue; + } + + if (vstart) + { + unsigned int bytes_read; + + off = offset + (vstart - *start_ptr); + + vbegin = read_uleb128 (vstart, &bytes_read, section_end); + vstart += bytes_read; + print_dwarf_view (vbegin, pointer_size, 1); + + vend = read_uleb128 (vstart, &bytes_read, section_end); + vstart += bytes_read; + print_dwarf_view (vend, pointer_size, 1); + + printf (_("views at %8.8lx for:\n %*s "), + (unsigned long) off, 8, ""); + } + + if (start + 2 > section_end) + { + warn (_("Location list starting at offset 0x%lx is not terminated.\n"), + (unsigned long) offset); + break; + } + + SAFE_BYTE_GET_AND_INC (length, start, 2, section_end); + + if (start + length > section_end) + { + warn (_("Location list starting at offset 0x%lx is not terminated.\n"), + (unsigned long) offset); + break; + } + + print_dwarf_vma (begin + base_address, pointer_size); + print_dwarf_vma (end + base_address, pointer_size); + + putchar ('('); + need_frame_base = decode_location_expression (start, + pointer_size, + offset_size, + dwarf_version, + length, + cu_offset, section); + putchar (')'); + + if (need_frame_base && !has_frame_base) + printf (_(" [without DW_AT_frame_base]")); + + if (begin == end && vbegin == vend) + fputs (_(" (start == end)"), stdout); + else if (begin > end || (begin == end && vbegin > vend)) + fputs (_(" (start > end)"), stdout); + + putchar ('\n'); + + start += length; + } + + *start_ptr = start; + *vstart_ptr = vstart; +} + +/* Display a location list from a normal (ie, non-dwo) .debug_loclists section. */ + +static void +display_loclists_list (struct dwarf_section *section, + unsigned char **start_ptr, + unsigned int debug_info_entry, + dwarf_vma offset, + dwarf_vma base_address, + unsigned char **vstart_ptr, + int has_frame_base) +{ + unsigned char *start = *start_ptr, *vstart = *vstart_ptr; + unsigned char *section_end = section->start + section->size; + unsigned long cu_offset; + unsigned int pointer_size; + unsigned int offset_size; + int dwarf_version; + unsigned int bytes_read; + + /* Initialize it due to a false compiler warning. */ + dwarf_vma begin = -1, vbegin = -1; + dwarf_vma end = -1, vend = -1; + dwarf_vma length; + int need_frame_base; + + if (debug_info_entry >= num_debug_info_entries) + { + warn (_("No debug information available for " + "loclists lists of entry: %u\n"), + debug_info_entry); + return; + } + + cu_offset = debug_information [debug_info_entry].cu_offset; + pointer_size = debug_information [debug_info_entry].pointer_size; + offset_size = debug_information [debug_info_entry].offset_size; + dwarf_version = debug_information [debug_info_entry].dwarf_version; + + if (pointer_size < 2 || pointer_size > 8) + { + warn (_("Invalid pointer size (%d) in debug info for entry %d\n"), + pointer_size, debug_info_entry); + return; + } + + while (1) + { + dwarf_vma off = offset + (start - *start_ptr); + enum dwarf_location_list_entry_type llet; + + if (start + 1 > section_end) + { + warn (_("Location list starting at offset 0x%lx is not terminated.\n"), + (unsigned long) offset); + break; + } + + printf (" %8.8lx ", (unsigned long) off); + + SAFE_BYTE_GET_AND_INC (llet, start, 1, section_end); + + if (vstart && llet == DW_LLE_offset_pair) + { + off = offset + (vstart - *start_ptr); + + vbegin = read_uleb128 (vstart, &bytes_read, section_end); + vstart += bytes_read; + print_dwarf_view (vbegin, pointer_size, 1); + + vend = read_uleb128 (vstart, &bytes_read, section_end); + vstart += bytes_read; + print_dwarf_view (vend, pointer_size, 1); + + printf (_("views at %8.8lx for:\n %*s "), + (unsigned long) off, 8, ""); + } + + switch (llet) + { + case DW_LLE_end_of_list: + printf (_("\n")); + break; + case DW_LLE_offset_pair: + begin = read_uleb128 (start, &bytes_read, section_end); + start += bytes_read; + end = read_uleb128 (start, &bytes_read, section_end); + start += bytes_read; + break; + case DW_LLE_base_address: + SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size, + section_end); + print_dwarf_vma (base_address, pointer_size); + printf (_("(base address)\n")); + break; +#ifdef DW_LLE_view_pair + case DW_LLE_view_pair: + if (vstart) + printf (_("View pair entry in loclist with locviews attribute\n")); + vbegin = read_uleb128 (start, &bytes_read, section_end); + start += bytes_read; + print_dwarf_view (vbegin, pointer_size, 1); + + vend = read_uleb128 (start, &bytes_read, section_end); + start += bytes_read; + print_dwarf_view (vend, pointer_size, 1); + + printf (_("views for:\n")); + continue; +#endif + default: + error (_("Invalid location list entry type %d\n"), llet); + return; + } + if (llet == DW_LLE_end_of_list) + break; + if (llet != DW_LLE_offset_pair) + continue; + + if (start + 2 > section_end) + { + warn (_("Location list starting at offset 0x%lx is not terminated.\n"), + (unsigned long) offset); + break; + } + + length = read_uleb128 (start, &bytes_read, section_end); + start += bytes_read; + + print_dwarf_vma (begin + base_address, pointer_size); + print_dwarf_vma (end + base_address, pointer_size); + + putchar ('('); + need_frame_base = decode_location_expression (start, + pointer_size, + offset_size, + dwarf_version, + length, + cu_offset, section); + putchar (')'); + + if (need_frame_base && !has_frame_base) + printf (_(" [without DW_AT_frame_base]")); + + if (begin == end && vbegin == vend) + fputs (_(" (start == end)"), stdout); + else if (begin > end || (begin == end && vbegin > vend)) + fputs (_(" (start > end)"), stdout); + + putchar ('\n'); + + start += length; + vbegin = vend = -1; + } + + if (vbegin != vm1 || vend != vm1) + printf (_("Trailing view pair not used in a range")); + + *start_ptr = start; + *vstart_ptr = vstart; +} + +/* Print a .debug_addr table index in decimal, surrounded by square brackets, + right-adjusted in a field of length LEN, and followed by a space. */ + +static void +print_addr_index (unsigned int idx, unsigned int len) +{ + static char buf[15]; + snprintf (buf, sizeof (buf), "[%d]", idx); + printf ("%*s ", len, buf); +} + +/* Display a location list from a .dwo section. It uses address indexes rather + than embedded addresses. This code closely follows display_loc_list, but the + two are sufficiently different that combining things is very ugly. */ + +static void +display_loc_list_dwo (struct dwarf_section *section, + unsigned char **start_ptr, + unsigned int debug_info_entry, + dwarf_vma offset, + unsigned char **vstart_ptr, + int has_frame_base) +{ + unsigned char *start = *start_ptr, *vstart = *vstart_ptr; + unsigned char *section_end = section->start + section->size; + unsigned long cu_offset; + unsigned int pointer_size; + unsigned int offset_size; + int dwarf_version; + int entry_type; + unsigned short length; + int need_frame_base; + unsigned int idx; + unsigned int bytes_read; + + if (debug_info_entry >= num_debug_info_entries) + { + warn (_("No debug information for loc lists of entry: %u\n"), + debug_info_entry); + return; + } + + cu_offset = debug_information [debug_info_entry].cu_offset; + pointer_size = debug_information [debug_info_entry].pointer_size; + offset_size = debug_information [debug_info_entry].offset_size; + dwarf_version = debug_information [debug_info_entry].dwarf_version; + + if (pointer_size < 2 || pointer_size > 8) + { + warn (_("Invalid pointer size (%d) in debug info for entry %d\n"), + pointer_size, debug_info_entry); + return; + } + + while (1) + { + printf (" %8.8lx ", (unsigned long) (offset + (start - *start_ptr))); + + if (start >= section_end) + { + warn (_("Location list starting at offset 0x%lx is not terminated.\n"), + (unsigned long) offset); + break; + } + + SAFE_BYTE_GET_AND_INC (entry_type, start, 1, section_end); + + if (vstart) + switch (entry_type) + { + default: + break; + + case 2: + case 3: + case 4: + { + dwarf_vma view; + dwarf_vma off = offset + (vstart - *start_ptr); + + view = read_uleb128 (vstart, &bytes_read, section_end); + vstart += bytes_read; + print_dwarf_view (view, 8, 1); + + view = read_uleb128 (vstart, &bytes_read, section_end); + vstart += bytes_read; + print_dwarf_view (view, 8, 1); + + printf (_("views at %8.8lx for:\n %*s "), + (unsigned long) off, 8, ""); + + } + break; + } + + switch (entry_type) + { + case 0: /* A terminating entry. */ + *start_ptr = start; + *vstart_ptr = vstart; + printf (_("\n")); + return; + case 1: /* A base-address entry. */ + idx = read_uleb128 (start, &bytes_read, section_end); + start += bytes_read; + print_addr_index (idx, 8); + printf ("%*s", 9 + (vstart ? 2 * 6 : 0), ""); + printf (_("(base address selection entry)\n")); + continue; + case 2: /* A start/end entry. */ + idx = read_uleb128 (start, &bytes_read, section_end); + start += bytes_read; + print_addr_index (idx, 8); + idx = read_uleb128 (start, &bytes_read, section_end); + start += bytes_read; + print_addr_index (idx, 8); + break; + case 3: /* A start/length entry. */ + idx = read_uleb128 (start, &bytes_read, section_end); + start += bytes_read; + print_addr_index (idx, 8); + SAFE_BYTE_GET_AND_INC (idx, start, 4, section_end); + printf ("%08x ", idx); + break; + case 4: /* An offset pair entry. */ + SAFE_BYTE_GET_AND_INC (idx, start, 4, section_end); + printf ("%08x ", idx); + SAFE_BYTE_GET_AND_INC (idx, start, 4, section_end); + printf ("%08x ", idx); + break; + default: + warn (_("Unknown location list entry type 0x%x.\n"), entry_type); + *start_ptr = start; + *vstart_ptr = vstart; + return; + } + + if (start + 2 > section_end) + { + warn (_("Location list starting at offset 0x%lx is not terminated.\n"), + (unsigned long) offset); + break; + } + + SAFE_BYTE_GET_AND_INC (length, start, 2, section_end); + if (start + length > section_end) + { + warn (_("Location list starting at offset 0x%lx is not terminated.\n"), + (unsigned long) offset); + break; + } + + putchar ('('); + need_frame_base = decode_location_expression (start, + pointer_size, + offset_size, + dwarf_version, + length, + cu_offset, section); + putchar (')'); + + if (need_frame_base && !has_frame_base) + printf (_(" [without DW_AT_frame_base]")); + + putchar ('\n'); + + start += length; + } + + *start_ptr = start; + *vstart_ptr = vstart; +} + +/* Sort array of indexes in ascending order of loc_offsets[idx] and + loc_views. */ + +static dwarf_vma *loc_offsets, *loc_views; + +static int +loc_offsets_compar (const void *ap, const void *bp) +{ + dwarf_vma a = loc_offsets[*(const unsigned int *) ap]; + dwarf_vma b = loc_offsets[*(const unsigned int *) bp]; + + int ret = (a > b) - (b > a); + if (ret) + return ret; + + a = loc_views[*(const unsigned int *) ap]; + b = loc_views[*(const unsigned int *) bp]; + + ret = (a > b) - (b > a); + + return ret; +} + +static int +display_debug_loc (struct dwarf_section *section, void *file) +{ + unsigned char *start = section->start, *vstart = NULL; + unsigned long bytes; + unsigned char *section_begin = start; + unsigned int num_loc_list = 0; + unsigned long last_offset = 0; + unsigned long last_view = 0; + unsigned int first = 0; + unsigned int i; + unsigned int j; + int seen_first_offset = 0; + int locs_sorted = 1; + unsigned char *next = start, *vnext = vstart; + unsigned int *array = NULL; + const char *suffix = strrchr (section->name, '.'); + int is_dwo = 0; + int is_loclists = strstr (section->name, "debug_loclists") != NULL; + dwarf_vma expected_start = 0; + + if (suffix && strcmp (suffix, ".dwo") == 0) + is_dwo = 1; + + bytes = section->size; + + if (bytes == 0) + { + printf (_("\nThe %s section is empty.\n"), section->name); + return 0; + } + + if (is_loclists) + { + unsigned char *hdrptr = section_begin; + dwarf_vma ll_length; + unsigned short ll_version; + unsigned char *end = section_begin + section->size; + unsigned char address_size, segment_selector_size; + uint32_t offset_entry_count; + + SAFE_BYTE_GET_AND_INC (ll_length, hdrptr, 4, end); + if (ll_length == 0xffffffff) + SAFE_BYTE_GET_AND_INC (ll_length, hdrptr, 8, end); + + SAFE_BYTE_GET_AND_INC (ll_version, hdrptr, 2, end); + if (ll_version != 5) + { + warn (_("The %s section contains corrupt or " + "unsupported version number: %d.\n"), + section->name, ll_version); + return 0; + } + + SAFE_BYTE_GET_AND_INC (address_size, hdrptr, 1, end); + + SAFE_BYTE_GET_AND_INC (segment_selector_size, hdrptr, 1, end); + if (segment_selector_size != 0) + { + warn (_("The %s section contains " + "unsupported segment selector size: %d.\n"), + section->name, segment_selector_size); + return 0; + } + + SAFE_BYTE_GET_AND_INC (offset_entry_count, hdrptr, 4, end); + if (offset_entry_count != 0) + { + warn (_("The %s section contains " + "unsupported offset entry count: %d.\n"), + section->name, offset_entry_count); + return 0; + } + + expected_start = hdrptr - section_begin; + } + + if (load_debug_info (file) == 0) + { + warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), + section->name); + return 0; + } + + /* Check the order of location list in .debug_info section. If + offsets of location lists are in the ascending order, we can + use `debug_information' directly. */ + for (i = 0; i < num_debug_info_entries; i++) + { + unsigned int num; + + num = debug_information [i].num_loc_offsets; + if (num > num_loc_list) + num_loc_list = num; + + /* Check if we can use `debug_information' directly. */ + if (locs_sorted && num != 0) + { + if (!seen_first_offset) + { + /* This is the first location list. */ + last_offset = debug_information [i].loc_offsets [0]; + last_view = debug_information [i].loc_views [0]; + first = i; + seen_first_offset = 1; + j = 1; + } + else + j = 0; + + for (; j < num; j++) + { + if (last_offset > + debug_information [i].loc_offsets [j] + || (last_offset == debug_information [i].loc_offsets [j] + && last_view > debug_information [i].loc_views [j])) + { + locs_sorted = 0; + break; + } + last_offset = debug_information [i].loc_offsets [j]; + last_view = debug_information [i].loc_views [j]; + } + } + } + + if (!seen_first_offset) + error (_("No location lists in .debug_info section!\n")); + + if (debug_information [first].num_loc_offsets > 0 + && debug_information [first].loc_offsets [0] != expected_start + && debug_information [first].loc_views [0] != expected_start) + warn (_("Location lists in %s section start at 0x%s\n"), + section->name, + dwarf_vmatoa ("x", debug_information [first].loc_offsets [0])); + + if (!locs_sorted) + array = (unsigned int *) xcmalloc (num_loc_list, sizeof (unsigned int)); + + introduce (section, FALSE); + + if (reloc_at (section, 0)) + printf (_(" Warning: This section has relocations - addresses seen here may not be accurate.\n\n")); + + printf (_(" Offset Begin End Expression\n")); + + seen_first_offset = 0; + for (i = first; i < num_debug_info_entries; i++) + { + dwarf_vma offset, voffset; + dwarf_vma base_address; + unsigned int k; + int has_frame_base; + + if (!locs_sorted) + { + for (k = 0; k < debug_information [i].num_loc_offsets; k++) + array[k] = k; + loc_offsets = debug_information [i].loc_offsets; + loc_views = debug_information [i].loc_views; + qsort (array, debug_information [i].num_loc_offsets, + sizeof (*array), loc_offsets_compar); + } + + int adjacent_view_loclists = 1; + for (k = 0; k < debug_information [i].num_loc_offsets; k++) + { + j = locs_sorted ? k : array[k]; + if (k + && (debug_information [i].loc_offsets [locs_sorted + ? k - 1 : array [k - 1]] + == debug_information [i].loc_offsets [j]) + && (debug_information [i].loc_views [locs_sorted + ? k - 1 : array [k - 1]] + == debug_information [i].loc_views [j])) + continue; + has_frame_base = debug_information [i].have_frame_base [j]; + offset = debug_information [i].loc_offsets [j]; + next = section_begin + offset; + voffset = debug_information [i].loc_views [j]; + if (voffset != vm1) + vnext = section_begin + voffset; + else + vnext = NULL; + base_address = debug_information [i].base_address; + + if (vnext && vnext < next) + { + vstart = vnext; + display_view_pair_list (section, &vstart, i, next); + if (start == vnext) + start = vstart; + } + + if (!seen_first_offset || !adjacent_view_loclists) + seen_first_offset = 1; + else + { + if (start < next) + warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"), + (unsigned long) (start - section_begin), + (unsigned long) offset); + else if (start > next) + warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"), + (unsigned long) (start - section_begin), + (unsigned long) offset); + } + start = next; + vstart = vnext; + + if (offset >= bytes) + { + warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"), + (unsigned long) offset); + continue; + } + + if (vnext && voffset >= bytes) + { + warn (_("View Offset 0x%lx is bigger than .debug_loc section size.\n"), + (unsigned long) voffset); + continue; + } + + if (!is_loclists) + { + if (is_dwo) + display_loc_list_dwo (section, &start, i, offset, + &vstart, has_frame_base); + else + display_loc_list (section, &start, i, offset, base_address, + &vstart, has_frame_base); + } + else + { + if (is_dwo) + warn (_("DWO is not yet supported.\n")); + else + display_loclists_list (section, &start, i, offset, base_address, + &vstart, has_frame_base); + } + + /* FIXME: this arrangement is quite simplistic. Nothing + requires locview lists to be adjacent to corresponding + loclists, and a single loclist could be augmented by + different locview lists, and vice-versa, unlikely as it + is that it would make sense to do so. Hopefully we'll + have view pair support built into loclists before we ever + need to address all these possibilities. */ + if (adjacent_view_loclists && vnext + && vnext != start && vstart != next) + { + adjacent_view_loclists = 0; + warn (_("Hole and overlap detection requires adjacent view lists and loclists.\n")); + } + + if (vnext && vnext == start) + display_view_pair_list (section, &start, i, vstart); + } + } + + if (start < section->start + section->size) + warn (ngettext ("There is %ld unused byte at the end of section %s\n", + "There are %ld unused bytes at the end of section %s\n", + (long) (section->start + section->size - start)), + (long) (section->start + section->size - start), section->name); + putchar ('\n'); + free (array); + return 1; +} + +static int +display_debug_str (struct dwarf_section *section, + void *file ATTRIBUTE_UNUSED) +{ + unsigned char *start = section->start; + unsigned long bytes = section->size; + dwarf_vma addr = section->address; + + if (bytes == 0) + { + printf (_("\nThe %s section is empty.\n"), section->name); + return 0; + } + + introduce (section, FALSE); + + while (bytes) + { + int j; + int k; + int lbytes; + + lbytes = (bytes > 16 ? 16 : bytes); + + printf (" 0x%8.8lx ", (unsigned long) addr); + + for (j = 0; j < 16; j++) + { + if (j < lbytes) + printf ("%2.2x", start[j]); + else + printf (" "); + + if ((j & 3) == 3) + printf (" "); + } + + for (j = 0; j < lbytes; j++) + { + k = start[j]; + if (k >= ' ' && k < 0x80) + printf ("%c", k); + else + printf ("."); + } + + putchar ('\n'); + + start += lbytes; + addr += lbytes; + bytes -= lbytes; + } + + putchar ('\n'); + + return 1; +} + +static int +display_debug_info (struct dwarf_section *section, void *file) +{ + return process_debug_info (section, file, section->abbrev_sec, FALSE, FALSE); +} + +static int +display_debug_types (struct dwarf_section *section, void *file) +{ + return process_debug_info (section, file, section->abbrev_sec, FALSE, TRUE); +} + +static int +display_trace_info (struct dwarf_section *section, void *file) +{ + return process_debug_info (section, file, section->abbrev_sec, FALSE, TRUE); +} + +static int +display_debug_aranges (struct dwarf_section *section, + void *file ATTRIBUTE_UNUSED) +{ + unsigned char *start = section->start; + unsigned char *end = start + section->size; + + introduce (section, FALSE); + + /* It does not matter if this load fails, + we test for that later on. */ + load_debug_info (file); + + while (start < end) + { + unsigned char *hdrptr; + DWARF2_Internal_ARange arange; + unsigned char *addr_ranges; + dwarf_vma length; + dwarf_vma address; + unsigned long sec_off; + unsigned char address_size; + int excess; + unsigned int offset_size; + unsigned int initial_length_size; + + hdrptr = start; + + SAFE_BYTE_GET_AND_INC (arange.ar_length, hdrptr, 4, end); + if (arange.ar_length == 0xffffffff) + { + SAFE_BYTE_GET_AND_INC (arange.ar_length, hdrptr, 8, end); + offset_size = 8; + initial_length_size = 12; + } + else + { + offset_size = 4; + initial_length_size = 4; + } + + sec_off = hdrptr - section->start; + if (sec_off + arange.ar_length < sec_off + || sec_off + arange.ar_length > section->size) + { + warn (_("Debug info is corrupted, %s header at %#lx has length %s\n"), + section->name, + sec_off - initial_length_size, + dwarf_vmatoa ("x", arange.ar_length)); + break; + } + + SAFE_BYTE_GET_AND_INC (arange.ar_version, hdrptr, 2, end); + SAFE_BYTE_GET_AND_INC (arange.ar_info_offset, hdrptr, offset_size, end); + + if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE + && num_debug_info_entries > 0 + && find_debug_info_for_offset (arange.ar_info_offset) == NULL) + warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), + (unsigned long) arange.ar_info_offset, section->name); + + SAFE_BYTE_GET_AND_INC (arange.ar_pointer_size, hdrptr, 1, end); + SAFE_BYTE_GET_AND_INC (arange.ar_segment_size, hdrptr, 1, end); + + if (arange.ar_version != 2 && arange.ar_version != 3) + { + /* PR 19872: A version number of 0 probably means that there is + padding at the end of the .debug_aranges section. Gold puts + it there when performing an incremental link, for example. + So do not generate a warning in this case. */ + if (arange.ar_version) + warn (_("Only DWARF 2 and 3 aranges are currently supported.\n")); + break; + } + + printf (_(" Length: %ld\n"), + (long) arange.ar_length); + printf (_(" Version: %d\n"), arange.ar_version); + printf (_(" Offset into .debug_info: 0x%lx\n"), + (unsigned long) arange.ar_info_offset); + printf (_(" Pointer Size: %d\n"), arange.ar_pointer_size); + printf (_(" Segment Size: %d\n"), arange.ar_segment_size); + + address_size = arange.ar_pointer_size + arange.ar_segment_size; + + /* PR 17512: file: 001-108546-0.001:0.1. */ + if (address_size == 0 || address_size > 8) + { + error (_("Invalid address size in %s section!\n"), + section->name); + break; + } + + /* The DWARF spec does not require that the address size be a power + of two, but we do. This will have to change if we ever encounter + an uneven architecture. */ + if ((address_size & (address_size - 1)) != 0) + { + warn (_("Pointer size + Segment size is not a power of two.\n")); + break; + } + + if (address_size > 4) + printf (_("\n Address Length\n")); + else + printf (_("\n Address Length\n")); + + addr_ranges = hdrptr; + + /* Must pad to an alignment boundary that is twice the address size. */ + excess = (hdrptr - start) % (2 * address_size); + if (excess) + addr_ranges += (2 * address_size) - excess; + + start += arange.ar_length + initial_length_size; + + while (addr_ranges + 2 * address_size <= start) + { + SAFE_BYTE_GET_AND_INC (address, addr_ranges, address_size, end); + SAFE_BYTE_GET_AND_INC (length, addr_ranges, address_size, end); + + printf (" "); + print_dwarf_vma (address, address_size); + print_dwarf_vma (length, address_size); + putchar ('\n'); + } + } + + printf ("\n"); + + return 1; +} + +/* Comparison function for qsort. */ +static int +comp_addr_base (const void * v0, const void * v1) +{ + debug_info * info0 = (debug_info *) v0; + debug_info * info1 = (debug_info *) v1; + return info0->addr_base - info1->addr_base; +} + +/* Display the debug_addr section. */ +static int +display_debug_addr (struct dwarf_section *section, + void *file) +{ + debug_info **debug_addr_info; + unsigned char *entry; + unsigned char *end; + unsigned int i; + unsigned int count; + + if (section->size == 0) + { + printf (_("\nThe %s section is empty.\n"), section->name); + return 0; + } + + if (load_debug_info (file) == 0) + { + warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), + section->name); + return 0; + } + + introduce (section, FALSE); + + /* PR 17531: file: cf38d01b. + We use xcalloc because a corrupt file may not have initialised all of the + fields in the debug_info structure, which means that the sort below might + try to move uninitialised data. */ + debug_addr_info = (debug_info **) xcalloc ((num_debug_info_entries + 1), + sizeof (debug_info *)); + + count = 0; + for (i = 0; i < num_debug_info_entries; i++) + if (debug_information [i].addr_base != DEBUG_INFO_UNAVAILABLE) + { + /* PR 17531: file: cf38d01b. */ + if (debug_information[i].addr_base >= section->size) + warn (_("Corrupt address base (%lx) found in debug section %u\n"), + (unsigned long) debug_information[i].addr_base, i); + else + debug_addr_info [count++] = debug_information + i; + } + + /* Add a sentinel to make iteration convenient. */ + debug_addr_info [count] = (debug_info *) xmalloc (sizeof (debug_info)); + debug_addr_info [count]->addr_base = section->size; + qsort (debug_addr_info, count, sizeof (debug_info *), comp_addr_base); + + for (i = 0; i < count; i++) + { + unsigned int idx; + unsigned int address_size = debug_addr_info [i]->pointer_size; + + printf (_(" For compilation unit at offset 0x%s:\n"), + dwarf_vmatoa ("x", debug_addr_info [i]->cu_offset)); + + printf (_("\tIndex\tAddress\n")); + entry = section->start + debug_addr_info [i]->addr_base; + end = section->start + debug_addr_info [i + 1]->addr_base; + idx = 0; + while (entry < end) + { + dwarf_vma base = byte_get (entry, address_size); + printf (_("\t%d:\t"), idx); + print_dwarf_vma (base, address_size); + printf ("\n"); + entry += address_size; + idx++; + } + } + printf ("\n"); + + free (debug_addr_info); + return 1; +} + +/* Display the .debug_str_offsets and .debug_str_offsets.dwo sections. */ +static int +display_debug_str_offsets (struct dwarf_section *section, + void *file ATTRIBUTE_UNUSED) +{ + if (section->size == 0) + { + printf (_("\nThe %s section is empty.\n"), section->name); + return 0; + } + /* TODO: Dump the contents. This is made somewhat difficult by not knowing + what the offset size is for this section. */ + return 1; +} + +/* Each debug_information[x].range_lists[y] gets this representation for + sorting purposes. */ + +struct range_entry +{ + /* The debug_information[x].range_lists[y] value. */ + dwarf_vma ranges_offset; + + /* Original debug_information to find parameters of the data. */ + debug_info *debug_info_p; +}; + +/* Sort struct range_entry in ascending order of its RANGES_OFFSET. */ + +static int +range_entry_compar (const void *ap, const void *bp) +{ + const struct range_entry *a_re = (const struct range_entry *) ap; + const struct range_entry *b_re = (const struct range_entry *) bp; + const dwarf_vma a = a_re->ranges_offset; + const dwarf_vma b = b_re->ranges_offset; + + return (a > b) - (b > a); +} + +static void +display_debug_ranges_list (unsigned char *start, unsigned char *finish, + unsigned int pointer_size, unsigned long offset, + unsigned long base_address) +{ + while (start < finish) + { + dwarf_vma begin; + dwarf_vma end; + + SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish); + if (start >= finish) + break; + SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish); + + printf (" %8.8lx ", offset); + + if (begin == 0 && end == 0) + { + printf (_("\n")); + break; + } + + /* Check base address specifiers. */ + if (is_max_address (begin, pointer_size) + && !is_max_address (end, pointer_size)) + { + base_address = end; + print_dwarf_vma (begin, pointer_size); + print_dwarf_vma (end, pointer_size); + printf ("(base address)\n"); + continue; + } + + print_dwarf_vma (begin + base_address, pointer_size); + print_dwarf_vma (end + base_address, pointer_size); + + if (begin == end) + fputs (_("(start == end)"), stdout); + else if (begin > end) + fputs (_("(start > end)"), stdout); + + putchar ('\n'); + } +} + +static void +display_debug_rnglists_list (unsigned char *start, unsigned char *finish, + unsigned int pointer_size, unsigned long offset, + unsigned long base_address) +{ + unsigned char *next = start; + + while (1) + { + unsigned long off = offset + (start - next); + enum dwarf_range_list_entry rlet; + /* Initialize it due to a false compiler warning. */ + dwarf_vma begin = -1, length, end = -1; + unsigned int bytes_read; + + if (start + 1 > finish) + { + warn (_("Range list starting at offset 0x%lx is not terminated.\n"), + offset); + break; + } + + printf (" %8.8lx ", off); + + SAFE_BYTE_GET_AND_INC (rlet, start, 1, finish); + + switch (rlet) + { + case DW_RLE_end_of_list: + printf (_("\n")); + break; + case DW_RLE_base_address: + SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size, finish); + print_dwarf_vma (base_address, pointer_size); + printf (_("(base address)\n")); + break; + case DW_RLE_start_length: + SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish); + length = read_uleb128 (start, &bytes_read, finish); + start += bytes_read; + end = begin + length; + break; + case DW_RLE_offset_pair: + begin = read_uleb128 (start, &bytes_read, finish); + start += bytes_read; + end = read_uleb128 (start, &bytes_read, finish); + start += bytes_read; + break; + case DW_RLE_start_end: + SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish); + SAFE_BYTE_GET_AND_INC (end, start, pointer_size, finish); + break; + default: + error (_("Invalid range list entry type %d\n"), rlet); + rlet = DW_RLE_end_of_list; + break; + } + if (rlet == DW_RLE_end_of_list) + break; + if (rlet == DW_RLE_base_address) + continue; + + print_dwarf_vma (begin + base_address, pointer_size); + print_dwarf_vma (end + base_address, pointer_size); + + if (begin == end) + fputs (_("(start == end)"), stdout); + else if (begin > end) + fputs (_("(start > end)"), stdout); + + putchar ('\n'); + } +} + +static int +display_debug_ranges (struct dwarf_section *section, + void *file ATTRIBUTE_UNUSED) +{ + unsigned char *start = section->start; + unsigned char *last_start = start; + unsigned long bytes = section->size; + unsigned char *section_begin = start; + unsigned char *finish = start + bytes; + unsigned int num_range_list, i; + struct range_entry *range_entries, *range_entry_fill; + int is_rnglists = strstr (section->name, "debug_rnglists") != NULL; + /* Initialize it due to a false compiler warning. */ + unsigned char address_size = 0; + + if (bytes == 0) + { + printf (_("\nThe %s section is empty.\n"), section->name); + return 0; + } + + if (is_rnglists) + { + dwarf_vma initial_length; + unsigned int initial_length_size; + unsigned char segment_selector_size; + unsigned int offset_size, offset_entry_count; + unsigned short version; + + /* Get and check the length of the block. */ + SAFE_BYTE_GET_AND_INC (initial_length, start, 4, finish); + + if (initial_length == 0xffffffff) + { + /* This section is 64-bit DWARF 3. */ + SAFE_BYTE_GET_AND_INC (initial_length, start, 8, finish); + offset_size = 8; + initial_length_size = 12; + } + else + { + offset_size = 4; + initial_length_size = 4; + } + + if (initial_length + initial_length_size > section->size) + { + /* If the length field has a relocation against it, then we should + not complain if it is inaccurate (and probably negative). + It is copied from .debug_line handling code. */ + if (reloc_at (section, (start - section->start) - offset_size)) + { + initial_length = (finish - start) - initial_length_size; + } + else + { + warn (_("The length field (0x%lx) in the debug_rnglists header is wrong - the section is too small\n"), + (long) initial_length); + return 0; + } + } + + /* Get and check the version number. */ + SAFE_BYTE_GET_AND_INC (version, start, 2, finish); + + if (version != 5) + { + warn (_("Only DWARF version 5 debug_rnglists info " + "is currently supported.\n")); + return 0; + } + + SAFE_BYTE_GET_AND_INC (address_size, start, 1, finish); + + SAFE_BYTE_GET_AND_INC (segment_selector_size, start, 1, finish); + if (segment_selector_size != 0) + { + warn (_("The %s section contains " + "unsupported segment selector size: %d.\n"), + section->name, segment_selector_size); + return 0; + } + + SAFE_BYTE_GET_AND_INC (offset_entry_count, start, 4, finish); + if (offset_entry_count != 0) + { + warn (_("The %s section contains " + "unsupported offset entry count: %u.\n"), + section->name, offset_entry_count); + return 0; + } + } + + if (load_debug_info (file) == 0) + { + warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), + section->name); + return 0; + } + + num_range_list = 0; + for (i = 0; i < num_debug_info_entries; i++) + num_range_list += debug_information [i].num_range_lists; + + if (num_range_list == 0) + { + /* This can happen when the file was compiled with -gsplit-debug + which removes references to range lists from the primary .o file. */ + printf (_("No range lists in .debug_info section.\n")); + return 1; + } + + range_entries = (struct range_entry *) + xmalloc (sizeof (*range_entries) * num_range_list); + range_entry_fill = range_entries; + + for (i = 0; i < num_debug_info_entries; i++) + { + debug_info *debug_info_p = &debug_information[i]; + unsigned int j; + + for (j = 0; j < debug_info_p->num_range_lists; j++) + { + range_entry_fill->ranges_offset = debug_info_p->range_lists[j]; + range_entry_fill->debug_info_p = debug_info_p; + range_entry_fill++; + } + } + + qsort (range_entries, num_range_list, sizeof (*range_entries), + range_entry_compar); + + if (dwarf_check != 0 && range_entries[0].ranges_offset != 0) + warn (_("Range lists in %s section start at 0x%lx\n"), + section->name, (unsigned long) range_entries[0].ranges_offset); + + introduce (section, FALSE); + + printf (_(" Offset Begin End\n")); + + for (i = 0; i < num_range_list; i++) + { + struct range_entry *range_entry = &range_entries[i]; + debug_info *debug_info_p = range_entry->debug_info_p; + unsigned int pointer_size; + dwarf_vma offset; + unsigned char *next; + dwarf_vma base_address; + + pointer_size = (is_rnglists ? address_size : debug_info_p->pointer_size); + offset = range_entry->ranges_offset; + next = section_begin + offset; + base_address = debug_info_p->base_address; + + /* PR 17512: file: 001-101485-0.001:0.1. */ + if (pointer_size < 2 || pointer_size > 8) + { + warn (_("Corrupt pointer size (%d) in debug entry at offset %8.8lx\n"), + pointer_size, (unsigned long) offset); + continue; + } + + if (dwarf_check != 0 && i > 0) + { + if (start < next) + warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"), + (unsigned long) (start - section_begin), + (unsigned long) (next - section_begin), section->name); + else if (start > next) + { + if (next == last_start) + continue; + warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"), + (unsigned long) (start - section_begin), + (unsigned long) (next - section_begin), section->name); + } + } + start = next; + last_start = next; + + (is_rnglists ? display_debug_rnglists_list : display_debug_ranges_list) + (start, finish, pointer_size, offset, base_address); + } + putchar ('\n'); + + free (range_entries); + + return 1; +} + +typedef struct Frame_Chunk +{ + struct Frame_Chunk *next; + unsigned char *chunk_start; + unsigned int ncols; + /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */ + short int *col_type; + int *col_offset; + char *augmentation; + unsigned int code_factor; + int data_factor; + dwarf_vma pc_begin; + dwarf_vma pc_range; + unsigned int cfa_reg; + dwarf_vma cfa_offset; + unsigned int ra; + unsigned char fde_encoding; + unsigned char cfa_exp; + unsigned char ptr_size; + unsigned char segment_size; +} +Frame_Chunk; + +static const char *const *dwarf_regnames; +static unsigned int dwarf_regnames_count; + +/* A marker for a col_type that means this column was never referenced + in the frame info. */ +#define DW_CFA_unreferenced (-1) + +/* Return 0 if no more space is needed, 1 if more space is needed, + -1 for invalid reg. */ + +static int +frame_need_space (Frame_Chunk *fc, unsigned int reg) +{ + unsigned int prev = fc->ncols; + + if (reg < (unsigned int) fc->ncols) + return 0; + + if (dwarf_regnames_count + && reg > dwarf_regnames_count) + return -1; + + fc->ncols = reg + 1; + /* PR 17512: file: 10450-2643-0.004. + If reg == -1 then this can happen... */ + if (fc->ncols == 0) + return -1; + + /* PR 17512: file: 2844a11d. */ + if (fc->ncols > 1024) + { + error (_("Unfeasibly large register number: %u\n"), reg); + fc->ncols = 0; + /* FIXME: 1024 is an arbitrary limit. Increase it if + we ever encounter a valid binary that exceeds it. */ + return -1; + } + + fc->col_type = (short int *) xcrealloc (fc->col_type, fc->ncols, + sizeof (short int)); + fc->col_offset = (int *) xcrealloc (fc->col_offset, fc->ncols, sizeof (int)); + /* PR 17512: file:002-10025-0.005. */ + if (fc->col_type == NULL || fc->col_offset == NULL) + { + error (_("Out of memory allocating %u columns in dwarf frame arrays\n"), + fc->ncols); + fc->ncols = 0; + return -1; + } + + while (prev < fc->ncols) + { + fc->col_type[prev] = DW_CFA_unreferenced; + fc->col_offset[prev] = 0; + prev++; + } + return 1; +} + +static const char *const dwarf_regnames_i386[] = +{ + "eax", "ecx", "edx", "ebx", /* 0 - 3 */ + "esp", "ebp", "esi", "edi", /* 4 - 7 */ + "eip", "eflags", NULL, /* 8 - 10 */ + "st0", "st1", "st2", "st3", /* 11 - 14 */ + "st4", "st5", "st6", "st7", /* 15 - 18 */ + NULL, NULL, /* 19 - 20 */ + "xmm0", "xmm1", "xmm2", "xmm3", /* 21 - 24 */ + "xmm4", "xmm5", "xmm6", "xmm7", /* 25 - 28 */ + "mm0", "mm1", "mm2", "mm3", /* 29 - 32 */ + "mm4", "mm5", "mm6", "mm7", /* 33 - 36 */ + "fcw", "fsw", "mxcsr", /* 37 - 39 */ + "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, /* 40 - 47 */ + "tr", "ldtr", /* 48 - 49 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 50 - 57 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 58 - 65 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 66 - 73 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 74 - 81 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 82 - 89 */ + NULL, NULL, NULL, /* 90 - 92 */ + "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" /* 93 - 100 */ +}; + +static const char *const dwarf_regnames_iamcu[] = +{ + "eax", "ecx", "edx", "ebx", /* 0 - 3 */ + "esp", "ebp", "esi", "edi", /* 4 - 7 */ + "eip", "eflags", NULL, /* 8 - 10 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 11 - 18 */ + NULL, NULL, /* 19 - 20 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 21 - 28 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 29 - 36 */ + NULL, NULL, NULL, /* 37 - 39 */ + "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, /* 40 - 47 */ + "tr", "ldtr", /* 48 - 49 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 50 - 57 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 58 - 65 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 66 - 73 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 74 - 81 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 82 - 89 */ + NULL, NULL, NULL, /* 90 - 92 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL /* 93 - 100 */ +}; + +void +init_dwarf_regnames_i386 (void) +{ + dwarf_regnames = dwarf_regnames_i386; + dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_i386); +} + +void +init_dwarf_regnames_iamcu (void) +{ + dwarf_regnames = dwarf_regnames_iamcu; + dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_iamcu); +} + +static const char *const dwarf_regnames_x86_64[] = +{ + "rax", "rdx", "rcx", "rbx", + "rsi", "rdi", "rbp", "rsp", + "r8", "r9", "r10", "r11", + "r12", "r13", "r14", "r15", + "rip", + "xmm0", "xmm1", "xmm2", "xmm3", + "xmm4", "xmm5", "xmm6", "xmm7", + "xmm8", "xmm9", "xmm10", "xmm11", + "xmm12", "xmm13", "xmm14", "xmm15", + "st0", "st1", "st2", "st3", + "st4", "st5", "st6", "st7", + "mm0", "mm1", "mm2", "mm3", + "mm4", "mm5", "mm6", "mm7", + "rflags", + "es", "cs", "ss", "ds", "fs", "gs", NULL, NULL, + "fs.base", "gs.base", NULL, NULL, + "tr", "ldtr", + "mxcsr", "fcw", "fsw", + "xmm16", "xmm17", "xmm18", "xmm19", + "xmm20", "xmm21", "xmm22", "xmm23", + "xmm24", "xmm25", "xmm26", "xmm27", + "xmm28", "xmm29", "xmm30", "xmm31", + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 83 - 90 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 91 - 98 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 99 - 106 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 107 - 114 */ + NULL, NULL, NULL, /* 115 - 117 */ + "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" +}; + +void +init_dwarf_regnames_x86_64 (void) +{ + dwarf_regnames = dwarf_regnames_x86_64; + dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64); +} + +static const char *const dwarf_regnames_aarch64[] = +{ + "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", + "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", + "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23", + "x24", "x25", "x26", "x27", "x28", "x29", "x30", "sp", + NULL, "elr", NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", + "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", + "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", + "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", +}; + +void +init_dwarf_regnames_aarch64 (void) +{ + dwarf_regnames = dwarf_regnames_aarch64; + dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_aarch64); +} + +static const char *const dwarf_regnames_s390[] = +{ + /* Avoid saying "r5 (r5)", so omit the names of r0-r15. */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + "f0", "f2", "f4", "f6", "f1", "f3", "f5", "f7", + "f8", "f10", "f12", "f14", "f9", "f11", "f13", "f15", + "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", + "cr8", "cr9", "cr10", "cr11", "cr12", "cr13", "cr14", "cr15", + "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", + "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15", + "pswm", "pswa", + NULL, NULL, + "v16", "v18", "v20", "v22", "v17", "v19", "v21", "v23", + "v24", "v26", "v28", "v30", "v25", "v27", "v29", "v31", +}; + +void +init_dwarf_regnames_s390 (void) +{ + dwarf_regnames = dwarf_regnames_s390; + dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_s390); +} + +void +init_dwarf_regnames (unsigned int e_machine) +{ + switch (e_machine) + { + case EM_386: + init_dwarf_regnames_i386 (); + break; + + case EM_IAMCU: + init_dwarf_regnames_iamcu (); + break; + + case EM_X86_64: + case EM_L1OM: + case EM_K1OM: + init_dwarf_regnames_x86_64 (); + break; + + case EM_AARCH64: + init_dwarf_regnames_aarch64 (); + break; + + case EM_S390: + init_dwarf_regnames_s390 (); + break; + + default: + break; + } +} + +static const char * +regname (unsigned int regno, int row) +{ + static char reg[64]; + + if (dwarf_regnames + && regno < dwarf_regnames_count + && dwarf_regnames [regno] != NULL) + { + if (row) + return dwarf_regnames [regno]; + snprintf (reg, sizeof (reg), "r%d (%s)", regno, + dwarf_regnames [regno]); + } + else + snprintf (reg, sizeof (reg), "r%d", regno); + return reg; +} + +static void +frame_display_row (Frame_Chunk *fc, int *need_col_headers, unsigned int *max_regs) +{ + unsigned int r; + char tmp[100]; + + if (*max_regs != fc->ncols) + *max_regs = fc->ncols; + + if (*need_col_headers) + { + static const char *sloc = " LOC"; + + *need_col_headers = 0; + + printf ("%-*s CFA ", eh_addr_size * 2, sloc); + + for (r = 0; r < *max_regs; r++) + if (fc->col_type[r] != DW_CFA_unreferenced) + { + if (r == fc->ra) + printf ("ra "); + else + printf ("%-5s ", regname (r, 1)); + } + + printf ("\n"); + } + + print_dwarf_vma (fc->pc_begin, eh_addr_size); + if (fc->cfa_exp) + strcpy (tmp, "exp"); + else + sprintf (tmp, "%s%+d", regname (fc->cfa_reg, 1), (int) fc->cfa_offset); + printf ("%-8s ", tmp); + + for (r = 0; r < fc->ncols; r++) + { + if (fc->col_type[r] != DW_CFA_unreferenced) + { + switch (fc->col_type[r]) + { + case DW_CFA_undefined: + strcpy (tmp, "u"); + break; + case DW_CFA_same_value: + strcpy (tmp, "s"); + break; + case DW_CFA_offset: + sprintf (tmp, "c%+d", fc->col_offset[r]); + break; + case DW_CFA_val_offset: + sprintf (tmp, "v%+d", fc->col_offset[r]); + break; + case DW_CFA_register: + sprintf (tmp, "%s", regname (fc->col_offset[r], 0)); + break; + case DW_CFA_expression: + strcpy (tmp, "exp"); + break; + case DW_CFA_val_expression: + strcpy (tmp, "vexp"); + break; + default: + strcpy (tmp, "n/a"); + break; + } + printf ("%-5s ", tmp); + } + } + printf ("\n"); +} + +#define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end) + +static unsigned char * +read_cie (unsigned char *start, unsigned char *end, + Frame_Chunk **p_cie, int *p_version, + bfd_size_type *p_aug_len, unsigned char **p_aug) +{ + int version; + Frame_Chunk *fc; + unsigned int length_return; + unsigned char *augmentation_data = NULL; + bfd_size_type augmentation_data_len = 0; + + * p_cie = NULL; + /* PR 17512: file: 001-228113-0.004. */ + if (start >= end) + return end; + + fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); + memset (fc, 0, sizeof (Frame_Chunk)); + + fc->col_type = (short int *) xmalloc (sizeof (short int)); + fc->col_offset = (int *) xmalloc (sizeof (int)); + + version = *start++; + + fc->augmentation = (char *) start; + /* PR 17512: file: 001-228113-0.004. + Skip past augmentation name, but avoid running off the end of the data. */ + while (start < end) + if (* start ++ == '\0') + break; + if (start == end) + { + warn (_("No terminator for augmentation name\n")); + return start; + } + + if (strcmp (fc->augmentation, "eh") == 0) + start += eh_addr_size; + + if (version >= 4) + { + GET (fc->ptr_size, 1); + if (fc->ptr_size < 1 || fc->ptr_size > 8) + { + warn (_("Invalid pointer size (%d) in CIE data\n"), fc->ptr_size); + return end; + } + + GET (fc->segment_size, 1); + /* PR 17512: file: e99d2804. */ + if (fc->segment_size > 8 || fc->segment_size + fc->ptr_size > 8) + { + warn (_("Invalid segment size (%d) in CIE data\n"), fc->segment_size); + return end; + } + + eh_addr_size = fc->ptr_size; + } + else + { + fc->ptr_size = eh_addr_size; + fc->segment_size = 0; + } + READ_ULEB (fc->code_factor); + READ_SLEB (fc->data_factor); + if (version == 1) + { + GET (fc->ra, 1); + } + else + { + READ_ULEB (fc->ra); + } + + if (fc->augmentation[0] == 'z') + { + READ_ULEB (augmentation_data_len); + augmentation_data = start; + /* PR 17512: file: 11042-2589-0.004. */ + if (augmentation_data_len > (bfd_size_type) (end - start)) + { + warn (_("Augmentation data too long: 0x%s, expected at most %#lx\n"), + dwarf_vmatoa ("x", augmentation_data_len), + (unsigned long) (end - start)); + return end; + } + start += augmentation_data_len; + } + + if (augmentation_data_len) + { + unsigned char *p; + unsigned char *q; + unsigned char *qend; + + p = (unsigned char *) fc->augmentation + 1; + q = augmentation_data; + qend = q + augmentation_data_len; + + while (p < end && q < qend) + { + if (*p == 'L') + q++; + else if (*p == 'P') + q += 1 + size_of_encoded_value (*q); + else if (*p == 'R') + fc->fde_encoding = *q++; + else if (*p == 'S') + ; + else + break; + p++; + } + /* Note - it is OK if this loop terminates with q < qend. + Padding may have been inserted to align the end of the CIE. */ + } + + *p_cie = fc; + if (p_version) + *p_version = version; + if (p_aug_len) + { + *p_aug_len = augmentation_data_len; + *p_aug = augmentation_data; + } + return start; +} + +/* Prints out the contents on the DATA array formatted as unsigned bytes. + If do_wide is not enabled, then formats the output to fit into 80 columns. + PRINTED contains the number of characters already written to the current + output line. */ + +static void +display_data (bfd_size_type printed, + const unsigned char * data, + const bfd_size_type len) +{ + if (do_wide || len < ((80 - printed) / 3)) + for (printed = 0; printed < len; ++printed) + printf (" %02x", data[printed]); + else + { + for (printed = 0; printed < len; ++printed) + { + if (printed % (80 / 3) == 0) + putchar ('\n'); + printf (" %02x", data[printed]); + } + } +} + +/* Prints out the contents on the augmentation data array. + If do_wide is not enabled, then formats the output to fit into 80 columns. */ + +static void +display_augmentation_data (const unsigned char * data, const bfd_size_type len) +{ + bfd_size_type i; + + i = printf (_(" Augmentation data: ")); + display_data (i, data, len); +} + +static int +display_debug_frames (struct dwarf_section *section, + void *file ATTRIBUTE_UNUSED) +{ + unsigned char *start = section->start; + unsigned char *end = start + section->size; + unsigned char *section_start = start; + Frame_Chunk *chunks = 0, *forward_refs = 0; + Frame_Chunk *remembered_state = 0; + Frame_Chunk *rs; + int is_eh = strcmp (section->name, ".eh_frame") == 0; + unsigned int length_return; + unsigned int max_regs = 0; + const char *bad_reg = _("bad register: "); + unsigned int saved_eh_addr_size = eh_addr_size; + + introduce (section, FALSE); + + while (start < end) + { + unsigned char *saved_start; + unsigned char *block_end; + dwarf_vma length; + dwarf_vma cie_id; + Frame_Chunk *fc; + Frame_Chunk *cie; + int need_col_headers = 1; + unsigned char *augmentation_data = NULL; + bfd_size_type augmentation_data_len = 0; + unsigned int encoded_ptr_size = saved_eh_addr_size; + unsigned int offset_size; + unsigned int initial_length_size; + bfd_boolean all_nops; + + saved_start = start; + + SAFE_BYTE_GET_AND_INC (length, start, 4, end); + + if (length == 0) + { + printf ("\n%08lx ZERO terminator\n\n", + (unsigned long)(saved_start - section_start)); + /* Skip any zero terminators that directly follow. + A corrupt section size could have loaded a whole + slew of zero filled memory bytes. eg + PR 17512: file: 070-19381-0.004. */ + while (start < end && * start == 0) + ++ start; + continue; + } + + if (length == 0xffffffff) + { + SAFE_BYTE_GET_AND_INC (length, start, 8, end); + offset_size = 8; + initial_length_size = 12; + } + else + { + offset_size = 4; + initial_length_size = 4; + } + + block_end = saved_start + length + initial_length_size; + if (block_end > end || block_end < start) + { + warn ("Invalid length 0x%s in FDE at %#08lx\n", + dwarf_vmatoa_1 (NULL, length, offset_size), + (unsigned long) (saved_start - section_start)); + block_end = end; + } + + SAFE_BYTE_GET_AND_INC (cie_id, start, offset_size, end); + + if (is_eh ? (cie_id == 0) : ((offset_size == 4 && cie_id == DW_CIE_ID) + || (offset_size == 8 && cie_id == DW64_CIE_ID))) + { + int version; + unsigned int mreg; + + start = read_cie (start, end, &cie, &version, + &augmentation_data_len, &augmentation_data); + /* PR 17512: file: 027-135133-0.005. */ + if (cie == NULL) + break; + + fc = cie; + fc->next = chunks; + chunks = fc; + fc->chunk_start = saved_start; + mreg = max_regs > 0 ? max_regs - 1 : 0; + if (mreg < fc->ra) + mreg = fc->ra; + if (frame_need_space (fc, mreg) < 0) + break; + if (fc->fde_encoding) + encoded_ptr_size = size_of_encoded_value (fc->fde_encoding); + + printf ("\n%08lx ", (unsigned long) (saved_start - section_start)); + print_dwarf_vma (length, fc->ptr_size); + print_dwarf_vma (cie_id, offset_size); + + if (do_debug_frames_interp) + { + printf ("CIE \"%s\" cf=%d df=%d ra=%d\n", fc->augmentation, + fc->code_factor, fc->data_factor, fc->ra); + } + else + { + printf ("CIE\n"); + printf (" Version: %d\n", version); + printf (" Augmentation: \"%s\"\n", fc->augmentation); + if (version >= 4) + { + printf (" Pointer Size: %u\n", fc->ptr_size); + printf (" Segment Size: %u\n", fc->segment_size); + } + printf (" Code alignment factor: %u\n", fc->code_factor); + printf (" Data alignment factor: %d\n", fc->data_factor); + printf (" Return address column: %d\n", fc->ra); + + if (augmentation_data_len) + display_augmentation_data (augmentation_data, augmentation_data_len); + + putchar ('\n'); + } + } + else + { + unsigned char *look_for; + static Frame_Chunk fde_fc; + unsigned long segment_selector; + + if (is_eh) + { + dwarf_vma sign = (dwarf_vma) 1 << (offset_size * 8 - 1); + look_for = start - 4 - ((cie_id ^ sign) - sign); + } + else + look_for = section_start + cie_id; + + if (look_for <= saved_start) + { + for (cie = chunks; cie ; cie = cie->next) + if (cie->chunk_start == look_for) + break; + } + else + { + for (cie = forward_refs; cie ; cie = cie->next) + if (cie->chunk_start == look_for) + break; + if (!cie) + { + unsigned int off_size; + unsigned char *cie_scan; + + cie_scan = look_for; + off_size = 4; + SAFE_BYTE_GET_AND_INC (length, cie_scan, 4, end); + if (length == 0xffffffff) + { + SAFE_BYTE_GET_AND_INC (length, cie_scan, 8, end); + off_size = 8; + } + if (length != 0) + { + dwarf_vma c_id; + + SAFE_BYTE_GET_AND_INC (c_id, cie_scan, off_size, end); + if (is_eh + ? c_id == 0 + : ((off_size == 4 && c_id == DW_CIE_ID) + || (off_size == 8 && c_id == DW64_CIE_ID))) + { + int version; + unsigned int mreg; + + read_cie (cie_scan, end, &cie, &version, + &augmentation_data_len, &augmentation_data); + /* PR 17512: file: 3450-2098-0.004. */ + if (cie == NULL) + { + warn (_("Failed to read CIE information\n")); + break; + } + cie->next = forward_refs; + forward_refs = cie; + cie->chunk_start = look_for; + mreg = max_regs > 0 ? max_regs - 1 : 0; + if (mreg < cie->ra) + mreg = cie->ra; + if (frame_need_space (cie, mreg) < 0) + { + warn (_("Invalid max register\n")); + break; + } + if (cie->fde_encoding) + encoded_ptr_size + = size_of_encoded_value (cie->fde_encoding); + } + } + } + } + + fc = &fde_fc; + memset (fc, 0, sizeof (Frame_Chunk)); + + if (!cie) + { + warn ("Invalid CIE pointer 0x%s in FDE at %#08lx\n", + dwarf_vmatoa_1 (NULL, cie_id, offset_size), + (unsigned long) (saved_start - section_start)); + fc->ncols = 0; + fc->col_type = (short int *) xmalloc (sizeof (short int)); + fc->col_offset = (int *) xmalloc (sizeof (int)); + if (frame_need_space (fc, max_regs > 0 ? max_regs - 1 : 0) < 0) + { + warn (_("Invalid max register\n")); + break; + } + cie = fc; + fc->augmentation = ""; + fc->fde_encoding = 0; + fc->ptr_size = eh_addr_size; + fc->segment_size = 0; + } + else + { + fc->ncols = cie->ncols; + fc->col_type = (short int *) xcmalloc (fc->ncols, sizeof (short int)); + fc->col_offset = (int *) xcmalloc (fc->ncols, sizeof (int)); + memcpy (fc->col_type, cie->col_type, fc->ncols * sizeof (short int)); + memcpy (fc->col_offset, cie->col_offset, fc->ncols * sizeof (int)); + fc->augmentation = cie->augmentation; + fc->ptr_size = cie->ptr_size; + eh_addr_size = cie->ptr_size; + fc->segment_size = cie->segment_size; + fc->code_factor = cie->code_factor; + fc->data_factor = cie->data_factor; + fc->cfa_reg = cie->cfa_reg; + fc->cfa_offset = cie->cfa_offset; + fc->ra = cie->ra; + if (frame_need_space (fc, max_regs > 0 ? max_regs - 1: 0) < 0) + { + warn (_("Invalid max register\n")); + break; + } + fc->fde_encoding = cie->fde_encoding; + } + + if (fc->fde_encoding) + encoded_ptr_size = size_of_encoded_value (fc->fde_encoding); + + segment_selector = 0; + if (fc->segment_size) + { + if (fc->segment_size > sizeof (segment_selector)) + { + /* PR 17512: file: 9e196b3e. */ + warn (_("Probably corrupt segment size: %d - using 4 instead\n"), fc->segment_size); + fc->segment_size = 4; + } + SAFE_BYTE_GET_AND_INC (segment_selector, start, fc->segment_size, end); + } + + fc->pc_begin = get_encoded_value (&start, fc->fde_encoding, section, end); + + /* FIXME: It appears that sometimes the final pc_range value is + encoded in less than encoded_ptr_size bytes. See the x86_64 + run of the "objcopy on compressed debug sections" test for an + example of this. */ + SAFE_BYTE_GET_AND_INC (fc->pc_range, start, encoded_ptr_size, end); + + if (cie->augmentation[0] == 'z') + { + READ_ULEB (augmentation_data_len); + augmentation_data = start; + start += augmentation_data_len; + /* PR 17512 file: 722-8446-0.004 and PR 22386. */ + if (start >= end + || ((bfd_signed_vma) augmentation_data_len) < 0 + || augmentation_data > start) + { + warn (_("Corrupt augmentation data length: 0x%s\n"), + dwarf_vmatoa ("x", augmentation_data_len)); + start = end; + augmentation_data = NULL; + augmentation_data_len = 0; + } + } + + printf ("\n%08lx %s %s FDE cie=%08lx pc=", + (unsigned long)(saved_start - section_start), + dwarf_vmatoa_1 (NULL, length, fc->ptr_size), + dwarf_vmatoa_1 (NULL, cie_id, offset_size), + (unsigned long)(cie->chunk_start - section_start)); + + if (fc->segment_size) + printf ("%04lx:", segment_selector); + + printf ("%s..%s\n", + dwarf_vmatoa_1 (NULL, fc->pc_begin, fc->ptr_size), + dwarf_vmatoa_1 (NULL, fc->pc_begin + fc->pc_range, fc->ptr_size)); + + if (! do_debug_frames_interp && augmentation_data_len) + { + display_augmentation_data (augmentation_data, augmentation_data_len); + putchar ('\n'); + } + } + + /* At this point, fc is the current chunk, cie (if any) is set, and + we're about to interpret instructions for the chunk. */ + /* ??? At present we need to do this always, since this sizes the + fc->col_type and fc->col_offset arrays, which we write into always. + We should probably split the interpreted and non-interpreted bits + into two different routines, since there's so much that doesn't + really overlap between them. */ + if (1 || do_debug_frames_interp) + { + /* Start by making a pass over the chunk, allocating storage + and taking note of what registers are used. */ + unsigned char *tmp = start; + + while (start < block_end) + { + unsigned int reg, op, opa; + unsigned long temp; + unsigned char * new_start; + + op = *start++; + opa = op & 0x3f; + if (op & 0xc0) + op &= 0xc0; + + /* Warning: if you add any more cases to this switch, be + sure to add them to the corresponding switch below. */ + switch (op) + { + case DW_CFA_advance_loc: + break; + case DW_CFA_offset: + SKIP_ULEB (); + if (frame_need_space (fc, opa) >= 0) + fc->col_type[opa] = DW_CFA_undefined; + break; + case DW_CFA_restore: + if (frame_need_space (fc, opa) >= 0) + fc->col_type[opa] = DW_CFA_undefined; + break; + case DW_CFA_set_loc: + start += encoded_ptr_size; + break; + case DW_CFA_advance_loc1: + start += 1; + break; + case DW_CFA_advance_loc2: + start += 2; + break; + case DW_CFA_advance_loc4: + start += 4; + break; + case DW_CFA_offset_extended: + case DW_CFA_val_offset: + READ_ULEB (reg); + SKIP_ULEB (); + if (frame_need_space (fc, reg) >= 0) + fc->col_type[reg] = DW_CFA_undefined; + break; + case DW_CFA_restore_extended: + READ_ULEB (reg); + if (frame_need_space (fc, reg) >= 0) + fc->col_type[reg] = DW_CFA_undefined; + break; + case DW_CFA_undefined: + READ_ULEB (reg); + if (frame_need_space (fc, reg) >= 0) + fc->col_type[reg] = DW_CFA_undefined; + break; + case DW_CFA_same_value: + READ_ULEB (reg); + if (frame_need_space (fc, reg) >= 0) + fc->col_type[reg] = DW_CFA_undefined; + break; + case DW_CFA_register: + READ_ULEB (reg); + SKIP_ULEB (); + if (frame_need_space (fc, reg) >= 0) + fc->col_type[reg] = DW_CFA_undefined; + break; + case DW_CFA_def_cfa: + SKIP_ULEB (); + SKIP_ULEB (); + break; + case DW_CFA_def_cfa_register: + SKIP_ULEB (); + break; + case DW_CFA_def_cfa_offset: + SKIP_ULEB (); + break; + case DW_CFA_def_cfa_expression: + READ_ULEB (temp); + new_start = start + temp; + if (new_start < start) + { + warn (_("Corrupt CFA_def expression value: %lu\n"), temp); + start = block_end; + } + else + start = new_start; + break; + case DW_CFA_expression: + case DW_CFA_val_expression: + READ_ULEB (reg); + READ_ULEB (temp); + new_start = start + temp; + if (new_start < start) + { + /* PR 17512: file:306-192417-0.005. */ + warn (_("Corrupt CFA expression value: %lu\n"), temp); + start = block_end; + } + else + start = new_start; + if (frame_need_space (fc, reg) >= 0) + fc->col_type[reg] = DW_CFA_undefined; + break; + case DW_CFA_offset_extended_sf: + case DW_CFA_val_offset_sf: + READ_ULEB (reg); + SKIP_SLEB (); + if (frame_need_space (fc, reg) >= 0) + fc->col_type[reg] = DW_CFA_undefined; + break; + case DW_CFA_def_cfa_sf: + SKIP_ULEB (); + SKIP_SLEB (); + break; + case DW_CFA_def_cfa_offset_sf: + SKIP_SLEB (); + break; + case DW_CFA_MIPS_advance_loc8: + start += 8; + break; + case DW_CFA_GNU_args_size: + SKIP_ULEB (); + break; + case DW_CFA_GNU_negative_offset_extended: + READ_ULEB (reg); + SKIP_ULEB (); + if (frame_need_space (fc, reg) >= 0) + fc->col_type[reg] = DW_CFA_undefined; + break; + default: + break; + } + } + start = tmp; + } + + all_nops = TRUE; + + /* Now we know what registers are used, make a second pass over + the chunk, this time actually printing out the info. */ + + while (start < block_end) + { + unsigned char * tmp; + unsigned op, opa; + unsigned long ul, roffs; + /* Note: It is tempting to use an unsigned long for 'reg' but there + are various functions, notably frame_space_needed() that assume that + reg is an unsigned int. */ + unsigned int reg; + dwarf_signed_vma l; + dwarf_vma ofs; + dwarf_vma vma; + const char *reg_prefix = ""; + + op = *start++; + opa = op & 0x3f; + if (op & 0xc0) + op &= 0xc0; + + /* Make a note if something other than DW_CFA_nop happens. */ + if (op != DW_CFA_nop) + all_nops = FALSE; + + /* Warning: if you add any more cases to this switch, be + sure to add them to the corresponding switch above. */ + switch (op) + { + case DW_CFA_advance_loc: + if (do_debug_frames_interp) + frame_display_row (fc, &need_col_headers, &max_regs); + else + printf (" DW_CFA_advance_loc: %d to %s\n", + opa * fc->code_factor, + dwarf_vmatoa_1 (NULL, + fc->pc_begin + opa * fc->code_factor, + fc->ptr_size)); + fc->pc_begin += opa * fc->code_factor; + break; + + case DW_CFA_offset: + READ_ULEB (roffs); + if (opa >= (unsigned int) fc->ncols) + reg_prefix = bad_reg; + if (! do_debug_frames_interp || *reg_prefix != '\0') + printf (" DW_CFA_offset: %s%s at cfa%+ld\n", + reg_prefix, regname (opa, 0), + roffs * fc->data_factor); + if (*reg_prefix == '\0') + { + fc->col_type[opa] = DW_CFA_offset; + fc->col_offset[opa] = roffs * fc->data_factor; + } + break; + + case DW_CFA_restore: + if (opa >= (unsigned int) fc->ncols) + reg_prefix = bad_reg; + if (! do_debug_frames_interp || *reg_prefix != '\0') + printf (" DW_CFA_restore: %s%s\n", + reg_prefix, regname (opa, 0)); + if (*reg_prefix != '\0') + break; + + if (opa >= (unsigned int) cie->ncols + || (do_debug_frames_interp + && cie->col_type[opa] == DW_CFA_unreferenced)) + { + fc->col_type[opa] = DW_CFA_undefined; + fc->col_offset[opa] = 0; + } + else + { + fc->col_type[opa] = cie->col_type[opa]; + fc->col_offset[opa] = cie->col_offset[opa]; + } + break; + + case DW_CFA_set_loc: + vma = get_encoded_value (&start, fc->fde_encoding, section, block_end); + if (do_debug_frames_interp) + frame_display_row (fc, &need_col_headers, &max_regs); + else + printf (" DW_CFA_set_loc: %s\n", + dwarf_vmatoa_1 (NULL, vma, fc->ptr_size)); + fc->pc_begin = vma; + break; + + case DW_CFA_advance_loc1: + SAFE_BYTE_GET_AND_INC (ofs, start, 1, end); + if (do_debug_frames_interp) + frame_display_row (fc, &need_col_headers, &max_regs); + else + printf (" DW_CFA_advance_loc1: %ld to %s\n", + (unsigned long) (ofs * fc->code_factor), + dwarf_vmatoa_1 (NULL, + fc->pc_begin + ofs * fc->code_factor, + fc->ptr_size)); + fc->pc_begin += ofs * fc->code_factor; + break; + + case DW_CFA_advance_loc2: + SAFE_BYTE_GET_AND_INC (ofs, start, 2, block_end); + if (do_debug_frames_interp) + frame_display_row (fc, &need_col_headers, &max_regs); + else + printf (" DW_CFA_advance_loc2: %ld to %s\n", + (unsigned long) (ofs * fc->code_factor), + dwarf_vmatoa_1 (NULL, + fc->pc_begin + ofs * fc->code_factor, + fc->ptr_size)); + fc->pc_begin += ofs * fc->code_factor; + break; + + case DW_CFA_advance_loc4: + SAFE_BYTE_GET_AND_INC (ofs, start, 4, block_end); + if (do_debug_frames_interp) + frame_display_row (fc, &need_col_headers, &max_regs); + else + printf (" DW_CFA_advance_loc4: %ld to %s\n", + (unsigned long) (ofs * fc->code_factor), + dwarf_vmatoa_1 (NULL, + fc->pc_begin + ofs * fc->code_factor, + fc->ptr_size)); + fc->pc_begin += ofs * fc->code_factor; + break; + + case DW_CFA_offset_extended: + READ_ULEB (reg); + READ_ULEB (roffs); + if (reg >= (unsigned int) fc->ncols) + reg_prefix = bad_reg; + if (! do_debug_frames_interp || *reg_prefix != '\0') + printf (" DW_CFA_offset_extended: %s%s at cfa%+ld\n", + reg_prefix, regname (reg, 0), + roffs * fc->data_factor); + if (*reg_prefix == '\0') + { + fc->col_type[reg] = DW_CFA_offset; + fc->col_offset[reg] = roffs * fc->data_factor; + } + break; + + case DW_CFA_val_offset: + READ_ULEB (reg); + READ_ULEB (roffs); + if (reg >= (unsigned int) fc->ncols) + reg_prefix = bad_reg; + if (! do_debug_frames_interp || *reg_prefix != '\0') + printf (" DW_CFA_val_offset: %s%s is cfa%+ld\n", + reg_prefix, regname (reg, 0), + roffs * fc->data_factor); + if (*reg_prefix == '\0') + { + fc->col_type[reg] = DW_CFA_val_offset; + fc->col_offset[reg] = roffs * fc->data_factor; + } + break; + + case DW_CFA_restore_extended: + READ_ULEB (reg); + if (reg >= (unsigned int) fc->ncols) + reg_prefix = bad_reg; + if (! do_debug_frames_interp || *reg_prefix != '\0') + printf (" DW_CFA_restore_extended: %s%s\n", + reg_prefix, regname (reg, 0)); + if (*reg_prefix != '\0') + break; + + if (reg >= (unsigned int) cie->ncols) + { + fc->col_type[reg] = DW_CFA_undefined; + fc->col_offset[reg] = 0; + } + else + { + fc->col_type[reg] = cie->col_type[reg]; + fc->col_offset[reg] = cie->col_offset[reg]; + } + break; + + case DW_CFA_undefined: + READ_ULEB (reg); + if (reg >= (unsigned int) fc->ncols) + reg_prefix = bad_reg; + if (! do_debug_frames_interp || *reg_prefix != '\0') + printf (" DW_CFA_undefined: %s%s\n", + reg_prefix, regname (reg, 0)); + if (*reg_prefix == '\0') + { + fc->col_type[reg] = DW_CFA_undefined; + fc->col_offset[reg] = 0; + } + break; + + case DW_CFA_same_value: + READ_ULEB (reg); + if (reg >= (unsigned int) fc->ncols) + reg_prefix = bad_reg; + if (! do_debug_frames_interp || *reg_prefix != '\0') + printf (" DW_CFA_same_value: %s%s\n", + reg_prefix, regname (reg, 0)); + if (*reg_prefix == '\0') + { + fc->col_type[reg] = DW_CFA_same_value; + fc->col_offset[reg] = 0; + } + break; + + case DW_CFA_register: + READ_ULEB (reg); + READ_ULEB (roffs); + if (reg >= (unsigned int) fc->ncols) + reg_prefix = bad_reg; + if (! do_debug_frames_interp || *reg_prefix != '\0') + { + printf (" DW_CFA_register: %s%s in ", + reg_prefix, regname (reg, 0)); + puts (regname (roffs, 0)); + } + if (*reg_prefix == '\0') + { + fc->col_type[reg] = DW_CFA_register; + fc->col_offset[reg] = roffs; + } + break; + + case DW_CFA_remember_state: + if (! do_debug_frames_interp) + printf (" DW_CFA_remember_state\n"); + rs = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); + rs->cfa_offset = fc->cfa_offset; + rs->cfa_reg = fc->cfa_reg; + rs->ra = fc->ra; + rs->cfa_exp = fc->cfa_exp; + rs->ncols = fc->ncols; + rs->col_type = (short int *) xcmalloc (rs->ncols, + sizeof (* rs->col_type)); + rs->col_offset = (int *) xcmalloc (rs->ncols, sizeof (* rs->col_offset)); + memcpy (rs->col_type, fc->col_type, rs->ncols * sizeof (* fc->col_type)); + memcpy (rs->col_offset, fc->col_offset, rs->ncols * sizeof (* fc->col_offset)); + rs->next = remembered_state; + remembered_state = rs; + break; + + case DW_CFA_restore_state: + if (! do_debug_frames_interp) + printf (" DW_CFA_restore_state\n"); + rs = remembered_state; + if (rs) + { + remembered_state = rs->next; + fc->cfa_offset = rs->cfa_offset; + fc->cfa_reg = rs->cfa_reg; + fc->ra = rs->ra; + fc->cfa_exp = rs->cfa_exp; + if (frame_need_space (fc, rs->ncols - 1) < 0) + { + warn (_("Invalid column number in saved frame state\n")); + fc->ncols = 0; + break; + } + memcpy (fc->col_type, rs->col_type, rs->ncols * sizeof (* rs->col_type)); + memcpy (fc->col_offset, rs->col_offset, + rs->ncols * sizeof (* rs->col_offset)); + free (rs->col_type); + free (rs->col_offset); + free (rs); + } + else if (do_debug_frames_interp) + printf ("Mismatched DW_CFA_restore_state\n"); + break; + + case DW_CFA_def_cfa: + READ_ULEB (fc->cfa_reg); + READ_ULEB (fc->cfa_offset); + fc->cfa_exp = 0; + if (! do_debug_frames_interp) + printf (" DW_CFA_def_cfa: %s ofs %d\n", + regname (fc->cfa_reg, 0), (int) fc->cfa_offset); + break; + + case DW_CFA_def_cfa_register: + READ_ULEB (fc->cfa_reg); + fc->cfa_exp = 0; + if (! do_debug_frames_interp) + printf (" DW_CFA_def_cfa_register: %s\n", + regname (fc->cfa_reg, 0)); + break; + + case DW_CFA_def_cfa_offset: + READ_ULEB (fc->cfa_offset); + if (! do_debug_frames_interp) + printf (" DW_CFA_def_cfa_offset: %d\n", (int) fc->cfa_offset); + break; + + case DW_CFA_nop: + if (! do_debug_frames_interp) + printf (" DW_CFA_nop\n"); + break; + + case DW_CFA_def_cfa_expression: + READ_ULEB (ul); + if (start >= block_end || ul > (unsigned long) (block_end - start)) + { + printf (_(" DW_CFA_def_cfa_expression: \n"), ul); + break; + } + if (! do_debug_frames_interp) + { + printf (" DW_CFA_def_cfa_expression ("); + decode_location_expression (start, eh_addr_size, 0, -1, + ul, 0, section); + printf (")\n"); + } + fc->cfa_exp = 1; + start += ul; + break; + + case DW_CFA_expression: + READ_ULEB (reg); + READ_ULEB (ul); + if (reg >= (unsigned int) fc->ncols) + reg_prefix = bad_reg; + /* PR 17512: file: 069-133014-0.006. */ + /* PR 17512: file: 98c02eb4. */ + tmp = start + ul; + if (start >= block_end || tmp > block_end || tmp < start) + { + printf (_(" DW_CFA_expression: \n"), ul); + break; + } + if (! do_debug_frames_interp || *reg_prefix != '\0') + { + printf (" DW_CFA_expression: %s%s (", + reg_prefix, regname (reg, 0)); + decode_location_expression (start, eh_addr_size, 0, -1, + ul, 0, section); + printf (")\n"); + } + if (*reg_prefix == '\0') + fc->col_type[reg] = DW_CFA_expression; + start = tmp; + break; + + case DW_CFA_val_expression: + READ_ULEB (reg); + READ_ULEB (ul); + if (reg >= (unsigned int) fc->ncols) + reg_prefix = bad_reg; + tmp = start + ul; + if (start >= block_end || tmp > block_end || tmp < start) + { + printf (" DW_CFA_val_expression: \n", ul); + break; + } + if (! do_debug_frames_interp || *reg_prefix != '\0') + { + printf (" DW_CFA_val_expression: %s%s (", + reg_prefix, regname (reg, 0)); + decode_location_expression (start, eh_addr_size, 0, -1, + ul, 0, section); + printf (")\n"); + } + if (*reg_prefix == '\0') + fc->col_type[reg] = DW_CFA_val_expression; + start = tmp; + break; + + case DW_CFA_offset_extended_sf: + READ_ULEB (reg); + READ_SLEB (l); + if (frame_need_space (fc, reg) < 0) + reg_prefix = bad_reg; + if (! do_debug_frames_interp || *reg_prefix != '\0') + printf (" DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n", + reg_prefix, regname (reg, 0), + (long)(l * fc->data_factor)); + if (*reg_prefix == '\0') + { + fc->col_type[reg] = DW_CFA_offset; + fc->col_offset[reg] = l * fc->data_factor; + } + break; + + case DW_CFA_val_offset_sf: + READ_ULEB (reg); + READ_SLEB (l); + if (frame_need_space (fc, reg) < 0) + reg_prefix = bad_reg; + if (! do_debug_frames_interp || *reg_prefix != '\0') + printf (" DW_CFA_val_offset_sf: %s%s is cfa%+ld\n", + reg_prefix, regname (reg, 0), + (long)(l * fc->data_factor)); + if (*reg_prefix == '\0') + { + fc->col_type[reg] = DW_CFA_val_offset; + fc->col_offset[reg] = l * fc->data_factor; + } + break; + + case DW_CFA_def_cfa_sf: + READ_ULEB (fc->cfa_reg); + READ_ULEB (fc->cfa_offset); + fc->cfa_offset = fc->cfa_offset * fc->data_factor; + fc->cfa_exp = 0; + if (! do_debug_frames_interp) + printf (" DW_CFA_def_cfa_sf: %s ofs %d\n", + regname (fc->cfa_reg, 0), (int) fc->cfa_offset); + break; + + case DW_CFA_def_cfa_offset_sf: + READ_ULEB (fc->cfa_offset); + fc->cfa_offset *= fc->data_factor; + if (! do_debug_frames_interp) + printf (" DW_CFA_def_cfa_offset_sf: %d\n", (int) fc->cfa_offset); + break; + + case DW_CFA_MIPS_advance_loc8: + SAFE_BYTE_GET_AND_INC (ofs, start, 8, block_end); + if (do_debug_frames_interp) + frame_display_row (fc, &need_col_headers, &max_regs); + else + printf (" DW_CFA_MIPS_advance_loc8: %ld to %s\n", + (unsigned long) (ofs * fc->code_factor), + dwarf_vmatoa_1 (NULL, + fc->pc_begin + ofs * fc->code_factor, + fc->ptr_size)); + fc->pc_begin += ofs * fc->code_factor; + break; + + case DW_CFA_GNU_window_save: + if (! do_debug_frames_interp) + printf (" DW_CFA_GNU_window_save\n"); + break; + + case DW_CFA_GNU_args_size: + READ_ULEB (ul); + if (! do_debug_frames_interp) + printf (" DW_CFA_GNU_args_size: %ld\n", ul); + break; + + case DW_CFA_GNU_negative_offset_extended: + READ_ULEB (reg); + READ_SLEB (l); + l = - l; + if (frame_need_space (fc, reg) < 0) + reg_prefix = bad_reg; + if (! do_debug_frames_interp || *reg_prefix != '\0') + printf (" DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n", + reg_prefix, regname (reg, 0), + (long)(l * fc->data_factor)); + if (*reg_prefix == '\0') + { + fc->col_type[reg] = DW_CFA_offset; + fc->col_offset[reg] = l * fc->data_factor; + } + break; + + default: + if (op >= DW_CFA_lo_user && op <= DW_CFA_hi_user) + printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op); + else + warn (_("Unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op); + start = block_end; + } + } + + /* Interpret the CFA - as long as it is not completely full of NOPs. */ + if (do_debug_frames_interp && ! all_nops) + frame_display_row (fc, &need_col_headers, &max_regs); + + start = block_end; + eh_addr_size = saved_eh_addr_size; + } + + printf ("\n"); + + return 1; +} + +#undef GET + +static int +display_debug_names (struct dwarf_section *section, void *file) +{ + unsigned char *hdrptr = section->start; + dwarf_vma unit_length; + unsigned char *unit_start; + const unsigned char *const section_end = section->start + section->size; + unsigned char *unit_end; + + introduce (section, FALSE); + + load_debug_section_with_follow (str, file); + + for (; hdrptr < section_end; hdrptr = unit_end) + { + unsigned int offset_size; + uint16_t dwarf_version, padding; + uint32_t comp_unit_count, local_type_unit_count, foreign_type_unit_count; + uint32_t bucket_count, name_count, abbrev_table_size; + uint32_t augmentation_string_size; + unsigned int i; + unsigned long sec_off; + + unit_start = hdrptr; + + /* Get and check the length of the block. */ + SAFE_BYTE_GET_AND_INC (unit_length, hdrptr, 4, section_end); + + if (unit_length == 0xffffffff) + { + /* This section is 64-bit DWARF. */ + SAFE_BYTE_GET_AND_INC (unit_length, hdrptr, 8, section_end); + offset_size = 8; + } + else + offset_size = 4; + unit_end = hdrptr + unit_length; + + sec_off = hdrptr - section->start; + if (sec_off + unit_length < sec_off + || sec_off + unit_length > section->size) + { + warn (_("Debug info is corrupted, %s header at %#lx has length %s\n"), + section->name, + (unsigned long) (unit_start - section->start), + dwarf_vmatoa ("x", unit_length)); + return 0; + } + + /* Get and check the version number. */ + SAFE_BYTE_GET_AND_INC (dwarf_version, hdrptr, 2, unit_end); + printf (_("Version %ld\n"), (long) dwarf_version); + + /* Prior versions did not exist, and future versions may not be + backwards compatible. */ + if (dwarf_version != 5) + { + warn (_("Only DWARF version 5 .debug_names " + "is currently supported.\n")); + return 0; + } + + SAFE_BYTE_GET_AND_INC (padding, hdrptr, 2, unit_end); + if (padding != 0) + warn (_("Padding field of .debug_names must be 0 (found 0x%x)\n"), + padding); + + SAFE_BYTE_GET_AND_INC (comp_unit_count, hdrptr, 4, unit_end); + if (comp_unit_count == 0) + warn (_("Compilation unit count must be >= 1 in .debug_names\n")); + + SAFE_BYTE_GET_AND_INC (local_type_unit_count, hdrptr, 4, unit_end); + SAFE_BYTE_GET_AND_INC (foreign_type_unit_count, hdrptr, 4, unit_end); + SAFE_BYTE_GET_AND_INC (bucket_count, hdrptr, 4, unit_end); + SAFE_BYTE_GET_AND_INC (name_count, hdrptr, 4, unit_end); + SAFE_BYTE_GET_AND_INC (abbrev_table_size, hdrptr, 4, unit_end); + + SAFE_BYTE_GET_AND_INC (augmentation_string_size, hdrptr, 4, unit_end); + if (augmentation_string_size % 4 != 0) + { + warn (_("Augmentation string length %u must be rounded up " + "to a multiple of 4 in .debug_names.\n"), + augmentation_string_size); + augmentation_string_size += (-augmentation_string_size) & 3; + } + printf (_("Augmentation string:")); + for (i = 0; i < augmentation_string_size; i++) + { + unsigned char uc; + + SAFE_BYTE_GET_AND_INC (uc, hdrptr, 1, unit_end); + printf (" %02x", uc); + } + putchar ('\n'); + putchar ('\n'); + + printf (_("CU table:\n")); + for (i = 0; i < comp_unit_count; i++) + { + uint64_t cu_offset; + + SAFE_BYTE_GET_AND_INC (cu_offset, hdrptr, offset_size, unit_end); + printf (_("[%3u] 0x%lx\n"), i, (unsigned long) cu_offset); + } + putchar ('\n'); + + printf (_("TU table:\n")); + for (i = 0; i < local_type_unit_count; i++) + { + uint64_t tu_offset; + + SAFE_BYTE_GET_AND_INC (tu_offset, hdrptr, offset_size, unit_end); + printf (_("[%3u] 0x%lx\n"), i, (unsigned long) tu_offset); + } + putchar ('\n'); + + printf (_("Foreign TU table:\n")); + for (i = 0; i < foreign_type_unit_count; i++) + { + uint64_t signature; + + SAFE_BYTE_GET_AND_INC (signature, hdrptr, 8, unit_end); + printf (_("[%3u] "), i); + print_dwarf_vma (signature, 8); + putchar ('\n'); + } + putchar ('\n'); + + const uint32_t *const hash_table_buckets = (uint32_t *) hdrptr; + hdrptr += bucket_count * sizeof (uint32_t); + const uint32_t *const hash_table_hashes = (uint32_t *) hdrptr; + hdrptr += name_count * sizeof (uint32_t); + unsigned char *const name_table_string_offsets = hdrptr; + hdrptr += name_count * offset_size; + unsigned char *const name_table_entry_offsets = hdrptr; + hdrptr += name_count * offset_size; + unsigned char *const abbrev_table = hdrptr; + hdrptr += abbrev_table_size; + const unsigned char *const abbrev_table_end = hdrptr; + unsigned char *const entry_pool = hdrptr; + if (hdrptr > unit_end) + { + warn (_("Entry pool offset (0x%lx) exceeds unit size 0x%lx " + "for unit 0x%lx in the debug_names\n"), + (long) (hdrptr - section->start), + (long) (unit_end - section->start), + (long) (unit_start - section->start)); + return 0; + } + + size_t buckets_filled = 0; + size_t bucketi; + for (bucketi = 0; bucketi < bucket_count; bucketi++) + { + const uint32_t bucket = hash_table_buckets[bucketi]; + + if (bucket != 0) + ++buckets_filled; + } + printf (ngettext ("Used %zu of %lu bucket.\n", + "Used %zu of %lu buckets.\n", + bucket_count), + buckets_filled, (unsigned long) bucket_count); + + uint32_t hash_prev = 0; + size_t hash_clash_count = 0; + size_t longest_clash = 0; + size_t this_length = 0; + size_t hashi; + for (hashi = 0; hashi < name_count; hashi++) + { + const uint32_t hash_this = hash_table_hashes[hashi]; + + if (hashi > 0) + { + if (hash_prev % bucket_count == hash_this % bucket_count) + { + ++hash_clash_count; + ++this_length; + longest_clash = MAX (longest_clash, this_length); + } + else + this_length = 0; + } + hash_prev = hash_this; + } + printf (_("Out of %lu items there are %zu bucket clashes" + " (longest of %zu entries).\n"), + (unsigned long) name_count, hash_clash_count, longest_clash); + assert (name_count == buckets_filled + hash_clash_count); + + struct abbrev_lookup_entry + { + dwarf_vma abbrev_tag; + unsigned char *abbrev_lookup_ptr; + }; + struct abbrev_lookup_entry *abbrev_lookup = NULL; + size_t abbrev_lookup_used = 0; + size_t abbrev_lookup_allocated = 0; + + unsigned char *abbrevptr = abbrev_table; + for (;;) + { + unsigned int bytes_read; + const dwarf_vma abbrev_tag = read_uleb128 (abbrevptr, &bytes_read, + abbrev_table_end); + abbrevptr += bytes_read; + if (abbrev_tag == 0) + break; + if (abbrev_lookup_used == abbrev_lookup_allocated) + { + abbrev_lookup_allocated = MAX (0x100, + abbrev_lookup_allocated * 2); + abbrev_lookup = xrealloc (abbrev_lookup, + (abbrev_lookup_allocated + * sizeof (*abbrev_lookup))); + } + assert (abbrev_lookup_used < abbrev_lookup_allocated); + struct abbrev_lookup_entry *entry; + for (entry = abbrev_lookup; + entry < abbrev_lookup + abbrev_lookup_used; + entry++) + if (entry->abbrev_tag == abbrev_tag) + { + warn (_("Duplicate abbreviation tag %lu " + "in unit 0x%lx in the debug_names\n"), + (long) abbrev_tag, (long) (unit_start - section->start)); + break; + } + entry = &abbrev_lookup[abbrev_lookup_used++]; + entry->abbrev_tag = abbrev_tag; + entry->abbrev_lookup_ptr = abbrevptr; + + /* Skip DWARF tag. */ + read_uleb128 (abbrevptr, &bytes_read, abbrev_table_end); + abbrevptr += bytes_read; + for (;;) + { + const dwarf_vma xindex = read_uleb128 (abbrevptr, + &bytes_read, + abbrev_table_end); + abbrevptr += bytes_read; + const dwarf_vma form = read_uleb128 (abbrevptr, &bytes_read, + abbrev_table_end); + abbrevptr += bytes_read; + if (xindex == 0 && form == 0) + break; + } + } + + printf (_("\nSymbol table:\n")); + uint32_t namei; + for (namei = 0; namei < name_count; ++namei) + { + uint64_t string_offset, entry_offset; + + SAFE_BYTE_GET (string_offset, + name_table_string_offsets + namei * offset_size, + offset_size, unit_end); + SAFE_BYTE_GET (entry_offset, + name_table_entry_offsets + namei * offset_size, + offset_size, unit_end); + + printf ("[%3u] #%08x %s:", namei, hash_table_hashes[namei], + fetch_indirect_string (string_offset)); + + unsigned char *entryptr = entry_pool + entry_offset; + + // We need to scan first whether there is a single or multiple + // entries. TAGNO is -2 for the first entry, it is -1 for the + // initial tag read of the second entry, then it becomes 0 for the + // first entry for real printing etc. + int tagno = -2; + /* Initialize it due to a false compiler warning. */ + dwarf_vma second_abbrev_tag = -1; + for (;;) + { + unsigned int bytes_read; + const dwarf_vma abbrev_tag = read_uleb128 (entryptr, &bytes_read, + unit_end); + entryptr += bytes_read; + if (tagno == -1) + { + second_abbrev_tag = abbrev_tag; + tagno = 0; + entryptr = entry_pool + entry_offset; + continue; + } + if (abbrev_tag == 0) + break; + if (tagno >= 0) + printf ("%s<%lu>", + (tagno == 0 && second_abbrev_tag == 0 ? " " : "\n\t"), + (unsigned long) abbrev_tag); + + const struct abbrev_lookup_entry *entry; + for (entry = abbrev_lookup; + entry < abbrev_lookup + abbrev_lookup_used; + entry++) + if (entry->abbrev_tag == abbrev_tag) + break; + if (entry >= abbrev_lookup + abbrev_lookup_used) + { + warn (_("Undefined abbreviation tag %lu " + "in unit 0x%lx in the debug_names\n"), + (long) abbrev_tag, + (long) (unit_start - section->start)); + break; + } + abbrevptr = entry->abbrev_lookup_ptr; + const dwarf_vma dwarf_tag = read_uleb128 (abbrevptr, &bytes_read, + abbrev_table_end); + abbrevptr += bytes_read; + if (tagno >= 0) + printf (" %s", get_TAG_name (dwarf_tag)); + for (;;) + { + const dwarf_vma xindex = read_uleb128 (abbrevptr, + &bytes_read, + abbrev_table_end); + abbrevptr += bytes_read; + const dwarf_vma form = read_uleb128 (abbrevptr, &bytes_read, + abbrev_table_end); + abbrevptr += bytes_read; + if (xindex == 0 && form == 0) + break; + + if (tagno >= 0) + printf (" %s", get_IDX_name (xindex)); + entryptr = read_and_display_attr_value (0, form, 0, entryptr, + unit_end, 0, 0, + offset_size, + dwarf_version, NULL, + (tagno < 0), NULL, + NULL, '='); + } + ++tagno; + } + if (tagno <= 0) + printf (_(" ")); + putchar ('\n'); + } + + free (abbrev_lookup); + } + + return 1; +} + +static int +display_debug_links (struct dwarf_section * section, + void * file ATTRIBUTE_UNUSED) +{ + const unsigned char * filename; + unsigned int filelen; + + introduce (section, FALSE); + + /* The .gnu_debuglink section is formatted as: + (c-string) Filename. + (padding) If needed to reach a 4 byte boundary. + (uint32_t) CRC32 value. + + The .gun_debugaltlink section is formatted as: + (c-string) Filename. + (binary) Build-ID. */ + + filename = section->start; + filelen = strnlen ((const char *) filename, section->size); + if (filelen == section->size) + { + warn (_("The debuglink filename is corrupt/missing\n")); + return 0; + } + + printf (_(" Separate debug info file: %s\n"), filename); + + if (const_strneq (section->name, ".gnu_debuglink")) + { + unsigned int crc32; + unsigned int crc_offset; + + crc_offset = filelen + 1; + crc_offset = (crc_offset + 3) & ~3; + if (crc_offset + 4 > section->size) + { + warn (_("CRC offset missing/truncated\n")); + return 0; + } + + crc32 = byte_get (filename + crc_offset, 4); + + printf (_(" CRC value: %#x\n"), crc32); + + if (crc_offset + 4 < section->size) + { + warn (_("There are %#lx extraneous bytes at the end of the section\n"), + (long)(section->size - (crc_offset + 4))); + return 0; + } + } + else /* const_strneq (section->name, ".gnu_debugaltlink") */ + { + const unsigned char * build_id = section->start + filelen + 1; + bfd_size_type build_id_len = section->size - (filelen + 1); + bfd_size_type printed; + + /* FIXME: Should we support smaller build-id notes ? */ + if (build_id_len < 0x14) + { + warn (_("Build-ID is too short (%#lx bytes)\n"), (long) build_id_len); + return 0; + } + + printed = printf (_(" Build-ID (%#lx bytes):"), (long) build_id_len); + display_data (printed, build_id, build_id_len); + putchar ('\n'); + } + + putchar ('\n'); + return 1; +} + +static int +display_gdb_index (struct dwarf_section *section, + void *file ATTRIBUTE_UNUSED) +{ + unsigned char *start = section->start; + uint32_t version; + uint32_t cu_list_offset, tu_list_offset; + uint32_t address_table_offset, symbol_table_offset, constant_pool_offset; + unsigned int cu_list_elements, tu_list_elements; + unsigned int address_table_size, symbol_table_slots; + unsigned char *cu_list, *tu_list; + unsigned char *address_table, *symbol_table, *constant_pool; + unsigned int i; + + /* The documentation for the format of this file is in gdb/dwarf2read.c. */ + + introduce (section, FALSE); + + if (section->size < 6 * sizeof (uint32_t)) + { + warn (_("Truncated header in the %s section.\n"), section->name); + return 0; + } + + version = byte_get_little_endian (start, 4); + printf (_("Version %ld\n"), (long) version); + + /* Prior versions are obsolete, and future versions may not be + backwards compatible. */ + if (version < 3 || version > 8) + { + warn (_("Unsupported version %lu.\n"), (unsigned long) version); + return 0; + } + if (version < 4) + warn (_("The address table data in version 3 may be wrong.\n")); + if (version < 5) + warn (_("Version 4 does not support case insensitive lookups.\n")); + if (version < 6) + warn (_("Version 5 does not include inlined functions.\n")); + if (version < 7) + warn (_("Version 6 does not include symbol attributes.\n")); + /* Version 7 indices generated by Gold have bad type unit references, + PR binutils/15021. But we don't know if the index was generated by + Gold or not, so to avoid worrying users with gdb-generated indices + we say nothing for version 7 here. */ + + cu_list_offset = byte_get_little_endian (start + 4, 4); + tu_list_offset = byte_get_little_endian (start + 8, 4); + address_table_offset = byte_get_little_endian (start + 12, 4); + symbol_table_offset = byte_get_little_endian (start + 16, 4); + constant_pool_offset = byte_get_little_endian (start + 20, 4); + + if (cu_list_offset > section->size + || tu_list_offset > section->size + || address_table_offset > section->size + || symbol_table_offset > section->size + || constant_pool_offset > section->size) + { + warn (_("Corrupt header in the %s section.\n"), section->name); + return 0; + } + + /* PR 17531: file: 418d0a8a. */ + if (tu_list_offset < cu_list_offset) + { + warn (_("TU offset (%x) is less than CU offset (%x)\n"), + tu_list_offset, cu_list_offset); + return 0; + } + + cu_list_elements = (tu_list_offset - cu_list_offset) / 8; + + if (address_table_offset < tu_list_offset) + { + warn (_("Address table offset (%x) is less than TU offset (%x)\n"), + address_table_offset, tu_list_offset); + return 0; + } + + tu_list_elements = (address_table_offset - tu_list_offset) / 8; + + /* PR 17531: file: 18a47d3d. */ + if (symbol_table_offset < address_table_offset) + { + warn (_("Symbol table offset (%x) is less then Address table offset (%x)\n"), + symbol_table_offset, address_table_offset); + return 0; + } + + address_table_size = symbol_table_offset - address_table_offset; + + if (constant_pool_offset < symbol_table_offset) + { + warn (_("Constant pool offset (%x) is less than symbol table offset (%x)\n"), + constant_pool_offset, symbol_table_offset); + return 0; + } + + symbol_table_slots = (constant_pool_offset - symbol_table_offset) / 8; + + cu_list = start + cu_list_offset; + tu_list = start + tu_list_offset; + address_table = start + address_table_offset; + symbol_table = start + symbol_table_offset; + constant_pool = start + constant_pool_offset; + + if (address_table + address_table_size > section->start + section->size) + { + warn (_("Address table extends beyond end of section.\n")); + return 0; + } + + printf (_("\nCU table:\n")); + for (i = 0; i < cu_list_elements; i += 2) + { + uint64_t cu_offset = byte_get_little_endian (cu_list + i * 8, 8); + uint64_t cu_length = byte_get_little_endian (cu_list + i * 8 + 8, 8); + + printf (_("[%3u] 0x%lx - 0x%lx\n"), i / 2, + (unsigned long) cu_offset, + (unsigned long) (cu_offset + cu_length - 1)); + } + + printf (_("\nTU table:\n")); + for (i = 0; i < tu_list_elements; i += 3) + { + uint64_t tu_offset = byte_get_little_endian (tu_list + i * 8, 8); + uint64_t type_offset = byte_get_little_endian (tu_list + i * 8 + 8, 8); + uint64_t signature = byte_get_little_endian (tu_list + i * 8 + 16, 8); + + printf (_("[%3u] 0x%lx 0x%lx "), i / 3, + (unsigned long) tu_offset, + (unsigned long) type_offset); + print_dwarf_vma (signature, 8); + printf ("\n"); + } + + printf (_("\nAddress table:\n")); + for (i = 0; i < address_table_size && i <= address_table_size - (2 * 8 + 4); + i += 2 * 8 + 4) + { + uint64_t low = byte_get_little_endian (address_table + i, 8); + uint64_t high = byte_get_little_endian (address_table + i + 8, 8); + uint32_t cu_index = byte_get_little_endian (address_table + i + 16, 4); + + print_dwarf_vma (low, 8); + print_dwarf_vma (high, 8); + printf (_("%lu\n"), (unsigned long) cu_index); + } + + printf (_("\nSymbol table:\n")); + for (i = 0; i < symbol_table_slots; ++i) + { + uint32_t name_offset = byte_get_little_endian (symbol_table + i * 8, 4); + uint32_t cu_vector_offset = byte_get_little_endian (symbol_table + i * 8 + 4, 4); + uint32_t num_cus, cu; + + if (name_offset != 0 + || cu_vector_offset != 0) + { + unsigned int j; + unsigned char * adr; + + adr = constant_pool + name_offset; + /* PR 17531: file: 5b7b07ad. */ + if (adr < constant_pool || adr >= section->start + section->size) + { + printf (_("[%3u] "), i, name_offset); + warn (_("Corrupt name offset of 0x%x found for symbol table slot %d\n"), + name_offset, i); + } + else + printf ("[%3u] %.*s:", i, + (int) (section->size - (constant_pool_offset + name_offset)), + constant_pool + name_offset); + + adr = constant_pool + cu_vector_offset; + if (adr < constant_pool || adr >= section->start + section->size - 3) + { + printf (_("\n"), cu_vector_offset); + warn (_("Corrupt CU vector offset of 0x%x found for symbol table slot %d\n"), + cu_vector_offset, i); + continue; + } + + num_cus = byte_get_little_endian (adr, 4); + + adr = constant_pool + cu_vector_offset + 4 + num_cus * 4; + if (num_cus * 4 < num_cus + || adr >= section->start + section->size + || adr < constant_pool) + { + printf ("\n", num_cus); + warn (_("Invalid number of CUs (0x%x) for symbol table slot %d\n"), + num_cus, i); + continue; + } + + if (num_cus > 1) + printf ("\n"); + + for (j = 0; j < num_cus; ++j) + { + int is_static; + gdb_index_symbol_kind kind; + + cu = byte_get_little_endian (constant_pool + cu_vector_offset + 4 + j * 4, 4); + is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu); + kind = GDB_INDEX_SYMBOL_KIND_VALUE (cu); + cu = GDB_INDEX_CU_VALUE (cu); + /* Convert to TU number if it's for a type unit. */ + if (cu >= cu_list_elements / 2) + printf ("%cT%lu", num_cus > 1 ? '\t' : ' ', + (unsigned long) (cu - cu_list_elements / 2)); + else + printf ("%c%lu", num_cus > 1 ? '\t' : ' ', (unsigned long) cu); + + printf (" [%s, %s]", + is_static ? _("static") : _("global"), + get_gdb_index_symbol_kind_name (kind)); + if (num_cus > 1) + printf ("\n"); + } + if (num_cus <= 1) + printf ("\n"); + } + } + + return 1; +} + +/* Pre-allocate enough space for the CU/TU sets needed. */ + +static void +prealloc_cu_tu_list (unsigned int nshndx) +{ + if (shndx_pool == NULL) + { + shndx_pool_size = nshndx; + shndx_pool_used = 0; + shndx_pool = (unsigned int *) xcmalloc (shndx_pool_size, + sizeof (unsigned int)); + } + else + { + shndx_pool_size = shndx_pool_used + nshndx; + shndx_pool = (unsigned int *) xcrealloc (shndx_pool, shndx_pool_size, + sizeof (unsigned int)); + } +} + +static void +add_shndx_to_cu_tu_entry (unsigned int shndx) +{ + if (shndx_pool_used >= shndx_pool_size) + { + error (_("Internal error: out of space in the shndx pool.\n")); + return; + } + shndx_pool [shndx_pool_used++] = shndx; +} + +static void +end_cu_tu_entry (void) +{ + if (shndx_pool_used >= shndx_pool_size) + { + error (_("Internal error: out of space in the shndx pool.\n")); + return; + } + shndx_pool [shndx_pool_used++] = 0; +} + +/* Return the short name of a DWARF section given by a DW_SECT enumerator. */ + +static const char * +get_DW_SECT_short_name (unsigned int dw_sect) +{ + static char buf[16]; + + switch (dw_sect) + { + case DW_SECT_INFO: + return "info"; + case DW_SECT_TYPES: + return "types"; + case DW_SECT_ABBREV: + return "abbrev"; + case DW_SECT_LINE: + return "line"; + case DW_SECT_LOC: + return "loc"; + case DW_SECT_STR_OFFSETS: + return "str_off"; + case DW_SECT_MACINFO: + return "macinfo"; + case DW_SECT_MACRO: + return "macro"; + default: + break; + } + + snprintf (buf, sizeof (buf), "%d", dw_sect); + return buf; +} + +/* Process a CU or TU index. If DO_DISPLAY is true, print the contents. + These sections are extensions for Fission. + See http://gcc.gnu.org/wiki/DebugFissionDWP. */ + +static int +process_cu_tu_index (struct dwarf_section *section, int do_display) +{ + unsigned char *phdr = section->start; + unsigned char *limit = phdr + section->size; + unsigned char *phash; + unsigned char *pindex; + unsigned char *ppool; + unsigned int version; + unsigned int ncols = 0; + unsigned int nused; + unsigned int nslots; + unsigned int i; + unsigned int j; + dwarf_vma signature_high; + dwarf_vma signature_low; + char buf[64]; + + /* PR 17512: file: 002-168123-0.004. */ + if (phdr == NULL) + { + warn (_("Section %s is empty\n"), section->name); + return 0; + } + /* PR 17512: file: 002-376-0.004. */ + if (section->size < 24) + { + warn (_("Section %s is too small to contain a CU/TU header\n"), + section->name); + return 0; + } + + SAFE_BYTE_GET (version, phdr, 4, limit); + if (version >= 2) + SAFE_BYTE_GET (ncols, phdr + 4, 4, limit); + SAFE_BYTE_GET (nused, phdr + 8, 4, limit); + SAFE_BYTE_GET (nslots, phdr + 12, 4, limit); + + phash = phdr + 16; + pindex = phash + nslots * 8; + ppool = pindex + nslots * 4; + + /* PR 17531: file: 45d69832. */ + if (pindex < phash || ppool < phdr || (pindex == phash && nslots != 0)) + { + warn (ngettext ("Section %s is too small for %d slot\n", + "Section %s is too small for %d slots\n", + nslots), + section->name, nslots); + return 0; + } + + if (do_display) + { + introduce (section, FALSE); + + printf (_(" Version: %d\n"), version); + if (version >= 2) + printf (_(" Number of columns: %d\n"), ncols); + printf (_(" Number of used entries: %d\n"), nused); + printf (_(" Number of slots: %d\n\n"), nslots); + } + + if (ppool > limit || ppool < phdr) + { + warn (_("Section %s too small for %d hash table entries\n"), + section->name, nslots); + return 0; + } + + if (version == 1) + { + if (!do_display) + prealloc_cu_tu_list ((limit - ppool) / 4); + for (i = 0; i < nslots; i++) + { + unsigned char *shndx_list; + unsigned int shndx; + + SAFE_BYTE_GET64 (phash, &signature_high, &signature_low, limit); + if (signature_high != 0 || signature_low != 0) + { + SAFE_BYTE_GET (j, pindex, 4, limit); + shndx_list = ppool + j * 4; + /* PR 17531: file: 705e010d. */ + if (shndx_list < ppool) + { + warn (_("Section index pool located before start of section\n")); + return 0; + } + + if (do_display) + printf (_(" [%3d] Signature: 0x%s Sections: "), + i, dwarf_vmatoa64 (signature_high, signature_low, + buf, sizeof (buf))); + for (;;) + { + if (shndx_list >= limit) + { + warn (_("Section %s too small for shndx pool\n"), + section->name); + return 0; + } + SAFE_BYTE_GET (shndx, shndx_list, 4, limit); + if (shndx == 0) + break; + if (do_display) + printf (" %d", shndx); + else + add_shndx_to_cu_tu_entry (shndx); + shndx_list += 4; + } + if (do_display) + printf ("\n"); + else + end_cu_tu_entry (); + } + phash += 8; + pindex += 4; + } + } + else if (version == 2) + { + unsigned int val; + unsigned int dw_sect; + unsigned char *ph = phash; + unsigned char *pi = pindex; + unsigned char *poffsets = ppool + ncols * 4; + unsigned char *psizes = poffsets + nused * ncols * 4; + unsigned char *pend = psizes + nused * ncols * 4; + bfd_boolean is_tu_index; + struct cu_tu_set *this_set = NULL; + unsigned int row; + unsigned char *prow; + + is_tu_index = strcmp (section->name, ".debug_tu_index") == 0; + + /* PR 17531: file: 0dd159bf. + Check for wraparound with an overlarge ncols value. */ + if (poffsets < ppool || (unsigned int) ((poffsets - ppool) / 4) != ncols) + { + warn (_("Overlarge number of columns: %x\n"), ncols); + return 0; + } + + if (pend > limit) + { + warn (_("Section %s too small for offset and size tables\n"), + section->name); + return 0; + } + + if (do_display) + { + printf (_(" Offset table\n")); + printf (" slot %-16s ", + is_tu_index ? _("signature") : _("dwo_id")); + } + else + { + if (is_tu_index) + { + tu_count = nused; + tu_sets = xcalloc2 (nused, sizeof (struct cu_tu_set)); + this_set = tu_sets; + } + else + { + cu_count = nused; + cu_sets = xcalloc2 (nused, sizeof (struct cu_tu_set)); + this_set = cu_sets; + } + } + + if (do_display) + { + for (j = 0; j < ncols; j++) + { + SAFE_BYTE_GET (dw_sect, ppool + j * 4, 4, limit); + printf (" %8s", get_DW_SECT_short_name (dw_sect)); + } + printf ("\n"); + } + + for (i = 0; i < nslots; i++) + { + SAFE_BYTE_GET64 (ph, &signature_high, &signature_low, limit); + + SAFE_BYTE_GET (row, pi, 4, limit); + if (row != 0) + { + /* PR 17531: file: a05f6ab3. */ + if (row > nused) + { + warn (_("Row index (%u) is larger than number of used entries (%u)\n"), + row, nused); + return 0; + } + + if (!do_display) + memcpy (&this_set[row - 1].signature, ph, sizeof (uint64_t)); + + prow = poffsets + (row - 1) * ncols * 4; + /* PR 17531: file: b8ce60a8. */ + if (prow < poffsets || prow > limit) + { + warn (_("Row index (%u) * num columns (%u) > space remaining in section\n"), + row, ncols); + return 0; + } + + if (do_display) + printf (_(" [%3d] 0x%s"), + i, dwarf_vmatoa64 (signature_high, signature_low, + buf, sizeof (buf))); + for (j = 0; j < ncols; j++) + { + SAFE_BYTE_GET (val, prow + j * 4, 4, limit); + if (do_display) + printf (" %8d", val); + else + { + SAFE_BYTE_GET (dw_sect, ppool + j * 4, 4, limit); + + /* PR 17531: file: 10796eb3. */ + if (dw_sect >= DW_SECT_MAX) + warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect); + else + this_set [row - 1].section_offsets [dw_sect] = val; + } + } + + if (do_display) + printf ("\n"); + } + ph += 8; + pi += 4; + } + + ph = phash; + pi = pindex; + if (do_display) + { + printf ("\n"); + printf (_(" Size table\n")); + printf (" slot %-16s ", + is_tu_index ? _("signature") : _("dwo_id")); + } + + for (j = 0; j < ncols; j++) + { + SAFE_BYTE_GET (val, ppool + j * 4, 4, limit); + if (do_display) + printf (" %8s", get_DW_SECT_short_name (val)); + } + + if (do_display) + printf ("\n"); + + for (i = 0; i < nslots; i++) + { + SAFE_BYTE_GET64 (ph, &signature_high, &signature_low, limit); + + SAFE_BYTE_GET (row, pi, 4, limit); + if (row != 0) + { + prow = psizes + (row - 1) * ncols * 4; + + if (do_display) + printf (_(" [%3d] 0x%s"), + i, dwarf_vmatoa64 (signature_high, signature_low, + buf, sizeof (buf))); + + for (j = 0; j < ncols; j++) + { + SAFE_BYTE_GET (val, prow + j * 4, 4, limit); + if (do_display) + printf (" %8d", val); + else + { + SAFE_BYTE_GET (dw_sect, ppool + j * 4, 4, limit); + if (dw_sect >= DW_SECT_MAX) + warn (_("Overlarge Dwarf section index detected: %u\n"), dw_sect); + else + this_set [row - 1].section_sizes [dw_sect] = val; + } + } + + if (do_display) + printf ("\n"); + } + + ph += 8; + pi += 4; + } + } + else if (do_display) + printf (_(" Unsupported version (%d)\n"), version); + + if (do_display) + printf ("\n"); + + return 1; +} + +/* Load the CU and TU indexes if present. This will build a list of + section sets that we can use to associate a .debug_info.dwo section + with its associated .debug_abbrev.dwo section in a .dwp file. */ + +static bfd_boolean +load_cu_tu_indexes (void *file) +{ + static int cu_tu_indexes_read = -1; /* Tri-state variable. */ + + /* If we have already loaded (or tried to load) the CU and TU indexes + then do not bother to repeat the task. */ + if (cu_tu_indexes_read == -1) + { + cu_tu_indexes_read = TRUE; + + if (load_debug_section_with_follow (dwp_cu_index, file)) + if (! process_cu_tu_index (&debug_displays [dwp_cu_index].section, 0)) + cu_tu_indexes_read = FALSE; + + if (load_debug_section_with_follow (dwp_tu_index, file)) + if (! process_cu_tu_index (&debug_displays [dwp_tu_index].section, 0)) + cu_tu_indexes_read = FALSE; + } + + return (bfd_boolean) cu_tu_indexes_read; +} + +/* Find the set of sections that includes section SHNDX. */ + +unsigned int * +find_cu_tu_set (void *file, unsigned int shndx) +{ + unsigned int i; + + if (! load_cu_tu_indexes (file)) + return NULL; + + /* Find SHNDX in the shndx pool. */ + for (i = 0; i < shndx_pool_used; i++) + if (shndx_pool [i] == shndx) + break; + + if (i >= shndx_pool_used) + return NULL; + + /* Now backup to find the first entry in the set. */ + while (i > 0 && shndx_pool [i - 1] != 0) + i--; + + return shndx_pool + i; +} + +/* Display a .debug_cu_index or .debug_tu_index section. */ + +static int +display_cu_index (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) +{ + return process_cu_tu_index (section, 1); +} + +static int +display_debug_not_supported (struct dwarf_section *section, + void *file ATTRIBUTE_UNUSED) +{ + printf (_("Displaying the debug contents of section %s is not yet supported.\n"), + section->name); + + return 1; +} + +/* Like malloc, but takes two parameters like calloc. + Verifies that the first parameter is not too large. + Note: does *not* initialise the allocated memory to zero. */ + +void * +cmalloc (size_t nmemb, size_t size) +{ + /* Check for overflow. */ + if (nmemb >= ~(size_t) 0 / size) + return NULL; + + return xmalloc (nmemb * size); +} + +/* Like xmalloc, but takes two parameters like calloc. + Verifies that the first parameter is not too large. + Note: does *not* initialise the allocated memory to zero. */ + +void * +xcmalloc (size_t nmemb, size_t size) +{ + /* Check for overflow. */ + if (nmemb >= ~(size_t) 0 / size) + { + fprintf (stderr, + _("Attempt to allocate an array with an excessive number of elements: 0x%lx\n"), + (long) nmemb); + xexit (1); + } + + return xmalloc (nmemb * size); +} + +/* Like xrealloc, but takes three parameters. + Verifies that the second parameter is not too large. + Note: does *not* initialise any new memory to zero. */ + +void * +xcrealloc (void *ptr, size_t nmemb, size_t size) +{ + /* Check for overflow. */ + if (nmemb >= ~(size_t) 0 / size) + { + error (_("Attempt to re-allocate an array with an excessive number of elements: 0x%lx\n"), + (long) nmemb); + xexit (1); + } + + return xrealloc (ptr, nmemb * size); +} + +/* Like xcalloc, but verifies that the first parameter is not too large. */ + +void * +xcalloc2 (size_t nmemb, size_t size) +{ + /* Check for overflow. */ + if (nmemb >= ~(size_t) 0 / size) + { + error (_("Attempt to allocate a zero'ed array with an excessive number of elements: 0x%lx\n"), + (long) nmemb); + xexit (1); + } + + return xcalloc (nmemb, size); +} + +static unsigned long +calc_gnu_debuglink_crc32 (unsigned long crc, + const unsigned char * buf, + bfd_size_type len) +{ + static const unsigned long crc32_table[256] = + { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d + }; + const unsigned char *end; + + crc = ~crc & 0xffffffff; + for (end = buf + len; buf < end; ++ buf) + crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8); + return ~crc & 0xffffffff; +} + +typedef bfd_boolean (* check_func_type) (const char *, void *); +typedef const char * (* parse_func_type) (struct dwarf_section *, void *); + +static bfd_boolean +check_gnu_debuglink (const char * pathname, void * crc_pointer) +{ + static unsigned char buffer [8 * 1024]; + FILE * f; + bfd_size_type count; + unsigned long crc = 0; + void * sep_data; + + sep_data = open_debug_file (pathname); + if (sep_data == NULL) + return FALSE; + + /* Yes - we are opening the file twice... */ + f = fopen (pathname, "rb"); + if (f == NULL) + { + /* Paranoia: This should never happen. */ + close_debug_file (sep_data); + warn (_("Unable to reopen separate debug info file: %s\n"), pathname); + return FALSE; + } + + while ((count = fread (buffer, 1, sizeof (buffer), f)) > 0) + crc = calc_gnu_debuglink_crc32 (crc, buffer, count); + + fclose (f); + + if (crc != * (unsigned long *) crc_pointer) + { + close_debug_file (sep_data); + warn (_("Separate debug info file %s found, but CRC does not match - ignoring\n"), + pathname); + return FALSE; + } + + return TRUE; +} + +static const char * +parse_gnu_debuglink (struct dwarf_section * section, void * data) +{ + const char * name; + unsigned int crc_offset; + unsigned long * crc32 = (unsigned long *) data; + + /* The name is first. + The CRC value is stored after the filename, aligned up to 4 bytes. */ + name = (const char *) section->start; + + crc_offset = strnlen (name, section->size) + 1; + crc_offset = (crc_offset + 3) & ~3; + if (crc_offset + 4 > section->size) + return NULL; + + * crc32 = byte_get (section->start + crc_offset, 4); + return name; +} + +static bfd_boolean +check_gnu_debugaltlink (const char * filename, void * data ATTRIBUTE_UNUSED) +{ + void * sep_data = open_debug_file (filename); + + if (sep_data == NULL) + return FALSE; + + /* FIXME: We should now extract the build-id in the separate file + and check it... */ + + return TRUE; +} + +typedef struct build_id_data +{ + bfd_size_type len; + const unsigned char * data; +} Build_id_data; + +static const char * +parse_gnu_debugaltlink (struct dwarf_section * section, void * data) +{ + const char * name; + bfd_size_type namelen; + bfd_size_type id_len; + Build_id_data * build_id_data; + + /* The name is first. + The build-id follows immediately, with no padding, up to the section's end. */ + + name = (const char *) section->start; + namelen = strnlen (name, section->size) + 1; + if (namelen >= section->size) + return NULL; + + id_len = section->size - namelen; + if (id_len < 0x14) + return NULL; + + build_id_data = calloc (1, sizeof * build_id_data); + if (build_id_data == NULL) + return NULL; + + build_id_data->len = id_len; + build_id_data->data = section->start + namelen; + + * (Build_id_data **) data = build_id_data; + + return name; +} + +static void * +load_separate_debug_info (const char * main_filename, + struct dwarf_section * xlink, + parse_func_type parse_func, + check_func_type check_func, + void * func_data) +{ + const char * separate_filename; + char * debugfile; + char * canon_dir; + size_t canon_dirlen; + size_t dirlen; + + if ((separate_filename = parse_func (xlink, func_data)) == NULL) + { + warn (_("Corrupt debuglink section: %s\n"), + xlink->name ? xlink->name : xlink->uncompressed_name); + return FALSE; + } + + /* Attempt to locate the separate file. + This should duplicate the logic in bfd/opncls.c:find_separate_debug_file(). */ + + canon_dir = lrealpath (main_filename); + + for (canon_dirlen = strlen (canon_dir); canon_dirlen > 0; canon_dirlen--) + if (IS_DIR_SEPARATOR (canon_dir[canon_dirlen - 1])) + break; + canon_dir[canon_dirlen] = '\0'; + +#ifndef DEBUGDIR +#define DEBUGDIR "/lib/debug" +#endif +#ifndef EXTRA_DEBUG_ROOT1 +#define EXTRA_DEBUG_ROOT1 "/usr/lib/debug" +#endif +#ifndef EXTRA_DEBUG_ROOT2 +#define EXTRA_DEBUG_ROOT2 "/usr/lib/debug/usr" +#endif + + debugfile = (char *) malloc (strlen (DEBUGDIR) + 1 + + canon_dirlen + + strlen (".debug/") +#ifdef EXTRA_DEBUG_ROOT1 + + strlen (EXTRA_DEBUG_ROOT1) +#endif +#ifdef EXTRA_DEBUG_ROOT2 + + strlen (EXTRA_DEBUG_ROOT2) +#endif + + strlen (separate_filename) + + 1); + if (debugfile == NULL) + { + warn (_("Out of memory")); + return NULL; + } + + /* First try in the current directory. */ + sprintf (debugfile, "%s", separate_filename); + if (check_func (debugfile, func_data)) + goto found; + + /* Then try in a subdirectory called .debug. */ + sprintf (debugfile, ".debug/%s", separate_filename); + if (check_func (debugfile, func_data)) + goto found; + + /* Then try in the same directory as the original file. */ + sprintf (debugfile, "%s%s", canon_dir, separate_filename); + if (check_func (debugfile, func_data)) + goto found; + + /* And the .debug subdirectory of that directory. */ + sprintf (debugfile, "%s.debug/%s", canon_dir, separate_filename); + if (check_func (debugfile, func_data)) + goto found; + +#ifdef EXTRA_DEBUG_ROOT1 + /* Try the first extra debug file root. */ + sprintf (debugfile, "%s/%s", EXTRA_DEBUG_ROOT1, separate_filename); + if (check_func (debugfile, func_data)) + goto found; +#endif + +#ifdef EXTRA_DEBUG_ROOT2 + /* Try the second extra debug file root. */ + sprintf (debugfile, "%s/%s", EXTRA_DEBUG_ROOT2, separate_filename); + if (check_func (debugfile, func_data)) + goto found; +#endif + + /* Then try in the global debugfile directory. */ + strcpy (debugfile, DEBUGDIR); + dirlen = strlen (DEBUGDIR) - 1; + if (dirlen > 0 && DEBUGDIR[dirlen] != '/') + strcat (debugfile, "/"); + strcat (debugfile, (const char *) separate_filename); + + if (check_func (debugfile, func_data)) + goto found; + + /* Failed to find the file. */ + warn (_("could not find separate debug file '%s'\n"), separate_filename); + warn (_("tried: %s\n"), debugfile); + +#ifdef EXTRA_DEBUG_ROOT2 + sprintf (debugfile, "%s/%s", EXTRA_DEBUG_ROOT2, separate_filename); + warn (_("tried: %s\n"), debugfile); +#endif + +#ifdef EXTRA_DEBUG_ROOT1 + sprintf (debugfile, "%s/%s", EXTRA_DEBUG_ROOT1, separate_filename); + warn (_("tried: %s\n"), debugfile); +#endif + + sprintf (debugfile, "%s.debug/%s", canon_dir, separate_filename); + warn (_("tried: %s\n"), debugfile); + + sprintf (debugfile, "%s%s", canon_dir, separate_filename); + warn (_("tried: %s\n"), debugfile); + + sprintf (debugfile, ".debug/%s", separate_filename); + warn (_("tried: %s\n"), debugfile); + + sprintf (debugfile, "%s", separate_filename); + warn (_("tried: %s\n"), debugfile); + + free (canon_dir); + free (debugfile); + return NULL; + + found: + free (canon_dir); + + /* Now open the file.... */ + if ((separate_debug_file = open_debug_file (debugfile)) == NULL) + { + warn (_("failed to open separate debug file: %s\n"), debugfile); + free (debugfile); + return FALSE; + } + + /* FIXME: We do not check to see if there are any other separate debug info + files that would also match. */ + + printf (_("%s: Found separate debug info file: %s\n\n"), main_filename, debugfile); + separate_debug_filename = debugfile; + + /* Do not free debugfile - it might be referenced inside + the structure returned by open_debug_file(). */ + return separate_debug_file; +} + +/* Attempt to load a separate dwarf object file. */ + +static void * +load_dwo_file (const char * main_filename) +{ + char * filename; + + /* FIXME: Skip adding / if dwo_dir ends in /. */ + filename = concat (dwo_dir, "/", dwo_name, NULL); + if (filename == NULL) + { + warn (_("Out of memory allocating dwo filename\n")); + return NULL; + } + + if ((separate_debug_file = open_debug_file (filename)) == NULL) + { + warn (_("Unable to load dwo file: %s\n"), filename); + free (filename); + return NULL; + } + + /* FIXME: We should check the dwo_id. */ + + printf (_("%s: Found separate debug object file: %s\n\n"), main_filename, filename); + separate_debug_filename = filename; + return separate_debug_file; +} + +/* Load a separate debug info file, if it exists. + Returns the data pointer that is the result of calling open_debug_file + on the separate debug info file, or NULL if there were problems or there + is no such file. */ + +void * +load_separate_debug_file (void * file, const char * filename) +{ + /* See if there is a dwo link. */ + if (load_debug_section (str, file) + && load_debug_section (abbrev, file) + && load_debug_section (info, file)) + { + dwo_name = dwo_dir = NULL; + dwo_id = NULL; + dwo_id_len = 0; + + if (process_debug_info (& debug_displays[info].section, file, abbrev, TRUE, FALSE)) + { + if (dwo_name != NULL) + { + if (do_debug_links) + { + printf (_("The %s section contains a link to a dwo file:\n"), + debug_displays [info].section.uncompressed_name); + printf (_(" Name: %s\n"), dwo_name); + printf (_(" Directory: %s\n"), dwo_dir ? dwo_dir : _("")); + if (dwo_id != NULL) + display_data (printf (_(" ID: ")), dwo_id, dwo_id_len); + else + printf (_(" ID: \n")); + printf ("\n\n"); + } + + /* FIXME: We do not check to see if there are any more dwo links in the file... */ + if (do_follow_links) + return load_dwo_file (filename); + } + } + } + + if (! do_follow_links) + return NULL; + + /* FIXME: We do not check for the presence of both link sections in the same file. */ + /* FIXME: We do not check the separate debug info file to see if it too contains debuglinks. */ + /* FIXME: We do not check for the presence of multiple, same-name debuglink sections. */ + /* FIXME: We do not check for the presence of a dwo link as well as a debuglink. */ + + if (load_debug_section (gnu_debugaltlink, file)) + { + Build_id_data * build_id_data; + + return load_separate_debug_info (filename, + & debug_displays[gnu_debugaltlink].section, + parse_gnu_debugaltlink, + check_gnu_debugaltlink, + & build_id_data); + } + + if (load_debug_section (gnu_debuglink, file)) + { + unsigned long crc32; + + return load_separate_debug_info (filename, + & debug_displays[gnu_debuglink].section, + parse_gnu_debuglink, + check_gnu_debuglink, + & crc32); + } + + do_follow_links = 0; + return NULL; +} + +void +free_debug_memory (void) +{ + unsigned int i; + + free_abbrevs (); + + for (i = 0; i < max; i++) + free_debug_section ((enum dwarf_section_display_enum) i); + + if (debug_information != NULL) + { + if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE) + { + for (i = 0; i < num_debug_info_entries; i++) + { + if (!debug_information [i].max_loc_offsets) + { + free (debug_information [i].loc_offsets); + free (debug_information [i].have_frame_base); + } + if (!debug_information [i].max_range_lists) + free (debug_information [i].range_lists); + } + } + free (debug_information); + debug_information = NULL; + alloc_num_debug_info_entries = num_debug_info_entries = 0; + } + + if (separate_debug_file != NULL) + { + close_debug_file (separate_debug_file); + separate_debug_file = NULL; + + free ((void *) separate_debug_filename); + separate_debug_filename = NULL; + } +} + +void +dwarf_select_sections_by_names (const char *names) +{ + typedef struct + { + const char * option; + int * variable; + int val; + } + debug_dump_long_opts; + + static const debug_dump_long_opts opts_table [] = + { + /* Please keep this table alpha- sorted. */ + { "Ranges", & do_debug_ranges, 1 }, + { "abbrev", & do_debug_abbrevs, 1 }, + { "addr", & do_debug_addr, 1 }, + { "aranges", & do_debug_aranges, 1 }, + { "cu_index", & do_debug_cu_index, 1 }, + { "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED }, + { "follow-links", & do_follow_links, 1 }, + { "frames", & do_debug_frames, 1 }, + { "frames-interp", & do_debug_frames_interp, 1 }, + /* The special .gdb_index section. */ + { "gdb_index", & do_gdb_index, 1 }, + { "info", & do_debug_info, 1 }, + { "line", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, /* For backwards compatibility. */ + { "links", & do_debug_links, 1 }, + { "loc", & do_debug_loc, 1 }, + { "macro", & do_debug_macinfo, 1 }, + { "pubnames", & do_debug_pubnames, 1 }, + { "pubtypes", & do_debug_pubtypes, 1 }, + /* This entry is for compatibility + with earlier versions of readelf. */ + { "ranges", & do_debug_aranges, 1 }, + { "rawline", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, + { "str", & do_debug_str, 1 }, + /* These trace_* sections are used by Itanium VMS. */ + { "trace_abbrev", & do_trace_abbrevs, 1 }, + { "trace_aranges", & do_trace_aranges, 1 }, + { "trace_info", & do_trace_info, 1 }, + { NULL, NULL, 0 } + }; + + const char *p; + + p = names; + while (*p) + { + const debug_dump_long_opts * entry; + + for (entry = opts_table; entry->option; entry++) + { + size_t len = strlen (entry->option); + + if (strncmp (p, entry->option, len) == 0 + && (p[len] == ',' || p[len] == '\0')) + { + * entry->variable |= entry->val; + + /* The --debug-dump=frames-interp option also + enables the --debug-dump=frames option. */ + if (do_debug_frames_interp) + do_debug_frames = 1; + + p += len; + break; + } + } + + if (entry->option == NULL) + { + warn (_("Unrecognized debug option '%s'\n"), p); + p = strchr (p, ','); + if (p == NULL) + break; + } + + if (*p == ',') + p++; + } +} + +void +dwarf_select_sections_by_letters (const char *letters) +{ + unsigned int lindex = 0; + + while (letters[lindex]) + switch (letters[lindex++]) + { + case 'A': do_debug_addr = 1; break; + case 'a': do_debug_abbrevs = 1; break; + case 'c': do_debug_cu_index = 1; break; + case 'F': do_debug_frames_interp = 1; /* Fall through. */ + case 'f': do_debug_frames = 1; break; + case 'g': do_gdb_index = 1; break; + case 'i': do_debug_info = 1; break; + case 'K': do_follow_links = 1; break; + case 'k': do_debug_links = 1; break; + case 'l': do_debug_lines |= FLAG_DEBUG_LINES_RAW; break; + case 'L': do_debug_lines |= FLAG_DEBUG_LINES_DECODED; break; + case 'm': do_debug_macinfo = 1; break; + case 'o': do_debug_loc = 1; break; + case 'p': do_debug_pubnames = 1; break; + case 'R': do_debug_ranges = 1; break; + case 'r': do_debug_aranges = 1; break; + case 's': do_debug_str = 1; break; + case 'T': do_trace_aranges = 1; break; + case 't': do_debug_pubtypes = 1; break; + case 'U': do_trace_info = 1; break; + case 'u': do_trace_abbrevs = 1; break; + + default: + warn (_("Unrecognized debug option '%s'\n"), letters); + break; + } +} + +void +dwarf_select_sections_all (void) +{ + do_debug_info = 1; + do_debug_abbrevs = 1; + do_debug_lines = FLAG_DEBUG_LINES_RAW; + do_debug_pubnames = 1; + do_debug_pubtypes = 1; + do_debug_aranges = 1; + do_debug_ranges = 1; + do_debug_frames = 1; + do_debug_macinfo = 1; + do_debug_str = 1; + do_debug_loc = 1; + do_gdb_index = 1; + do_trace_info = 1; + do_trace_abbrevs = 1; + do_trace_aranges = 1; + do_debug_addr = 1; + do_debug_cu_index = 1; + do_follow_links = 1; + do_debug_links = 1; +} + +#define NO_ABBREVS NULL, NULL, NULL, 0, 0, 0, NULL, 0, NULL +#define ABBREV(N) NULL, NULL, NULL, 0, 0, N, NULL, 0, NULL + +/* N.B. The order here must match the order in section_display_enum. */ + +struct dwarf_section_display debug_displays[] = +{ + { { ".debug_abbrev", ".zdebug_abbrev", NO_ABBREVS }, display_debug_abbrev, &do_debug_abbrevs, FALSE }, + { { ".debug_aranges", ".zdebug_aranges", NO_ABBREVS }, display_debug_aranges, &do_debug_aranges, TRUE }, + { { ".debug_frame", ".zdebug_frame", NO_ABBREVS }, display_debug_frames, &do_debug_frames, TRUE }, + { { ".debug_info", ".zdebug_info", ABBREV (abbrev)}, display_debug_info, &do_debug_info, TRUE }, + { { ".debug_line", ".zdebug_line", NO_ABBREVS }, display_debug_lines, &do_debug_lines, TRUE }, + { { ".debug_pubnames", ".zdebug_pubnames", NO_ABBREVS }, display_debug_pubnames, &do_debug_pubnames, FALSE }, + { { ".debug_gnu_pubnames", ".zdebug_gnu_pubnames", NO_ABBREVS }, display_debug_gnu_pubnames, &do_debug_pubnames, FALSE }, + { { ".eh_frame", "", NO_ABBREVS }, display_debug_frames, &do_debug_frames, TRUE }, + { { ".debug_macinfo", ".zdebug_macinfo", NO_ABBREVS }, display_debug_macinfo, &do_debug_macinfo, FALSE }, + { { ".debug_macro", ".zdebug_macro", NO_ABBREVS }, display_debug_macro, &do_debug_macinfo, TRUE }, + { { ".debug_str", ".zdebug_str", NO_ABBREVS }, display_debug_str, &do_debug_str, FALSE }, + { { ".debug_line_str", ".zdebug_line_str", NO_ABBREVS }, display_debug_str, &do_debug_str, FALSE }, + { { ".debug_loc", ".zdebug_loc", NO_ABBREVS }, display_debug_loc, &do_debug_loc, TRUE }, + { { ".debug_loclists", ".zdebug_loclists", NO_ABBREVS }, display_debug_loc, &do_debug_loc, TRUE }, + { { ".debug_pubtypes", ".zdebug_pubtypes", NO_ABBREVS }, display_debug_pubnames, &do_debug_pubtypes, FALSE }, + { { ".debug_gnu_pubtypes", ".zdebug_gnu_pubtypes", NO_ABBREVS }, display_debug_gnu_pubnames, &do_debug_pubtypes, FALSE }, + { { ".debug_ranges", ".zdebug_ranges", NO_ABBREVS }, display_debug_ranges, &do_debug_ranges, TRUE }, + { { ".debug_rnglists", ".zdebug_rnglists", NO_ABBREVS }, display_debug_ranges, &do_debug_ranges, TRUE }, + { { ".debug_static_func", ".zdebug_static_func", NO_ABBREVS }, display_debug_not_supported, NULL, FALSE }, + { { ".debug_static_vars", ".zdebug_static_vars", NO_ABBREVS }, display_debug_not_supported, NULL, FALSE }, + { { ".debug_types", ".zdebug_types", ABBREV (abbrev) }, display_debug_types, &do_debug_info, TRUE }, + { { ".debug_weaknames", ".zdebug_weaknames", NO_ABBREVS }, display_debug_not_supported, NULL, FALSE }, + { { ".gdb_index", "", NO_ABBREVS }, display_gdb_index, &do_gdb_index, FALSE }, + { { ".debug_names", "", NO_ABBREVS }, display_debug_names, &do_gdb_index, FALSE }, + { { ".trace_info", "", ABBREV (trace_abbrev) }, display_trace_info, &do_trace_info, TRUE }, + { { ".trace_abbrev", "", NO_ABBREVS }, display_debug_abbrev, &do_trace_abbrevs, FALSE }, + { { ".trace_aranges", "", NO_ABBREVS }, display_debug_aranges, &do_trace_aranges, FALSE }, + { { ".debug_info.dwo", ".zdebug_info.dwo", ABBREV (abbrev_dwo) }, display_debug_info, &do_debug_info, TRUE }, + { { ".debug_abbrev.dwo", ".zdebug_abbrev.dwo", NO_ABBREVS }, display_debug_abbrev, &do_debug_abbrevs, FALSE }, + { { ".debug_types.dwo", ".zdebug_types.dwo", ABBREV (abbrev_dwo) }, display_debug_types, &do_debug_info, TRUE }, + { { ".debug_line.dwo", ".zdebug_line.dwo", NO_ABBREVS }, display_debug_lines, &do_debug_lines, TRUE }, + { { ".debug_loc.dwo", ".zdebug_loc.dwo", NO_ABBREVS }, display_debug_loc, &do_debug_loc, TRUE }, + { { ".debug_macro.dwo", ".zdebug_macro.dwo", NO_ABBREVS }, display_debug_macro, &do_debug_macinfo, TRUE }, + { { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo", NO_ABBREVS }, display_debug_macinfo, &do_debug_macinfo, FALSE }, + { { ".debug_str.dwo", ".zdebug_str.dwo", NO_ABBREVS }, display_debug_str, &do_debug_str, TRUE }, + { { ".debug_str_offsets", ".zdebug_str_offsets", NO_ABBREVS }, display_debug_str_offsets, NULL, FALSE }, + { { ".debug_str_offsets.dwo", ".zdebug_str_offsets.dwo", NO_ABBREVS }, display_debug_str_offsets, NULL, FALSE }, + { { ".debug_addr", ".zdebug_addr", NO_ABBREVS }, display_debug_addr, &do_debug_addr, TRUE }, + { { ".debug_cu_index", "", NO_ABBREVS }, display_cu_index, &do_debug_cu_index, FALSE }, + { { ".debug_tu_index", "", NO_ABBREVS }, display_cu_index, &do_debug_cu_index, FALSE }, + { { ".gnu_debuglink", "", NO_ABBREVS }, display_debug_links, &do_debug_links, FALSE }, + { { ".gnu_debugaltlink", "", NO_ABBREVS }, display_debug_links, &do_debug_links, FALSE }, + /* Separate debug info files can containt their own .debug_str section, + and this might be in *addition* to a .debug_str section already present + in the main file. Hence we need to have two entries for .debug_str. */ + { { ".debug_str", ".zdebug_str", NO_ABBREVS }, display_debug_str, &do_debug_str, FALSE }, +}; + +/* A static assertion. */ +extern int debug_displays_assert[ARRAY_SIZE (debug_displays) == max ? 1 : -1]; diff --git a/support/sdbinutils/binutils/dwarf.h b/support/sdbinutils/binutils/dwarf.h new file mode 100644 index 0000000..7f7c79d --- /dev/null +++ b/support/sdbinutils/binutils/dwarf.h @@ -0,0 +1,249 @@ +/* dwarf.h - DWARF support header file + Copyright (C) 2005-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "dwarf2.h" /* for enum dwarf_unit_type */ + +typedef unsigned HOST_WIDEST_INT dwarf_vma; +typedef HOST_WIDEST_INT dwarf_signed_vma; +typedef unsigned HOST_WIDEST_INT dwarf_size_type; + +/* Structure found in the .debug_line section. */ +typedef struct +{ + dwarf_vma li_length; + unsigned short li_version; + dwarf_vma li_prologue_length; + unsigned char li_min_insn_length; + unsigned char li_max_ops_per_insn; + unsigned char li_default_is_stmt; + int li_line_base; + unsigned char li_line_range; + unsigned char li_opcode_base; + unsigned int li_offset_size; +} +DWARF2_Internal_LineInfo; + +/* Structure found in .debug_pubnames section. */ +typedef struct +{ + dwarf_vma pn_length; + unsigned short pn_version; + dwarf_vma pn_offset; + dwarf_vma pn_size; +} +DWARF2_Internal_PubNames; + +/* Structure found in .debug_info section. */ +typedef struct +{ + dwarf_vma cu_length; + unsigned short cu_version; + dwarf_vma cu_abbrev_offset; + unsigned char cu_pointer_size; + enum dwarf_unit_type cu_unit_type; +} +DWARF2_Internal_CompUnit; + +/* Structure found in .debug_aranges section. */ +typedef struct +{ + dwarf_vma ar_length; + unsigned short ar_version; + dwarf_vma ar_info_offset; + unsigned char ar_pointer_size; + unsigned char ar_segment_size; +} +DWARF2_Internal_ARange; + +/* N.B. The order here must match the order in debug_displays. */ + +enum dwarf_section_display_enum +{ + abbrev = 0, + aranges, + frame, + info, + line, + pubnames, + gnu_pubnames, + eh_frame, + macinfo, + macro, + str, + line_str, + loc, + loclists, + pubtypes, + gnu_pubtypes, + ranges, + rnglists, + static_func, + static_vars, + types, + weaknames, + gdb_index, + debug_names, + trace_info, + trace_abbrev, + trace_aranges, + info_dwo, + abbrev_dwo, + types_dwo, + line_dwo, + loc_dwo, + macro_dwo, + macinfo_dwo, + str_dwo, + str_index, + str_index_dwo, + debug_addr, + dwp_cu_index, + dwp_tu_index, + gnu_debuglink, + gnu_debugaltlink, + separate_debug_str, + max +}; + +struct dwarf_section +{ + /* A debug section has a different name when it's stored compressed + or not. COMPRESSED_NAME and UNCOMPRESSED_NAME are the two + possibilities. NAME is set to whichever one is used for this + input file, as determined by load_debug_section(). */ + const char * uncompressed_name; + const char * compressed_name; + const char * name; + /* If non-NULL then FILENAME is the name of the separate debug info + file containing the section. */ + const char * filename; + unsigned char * start; + dwarf_vma address; + dwarf_size_type size; + enum dwarf_section_display_enum abbrev_sec; + /* Used by clients to help them implement the reloc_at callback. */ + void * reloc_info; + unsigned long num_relocs; + /* A spare field for random use. */ + void * user_data; +}; + +/* A structure containing the name of a debug section + and a pointer to a function that can decode it. */ +struct dwarf_section_display +{ + struct dwarf_section section; + int (* display) (struct dwarf_section *, void *); + int * enabled; + bfd_boolean relocate; +}; + +extern struct dwarf_section_display debug_displays []; + +/* This structure records the information that + we extract from the.debug_info section. */ +typedef struct +{ + unsigned int pointer_size; + unsigned int offset_size; + int dwarf_version; + dwarf_vma cu_offset; + dwarf_vma base_address; + /* This field is filled in when reading the attribute DW_AT_GNU_addr_base and + is used with the form DW_AT_GNU_FORM_addr_index. */ + dwarf_vma addr_base; + /* This field is filled in when reading the attribute DW_AT_GNU_ranges_base and + is used when calculating ranges. */ + dwarf_vma ranges_base; + /* This is an array of offsets to the location list table. */ + dwarf_vma * loc_offsets; + /* This is an array of offsets to the location view table. */ + dwarf_vma * loc_views; + int * have_frame_base; + unsigned int num_loc_offsets; + unsigned int max_loc_offsets; + unsigned int num_loc_views; + /* List of .debug_ranges offsets seen in this .debug_info. */ + dwarf_vma * range_lists; + unsigned int num_range_lists; + unsigned int max_range_lists; +} +debug_info; + +extern unsigned int eh_addr_size; + +extern int do_debug_info; +extern int do_debug_abbrevs; +extern int do_debug_lines; +extern int do_debug_pubnames; +extern int do_debug_pubtypes; +extern int do_debug_aranges; +extern int do_debug_ranges; +extern int do_debug_frames; +extern int do_debug_frames_interp; +extern int do_debug_macinfo; +extern int do_debug_str; +extern int do_debug_loc; +extern int do_gdb_index; +extern int do_trace_info; +extern int do_trace_abbrevs; +extern int do_trace_aranges; +extern int do_debug_addr; +extern int do_debug_cu_index; +extern int do_wide; +extern int do_debug_links; + +extern int dwarf_cutoff_level; +extern unsigned long dwarf_start_die; + +extern int dwarf_check; + +extern void init_dwarf_regnames (unsigned int); +extern void init_dwarf_regnames_i386 (void); +extern void init_dwarf_regnames_iamcu (void); +extern void init_dwarf_regnames_x86_64 (void); +extern void init_dwarf_regnames_aarch64 (void); +extern void init_dwarf_regnames_s390 (void); + +extern bfd_boolean load_debug_section (enum dwarf_section_display_enum, void *); +extern void free_debug_section (enum dwarf_section_display_enum); +extern void * load_separate_debug_file (void *, const char *); +extern void close_debug_file (void *); +extern void * open_debug_file (const char *); + +extern void free_debug_memory (void); + +extern void dwarf_select_sections_by_names (const char *); +extern void dwarf_select_sections_by_letters (const char *); +extern void dwarf_select_sections_all (void); + +extern unsigned int * find_cu_tu_set (void *, unsigned int); + +extern void * cmalloc (size_t, size_t); +extern void * xcalloc2 (size_t, size_t); +extern void * xcmalloc (size_t, size_t); +extern void * xcrealloc (void *, size_t, size_t); + +extern dwarf_vma read_leb128 (unsigned char *, unsigned int *, bfd_boolean, const unsigned char * const); + +/* A callback into the client. Returns TRUE if there is a + relocation against the given debug section at the given + offset. */ +extern bfd_boolean reloc_at (struct dwarf_section *, dwarf_vma); diff --git a/support/sdbinutils/binutils/elfcomm.c b/support/sdbinutils/binutils/elfcomm.c new file mode 100644 index 0000000..3fcd79e --- /dev/null +++ b/support/sdbinutils/binutils/elfcomm.c @@ -0,0 +1,929 @@ +/* elfcomm.c -- common code for ELF format file. + Copyright (C) 2010-2018 Free Software Foundation, Inc. + + Originally developed by Eric Youngdale + Modifications by Nick Clifton + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "sysdep.h" +#include "libiberty.h" +#include "filenames.h" +#include "bfd.h" +#include "aout/ar.h" +#include "bucomm.h" +#include "elfcomm.h" +#include + +void +error (const char *message, ...) +{ + va_list args; + + /* Try to keep error messages in sync with the program's normal output. */ + fflush (stdout); + + va_start (args, message); + fprintf (stderr, _("%s: Error: "), program_name); + vfprintf (stderr, message, args); + va_end (args); +} + +void +warn (const char *message, ...) +{ + va_list args; + + /* Try to keep warning messages in sync with the program's normal output. */ + fflush (stdout); + + va_start (args, message); + fprintf (stderr, _("%s: Warning: "), program_name); + vfprintf (stderr, message, args); + va_end (args); +} + +void (*byte_put) (unsigned char *, elf_vma, int); + +void +byte_put_little_endian (unsigned char * field, elf_vma value, int size) +{ + switch (size) + { + case 8: + field[7] = (((value >> 24) >> 24) >> 8) & 0xff; + field[6] = ((value >> 24) >> 24) & 0xff; + field[5] = ((value >> 24) >> 16) & 0xff; + field[4] = ((value >> 24) >> 8) & 0xff; + /* Fall through. */ + case 4: + field[3] = (value >> 24) & 0xff; + /* Fall through. */ + case 3: + field[2] = (value >> 16) & 0xff; + /* Fall through. */ + case 2: + field[1] = (value >> 8) & 0xff; + /* Fall through. */ + case 1: + field[0] = value & 0xff; + break; + + default: + error (_("Unhandled data length: %d\n"), size); + abort (); + } +} + +void +byte_put_big_endian (unsigned char * field, elf_vma value, int size) +{ + switch (size) + { + case 8: + field[7] = value & 0xff; + field[6] = (value >> 8) & 0xff; + field[5] = (value >> 16) & 0xff; + field[4] = (value >> 24) & 0xff; + value >>= 16; + value >>= 16; + /* Fall through. */ + case 4: + field[3] = value & 0xff; + value >>= 8; + /* Fall through. */ + case 3: + field[2] = value & 0xff; + value >>= 8; + /* Fall through. */ + case 2: + field[1] = value & 0xff; + value >>= 8; + /* Fall through. */ + case 1: + field[0] = value & 0xff; + break; + + default: + error (_("Unhandled data length: %d\n"), size); + abort (); + } +} + +elf_vma (*byte_get) (const unsigned char *, int); + +elf_vma +byte_get_little_endian (const unsigned char *field, int size) +{ + switch (size) + { + case 1: + return *field; + + case 2: + return ((unsigned int) (field[0])) + | (((unsigned int) (field[1])) << 8); + + case 3: + return ((unsigned long) (field[0])) + | (((unsigned long) (field[1])) << 8) + | (((unsigned long) (field[2])) << 16); + + case 4: + return ((unsigned long) (field[0])) + | (((unsigned long) (field[1])) << 8) + | (((unsigned long) (field[2])) << 16) + | (((unsigned long) (field[3])) << 24); + + case 5: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[0])) + | (((elf_vma) (field[1])) << 8) + | (((elf_vma) (field[2])) << 16) + | (((elf_vma) (field[3])) << 24) + | (((elf_vma) (field[4])) << 32); + else if (sizeof (elf_vma) == 4) + /* We want to extract data from an 8 byte wide field and + place it into a 4 byte wide field. Since this is a little + endian source we can just use the 4 byte extraction code. */ + return ((unsigned long) (field[0])) + | (((unsigned long) (field[1])) << 8) + | (((unsigned long) (field[2])) << 16) + | (((unsigned long) (field[3])) << 24); + /* Fall through. */ + + case 6: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[0])) + | (((elf_vma) (field[1])) << 8) + | (((elf_vma) (field[2])) << 16) + | (((elf_vma) (field[3])) << 24) + | (((elf_vma) (field[4])) << 32) + | (((elf_vma) (field[5])) << 40); + else if (sizeof (elf_vma) == 4) + /* We want to extract data from an 8 byte wide field and + place it into a 4 byte wide field. Since this is a little + endian source we can just use the 4 byte extraction code. */ + return ((unsigned long) (field[0])) + | (((unsigned long) (field[1])) << 8) + | (((unsigned long) (field[2])) << 16) + | (((unsigned long) (field[3])) << 24); + /* Fall through. */ + + case 7: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[0])) + | (((elf_vma) (field[1])) << 8) + | (((elf_vma) (field[2])) << 16) + | (((elf_vma) (field[3])) << 24) + | (((elf_vma) (field[4])) << 32) + | (((elf_vma) (field[5])) << 40) + | (((elf_vma) (field[6])) << 48); + else if (sizeof (elf_vma) == 4) + /* We want to extract data from an 8 byte wide field and + place it into a 4 byte wide field. Since this is a little + endian source we can just use the 4 byte extraction code. */ + return ((unsigned long) (field[0])) + | (((unsigned long) (field[1])) << 8) + | (((unsigned long) (field[2])) << 16) + | (((unsigned long) (field[3])) << 24); + /* Fall through. */ + + case 8: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[0])) + | (((elf_vma) (field[1])) << 8) + | (((elf_vma) (field[2])) << 16) + | (((elf_vma) (field[3])) << 24) + | (((elf_vma) (field[4])) << 32) + | (((elf_vma) (field[5])) << 40) + | (((elf_vma) (field[6])) << 48) + | (((elf_vma) (field[7])) << 56); + else if (sizeof (elf_vma) == 4) + /* We want to extract data from an 8 byte wide field and + place it into a 4 byte wide field. Since this is a little + endian source we can just use the 4 byte extraction code. */ + return ((unsigned long) (field[0])) + | (((unsigned long) (field[1])) << 8) + | (((unsigned long) (field[2])) << 16) + | (((unsigned long) (field[3])) << 24); + /* Fall through. */ + + default: + error (_("Unhandled data length: %d\n"), size); + abort (); + } +} + +elf_vma +byte_get_big_endian (const unsigned char *field, int size) +{ + switch (size) + { + case 1: + return *field; + + case 2: + return ((unsigned int) (field[1])) | (((int) (field[0])) << 8); + + case 3: + return ((unsigned long) (field[2])) + | (((unsigned long) (field[1])) << 8) + | (((unsigned long) (field[0])) << 16); + + case 4: + return ((unsigned long) (field[3])) + | (((unsigned long) (field[2])) << 8) + | (((unsigned long) (field[1])) << 16) + | (((unsigned long) (field[0])) << 24); + + case 5: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[4])) + | (((elf_vma) (field[3])) << 8) + | (((elf_vma) (field[2])) << 16) + | (((elf_vma) (field[1])) << 24) + | (((elf_vma) (field[0])) << 32); + else if (sizeof (elf_vma) == 4) + { + /* Although we are extracting data from an 8 byte wide field, + we are returning only 4 bytes of data. */ + field += 1; + return ((unsigned long) (field[3])) + | (((unsigned long) (field[2])) << 8) + | (((unsigned long) (field[1])) << 16) + | (((unsigned long) (field[0])) << 24); + } + /* Fall through. */ + + case 6: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[5])) + | (((elf_vma) (field[4])) << 8) + | (((elf_vma) (field[3])) << 16) + | (((elf_vma) (field[2])) << 24) + | (((elf_vma) (field[1])) << 32) + | (((elf_vma) (field[0])) << 40); + else if (sizeof (elf_vma) == 4) + { + /* Although we are extracting data from an 8 byte wide field, + we are returning only 4 bytes of data. */ + field += 2; + return ((unsigned long) (field[3])) + | (((unsigned long) (field[2])) << 8) + | (((unsigned long) (field[1])) << 16) + | (((unsigned long) (field[0])) << 24); + } + /* Fall through. */ + + case 7: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[6])) + | (((elf_vma) (field[5])) << 8) + | (((elf_vma) (field[4])) << 16) + | (((elf_vma) (field[3])) << 24) + | (((elf_vma) (field[2])) << 32) + | (((elf_vma) (field[1])) << 40) + | (((elf_vma) (field[0])) << 48); + else if (sizeof (elf_vma) == 4) + { + /* Although we are extracting data from an 8 byte wide field, + we are returning only 4 bytes of data. */ + field += 3; + return ((unsigned long) (field[3])) + | (((unsigned long) (field[2])) << 8) + | (((unsigned long) (field[1])) << 16) + | (((unsigned long) (field[0])) << 24); + } + /* Fall through. */ + + case 8: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[7])) + | (((elf_vma) (field[6])) << 8) + | (((elf_vma) (field[5])) << 16) + | (((elf_vma) (field[4])) << 24) + | (((elf_vma) (field[3])) << 32) + | (((elf_vma) (field[2])) << 40) + | (((elf_vma) (field[1])) << 48) + | (((elf_vma) (field[0])) << 56); + else if (sizeof (elf_vma) == 4) + { + /* Although we are extracting data from an 8 byte wide field, + we are returning only 4 bytes of data. */ + field += 4; + return ((unsigned long) (field[3])) + | (((unsigned long) (field[2])) << 8) + | (((unsigned long) (field[1])) << 16) + | (((unsigned long) (field[0])) << 24); + } + /* Fall through. */ + + default: + error (_("Unhandled data length: %d\n"), size); + abort (); + } +} + +elf_vma +byte_get_signed (const unsigned char *field, int size) +{ + elf_vma x = byte_get (field, size); + + switch (size) + { + case 1: + return (x ^ 0x80) - 0x80; + case 2: + return (x ^ 0x8000) - 0x8000; + case 3: + return (x ^ 0x800000) - 0x800000; + case 4: + return (x ^ 0x80000000) - 0x80000000; + case 5: + case 6: + case 7: + case 8: + /* Reads of 5-, 6-, and 7-byte numbers are the result of + trying to read past the end of a buffer, and will therefore + not have meaningful values, so we don't try to deal with + the sign in these cases. */ + return x; + default: + abort (); + } +} + +/* Return the high-order 32-bits and the low-order 32-bits + of an 8-byte value separately. */ + +void +byte_get_64 (const unsigned char *field, elf_vma *high, elf_vma *low) +{ + if (byte_get == byte_get_big_endian) + { + *high = byte_get_big_endian (field, 4); + *low = byte_get_big_endian (field + 4, 4); + } + else + { + *high = byte_get_little_endian (field + 4, 4); + *low = byte_get_little_endian (field, 4); + } + return; +} + +/* Return the path name for a proxy entry in a thin archive, adjusted + relative to the path name of the thin archive itself if necessary. + Always returns a pointer to malloc'ed memory. */ + +char * +adjust_relative_path (const char *file_name, const char *name, + unsigned long name_len) +{ + char * member_file_name; + const char * base_name = lbasename (file_name); + size_t amt; + + /* This is a proxy entry for a thin archive member. + If the extended name table contains an absolute path + name, or if the archive is in the current directory, + use the path name as given. Otherwise, we need to + find the member relative to the directory where the + archive is located. */ + if (IS_ABSOLUTE_PATH (name) || base_name == file_name) + { + amt = name_len + 1; + if (amt == 0) + return NULL; + member_file_name = (char *) malloc (amt); + if (member_file_name == NULL) + { + error (_("Out of memory\n")); + return NULL; + } + memcpy (member_file_name, name, name_len); + member_file_name[name_len] = '\0'; + } + else + { + /* Concatenate the path components of the archive file name + to the relative path name from the extended name table. */ + size_t prefix_len = base_name - file_name; + + amt = prefix_len + name_len + 1; + /* PR 17531: file: 2896dc8b + Catch wraparound. */ + if (amt < prefix_len || amt < name_len) + { + error (_("Abnormal length of thin archive member name: %lx\n"), + name_len); + return NULL; + } + + member_file_name = (char *) malloc (amt); + if (member_file_name == NULL) + { + error (_("Out of memory\n")); + return NULL; + } + memcpy (member_file_name, file_name, prefix_len); + memcpy (member_file_name + prefix_len, name, name_len); + member_file_name[prefix_len + name_len] = '\0'; + } + return member_file_name; +} + +/* Processes the archive index table and symbol table in ARCH. + Entries in the index table are SIZEOF_AR_INDEX bytes long. + Fills in ARCH->next_arhdr_offset and ARCH->arhdr. + If READ_SYMBOLS is true then fills in ARCH->index_num, ARCH->index_array, + ARCH->sym_size and ARCH->sym_table. + It is the caller's responsibility to free ARCH->index_array and + ARCH->sym_table. + Returns TRUE upon success, FALSE otherwise. + If failure occurs an error message is printed. */ + +static bfd_boolean +process_archive_index_and_symbols (struct archive_info * arch, + unsigned int sizeof_ar_index, + bfd_boolean read_symbols) +{ + size_t got; + unsigned long size; + char fmag_save; + + fmag_save = arch->arhdr.ar_fmag[0]; + arch->arhdr.ar_fmag[0] = 0; + size = strtoul (arch->arhdr.ar_size, NULL, 10); + arch->arhdr.ar_fmag[0] = fmag_save; + /* PR 17531: file: 912bd7de. */ + if ((signed long) size < 0) + { + error (_("%s: invalid archive header size: %ld\n"), + arch->file_name, size); + return FALSE; + } + + size = size + (size & 1); + + arch->next_arhdr_offset += sizeof arch->arhdr + size; + + if (! read_symbols) + { + if (fseek (arch->file, size, SEEK_CUR) != 0) + { + error (_("%s: failed to skip archive symbol table\n"), + arch->file_name); + return FALSE; + } + } + else + { + unsigned long i; + /* A buffer used to hold numbers read in from an archive index. + These are always SIZEOF_AR_INDEX bytes long and stored in + big-endian format. */ + unsigned char integer_buffer[sizeof arch->index_num]; + unsigned char * index_buffer; + + assert (sizeof_ar_index <= sizeof integer_buffer); + + /* Check the size of the archive index. */ + if (size < sizeof_ar_index) + { + error (_("%s: the archive index is empty\n"), arch->file_name); + return FALSE; + } + + /* Read the number of entries in the archive index. */ + got = fread (integer_buffer, 1, sizeof_ar_index, arch->file); + if (got != sizeof_ar_index) + { + error (_("%s: failed to read archive index\n"), arch->file_name); + return FALSE; + } + + arch->index_num = byte_get_big_endian (integer_buffer, sizeof_ar_index); + size -= sizeof_ar_index; + + if (size < arch->index_num * sizeof_ar_index + /* PR 17531: file: 585515d1. */ + || size < arch->index_num) + { + error (_("%s: the archive index is supposed to have 0x%lx entries of %d bytes, but the size is only 0x%lx\n"), + arch->file_name, (long) arch->index_num, sizeof_ar_index, size); + return FALSE; + } + + /* Read in the archive index. */ + index_buffer = (unsigned char *) + malloc (arch->index_num * sizeof_ar_index); + if (index_buffer == NULL) + { + error (_("Out of memory whilst trying to read archive symbol index\n")); + return FALSE; + } + + got = fread (index_buffer, sizeof_ar_index, arch->index_num, arch->file); + if (got != arch->index_num) + { + free (index_buffer); + error (_("%s: failed to read archive index\n"), arch->file_name); + return FALSE; + } + + size -= arch->index_num * sizeof_ar_index; + + /* Convert the index numbers into the host's numeric format. */ + arch->index_array = (elf_vma *) + malloc (arch->index_num * sizeof (* arch->index_array)); + if (arch->index_array == NULL) + { + free (index_buffer); + error (_("Out of memory whilst trying to convert the archive symbol index\n")); + return FALSE; + } + + for (i = 0; i < arch->index_num; i++) + arch->index_array[i] = + byte_get_big_endian ((unsigned char *) (index_buffer + (i * sizeof_ar_index)), + sizeof_ar_index); + free (index_buffer); + + /* The remaining space in the header is taken up by the symbol table. */ + if (size < 1) + { + error (_("%s: the archive has an index but no symbols\n"), + arch->file_name); + return FALSE; + } + + arch->sym_table = (char *) malloc (size); + if (arch->sym_table == NULL) + { + error (_("Out of memory whilst trying to read archive index symbol table\n")); + return FALSE; + } + + arch->sym_size = size; + got = fread (arch->sym_table, 1, size, arch->file); + if (got != size) + { + error (_("%s: failed to read archive index symbol table\n"), + arch->file_name); + return FALSE; + } + } + + /* Read the next archive header. */ + got = fread (&arch->arhdr, 1, sizeof arch->arhdr, arch->file); + if (got != sizeof arch->arhdr && got != 0) + { + error (_("%s: failed to read archive header following archive index\n"), + arch->file_name); + return FALSE; + } + + return TRUE; +} + +/* Read the symbol table and long-name table from an archive. */ + +int +setup_archive (struct archive_info *arch, const char *file_name, + FILE *file, bfd_boolean is_thin_archive, + bfd_boolean read_symbols) +{ + size_t got; + + arch->file_name = strdup (file_name); + arch->file = file; + arch->index_num = 0; + arch->index_array = NULL; + arch->sym_table = NULL; + arch->sym_size = 0; + arch->longnames = NULL; + arch->longnames_size = 0; + arch->nested_member_origin = 0; + arch->is_thin_archive = is_thin_archive; + arch->uses_64bit_indicies = FALSE; + arch->next_arhdr_offset = SARMAG; + + /* Read the first archive member header. */ + if (fseek (file, SARMAG, SEEK_SET) != 0) + { + error (_("%s: failed to seek to first archive header\n"), file_name); + return 1; + } + got = fread (&arch->arhdr, 1, sizeof arch->arhdr, file); + if (got != sizeof arch->arhdr) + { + if (got == 0) + return 0; + + error (_("%s: failed to read archive header\n"), file_name); + return 1; + } + + /* See if this is the archive symbol table. */ + if (const_strneq (arch->arhdr.ar_name, "/ ")) + { + if (! process_archive_index_and_symbols (arch, 4, read_symbols)) + return 1; + } + else if (const_strneq (arch->arhdr.ar_name, "/SYM64/ ")) + { + arch->uses_64bit_indicies = TRUE; + if (! process_archive_index_and_symbols (arch, 8, read_symbols)) + return 1; + } + else if (read_symbols) + printf (_("%s has no archive index\n"), file_name); + + if (const_strneq (arch->arhdr.ar_name, "// ")) + { + /* This is the archive string table holding long member names. */ + char fmag_save = arch->arhdr.ar_fmag[0]; + arch->arhdr.ar_fmag[0] = 0; + arch->longnames_size = strtoul (arch->arhdr.ar_size, NULL, 10); + arch->arhdr.ar_fmag[0] = fmag_save; + /* PR 17531: file: 01068045. */ + if (arch->longnames_size < 8) + { + error (_("%s: long name table is too small, (size = %ld)\n"), + file_name, arch->longnames_size); + return 1; + } + /* PR 17531: file: 639d6a26. */ + if ((signed long) arch->longnames_size < 0) + { + error (_("%s: long name table is too big, (size = 0x%lx)\n"), + file_name, arch->longnames_size); + return 1; + } + + arch->next_arhdr_offset += sizeof arch->arhdr + arch->longnames_size; + + /* Plus one to allow for a string terminator. */ + arch->longnames = (char *) malloc (arch->longnames_size + 1); + if (arch->longnames == NULL) + { + error (_("Out of memory reading long symbol names in archive\n")); + return 1; + } + + if (fread (arch->longnames, arch->longnames_size, 1, file) != 1) + { + free (arch->longnames); + arch->longnames = NULL; + error (_("%s: failed to read long symbol name string table\n"), + file_name); + return 1; + } + + if ((arch->longnames_size & 1) != 0) + getc (file); + + arch->longnames[arch->longnames_size] = 0; + } + + return 0; +} + +/* Open and setup a nested archive, if not already open. */ + +int +setup_nested_archive (struct archive_info *nested_arch, + const char *member_file_name) +{ + FILE * member_file; + + /* Have we already setup this archive? */ + if (nested_arch->file_name != NULL + && streq (nested_arch->file_name, member_file_name)) + return 0; + + /* Close previous file and discard cached information. */ + if (nested_arch->file != NULL) + fclose (nested_arch->file); + release_archive (nested_arch); + + member_file = fopen (member_file_name, "rb"); + if (member_file == NULL) + return 1; + return setup_archive (nested_arch, member_file_name, member_file, + FALSE, FALSE); +} + +/* Release the memory used for the archive information. */ + +void +release_archive (struct archive_info * arch) +{ + if (arch->file_name != NULL) + free (arch->file_name); + if (arch->index_array != NULL) + free (arch->index_array); + if (arch->sym_table != NULL) + free (arch->sym_table); + if (arch->longnames != NULL) + free (arch->longnames); +} + +/* Get the name of an archive member from the current archive header. + For simple names, this will modify the ar_name field of the current + archive header. For long names, it will return a pointer to the + longnames table. For nested archives, it will open the nested archive + and get the name recursively. NESTED_ARCH is a single-entry cache so + we don't keep rereading the same information from a nested archive. */ + +char * +get_archive_member_name (struct archive_info *arch, + struct archive_info *nested_arch) +{ + unsigned long j, k; + + if (arch->arhdr.ar_name[0] == '/') + { + /* We have a long name. */ + char *endp; + char *member_file_name; + char *member_name; + char fmag_save; + + if (arch->longnames == NULL || arch->longnames_size == 0) + { + error (_("Archive member uses long names, but no longname table found\n")); + return NULL; + } + + arch->nested_member_origin = 0; + fmag_save = arch->arhdr.ar_fmag[0]; + arch->arhdr.ar_fmag[0] = 0; + k = j = strtoul (arch->arhdr.ar_name + 1, &endp, 10); + if (arch->is_thin_archive && endp != NULL && * endp == ':') + arch->nested_member_origin = strtoul (endp + 1, NULL, 10); + arch->arhdr.ar_fmag[0] = fmag_save; + + if (j > arch->longnames_size) + { + error (_("Found long name index (%ld) beyond end of long name table\n"),j); + return NULL; + } + while ((j < arch->longnames_size) + && (arch->longnames[j] != '\n') + && (arch->longnames[j] != '\0')) + j++; + if (j > 0 && arch->longnames[j-1] == '/') + j--; + if (j > arch->longnames_size) + j = arch->longnames_size; + arch->longnames[j] = '\0'; + + if (!arch->is_thin_archive || arch->nested_member_origin == 0) + return arch->longnames + k; + + /* PR 17531: file: 2896dc8b. */ + if (k >= j) + { + error (_("Invalid Thin archive member name\n")); + return NULL; + } + + /* This is a proxy for a member of a nested archive. + Find the name of the member in that archive. */ + member_file_name = adjust_relative_path (arch->file_name, + arch->longnames + k, j - k); + if (member_file_name != NULL + && setup_nested_archive (nested_arch, member_file_name) == 0) + { + member_name = get_archive_member_name_at (nested_arch, + arch->nested_member_origin, + NULL); + if (member_name != NULL) + { + free (member_file_name); + return member_name; + } + } + free (member_file_name); + + /* Last resort: just return the name of the nested archive. */ + return arch->longnames + k; + } + + /* We have a normal (short) name. */ + for (j = 0; j < sizeof (arch->arhdr.ar_name); j++) + if (arch->arhdr.ar_name[j] == '/') + { + arch->arhdr.ar_name[j] = '\0'; + return arch->arhdr.ar_name; + } + + /* The full ar_name field is used. Don't rely on ar_date starting + with a zero byte. */ + { + char *name = xmalloc (sizeof (arch->arhdr.ar_name) + 1); + memcpy (name, arch->arhdr.ar_name, sizeof (arch->arhdr.ar_name)); + name[sizeof (arch->arhdr.ar_name)] = '\0'; + return name; + } +} + +/* Get the name of an archive member at a given OFFSET within an archive + ARCH. */ + +char * +get_archive_member_name_at (struct archive_info *arch, + unsigned long offset, + struct archive_info *nested_arch) +{ + size_t got; + + if (fseek (arch->file, offset, SEEK_SET) != 0) + { + error (_("%s: failed to seek to next file name\n"), arch->file_name); + return NULL; + } + got = fread (&arch->arhdr, 1, sizeof arch->arhdr, arch->file); + if (got != sizeof arch->arhdr) + { + error (_("%s: failed to read archive header\n"), arch->file_name); + return NULL; + } + if (memcmp (arch->arhdr.ar_fmag, ARFMAG, 2) != 0) + { + error (_("%s: did not find a valid archive header\n"), + arch->file_name); + return NULL; + } + + return get_archive_member_name (arch, nested_arch); +} + +/* Construct a string showing the name of the archive member, qualified + with the name of the containing archive file. For thin archives, we + use square brackets to denote the indirection. For nested archives, + we show the qualified name of the external member inside the square + brackets (e.g., "thin.a[normal.a(foo.o)]"). */ + +char * +make_qualified_name (struct archive_info * arch, + struct archive_info * nested_arch, + const char *member_name) +{ + const char * error_name = _(""); + size_t len; + char * name; + + len = strlen (arch->file_name) + strlen (member_name) + 3; + if (arch->is_thin_archive + && arch->nested_member_origin != 0) + { + /* PR 15140: Allow for corrupt thin archives. */ + if (nested_arch->file_name) + len += strlen (nested_arch->file_name) + 2; + else + len += strlen (error_name) + 2; + } + + name = (char *) malloc (len); + if (name == NULL) + { + error (_("Out of memory\n")); + return NULL; + } + + if (arch->is_thin_archive + && arch->nested_member_origin != 0) + { + if (nested_arch->file_name) + snprintf (name, len, "%s[%s(%s)]", arch->file_name, + nested_arch->file_name, member_name); + else + snprintf (name, len, "%s[%s(%s)]", arch->file_name, + error_name, member_name); + } + else if (arch->is_thin_archive) + snprintf (name, len, "%s[%s]", arch->file_name, member_name); + else + snprintf (name, len, "%s(%s)", arch->file_name, member_name); + + return name; +} diff --git a/support/sdbinutils/binutils/elfcomm.h b/support/sdbinutils/binutils/elfcomm.h new file mode 100644 index 0000000..8a08ebf --- /dev/null +++ b/support/sdbinutils/binutils/elfcomm.h @@ -0,0 +1,104 @@ +/* elfcomm.h -- include file of common code for ELF format file. + Copyright (C) 2010-2018 Free Software Foundation, Inc. + + Originally developed by Eric Youngdale + Modifications by Nick Clifton + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#ifndef _ELFCOMM_H +#define _ELFCOMM_H + +#include "aout/ar.h" + +void error (const char *, ...) ATTRIBUTE_PRINTF_1; +void warn (const char *, ...) ATTRIBUTE_PRINTF_1; + +typedef unsigned HOST_WIDEST_INT elf_vma; + +extern void (*byte_put) (unsigned char *, elf_vma, int); +extern void byte_put_little_endian (unsigned char *, elf_vma, int); +extern void byte_put_big_endian (unsigned char *, elf_vma, int); + +extern elf_vma (*byte_get) (const unsigned char *, int); +extern elf_vma byte_get_signed (const unsigned char *, int); +extern elf_vma byte_get_little_endian (const unsigned char *, int); +extern elf_vma byte_get_big_endian (const unsigned char *, int); +extern void byte_get_64 (const unsigned char *, elf_vma *, elf_vma *); + +#define BYTE_PUT(field, val) byte_put (field, val, sizeof (field)) +#define BYTE_GET(field) byte_get (field, sizeof (field)) +#define BYTE_GET_SIGNED(field) byte_get_signed (field, sizeof (field)) + +/* This is just a bit of syntatic sugar. */ +#define streq(a,b) (strcmp ((a), (b)) == 0) +#define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0) +#define const_strneq(a,b) (strncmp ((a), (b), sizeof (b) - 1) == 0) + +/* Structure to hold information about an archive file. */ + +struct archive_info +{ + char * file_name; /* Archive file name. */ + FILE * file; /* Open file descriptor. */ + elf_vma index_num; /* Number of symbols in table. */ + elf_vma * index_array; /* The array of member offsets. */ + char * sym_table; /* The symbol table. */ + unsigned long sym_size; /* Size of the symbol table. */ + char * longnames; /* The long file names table. */ + unsigned long longnames_size; /* Size of the long file names table. */ + unsigned long nested_member_origin; /* Origin in the nested archive of the current member. */ + unsigned long next_arhdr_offset; /* Offset of the next archive header. */ + bfd_boolean is_thin_archive; /* TRUE if this is a thin archive. */ + bfd_boolean uses_64bit_indicies; /* TRUE if the index table uses 64bit entries. */ + struct ar_hdr arhdr; /* Current archive header. */ +}; + +/* Return the path name for a proxy entry in a thin archive. */ +extern char *adjust_relative_path (const char *, const char *, unsigned long); + +/* Read the symbol table and long-name table from an archive. */ +extern int setup_archive (struct archive_info *, const char *, FILE *, + bfd_boolean, bfd_boolean); + +/* Open and setup a nested archive, if not already open. */ +extern int setup_nested_archive (struct archive_info *, const char *); + +/* Release the memory used for the archive information. */ +extern void release_archive (struct archive_info *); + +/* Get the name of an archive member from the current archive header. */ + +extern char *get_archive_member_name (struct archive_info *, + struct archive_info *); + +/* Get the name of an archive member at a given offset within an + archive. */ + +extern char *get_archive_member_name_at (struct archive_info *, + unsigned long, + struct archive_info *); + +/* Construct a string showing the name of the archive member, qualified + with the name of the containing archive file. */ + +extern char *make_qualified_name (struct archive_info *, + struct archive_info *, + const char *); + +#endif /* _ELFCOMM_H */ diff --git a/support/sdbinutils/binutils/elfedit.c b/support/sdbinutils/binutils/elfedit.c new file mode 100644 index 0000000..5ad846e --- /dev/null +++ b/support/sdbinutils/binutils/elfedit.c @@ -0,0 +1,767 @@ +/* elfedit.c -- Update the ELF header of an ELF format file + Copyright (C) 2010-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "sysdep.h" +#include + +#if __GNUC__ >= 2 +/* Define BFD64 here, even if our default architecture is 32 bit ELF + as this will allow us to read in and parse 64bit and 32bit ELF files. + Only do this if we believe that the compiler can support a 64 bit + data type. For now we only rely on GCC being able to do this. */ +#define BFD64 +#endif + +#include "bfd.h" +#include "elfcomm.h" +#include "bucomm.h" + +#include "elf/common.h" +#include "elf/external.h" +#include "elf/internal.h" + +#include "getopt.h" +#include "libiberty.h" +#include "safe-ctype.h" +#include "filenames.h" + +char * program_name = "elfedit"; +static long archive_file_offset; +static unsigned long archive_file_size; +static Elf_Internal_Ehdr elf_header; +static Elf32_External_Ehdr ehdr32; +static Elf64_External_Ehdr ehdr64; +static int input_elf_machine = -1; +static int output_elf_machine = -1; +static int input_elf_type = -1; +static int output_elf_type = -1; +static int input_elf_osabi = -1; +static int output_elf_osabi = -1; +enum elfclass + { + ELF_CLASS_UNKNOWN = -1, + ELF_CLASS_NONE = ELFCLASSNONE, + ELF_CLASS_32 = ELFCLASS32, + ELF_CLASS_64 = ELFCLASS64, + ELF_CLASS_BOTH + }; +static enum elfclass input_elf_class = ELF_CLASS_UNKNOWN; +static enum elfclass output_elf_class = ELF_CLASS_BOTH; + +/* Return ELF class for a machine type, MACH. */ + +static enum elfclass +elf_class (int mach) +{ + switch (mach) + { + case EM_386: + case EM_IAMCU: + return ELF_CLASS_32; + case EM_L1OM: + case EM_K1OM: + return ELF_CLASS_64; + case EM_X86_64: + case EM_NONE: + return ELF_CLASS_BOTH; + default: + return ELF_CLASS_BOTH; + } +} + +static int +update_elf_header (const char *file_name, FILE *file) +{ + int class, machine, type, status, osabi; + + if (elf_header.e_ident[EI_MAG0] != ELFMAG0 + || elf_header.e_ident[EI_MAG1] != ELFMAG1 + || elf_header.e_ident[EI_MAG2] != ELFMAG2 + || elf_header.e_ident[EI_MAG3] != ELFMAG3) + { + error + (_("%s: Not an ELF file - wrong magic bytes at the start\n"), + file_name); + return 0; + } + + if (elf_header.e_ident[EI_VERSION] != EV_CURRENT) + { + error + (_("%s: Unsupported EI_VERSION: %d is not %d\n"), + file_name, elf_header.e_ident[EI_VERSION], + EV_CURRENT); + return 0; + } + + /* Return if e_machine is the same as output_elf_machine. */ + if (output_elf_machine == elf_header.e_machine) + return 1; + + class = elf_header.e_ident[EI_CLASS]; + machine = elf_header.e_machine; + + /* Skip if class doesn't match. */ + if (input_elf_class == ELF_CLASS_UNKNOWN) + input_elf_class = elf_class (machine); + + if (input_elf_class != ELF_CLASS_BOTH + && (int) input_elf_class != class) + { + error + (_("%s: Unmatched input EI_CLASS: %d is not %d\n"), + file_name, class, input_elf_class); + return 0; + } + + if (output_elf_class != ELF_CLASS_BOTH + && (int) output_elf_class != class) + { + error + (_("%s: Unmatched output EI_CLASS: %d is not %d\n"), + file_name, class, output_elf_class); + return 0; + } + + /* Skip if e_machine doesn't match. */ + if (input_elf_machine != -1 && machine != input_elf_machine) + { + error + (_("%s: Unmatched e_machine: %d is not %d\n"), + file_name, machine, input_elf_machine); + return 0; + } + + type = elf_header.e_type; + + /* Skip if e_type doesn't match. */ + if (input_elf_type != -1 && type != input_elf_type) + { + error + (_("%s: Unmatched e_type: %d is not %d\n"), + file_name, type, input_elf_type); + return 0; + } + + osabi = elf_header.e_ident[EI_OSABI]; + + /* Skip if OSABI doesn't match. */ + if (input_elf_osabi != -1 && osabi != input_elf_osabi) + { + error + (_("%s: Unmatched EI_OSABI: %d is not %d\n"), + file_name, osabi, input_elf_osabi); + return 0; + } + + /* Update e_machine, e_type and EI_OSABI. */ + switch (class) + { + default: + /* We should never get here. */ + abort (); + break; + case ELFCLASS32: + if (output_elf_machine != -1) + BYTE_PUT (ehdr32.e_machine, output_elf_machine); + if (output_elf_type != -1) + BYTE_PUT (ehdr32.e_type, output_elf_type); + if (output_elf_osabi != -1) + ehdr32.e_ident[EI_OSABI] = output_elf_osabi; + status = fwrite (&ehdr32, sizeof (ehdr32), 1, file) == 1; + break; + case ELFCLASS64: + if (output_elf_machine != -1) + BYTE_PUT (ehdr64.e_machine, output_elf_machine); + if (output_elf_type != -1) + BYTE_PUT (ehdr64.e_type, output_elf_type); + if (output_elf_osabi != -1) + ehdr64.e_ident[EI_OSABI] = output_elf_osabi; + status = fwrite (&ehdr64, sizeof (ehdr64), 1, file) == 1; + break; + } + + if (status != 1) + error (_("%s: Failed to update ELF header: %s\n"), + file_name, strerror (errno)); + + return status; +} + +static int +get_file_header (FILE * file) +{ + /* Read in the identity array. */ + if (fread (elf_header.e_ident, EI_NIDENT, 1, file) != 1) + return 0; + + /* Determine how to read the rest of the header. */ + switch (elf_header.e_ident[EI_DATA]) + { + default: /* fall through */ + case ELFDATANONE: /* fall through */ + case ELFDATA2LSB: + byte_get = byte_get_little_endian; + byte_put = byte_put_little_endian; + break; + case ELFDATA2MSB: + byte_get = byte_get_big_endian; + byte_put = byte_put_big_endian; + break; + } + + /* Read in the rest of the header. For now we only support 32 bit + and 64 bit ELF files. */ + switch (elf_header.e_ident[EI_CLASS]) + { + default: + error (_("Unsupported EI_CLASS: %d\n"), + elf_header.e_ident[EI_CLASS]); + return 0; + + case ELFCLASS32: + if (fread (ehdr32.e_type, sizeof (ehdr32) - EI_NIDENT, + 1, file) != 1) + return 0; + + elf_header.e_type = BYTE_GET (ehdr32.e_type); + elf_header.e_machine = BYTE_GET (ehdr32.e_machine); + elf_header.e_version = BYTE_GET (ehdr32.e_version); + elf_header.e_entry = BYTE_GET (ehdr32.e_entry); + elf_header.e_phoff = BYTE_GET (ehdr32.e_phoff); + elf_header.e_shoff = BYTE_GET (ehdr32.e_shoff); + elf_header.e_flags = BYTE_GET (ehdr32.e_flags); + elf_header.e_ehsize = BYTE_GET (ehdr32.e_ehsize); + elf_header.e_phentsize = BYTE_GET (ehdr32.e_phentsize); + elf_header.e_phnum = BYTE_GET (ehdr32.e_phnum); + elf_header.e_shentsize = BYTE_GET (ehdr32.e_shentsize); + elf_header.e_shnum = BYTE_GET (ehdr32.e_shnum); + elf_header.e_shstrndx = BYTE_GET (ehdr32.e_shstrndx); + + memcpy (&ehdr32, &elf_header, EI_NIDENT); + break; + + case ELFCLASS64: + /* If we have been compiled with sizeof (bfd_vma) == 4, then + we will not be able to cope with the 64bit data found in + 64 ELF files. Detect this now and abort before we start + overwriting things. */ + if (sizeof (bfd_vma) < 8) + { + error (_("This executable has been built without support for a\n\ +64 bit data type and so it cannot process 64 bit ELF files.\n")); + return 0; + } + + if (fread (ehdr64.e_type, sizeof (ehdr64) - EI_NIDENT, + 1, file) != 1) + return 0; + + elf_header.e_type = BYTE_GET (ehdr64.e_type); + elf_header.e_machine = BYTE_GET (ehdr64.e_machine); + elf_header.e_version = BYTE_GET (ehdr64.e_version); + elf_header.e_entry = BYTE_GET (ehdr64.e_entry); + elf_header.e_phoff = BYTE_GET (ehdr64.e_phoff); + elf_header.e_shoff = BYTE_GET (ehdr64.e_shoff); + elf_header.e_flags = BYTE_GET (ehdr64.e_flags); + elf_header.e_ehsize = BYTE_GET (ehdr64.e_ehsize); + elf_header.e_phentsize = BYTE_GET (ehdr64.e_phentsize); + elf_header.e_phnum = BYTE_GET (ehdr64.e_phnum); + elf_header.e_shentsize = BYTE_GET (ehdr64.e_shentsize); + elf_header.e_shnum = BYTE_GET (ehdr64.e_shnum); + elf_header.e_shstrndx = BYTE_GET (ehdr64.e_shstrndx); + + memcpy (&ehdr64, &elf_header, EI_NIDENT); + break; + } + return 1; +} + +/* Process one ELF object file according to the command line options. + This file may actually be stored in an archive. The file is + positioned at the start of the ELF object. */ + +static int +process_object (const char *file_name, FILE *file) +{ + /* Rememeber where we are. */ + long offset = ftell (file); + + if (! get_file_header (file)) + { + error (_("%s: Failed to read ELF header\n"), file_name); + return 1; + } + + /* Go to the position of the ELF header. */ + if (fseek (file, offset, SEEK_SET) != 0) + { + error (_("%s: Failed to seek to ELF header\n"), file_name); + } + + if (! update_elf_header (file_name, file)) + return 1; + + return 0; +} + +/* Process an ELF archive. + On entry the file is positioned just after the ARMAG string. */ + +static int +process_archive (const char * file_name, FILE * file, + bfd_boolean is_thin_archive) +{ + struct archive_info arch; + struct archive_info nested_arch; + size_t got; + int ret; + + /* The ARCH structure is used to hold information about this archive. */ + arch.file_name = NULL; + arch.file = NULL; + arch.index_array = NULL; + arch.sym_table = NULL; + arch.longnames = NULL; + + /* The NESTED_ARCH structure is used as a single-item cache of information + about a nested archive (when members of a thin archive reside within + another regular archive file). */ + nested_arch.file_name = NULL; + nested_arch.file = NULL; + nested_arch.index_array = NULL; + nested_arch.sym_table = NULL; + nested_arch.longnames = NULL; + + if (setup_archive (&arch, file_name, file, is_thin_archive, FALSE) != 0) + { + ret = 1; + goto out; + } + + ret = 0; + + while (1) + { + char * name; + size_t namelen; + char * qualified_name; + + /* Read the next archive header. */ + if (fseek (file, arch.next_arhdr_offset, SEEK_SET) != 0) + { + error (_("%s: failed to seek to next archive header\n"), + file_name); + return 1; + } + got = fread (&arch.arhdr, 1, sizeof arch.arhdr, file); + if (got != sizeof arch.arhdr) + { + if (got == 0) + break; + error (_("%s: failed to read archive header\n"), + file_name); + ret = 1; + break; + } + if (memcmp (arch.arhdr.ar_fmag, ARFMAG, 2) != 0) + { + error (_("%s: did not find a valid archive header\n"), + arch.file_name); + ret = 1; + break; + } + + arch.next_arhdr_offset += sizeof arch.arhdr; + + archive_file_size = strtoul (arch.arhdr.ar_size, NULL, 10); + if (archive_file_size & 01) + ++archive_file_size; + + name = get_archive_member_name (&arch, &nested_arch); + if (name == NULL) + { + error (_("%s: bad archive file name\n"), file_name); + ret = 1; + break; + } + namelen = strlen (name); + + qualified_name = make_qualified_name (&arch, &nested_arch, name); + if (qualified_name == NULL) + { + error (_("%s: bad archive file name\n"), file_name); + ret = 1; + break; + } + + if (is_thin_archive && arch.nested_member_origin == 0) + { + /* This is a proxy for an external member of a thin archive. */ + FILE *member_file; + char *member_file_name = adjust_relative_path (file_name, + name, namelen); + if (member_file_name == NULL) + { + ret = 1; + break; + } + + member_file = fopen (member_file_name, "r+b"); + if (member_file == NULL) + { + error (_("Input file '%s' is not readable\n"), + member_file_name); + free (member_file_name); + ret = 1; + break; + } + + archive_file_offset = arch.nested_member_origin; + + ret |= process_object (qualified_name, member_file); + + fclose (member_file); + free (member_file_name); + } + else if (is_thin_archive) + { + /* This is a proxy for a member of a nested archive. */ + archive_file_offset = arch.nested_member_origin + sizeof arch.arhdr; + + /* The nested archive file will have been opened and setup by + get_archive_member_name. */ + if (fseek (nested_arch.file, archive_file_offset, + SEEK_SET) != 0) + { + error (_("%s: failed to seek to archive member\n"), + nested_arch.file_name); + ret = 1; + break; + } + + ret |= process_object (qualified_name, nested_arch.file); + } + else + { + archive_file_offset = arch.next_arhdr_offset; + arch.next_arhdr_offset += archive_file_size; + + ret |= process_object (qualified_name, file); + } + + free (qualified_name); + } + + out: + if (nested_arch.file != NULL) + fclose (nested_arch.file); + release_archive (&nested_arch); + release_archive (&arch); + + return ret; +} + +static int +check_file (const char *file_name, struct stat *statbuf_p) +{ + struct stat statbuf; + + if (statbuf_p == NULL) + statbuf_p = &statbuf; + + if (stat (file_name, statbuf_p) < 0) + { + if (errno == ENOENT) + error (_("'%s': No such file\n"), file_name); + else + error (_("Could not locate '%s'. System error message: %s\n"), + file_name, strerror (errno)); + return 1; + } + + if (! S_ISREG (statbuf_p->st_mode)) + { + error (_("'%s' is not an ordinary file\n"), file_name); + return 1; + } + + return 0; +} + +static int +process_file (const char *file_name) +{ + FILE * file; + char armag[SARMAG]; + int ret; + + if (check_file (file_name, NULL)) + return 1; + + file = fopen (file_name, "r+b"); + if (file == NULL) + { + error (_("Input file '%s' is not readable\n"), file_name); + return 1; + } + + if (fread (armag, SARMAG, 1, file) != 1) + { + error (_("%s: Failed to read file's magic number\n"), + file_name); + fclose (file); + return 1; + } + + if (memcmp (armag, ARMAG, SARMAG) == 0) + ret = process_archive (file_name, file, FALSE); + else if (memcmp (armag, ARMAGT, SARMAG) == 0) + ret = process_archive (file_name, file, TRUE); + else + { + rewind (file); + archive_file_size = archive_file_offset = 0; + ret = process_object (file_name, file); + } + + fclose (file); + + return ret; +} + +static const struct +{ + int osabi; + const char *name; +} +osabis[] = +{ + { ELFOSABI_NONE, "none" }, + { ELFOSABI_HPUX, "HPUX" }, + { ELFOSABI_NETBSD, "NetBSD" }, + { ELFOSABI_GNU, "GNU" }, + { ELFOSABI_GNU, "Linux" }, + { ELFOSABI_SOLARIS, "Solaris" }, + { ELFOSABI_AIX, "AIX" }, + { ELFOSABI_IRIX, "Irix" }, + { ELFOSABI_FREEBSD, "FreeBSD" }, + { ELFOSABI_TRU64, "TRU64" }, + { ELFOSABI_MODESTO, "Modesto" }, + { ELFOSABI_OPENBSD, "OpenBSD" }, + { ELFOSABI_OPENVMS, "OpenVMS" }, + { ELFOSABI_NSK, "NSK" }, + { ELFOSABI_AROS, "AROS" }, + { ELFOSABI_FENIXOS, "FenixOS" } +}; + +/* Return ELFOSABI_XXX for an OSABI string, OSABI. */ + +static int +elf_osabi (const char *osabi) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE (osabis); i++) + if (strcasecmp (osabi, osabis[i].name) == 0) + return osabis[i].osabi; + + error (_("Unknown OSABI: %s\n"), osabi); + + return -1; +} + +/* Return EM_XXX for a machine string, MACH. */ + +static int +elf_machine (const char *mach) +{ + if (strcasecmp (mach, "i386") == 0) + return EM_386; + if (strcasecmp (mach, "iamcu") == 0) + return EM_IAMCU; + if (strcasecmp (mach, "l1om") == 0) + return EM_L1OM; + if (strcasecmp (mach, "k1om") == 0) + return EM_K1OM; + if (strcasecmp (mach, "x86_64") == 0) + return EM_X86_64; + if (strcasecmp (mach, "x86-64") == 0) + return EM_X86_64; + if (strcasecmp (mach, "none") == 0) + return EM_NONE; + + error (_("Unknown machine type: %s\n"), mach); + + return -1; +} + +/* Return ET_XXX for a type string, TYPE. */ + +static int +elf_type (const char *type) +{ + if (strcasecmp (type, "rel") == 0) + return ET_REL; + if (strcasecmp (type, "exec") == 0) + return ET_EXEC; + if (strcasecmp (type, "dyn") == 0) + return ET_DYN; + if (strcasecmp (type, "none") == 0) + return ET_NONE; + + error (_("Unknown type: %s\n"), type); + + return -1; +} + +enum command_line_switch + { + OPTION_INPUT_MACH = 150, + OPTION_OUTPUT_MACH, + OPTION_INPUT_TYPE, + OPTION_OUTPUT_TYPE, + OPTION_INPUT_OSABI, + OPTION_OUTPUT_OSABI + }; + +static struct option options[] = +{ + {"input-mach", required_argument, 0, OPTION_INPUT_MACH}, + {"output-mach", required_argument, 0, OPTION_OUTPUT_MACH}, + {"input-type", required_argument, 0, OPTION_INPUT_TYPE}, + {"output-type", required_argument, 0, OPTION_OUTPUT_TYPE}, + {"input-osabi", required_argument, 0, OPTION_INPUT_OSABI}, + {"output-osabi", required_argument, 0, OPTION_OUTPUT_OSABI}, + {"version", no_argument, 0, 'v'}, + {"help", no_argument, 0, 'h'}, + {0, no_argument, 0, 0} +}; + +ATTRIBUTE_NORETURN static void +usage (FILE *stream, int exit_status) +{ + fprintf (stream, _("Usage: %s elffile(s)\n"), + program_name); + fprintf (stream, _(" Update the ELF header of ELF files\n")); + fprintf (stream, _(" The options are:\n")); + fprintf (stream, _("\ + --input-mach Set input machine type to \n\ + --output-mach Set output machine type to \n\ + --input-type Set input file type to \n\ + --output-type Set output file type to \n\ + --input-osabi Set input OSABI to \n\ + --output-osabi Set output OSABI to \n\ + -h --help Display this information\n\ + -v --version Display the version number of %s\n\ +"), + program_name); + if (REPORT_BUGS_TO[0] && exit_status == 0) + fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); + exit (exit_status); +} + +int +main (int argc, char ** argv) +{ + int c, status; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + expandargv (&argc, &argv); + + while ((c = getopt_long (argc, argv, "hv", + options, (int *) 0)) != EOF) + { + switch (c) + { + case OPTION_INPUT_MACH: + input_elf_machine = elf_machine (optarg); + if (input_elf_machine < 0) + return 1; + input_elf_class = elf_class (input_elf_machine); + if (input_elf_class == ELF_CLASS_UNKNOWN) + return 1; + break; + + case OPTION_OUTPUT_MACH: + output_elf_machine = elf_machine (optarg); + if (output_elf_machine < 0) + return 1; + output_elf_class = elf_class (output_elf_machine); + if (output_elf_class == ELF_CLASS_UNKNOWN) + return 1; + break; + + case OPTION_INPUT_TYPE: + input_elf_type = elf_type (optarg); + if (input_elf_type < 0) + return 1; + break; + + case OPTION_OUTPUT_TYPE: + output_elf_type = elf_type (optarg); + if (output_elf_type < 0) + return 1; + break; + + case OPTION_INPUT_OSABI: + input_elf_osabi = elf_osabi (optarg); + if (input_elf_osabi < 0) + return 1; + break; + + case OPTION_OUTPUT_OSABI: + output_elf_osabi = elf_osabi (optarg); + if (output_elf_osabi < 0) + return 1; + break; + + case 'h': + usage (stdout, 0); + + case 'v': + print_version (program_name); + break; + + default: + usage (stderr, 1); + } + } + + if (optind == argc + || (output_elf_machine == -1 + && output_elf_type == -1 + && output_elf_osabi == -1)) + usage (stderr, 1); + + status = 0; + while (optind < argc) + status |= process_file (argv[optind++]); + + return status; +} diff --git a/support/sdbinutils/binutils/embedspu.sh b/support/sdbinutils/binutils/embedspu.sh new file mode 100755 index 0000000..dafb648 --- /dev/null +++ b/support/sdbinutils/binutils/embedspu.sh @@ -0,0 +1,260 @@ +#! /bin/sh +# Embed an SPU ELF executable into a PowerPC object file. +# +# Copyright (C) 2006-2018 Free Software Foundation, Inc. +# +# This file is part of GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. + +usage () +{ + echo "Usage: embedspu [flags] symbol_name input_filename output_filename" + echo + echo " input_filename: SPU ELF executable to be embedded" + echo " output_filename: Resulting PowerPC object file" + echo " symbol_name: Name of program handle struct to be defined" + echo " flags: GCC flags defining PowerPC object file format" + echo " (e.g. -m32 or -m64)" + exit 1 +} + +program_transform_name= +mydir=`dirname "$0"` + +find_prog () +{ + prog=`echo $1 | sed "$program_transform_name"` + prog="$mydir/$prog" + test -x "$prog" && return 0 + prog="$mydir/$1" + test -x "$prog" && return 0 + prog=`echo $1 | sed "$program_transform_name"` + which $prog > /dev/null 2> /dev/null && return 0 + return 1 +} + +SYMBOL= +INFILE= +OUTFILE= +FLAGS= + +parse_args () +{ + while test -n "$1"; do + case "$1" in + -*) FLAGS="${FLAGS} $1" ;; + *) if test -z "$SYMBOL"; then + SYMBOL="$1" + elif test -z "$INFILE"; then + INFILE="$1" + elif test -z "$OUTFILE"; then + OUTFILE="$1" + else + echo "Too many arguments!" + usage + fi ;; + esac + shift + done + if test -z "$OUTFILE"; then + usage + fi + if test ! -r "$INFILE"; then + echo "${INFILE}: File not found" + usage + fi +} + +main () +{ + parse_args "$@" + + # Find a powerpc gcc. Support running from a combined tree build. + if test -x "$mydir/../gcc/xgcc"; then + CC="$mydir/../gcc/xgcc -B$mydir/../gcc/" + else + find_prog gcc + if test $? -ne 0; then + echo "Cannot find $prog" + exit 1 + fi + CC="$prog" + fi + + # Find readelf. Any old readelf should do. + find_prog readelf + if test $? -ne 0; then + if which readelf > /dev/null 2> /dev/null; then + prog=readelf + else + echo "Cannot find $prog" + exit 1 + fi + fi + READELF="$prog" + + # Sanity check the input file + if ! ${READELF} -h ${INFILE} | grep 'Class:.*ELF32' >/dev/null 2>/dev/null \ + || ! ${READELF} -h ${INFILE} | grep 'Type:.*EXEC' >/dev/null 2>/dev/null \ + || ! ${READELF} -h ${INFILE} | egrep 'Machine:.*(SPU|17)' >/dev/null 2>/dev/null + then + echo "${INFILE}: Does not appear to be an SPU executable" + exit 1 + fi + + toe=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *\([0-9]*\)\] *\.toe *[PROGN]*BITS *\([0-9a-f]*\).*,\1 \2,p'` + toe_addr=`echo $toe | sed -n -e 's,.* ,,p'` + toe=`echo $toe | sed -n -e 's, .*,,p'` + has_ea=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *\([0-9]*\)\] *\._ea *PROGBITS.*,\1,p'` + # For loaded sections, pick off section number, address, and file offset + sections=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *\([0-9]*\)\] *[^ ]* *PROGBITS *\([0-9a-f]*\) *\([0-9a-f]*\).*,\1 \2 \3,p'` + sections=`echo ${sections}` + # For relocation sections, pick off file offset and info (points to + # section where relocs apply) + relas=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *[0-9]*\] *[^ ]* *RELA *[0-9a-f]* *0*\([0-9a-f][0-9a-f]*\).* \([0-9a-f][0-9a-f]*\) *[0-9a-f][0-9a-f]*$,\1 \2,p'` + relas=`echo ${relas}` + + # Build embedded SPU image. + # 1. The whole SPU ELF file is written to .rodata.speelf + # 2. Symbols starting with the string "_EAR_" in the SPU ELF image are + # special. They allow an SPU program to access corresponding symbols + # (ie. minus the _EAR_ prefix), in the PowerPC program. _EAR_ without + # a suffix is used to refer to the addrress of the SPU image in + # PowerPC address space. _EAR_* symbols must all be defined in .toe + # at 16 byte intervals, or they must be defined in other non-bss + # sections. + # Find all _EAR_ symbols in .toe using readelf, sort by address, and + # write the address of the corresponding PowerPC symbol in a table + # built in .data.spetoe. For _EAR_ symbols not in .toe, create + # .reloc commands to relocate their location directly. + # 3. Look for R_SPU_PPU32 and R_SPU_PPU64 relocations in the SPU ELF image + # and create .reloc commands for them. + # 4. Write a struct spe_program_handle to .data. + # 5. Write a table of _SPUEAR_ symbols. + ${CC} ${FLAGS} -x assembler-with-cpp -nostartfiles -nostdlib \ + -Wa,-mbig -Wa,-noexecstack -Wl,-r -Wl,-x -o ${OUTFILE} - <. */ +/* FIXME: write only variable. */ +static bfd_boolean big_archive = TRUE; + +/* Whether to include 32 bit objects. */ +static bfd_boolean X32 = TRUE; + +/* Whether to include 64 bit objects. */ +static bfd_boolean X64 = FALSE; + +static void +ar_emul_aix_usage (FILE *fp) +{ + AR_EMUL_USAGE_PRINT_OPTION_HEADER (fp); + /* xgettext:c-format */ + fprintf (fp, _(" [-g] - 32 bit small archive\n")); + fprintf (fp, _(" [-X32] - ignores 64 bit objects\n")); + fprintf (fp, _(" [-X64] - ignores 32 bit objects\n")); + fprintf (fp, _(" [-X32_64] - accepts 32 and 64 bit objects\n")); +} + +static bfd_boolean +check_aix (bfd *try_bfd) +{ + extern const bfd_target rs6000_xcoff_vec; + extern const bfd_target rs6000_xcoff64_vec; + extern const bfd_target rs6000_xcoff64_aix_vec; + + if (bfd_check_format (try_bfd, bfd_object)) + { + if (!X32 && try_bfd->xvec == &rs6000_xcoff_vec) + return FALSE; + + if (!X64 && (try_bfd->xvec == &rs6000_xcoff64_vec + || try_bfd->xvec == &rs6000_xcoff64_aix_vec)) + return FALSE; + } + return TRUE; +} + +static bfd_boolean +ar_emul_aix_append (bfd **after_bfd, char *file_name, const char *target, + bfd_boolean verbose, bfd_boolean flatten) +{ + bfd *new_bfd; + + new_bfd = bfd_openr (file_name, target); + AR_EMUL_ELEMENT_CHECK (new_bfd, file_name); + + return do_ar_emul_append (after_bfd, new_bfd, verbose, flatten, check_aix); +} + +static bfd_boolean +ar_emul_aix_replace (bfd **after_bfd, char *file_name, const char *target, + bfd_boolean verbose) +{ + bfd *new_bfd; + + new_bfd = bfd_openr (file_name, target); + AR_EMUL_ELEMENT_CHECK (new_bfd, file_name); + + if (!check_aix (new_bfd)) + return FALSE; + + AR_EMUL_REPLACE_PRINT_VERBOSE (verbose, file_name); + + new_bfd->archive_next = *after_bfd; + *after_bfd = new_bfd; + + return TRUE; +} + +static bfd_boolean +ar_emul_aix_parse_arg (char *arg) +{ + if (CONST_STRNEQ (arg, "-X32_64")) + { + big_archive = TRUE; + X32 = TRUE; + X64 = TRUE; + } + else if (CONST_STRNEQ (arg, "-X32")) + { + big_archive = TRUE; + X32 = TRUE; + X64 = FALSE; + } + else if (CONST_STRNEQ (arg, "-X64")) + { + big_archive = TRUE; + X32 = FALSE; + X64 = TRUE; + } + else if (CONST_STRNEQ (arg, "-g")) + { + big_archive = FALSE; + X32 = TRUE; + X64 = FALSE; + } + else + return FALSE; + + return TRUE; +} + +struct bin_emulation_xfer_struct bin_aix_emulation = +{ + ar_emul_aix_usage, + ar_emul_aix_append, + ar_emul_aix_replace, + ar_emul_aix_parse_arg, +}; diff --git a/support/sdbinutils/binutils/emul_vanilla.c b/support/sdbinutils/binutils/emul_vanilla.c new file mode 100644 index 0000000..dd850ff --- /dev/null +++ b/support/sdbinutils/binutils/emul_vanilla.c @@ -0,0 +1,30 @@ +/* Binutils emulation layer. + Copyright (C) 2002-2018 Free Software Foundation, Inc. + Written by Tom Rix, Red Hat Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "binemul.h" + +struct bin_emulation_xfer_struct bin_vanilla_emulation = +{ + ar_emul_default_usage, + ar_emul_default_append, + ar_emul_default_replace, + ar_emul_default_parse_arg, +}; diff --git a/support/sdbinutils/binutils/filemode.c b/support/sdbinutils/binutils/filemode.c new file mode 100644 index 0000000..56a167b --- /dev/null +++ b/support/sdbinutils/binutils/filemode.c @@ -0,0 +1,248 @@ +/* filemode.c -- make a string describing file modes + Copyright (C) 1985-2018 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 3, 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., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" + +static char ftypelet (unsigned long); +static void setst (unsigned long, char *); + +/* filemodestring - fill in string STR with an ls-style ASCII + representation of the st_mode field of file stats block STATP. + 10 characters are stored in STR; no terminating null is added. + The characters stored in STR are: + + 0 File type. 'd' for directory, 'c' for character + special, 'b' for block special, 'm' for multiplex, + 'l' for symbolic link, 's' for socket, 'p' for fifo, + '-' for any other file type + + 1 'r' if the owner may read, '-' otherwise. + + 2 'w' if the owner may write, '-' otherwise. + + 3 'x' if the owner may execute, 's' if the file is + set-user-id, '-' otherwise. + 'S' if the file is set-user-id, but the execute + bit isn't set. + + 4 'r' if group members may read, '-' otherwise. + + 5 'w' if group members may write, '-' otherwise. + + 6 'x' if group members may execute, 's' if the file is + set-group-id, '-' otherwise. + 'S' if it is set-group-id but not executable. + + 7 'r' if any user may read, '-' otherwise. + + 8 'w' if any user may write, '-' otherwise. + + 9 'x' if any user may execute, 't' if the file is "sticky" + (will be retained in swap space after execution), '-' + otherwise. + 'T' if the file is sticky but not executable. */ + +/* Get definitions for the file permission bits. */ + +#ifndef S_IRWXU +#define S_IRWXU 0700 +#endif +#ifndef S_IRUSR +#define S_IRUSR 0400 +#endif +#ifndef S_IWUSR +#define S_IWUSR 0200 +#endif +#ifndef S_IXUSR +#define S_IXUSR 0100 +#endif + +#ifndef S_IRWXG +#define S_IRWXG 0070 +#endif +#ifndef S_IRGRP +#define S_IRGRP 0040 +#endif +#ifndef S_IWGRP +#define S_IWGRP 0020 +#endif +#ifndef S_IXGRP +#define S_IXGRP 0010 +#endif + +#ifndef S_IRWXO +#define S_IRWXO 0007 +#endif +#ifndef S_IROTH +#define S_IROTH 0004 +#endif +#ifndef S_IWOTH +#define S_IWOTH 0002 +#endif +#ifndef S_IXOTH +#define S_IXOTH 0001 +#endif + +/* Like filemodestring, but only the relevant part of the `struct stat' + is given as an argument. */ + +void +mode_string (unsigned long mode, char *str) +{ + str[0] = ftypelet ((unsigned long) mode); + str[1] = (mode & S_IRUSR) != 0 ? 'r' : '-'; + str[2] = (mode & S_IWUSR) != 0 ? 'w' : '-'; + str[3] = (mode & S_IXUSR) != 0 ? 'x' : '-'; + str[4] = (mode & S_IRGRP) != 0 ? 'r' : '-'; + str[5] = (mode & S_IWGRP) != 0 ? 'w' : '-'; + str[6] = (mode & S_IXGRP) != 0 ? 'x' : '-'; + str[7] = (mode & S_IROTH) != 0 ? 'r' : '-'; + str[8] = (mode & S_IWOTH) != 0 ? 'w' : '-'; + str[9] = (mode & S_IXOTH) != 0 ? 'x' : '-'; + setst ((unsigned long) mode, str); +} + +/* Return a character indicating the type of file described by + file mode BITS: + 'd' for directories + 'b' for block special files + 'c' for character special files + 'm' for multiplexer files + 'l' for symbolic links + 's' for sockets + 'p' for fifos + '-' for any other file type. */ + +#ifndef S_ISDIR +#ifdef S_IFDIR +#define S_ISDIR(i) (((i) & S_IFMT) == S_IFDIR) +#else /* ! defined (S_IFDIR) */ +#define S_ISDIR(i) (((i) & 0170000) == 040000) +#endif /* ! defined (S_IFDIR) */ +#endif /* ! defined (S_ISDIR) */ + +#ifndef S_ISBLK +#ifdef S_IFBLK +#define S_ISBLK(i) (((i) & S_IFMT) == S_IFBLK) +#else /* ! defined (S_IFBLK) */ +#define S_ISBLK(i) 0 +#endif /* ! defined (S_IFBLK) */ +#endif /* ! defined (S_ISBLK) */ + +#ifndef S_ISCHR +#ifdef S_IFCHR +#define S_ISCHR(i) (((i) & S_IFMT) == S_IFCHR) +#else /* ! defined (S_IFCHR) */ +#define S_ISCHR(i) 0 +#endif /* ! defined (S_IFCHR) */ +#endif /* ! defined (S_ISCHR) */ + +#ifndef S_ISFIFO +#ifdef S_IFIFO +#define S_ISFIFO(i) (((i) & S_IFMT) == S_IFIFO) +#else /* ! defined (S_IFIFO) */ +#define S_ISFIFO(i) 0 +#endif /* ! defined (S_IFIFO) */ +#endif /* ! defined (S_ISFIFO) */ + +#ifndef S_ISSOCK +#ifdef S_IFSOCK +#define S_ISSOCK(i) (((i) & S_IFMT) == S_IFSOCK) +#else /* ! defined (S_IFSOCK) */ +#define S_ISSOCK(i) 0 +#endif /* ! defined (S_IFSOCK) */ +#endif /* ! defined (S_ISSOCK) */ + +#ifndef S_ISLNK +#ifdef S_IFLNK +#define S_ISLNK(i) (((i) & S_IFMT) == S_IFLNK) +#else /* ! defined (S_IFLNK) */ +#define S_ISLNK(i) 0 +#endif /* ! defined (S_IFLNK) */ +#endif /* ! defined (S_ISLNK) */ + +static char +ftypelet (unsigned long bits) +{ + if (S_ISDIR (bits)) + return 'd'; + if (S_ISLNK (bits)) + return 'l'; + if (S_ISBLK (bits)) + return 'b'; + if (S_ISCHR (bits)) + return 'c'; + if (S_ISSOCK (bits)) + return 's'; + if (S_ISFIFO (bits)) + return 'p'; + +#ifdef S_IFMT +#ifdef S_IFMPC + if ((bits & S_IFMT) == S_IFMPC + || (bits & S_IFMT) == S_IFMPB) + return 'm'; +#endif +#ifdef S_IFNWK + if ((bits & S_IFMT) == S_IFNWK) + return 'n'; +#endif +#endif + + return '-'; +} + +/* Set the 's' and 't' flags in file attributes string CHARS, + according to the file mode BITS. */ + +static void +setst (unsigned long bits ATTRIBUTE_UNUSED, char *chars ATTRIBUTE_UNUSED) +{ +#ifdef S_ISUID + if (bits & S_ISUID) + { + if (chars[3] != 'x') + /* Set-uid, but not executable by owner. */ + chars[3] = 'S'; + else + chars[3] = 's'; + } +#endif +#ifdef S_ISGID + if (bits & S_ISGID) + { + if (chars[6] != 'x') + /* Set-gid, but not executable by group. */ + chars[6] = 'S'; + else + chars[6] = 's'; + } +#endif +#ifdef S_ISVTX + if (bits & S_ISVTX) + { + if (chars[9] != 'x') + /* Sticky, but not executable by others. */ + chars[9] = 'T'; + else + chars[9] = 't'; + } +#endif +} diff --git a/support/sdbinutils/binutils/ieee.c b/support/sdbinutils/binutils/ieee.c new file mode 100644 index 0000000..eab3e4d --- /dev/null +++ b/support/sdbinutils/binutils/ieee.c @@ -0,0 +1,7410 @@ +/* ieee.c -- Read and write IEEE-695 debugging information. + Copyright (C) 1996-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor . + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* This file reads and writes IEEE-695 debugging information. */ + +#include "sysdep.h" +#include +#include "bfd.h" +#include "ieee.h" +#include "libiberty.h" +#include "debug.h" +#include "budbg.h" +#include "filenames.h" + +/* This structure holds an entry on the block stack. */ + +struct ieee_block +{ + /* The kind of block. */ + int kind; + /* The source file name, for a BB5 block. */ + const char *filename; + /* The index of the function type, for a BB4 or BB6 block. */ + unsigned int fnindx; + /* TRUE if this function is being skipped. */ + bfd_boolean skip; +}; + +/* This structure is the block stack. */ + +#define BLOCKSTACK_SIZE (16) + +struct ieee_blockstack +{ + /* The stack pointer. */ + struct ieee_block *bsp; + /* The stack. */ + struct ieee_block stack[BLOCKSTACK_SIZE]; +}; + +/* This structure holds information for a variable. */ + +enum ieee_var_kind + { + IEEE_UNKNOWN, + IEEE_EXTERNAL, + IEEE_GLOBAL, + IEEE_STATIC, + IEEE_LOCAL, + IEEE_FUNCTION + }; + +struct ieee_var +{ + /* Start of name. */ + const char *name; + /* Length of name. */ + unsigned long namlen; + /* Type. */ + debug_type type; + /* Slot if we make an indirect type. */ + debug_type *pslot; + /* Kind of variable or function. */ + enum ieee_var_kind kind; +}; + +/* This structure holds all the variables. */ + +struct ieee_vars +{ + /* Number of slots allocated. */ + unsigned int alloc; + /* Variables. */ + struct ieee_var *vars; +}; + +/* This structure holds information for a type. We need this because + we don't want to represent bitfields as real types. */ + +struct ieee_type +{ + /* Type. */ + debug_type type; + /* Slot if this is type is referenced before it is defined. */ + debug_type *pslot; + /* Slots for arguments if we make indirect types for them. */ + debug_type *arg_slots; + /* If this is a bitfield, this is the size in bits. If this is not + a bitfield, this is zero. */ + unsigned long bitsize; +}; + +/* This structure holds all the type information. */ + +struct ieee_types +{ + /* Number of slots allocated. */ + unsigned int alloc; + /* Types. */ + struct ieee_type *types; + /* Builtin types. */ +#define BUILTIN_TYPE_COUNT (60) + debug_type builtins[BUILTIN_TYPE_COUNT]; +}; + +/* This structure holds a linked last of structs with their tag names, + so that we can convert them to C++ classes if necessary. */ + +struct ieee_tag +{ + /* Next tag. */ + struct ieee_tag *next; + /* This tag name. */ + const char *name; + /* The type of the tag. */ + debug_type type; + /* The tagged type is an indirect type pointing at this slot. */ + debug_type slot; + /* This is an array of slots used when a field type is converted + into a indirect type, in case it needs to be later converted into + a reference type. */ + debug_type *fslots; +}; + +/* This structure holds the information we pass around to the parsing + functions. */ + +struct ieee_info +{ + /* The debugging handle. */ + void *dhandle; + /* The BFD. */ + bfd *abfd; + /* The start of the bytes to be parsed. */ + const bfd_byte *bytes; + /* The end of the bytes to be parsed. */ + const bfd_byte *pend; + /* The block stack. */ + struct ieee_blockstack blockstack; + /* Whether we have seen a BB1 or BB2. */ + bfd_boolean saw_filename; + /* The variables. */ + struct ieee_vars vars; + /* The global variables, after a global typedef block. */ + struct ieee_vars *global_vars; + /* The types. */ + struct ieee_types types; + /* The global types, after a global typedef block. */ + struct ieee_types *global_types; + /* The list of tagged structs. */ + struct ieee_tag *tags; +}; + +/* Basic builtin types, not including the pointers. */ + +enum builtin_types +{ + builtin_unknown = 0, + builtin_void = 1, + builtin_signed_char = 2, + builtin_unsigned_char = 3, + builtin_signed_short_int = 4, + builtin_unsigned_short_int = 5, + builtin_signed_long = 6, + builtin_unsigned_long = 7, + builtin_signed_long_long = 8, + builtin_unsigned_long_long = 9, + builtin_float = 10, + builtin_double = 11, + builtin_long_double = 12, + builtin_long_long_double = 13, + builtin_quoted_string = 14, + builtin_instruction_address = 15, + builtin_int = 16, + builtin_unsigned = 17, + builtin_unsigned_int = 18, + builtin_char = 19, + builtin_long = 20, + builtin_short = 21, + builtin_unsigned_short = 22, + builtin_short_int = 23, + builtin_signed_short = 24, + builtin_bcd_float = 25 +}; + +/* These are the values found in the derivation flags of a 'b' + component record of a 'T' type extension record in a C++ pmisc + record. These are bitmasks. */ + +/* Set for a private base class, clear for a public base class. + Protected base classes are not supported. */ +#define BASEFLAGS_PRIVATE (0x1) +/* Set for a virtual base class. */ +#define BASEFLAGS_VIRTUAL (0x2) +/* Set for a friend class, clear for a base class. */ +#define BASEFLAGS_FRIEND (0x10) + +/* These are the values found in the specs flags of a 'd', 'm', or 'v' + component record of a 'T' type extension record in a C++ pmisc + record. The same flags are used for a 'M' record in a C++ pmisc + record. */ + +/* The lower two bits hold visibility information. */ +#define CXXFLAGS_VISIBILITY (0x3) +/* This value in the lower two bits indicates a public member. */ +#define CXXFLAGS_VISIBILITY_PUBLIC (0x0) +/* This value in the lower two bits indicates a private member. */ +#define CXXFLAGS_VISIBILITY_PRIVATE (0x1) +/* This value in the lower two bits indicates a protected member. */ +#define CXXFLAGS_VISIBILITY_PROTECTED (0x2) +/* Set for a static member. */ +#define CXXFLAGS_STATIC (0x4) +/* Set for a virtual override. */ +#define CXXFLAGS_OVERRIDE (0x8) +/* Set for a friend function. */ +#define CXXFLAGS_FRIEND (0x10) +/* Set for a const function. */ +#define CXXFLAGS_CONST (0x20) +/* Set for a volatile function. */ +#define CXXFLAGS_VOLATILE (0x40) +/* Set for an overloaded function. */ +#define CXXFLAGS_OVERLOADED (0x80) +/* Set for an operator function. */ +#define CXXFLAGS_OPERATOR (0x100) +/* Set for a constructor or destructor. */ +#define CXXFLAGS_CTORDTOR (0x400) +/* Set for a constructor. */ +#define CXXFLAGS_CTOR (0x200) +/* Set for an inline function. */ +#define CXXFLAGS_INLINE (0x800) + +/* Local functions. */ + +static void ieee_error (struct ieee_info *, const bfd_byte *, const char *); +static void ieee_eof (struct ieee_info *); +static char *savestring (const char *, unsigned long); +static bfd_boolean ieee_read_number + (struct ieee_info *, const bfd_byte **, bfd_vma *); +static bfd_boolean ieee_read_optional_number + (struct ieee_info *, const bfd_byte **, bfd_vma *, bfd_boolean *); +static bfd_boolean ieee_read_id + (struct ieee_info *, const bfd_byte **, const char **, unsigned long *); +static bfd_boolean ieee_read_optional_id + (struct ieee_info *, const bfd_byte **, const char **, unsigned long *, + bfd_boolean *); +static bfd_boolean ieee_read_expression + (struct ieee_info *, const bfd_byte **, bfd_vma *); +static debug_type ieee_builtin_type + (struct ieee_info *, const bfd_byte *, unsigned int); +static bfd_boolean ieee_alloc_type + (struct ieee_info *, unsigned int, bfd_boolean); +static bfd_boolean ieee_read_type_index + (struct ieee_info *, const bfd_byte **, debug_type *); +static int ieee_regno_to_genreg (bfd *, int); +static int ieee_genreg_to_regno (bfd *, int); +static bfd_boolean parse_ieee_bb (struct ieee_info *, const bfd_byte **); +static bfd_boolean parse_ieee_be (struct ieee_info *, const bfd_byte **); +static bfd_boolean parse_ieee_nn (struct ieee_info *, const bfd_byte **); +static bfd_boolean parse_ieee_ty (struct ieee_info *, const bfd_byte **); +static bfd_boolean parse_ieee_atn (struct ieee_info *, const bfd_byte **); +static bfd_boolean ieee_read_cxx_misc + (struct ieee_info *, const bfd_byte **, unsigned long); +static bfd_boolean ieee_read_cxx_class + (struct ieee_info *, const bfd_byte **, unsigned long); +static bfd_boolean ieee_read_cxx_defaults + (struct ieee_info *, const bfd_byte **, unsigned long); +static bfd_boolean ieee_read_reference + (struct ieee_info *, const bfd_byte **); +static bfd_boolean ieee_require_asn + (struct ieee_info *, const bfd_byte **, bfd_vma *); +static bfd_boolean ieee_require_atn65 + (struct ieee_info *, const bfd_byte **, const char **, unsigned long *); + +/* Report an error in the IEEE debugging information. */ + +static void +ieee_error (struct ieee_info *info, const bfd_byte *p, const char *s) +{ + if (p != NULL) + fprintf (stderr, "%s: 0x%lx: %s (0x%x)\n", bfd_get_filename (info->abfd), + (unsigned long) (p - info->bytes), s, *p); + else + fprintf (stderr, "%s: %s\n", bfd_get_filename (info->abfd), s); +} + +/* Report an unexpected EOF in the IEEE debugging information. */ + +static void +ieee_eof (struct ieee_info *info) +{ + ieee_error (info, (const bfd_byte *) NULL, + _("unexpected end of debugging information")); +} + +/* Save a string in memory. */ + +static char * +savestring (const char *start, unsigned long len) +{ + char *ret; + + ret = (char *) xmalloc (len + 1); + memcpy (ret, start, len); + ret[len] = '\0'; + return ret; +} + +/* Read a number which must be present in an IEEE file. */ + +static bfd_boolean +ieee_read_number (struct ieee_info *info, const bfd_byte **pp, bfd_vma *pv) +{ + return ieee_read_optional_number (info, pp, pv, (bfd_boolean *) NULL); +} + +/* Read a number in an IEEE file. If ppresent is not NULL, the number + need not be there. */ + +static bfd_boolean +ieee_read_optional_number (struct ieee_info *info, const bfd_byte **pp, + bfd_vma *pv, bfd_boolean *ppresent) +{ + ieee_record_enum_type b; + + if (*pp >= info->pend) + { + if (ppresent != NULL) + { + *ppresent = FALSE; + return TRUE; + } + ieee_eof (info); + return FALSE; + } + + b = (ieee_record_enum_type) **pp; + ++*pp; + + if (b <= ieee_number_end_enum) + { + *pv = (bfd_vma) b; + if (ppresent != NULL) + *ppresent = TRUE; + return TRUE; + } + + if (b >= ieee_number_repeat_start_enum && b <= ieee_number_repeat_end_enum) + { + unsigned int i; + + i = (int) b - (int) ieee_number_repeat_start_enum; + if (*pp + i - 1 >= info->pend) + { + ieee_eof (info); + return FALSE; + } + + *pv = 0; + for (; i > 0; i--) + { + *pv <<= 8; + *pv += **pp; + ++*pp; + } + + if (ppresent != NULL) + *ppresent = TRUE; + + return TRUE; + } + + if (ppresent != NULL) + { + --*pp; + *ppresent = FALSE; + return TRUE; + } + + ieee_error (info, *pp - 1, _("invalid number")); + return FALSE; +} + +/* Read a required string from an IEEE file. */ + +static bfd_boolean +ieee_read_id (struct ieee_info *info, const bfd_byte **pp, + const char **pname, unsigned long *pnamlen) +{ + return ieee_read_optional_id (info, pp, pname, pnamlen, (bfd_boolean *) NULL); +} + +/* Read a string from an IEEE file. If ppresent is not NULL, the + string is optional. */ + +static bfd_boolean +ieee_read_optional_id (struct ieee_info *info, const bfd_byte **pp, + const char **pname, unsigned long *pnamlen, + bfd_boolean *ppresent) +{ + bfd_byte b; + unsigned long len; + + if (*pp >= info->pend) + { + ieee_eof (info); + return FALSE; + } + + b = **pp; + ++*pp; + + if (b <= 0x7f) + len = b; + else if ((ieee_record_enum_type) b == ieee_extension_length_1_enum) + { + len = **pp; + ++*pp; + } + else if ((ieee_record_enum_type) b == ieee_extension_length_2_enum) + { + len = (**pp << 8) + (*pp)[1]; + *pp += 2; + } + else + { + if (ppresent != NULL) + { + --*pp; + *ppresent = FALSE; + return TRUE; + } + ieee_error (info, *pp - 1, _("invalid string length")); + return FALSE; + } + + if ((unsigned long) (info->pend - *pp) < len) + { + ieee_eof (info); + return FALSE; + } + + *pname = (const char *) *pp; + *pnamlen = len; + *pp += len; + + if (ppresent != NULL) + *ppresent = TRUE; + + return TRUE; +} + +/* Read an expression from an IEEE file. Since this code is only used + to parse debugging information, I haven't bothered to write a full + blown IEEE expression parser. I've only thrown in the things I've + seen in debugging information. This can be easily extended if + necessary. */ + +static bfd_boolean +ieee_read_expression (struct ieee_info *info, const bfd_byte **pp, + bfd_vma *pv) +{ + const bfd_byte *expr_start; +#define EXPR_STACK_SIZE (10) + bfd_vma expr_stack[EXPR_STACK_SIZE]; + bfd_vma *esp; + + expr_start = *pp; + + esp = expr_stack; + + while (1) + { + const bfd_byte *start; + bfd_vma val; + bfd_boolean present; + ieee_record_enum_type c; + + start = *pp; + + if (! ieee_read_optional_number (info, pp, &val, &present)) + return FALSE; + + if (present) + { + if (esp - expr_stack >= EXPR_STACK_SIZE) + { + ieee_error (info, start, _("expression stack overflow")); + return FALSE; + } + *esp++ = val; + continue; + } + + c = (ieee_record_enum_type) **pp; + + if (c >= ieee_module_beginning_enum) + break; + + ++*pp; + + if (c == ieee_comma) + break; + + switch (c) + { + default: + ieee_error (info, start, _("unsupported IEEE expression operator")); + break; + + case ieee_variable_R_enum: + { + bfd_vma indx; + asection *s; + + if (! ieee_read_number (info, pp, &indx)) + return FALSE; + for (s = info->abfd->sections; s != NULL; s = s->next) + if ((bfd_vma) s->target_index == indx) + break; + if (s == NULL) + { + ieee_error (info, start, _("unknown section")); + return FALSE; + } + + if (esp - expr_stack >= EXPR_STACK_SIZE) + { + ieee_error (info, start, _("expression stack overflow")); + return FALSE; + } + + *esp++ = bfd_get_section_vma (info->abfd, s); + } + break; + + case ieee_function_plus_enum: + case ieee_function_minus_enum: + { + bfd_vma v1, v2; + + if (esp - expr_stack < 2) + { + ieee_error (info, start, _("expression stack underflow")); + return FALSE; + } + + v1 = *--esp; + v2 = *--esp; + *esp++ = v1 + v2; + } + break; + } + } + + if (esp - 1 != expr_stack) + { + ieee_error (info, expr_start, _("expression stack mismatch")); + return FALSE; + } + + *pv = *--esp; + + return TRUE; +} + +/* Return an IEEE builtin type. */ + +static debug_type +ieee_builtin_type (struct ieee_info *info, const bfd_byte *p, + unsigned int indx) +{ + void *dhandle; + debug_type type; + const char *name; + + if (indx < BUILTIN_TYPE_COUNT + && info->types.builtins[indx] != DEBUG_TYPE_NULL) + return info->types.builtins[indx]; + + dhandle = info->dhandle; + + if (indx >= 32 && indx < 64) + { + type = debug_make_pointer_type (dhandle, + ieee_builtin_type (info, p, indx - 32)); + assert (indx < BUILTIN_TYPE_COUNT); + info->types.builtins[indx] = type; + return type; + } + + switch ((enum builtin_types) indx) + { + default: + ieee_error (info, p, _("unknown builtin type")); + return NULL; + + case builtin_unknown: + type = debug_make_void_type (dhandle); + name = NULL; + break; + + case builtin_void: + type = debug_make_void_type (dhandle); + name = "void"; + break; + + case builtin_signed_char: + type = debug_make_int_type (dhandle, 1, FALSE); + name = "signed char"; + break; + + case builtin_unsigned_char: + type = debug_make_int_type (dhandle, 1, TRUE); + name = "unsigned char"; + break; + + case builtin_signed_short_int: + type = debug_make_int_type (dhandle, 2, FALSE); + name = "signed short int"; + break; + + case builtin_unsigned_short_int: + type = debug_make_int_type (dhandle, 2, TRUE); + name = "unsigned short int"; + break; + + case builtin_signed_long: + type = debug_make_int_type (dhandle, 4, FALSE); + name = "signed long"; + break; + + case builtin_unsigned_long: + type = debug_make_int_type (dhandle, 4, TRUE); + name = "unsigned long"; + break; + + case builtin_signed_long_long: + type = debug_make_int_type (dhandle, 8, FALSE); + name = "signed long long"; + break; + + case builtin_unsigned_long_long: + type = debug_make_int_type (dhandle, 8, TRUE); + name = "unsigned long long"; + break; + + case builtin_float: + type = debug_make_float_type (dhandle, 4); + name = "float"; + break; + + case builtin_double: + type = debug_make_float_type (dhandle, 8); + name = "double"; + break; + + case builtin_long_double: + /* FIXME: The size for this type should depend upon the + processor. */ + type = debug_make_float_type (dhandle, 12); + name = "long double"; + break; + + case builtin_long_long_double: + type = debug_make_float_type (dhandle, 16); + name = "long long double"; + break; + + case builtin_quoted_string: + type = debug_make_array_type (dhandle, + ieee_builtin_type (info, p, + ((unsigned int) + builtin_char)), + ieee_builtin_type (info, p, + ((unsigned int) + builtin_int)), + 0, -1, TRUE); + name = "QUOTED STRING"; + break; + + case builtin_instruction_address: + /* FIXME: This should be a code address. */ + type = debug_make_int_type (dhandle, 4, TRUE); + name = "instruction address"; + break; + + case builtin_int: + /* FIXME: The size for this type should depend upon the + processor. */ + type = debug_make_int_type (dhandle, 4, FALSE); + name = "int"; + break; + + case builtin_unsigned: + /* FIXME: The size for this type should depend upon the + processor. */ + type = debug_make_int_type (dhandle, 4, TRUE); + name = "unsigned"; + break; + + case builtin_unsigned_int: + /* FIXME: The size for this type should depend upon the + processor. */ + type = debug_make_int_type (dhandle, 4, TRUE); + name = "unsigned int"; + break; + + case builtin_char: + type = debug_make_int_type (dhandle, 1, FALSE); + name = "char"; + break; + + case builtin_long: + type = debug_make_int_type (dhandle, 4, FALSE); + name = "long"; + break; + + case builtin_short: + type = debug_make_int_type (dhandle, 2, FALSE); + name = "short"; + break; + + case builtin_unsigned_short: + type = debug_make_int_type (dhandle, 2, TRUE); + name = "unsigned short"; + break; + + case builtin_short_int: + type = debug_make_int_type (dhandle, 2, FALSE); + name = "short int"; + break; + + case builtin_signed_short: + type = debug_make_int_type (dhandle, 2, FALSE); + name = "signed short"; + break; + + case builtin_bcd_float: + ieee_error (info, p, _("BCD float type not supported")); + return DEBUG_TYPE_NULL; + } + + if (name != NULL) + type = debug_name_type (dhandle, name, type); + + assert (indx < BUILTIN_TYPE_COUNT); + + info->types.builtins[indx] = type; + + return type; +} + +/* Allocate more space in the type table. If ref is TRUE, this is a + reference to the type; if it is not already defined, we should set + up an indirect type. */ + +static bfd_boolean +ieee_alloc_type (struct ieee_info *info, unsigned int indx, bfd_boolean ref) +{ + unsigned int nalloc; + register struct ieee_type *t; + struct ieee_type *tend; + + if (indx >= info->types.alloc) + { + nalloc = info->types.alloc; + if (nalloc == 0) + nalloc = 4; + while (indx >= nalloc) + nalloc *= 2; + + info->types.types = ((struct ieee_type *) + xrealloc (info->types.types, + nalloc * sizeof *info->types.types)); + + memset (info->types.types + info->types.alloc, 0, + (nalloc - info->types.alloc) * sizeof *info->types.types); + + tend = info->types.types + nalloc; + for (t = info->types.types + info->types.alloc; t < tend; t++) + t->type = DEBUG_TYPE_NULL; + + info->types.alloc = nalloc; + } + + if (ref) + { + t = info->types.types + indx; + if (t->type == NULL) + { + t->pslot = (debug_type *) xmalloc (sizeof *t->pslot); + *t->pslot = DEBUG_TYPE_NULL; + t->type = debug_make_indirect_type (info->dhandle, t->pslot, + (const char *) NULL); + if (t->type == NULL) + return FALSE; + } + } + + return TRUE; +} + +/* Read a type index and return the corresponding type. */ + +static bfd_boolean +ieee_read_type_index (struct ieee_info *info, const bfd_byte **pp, + debug_type *ptype) +{ + const bfd_byte *start; + bfd_vma indx; + + start = *pp; + + if (! ieee_read_number (info, pp, &indx)) + return FALSE; + + if (indx < 256) + { + *ptype = ieee_builtin_type (info, start, indx); + if (*ptype == NULL) + return FALSE; + return TRUE; + } + + indx -= 256; + if (! ieee_alloc_type (info, indx, TRUE)) + return FALSE; + + *ptype = info->types.types[indx].type; + + return TRUE; +} + +/* Parse IEEE debugging information for a file. This is passed the + bytes which compose the Debug Information Part of an IEEE file. */ + +bfd_boolean +parse_ieee (void *dhandle, bfd *abfd, const bfd_byte *bytes, bfd_size_type len) +{ + struct ieee_info info; + unsigned int i; + const bfd_byte *p, *pend; + + info.dhandle = dhandle; + info.abfd = abfd; + info.bytes = bytes; + info.pend = bytes + len; + info.blockstack.bsp = info.blockstack.stack; + info.saw_filename = FALSE; + info.vars.alloc = 0; + info.vars.vars = NULL; + info.global_vars = NULL; + info.types.alloc = 0; + info.types.types = NULL; + info.global_types = NULL; + info.tags = NULL; + for (i = 0; i < BUILTIN_TYPE_COUNT; i++) + info.types.builtins[i] = DEBUG_TYPE_NULL; + + p = bytes; + pend = info.pend; + while (p < pend) + { + const bfd_byte *record_start; + ieee_record_enum_type c; + + record_start = p; + + c = (ieee_record_enum_type) *p++; + + if (c == ieee_at_record_enum) + c = (ieee_record_enum_type) (((unsigned int) c << 8) | *p++); + + if (c <= ieee_number_repeat_end_enum) + { + ieee_error (&info, record_start, _("unexpected number")); + return FALSE; + } + + switch (c) + { + default: + ieee_error (&info, record_start, _("unexpected record type")); + return FALSE; + + case ieee_bb_record_enum: + if (! parse_ieee_bb (&info, &p)) + return FALSE; + break; + + case ieee_be_record_enum: + if (! parse_ieee_be (&info, &p)) + return FALSE; + break; + + case ieee_nn_record: + if (! parse_ieee_nn (&info, &p)) + return FALSE; + break; + + case ieee_ty_record_enum: + if (! parse_ieee_ty (&info, &p)) + return FALSE; + break; + + case ieee_atn_record_enum: + if (! parse_ieee_atn (&info, &p)) + return FALSE; + break; + } + } + + if (info.blockstack.bsp != info.blockstack.stack) + { + ieee_error (&info, (const bfd_byte *) NULL, + _("blocks left on stack at end")); + return FALSE; + } + + return TRUE; +} + +/* Handle an IEEE BB record. */ + +static bfd_boolean +parse_ieee_bb (struct ieee_info *info, const bfd_byte **pp) +{ + const bfd_byte *block_start; + bfd_byte b; + bfd_vma size; + const char *name; + unsigned long namlen; + char *namcopy = NULL; + unsigned int fnindx; + bfd_boolean skip; + + block_start = *pp; + + b = **pp; + ++*pp; + + if (! ieee_read_number (info, pp, &size) + || ! ieee_read_id (info, pp, &name, &namlen)) + return FALSE; + + fnindx = (unsigned int) -1; + skip = FALSE; + + switch (b) + { + case 1: + /* BB1: Type definitions local to a module. */ + namcopy = savestring (name, namlen); + if (namcopy == NULL) + return FALSE; + if (! debug_set_filename (info->dhandle, namcopy)) + return FALSE; + info->saw_filename = TRUE; + + /* Discard any variables or types we may have seen before. */ + if (info->vars.vars != NULL) + free (info->vars.vars); + info->vars.vars = NULL; + info->vars.alloc = 0; + if (info->types.types != NULL) + free (info->types.types); + info->types.types = NULL; + info->types.alloc = 0; + + /* Initialize the types to the global types. */ + if (info->global_types != NULL) + { + info->types.alloc = info->global_types->alloc; + info->types.types = ((struct ieee_type *) + xmalloc (info->types.alloc + * sizeof (*info->types.types))); + memcpy (info->types.types, info->global_types->types, + info->types.alloc * sizeof (*info->types.types)); + } + + break; + + case 2: + /* BB2: Global type definitions. The name is supposed to be + empty, but we don't check. */ + if (! debug_set_filename (info->dhandle, "*global*")) + return FALSE; + info->saw_filename = TRUE; + break; + + case 3: + /* BB3: High level module block begin. We don't have to do + anything here. The name is supposed to be the same as for + the BB1, but we don't check. */ + break; + + case 4: + /* BB4: Global function. */ + { + bfd_vma stackspace, typindx, offset; + debug_type return_type; + + if (! ieee_read_number (info, pp, &stackspace) + || ! ieee_read_number (info, pp, &typindx) + || ! ieee_read_expression (info, pp, &offset)) + return FALSE; + + /* We have no way to record the stack space. FIXME. */ + + if (typindx < 256) + { + return_type = ieee_builtin_type (info, block_start, typindx); + if (return_type == DEBUG_TYPE_NULL) + return FALSE; + } + else + { + typindx -= 256; + if (! ieee_alloc_type (info, typindx, TRUE)) + return FALSE; + fnindx = typindx; + return_type = info->types.types[typindx].type; + if (debug_get_type_kind (info->dhandle, return_type) + == DEBUG_KIND_FUNCTION) + return_type = debug_get_return_type (info->dhandle, + return_type); + } + + namcopy = savestring (name, namlen); + if (namcopy == NULL) + return FALSE; + if (! debug_record_function (info->dhandle, namcopy, return_type, + TRUE, offset)) + return FALSE; + } + break; + + case 5: + /* BB5: File name for source line numbers. */ + { + unsigned int i; + + /* We ignore the date and time. FIXME. */ + for (i = 0; i < 6; i++) + { + bfd_vma ignore; + bfd_boolean present; + + if (! ieee_read_optional_number (info, pp, &ignore, &present)) + return FALSE; + if (! present) + break; + } + + if (! info->saw_filename) + { + namcopy = savestring (name, namlen); + if (namcopy == NULL) + return FALSE; + if (! debug_set_filename (info->dhandle, namcopy)) + return FALSE; + info->saw_filename = TRUE; + } + + namcopy = savestring (name, namlen); + if (namcopy == NULL) + return FALSE; + if (! debug_start_source (info->dhandle, namcopy)) + return FALSE; + } + break; + + case 6: + /* BB6: Local function or block. */ + { + bfd_vma stackspace, typindx, offset; + + if (! ieee_read_number (info, pp, &stackspace) + || ! ieee_read_number (info, pp, &typindx) + || ! ieee_read_expression (info, pp, &offset)) + return FALSE; + + /* We have no way to record the stack space. FIXME. */ + + if (namlen == 0) + { + if (! debug_start_block (info->dhandle, offset)) + return FALSE; + /* Change b to indicate that this is a block + rather than a function. */ + b = 0x86; + } + else + { + /* The MRI C++ compiler will output a fake function named + __XRYCPP to hold C++ debugging information. We skip + that function. This is not crucial, but it makes + converting from IEEE to other debug formats work + better. */ + if (strncmp (name, "__XRYCPP", namlen) == 0) + skip = TRUE; + else + { + debug_type return_type; + + if (typindx < 256) + { + return_type = ieee_builtin_type (info, block_start, + typindx); + if (return_type == NULL) + return FALSE; + } + else + { + typindx -= 256; + if (! ieee_alloc_type (info, typindx, TRUE)) + return FALSE; + fnindx = typindx; + return_type = info->types.types[typindx].type; + if (debug_get_type_kind (info->dhandle, return_type) + == DEBUG_KIND_FUNCTION) + return_type = debug_get_return_type (info->dhandle, + return_type); + } + + namcopy = savestring (name, namlen); + if (namcopy == NULL) + return FALSE; + if (! debug_record_function (info->dhandle, namcopy, + return_type, FALSE, offset)) + return FALSE; + } + } + } + break; + + case 10: + /* BB10: Assembler module scope. In the normal case, we + completely ignore all this information. FIXME. */ + { + const char *inam, *vstr; + unsigned long inamlen, vstrlen; + bfd_vma tool_type; + bfd_boolean present; + unsigned int i; + + if (! info->saw_filename) + { + namcopy = savestring (name, namlen); + if (namcopy == NULL) + return FALSE; + if (! debug_set_filename (info->dhandle, namcopy)) + return FALSE; + info->saw_filename = TRUE; + } + + if (! ieee_read_id (info, pp, &inam, &inamlen) + || ! ieee_read_number (info, pp, &tool_type) + || ! ieee_read_optional_id (info, pp, &vstr, &vstrlen, &present)) + return FALSE; + for (i = 0; i < 6; i++) + { + bfd_vma ignore; + + if (! ieee_read_optional_number (info, pp, &ignore, &present)) + return FALSE; + if (! present) + break; + } + } + break; + + case 11: + /* BB11: Module section. We completely ignore all this + information. FIXME. */ + { + bfd_vma sectype, secindx, offset, map; + bfd_boolean present; + + if (! ieee_read_number (info, pp, §ype) + || ! ieee_read_number (info, pp, &secindx) + || ! ieee_read_expression (info, pp, &offset) + || ! ieee_read_optional_number (info, pp, &map, &present)) + return FALSE; + } + break; + + default: + ieee_error (info, block_start, _("unknown BB type")); + return FALSE; + } + + + /* Push this block on the block stack. */ + + if (info->blockstack.bsp >= info->blockstack.stack + BLOCKSTACK_SIZE) + { + ieee_error (info, (const bfd_byte *) NULL, _("stack overflow")); + return FALSE; + } + + info->blockstack.bsp->kind = b; + if (b == 5) + info->blockstack.bsp->filename = namcopy; + info->blockstack.bsp->fnindx = fnindx; + info->blockstack.bsp->skip = skip; + ++info->blockstack.bsp; + + return TRUE; +} + +/* Handle an IEEE BE record. */ + +static bfd_boolean +parse_ieee_be (struct ieee_info *info, const bfd_byte **pp) +{ + bfd_vma offset; + + if (info->blockstack.bsp <= info->blockstack.stack) + { + ieee_error (info, *pp, _("stack underflow")); + return FALSE; + } + --info->blockstack.bsp; + + switch (info->blockstack.bsp->kind) + { + case 2: + /* When we end the global typedefs block, we copy out the + contents of info->vars. This is because the variable indices + may be reused in the local blocks. However, we need to + preserve them so that we can locate a function returning a + reference variable whose type is named in the global typedef + block. */ + info->global_vars = ((struct ieee_vars *) + xmalloc (sizeof *info->global_vars)); + info->global_vars->alloc = info->vars.alloc; + info->global_vars->vars = ((struct ieee_var *) + xmalloc (info->vars.alloc + * sizeof (*info->vars.vars))); + memcpy (info->global_vars->vars, info->vars.vars, + info->vars.alloc * sizeof (*info->vars.vars)); + + /* We also copy out the non builtin parts of info->types, since + the types are discarded when we start a new block. */ + info->global_types = ((struct ieee_types *) + xmalloc (sizeof *info->global_types)); + info->global_types->alloc = info->types.alloc; + info->global_types->types = ((struct ieee_type *) + xmalloc (info->types.alloc + * sizeof (*info->types.types))); + memcpy (info->global_types->types, info->types.types, + info->types.alloc * sizeof (*info->types.types)); + memset (info->global_types->builtins, 0, + sizeof (info->global_types->builtins)); + + break; + + case 4: + case 6: + if (! ieee_read_expression (info, pp, &offset)) + return FALSE; + if (! info->blockstack.bsp->skip) + { + if (! debug_end_function (info->dhandle, offset + 1)) + return FALSE; + } + break; + + case 0x86: + /* This is BE6 when BB6 started a block rather than a local + function. */ + if (! ieee_read_expression (info, pp, &offset)) + return FALSE; + if (! debug_end_block (info->dhandle, offset + 1)) + return FALSE; + break; + + case 5: + /* When we end a BB5, we look up the stack for the last BB5, if + there is one, so that we can call debug_start_source. */ + if (info->blockstack.bsp > info->blockstack.stack) + { + struct ieee_block *bl; + + bl = info->blockstack.bsp; + do + { + --bl; + if (bl->kind == 5) + { + if (! debug_start_source (info->dhandle, bl->filename)) + return FALSE; + break; + } + } + while (bl != info->blockstack.stack); + } + break; + + case 11: + if (! ieee_read_expression (info, pp, &offset)) + return FALSE; + /* We just ignore the module size. FIXME. */ + break; + + default: + /* Other block types do not have any trailing information. */ + break; + } + + return TRUE; +} + +/* Parse an NN record. */ + +static bfd_boolean +parse_ieee_nn (struct ieee_info *info, const bfd_byte **pp) +{ + const bfd_byte *nn_start; + bfd_vma varindx; + const char *name; + unsigned long namlen; + + nn_start = *pp; + + if (! ieee_read_number (info, pp, &varindx) + || ! ieee_read_id (info, pp, &name, &namlen)) + return FALSE; + + if (varindx < 32) + { + ieee_error (info, nn_start, _("illegal variable index")); + return FALSE; + } + varindx -= 32; + + if (varindx >= info->vars.alloc) + { + unsigned int alloc; + + alloc = info->vars.alloc; + if (alloc == 0) + alloc = 4; + while (varindx >= alloc) + alloc *= 2; + info->vars.vars = ((struct ieee_var *) + xrealloc (info->vars.vars, + alloc * sizeof *info->vars.vars)); + memset (info->vars.vars + info->vars.alloc, 0, + (alloc - info->vars.alloc) * sizeof *info->vars.vars); + info->vars.alloc = alloc; + } + + info->vars.vars[varindx].name = name; + info->vars.vars[varindx].namlen = namlen; + + return TRUE; +} + +/* Parse a TY record. */ + +static bfd_boolean +parse_ieee_ty (struct ieee_info *info, const bfd_byte **pp) +{ + const bfd_byte *ty_start, *ty_var_start, *ty_code_start; + bfd_vma typeindx, varindx, tc; + void *dhandle; + bfd_boolean tag, typdef; + debug_type *arg_slots; + unsigned long type_bitsize; + debug_type type; + + ty_start = *pp; + + if (! ieee_read_number (info, pp, &typeindx)) + return FALSE; + + if (typeindx < 256) + { + ieee_error (info, ty_start, _("illegal type index")); + return FALSE; + } + + typeindx -= 256; + if (! ieee_alloc_type (info, typeindx, FALSE)) + return FALSE; + + if (**pp != 0xce) + { + ieee_error (info, *pp, _("unknown TY code")); + return FALSE; + } + ++*pp; + + ty_var_start = *pp; + + if (! ieee_read_number (info, pp, &varindx)) + return FALSE; + + if (varindx < 32) + { + ieee_error (info, ty_var_start, _("illegal variable index")); + return FALSE; + } + varindx -= 32; + + if (varindx >= info->vars.alloc || info->vars.vars[varindx].name == NULL) + { + ieee_error (info, ty_var_start, _("undefined variable in TY")); + return FALSE; + } + + ty_code_start = *pp; + + if (! ieee_read_number (info, pp, &tc)) + return FALSE; + + dhandle = info->dhandle; + + tag = FALSE; + typdef = FALSE; + arg_slots = NULL; + type_bitsize = 0; + switch (tc) + { + default: + ieee_error (info, ty_code_start, _("unknown TY code")); + return FALSE; + + case '!': + /* Unknown type, with size. We treat it as int. FIXME. */ + { + bfd_vma size; + + if (! ieee_read_number (info, pp, &size)) + return FALSE; + type = debug_make_int_type (dhandle, size, FALSE); + } + break; + + case 'A': /* Array. */ + case 'a': /* FORTRAN array in column/row order. FIXME: Not + distinguished from normal array. */ + { + debug_type ele_type; + bfd_vma lower, upper; + + if (! ieee_read_type_index (info, pp, &ele_type) + || ! ieee_read_number (info, pp, &lower) + || ! ieee_read_number (info, pp, &upper)) + return FALSE; + type = debug_make_array_type (dhandle, ele_type, + ieee_builtin_type (info, ty_code_start, + ((unsigned int) + builtin_int)), + (bfd_signed_vma) lower, + (bfd_signed_vma) upper, + FALSE); + } + break; + + case 'E': + /* Simple enumeration. */ + { + bfd_vma size; + unsigned int alloc; + const char **names; + unsigned int c; + bfd_signed_vma *vals; + unsigned int i; + + if (! ieee_read_number (info, pp, &size)) + return FALSE; + /* FIXME: we ignore the enumeration size. */ + + alloc = 10; + names = (const char **) xmalloc (alloc * sizeof *names); + memset (names, 0, alloc * sizeof *names); + c = 0; + while (1) + { + const char *name; + unsigned long namlen; + bfd_boolean present; + + if (! ieee_read_optional_id (info, pp, &name, &namlen, &present)) + return FALSE; + if (! present) + break; + + if (c + 1 >= alloc) + { + alloc += 10; + names = ((const char **) + xrealloc (names, alloc * sizeof *names)); + } + + names[c] = savestring (name, namlen); + if (names[c] == NULL) + return FALSE; + ++c; + } + + names[c] = NULL; + + vals = (bfd_signed_vma *) xmalloc (c * sizeof *vals); + for (i = 0; i < c; i++) + vals[i] = i; + + type = debug_make_enum_type (dhandle, names, vals); + tag = TRUE; + } + break; + + case 'G': + /* Struct with bit fields. */ + { + bfd_vma size; + unsigned int alloc; + debug_field *fields; + unsigned int c; + + if (! ieee_read_number (info, pp, &size)) + return FALSE; + + alloc = 10; + fields = (debug_field *) xmalloc (alloc * sizeof *fields); + c = 0; + while (1) + { + const char *name; + unsigned long namlen; + bfd_boolean present; + debug_type ftype; + bfd_vma bitpos, bitsize; + + if (! ieee_read_optional_id (info, pp, &name, &namlen, &present)) + return FALSE; + if (! present) + break; + if (! ieee_read_type_index (info, pp, &ftype) + || ! ieee_read_number (info, pp, &bitpos) + || ! ieee_read_number (info, pp, &bitsize)) + return FALSE; + + if (c + 1 >= alloc) + { + alloc += 10; + fields = ((debug_field *) + xrealloc (fields, alloc * sizeof *fields)); + } + + fields[c] = debug_make_field (dhandle, savestring (name, namlen), + ftype, bitpos, bitsize, + DEBUG_VISIBILITY_PUBLIC); + if (fields[c] == NULL) + return FALSE; + ++c; + } + + fields[c] = NULL; + + type = debug_make_struct_type (dhandle, TRUE, size, fields); + tag = TRUE; + } + break; + + case 'N': + /* Enumeration. */ + { + unsigned int alloc; + const char **names; + bfd_signed_vma *vals; + unsigned int c; + + alloc = 10; + names = (const char **) xmalloc (alloc * sizeof *names); + vals = (bfd_signed_vma *) xmalloc (alloc * sizeof *names); + c = 0; + while (1) + { + const char *name; + unsigned long namlen; + bfd_boolean present; + bfd_vma val; + + if (! ieee_read_optional_id (info, pp, &name, &namlen, &present)) + return FALSE; + if (! present) + break; + if (! ieee_read_number (info, pp, &val)) + return FALSE; + + /* If the length of the name is zero, then the value is + actually the size of the enum. We ignore this + information. FIXME. */ + if (namlen == 0) + continue; + + if (c + 1 >= alloc) + { + alloc += 10; + names = ((const char **) + xrealloc (names, alloc * sizeof *names)); + vals = ((bfd_signed_vma *) + xrealloc (vals, alloc * sizeof *vals)); + } + + names[c] = savestring (name, namlen); + if (names[c] == NULL) + return FALSE; + vals[c] = (bfd_signed_vma) val; + ++c; + } + + names[c] = NULL; + + type = debug_make_enum_type (dhandle, names, vals); + tag = TRUE; + } + break; + + case 'O': /* Small pointer. We don't distinguish small and large + pointers. FIXME. */ + case 'P': /* Large pointer. */ + { + debug_type t; + + if (! ieee_read_type_index (info, pp, &t)) + return FALSE; + type = debug_make_pointer_type (dhandle, t); + } + break; + + case 'R': + /* Range. */ + { + bfd_vma low, high, signedp, size; + + if (! ieee_read_number (info, pp, &low) + || ! ieee_read_number (info, pp, &high) + || ! ieee_read_number (info, pp, &signedp) + || ! ieee_read_number (info, pp, &size)) + return FALSE; + + type = debug_make_range_type (dhandle, + debug_make_int_type (dhandle, size, + ! signedp), + (bfd_signed_vma) low, + (bfd_signed_vma) high); + } + break; + + case 'S': /* Struct. */ + case 'U': /* Union. */ + { + bfd_vma size; + unsigned int alloc; + debug_field *fields; + unsigned int c; + + if (! ieee_read_number (info, pp, &size)) + return FALSE; + + alloc = 10; + fields = (debug_field *) xmalloc (alloc * sizeof *fields); + c = 0; + while (1) + { + const char *name; + unsigned long namlen; + bfd_boolean present; + bfd_vma tindx; + bfd_vma offset; + debug_type ftype; + bfd_vma bitsize; + + if (! ieee_read_optional_id (info, pp, &name, &namlen, &present)) + return FALSE; + if (! present) + break; + if (! ieee_read_number (info, pp, &tindx) + || ! ieee_read_number (info, pp, &offset)) + return FALSE; + + if (tindx < 256) + { + ftype = ieee_builtin_type (info, ty_code_start, tindx); + bitsize = 0; + offset *= 8; + } + else + { + struct ieee_type *t; + + tindx -= 256; + if (! ieee_alloc_type (info, tindx, TRUE)) + return FALSE; + t = info->types.types + tindx; + ftype = t->type; + bitsize = t->bitsize; + if (bitsize == 0) + offset *= 8; + } + + if (c + 1 >= alloc) + { + alloc += 10; + fields = ((debug_field *) + xrealloc (fields, alloc * sizeof *fields)); + } + + fields[c] = debug_make_field (dhandle, savestring (name, namlen), + ftype, offset, bitsize, + DEBUG_VISIBILITY_PUBLIC); + if (fields[c] == NULL) + return FALSE; + ++c; + } + + fields[c] = NULL; + + type = debug_make_struct_type (dhandle, tc == 'S', size, fields); + tag = TRUE; + } + break; + + case 'T': + /* Typedef. */ + if (! ieee_read_type_index (info, pp, &type)) + return FALSE; + typdef = TRUE; + break; + + case 'X': + /* Procedure. FIXME: This is an extern declaration, which we + have no way of representing. */ + { + bfd_vma attr; + debug_type rtype; + bfd_vma nargs; + bfd_boolean present; + struct ieee_var *pv; + + /* FIXME: We ignore the attribute and the argument names. */ + + if (! ieee_read_number (info, pp, &attr) + || ! ieee_read_type_index (info, pp, &rtype) + || ! ieee_read_number (info, pp, &nargs)) + return FALSE; + do + { + const char *name; + unsigned long namlen; + + if (! ieee_read_optional_id (info, pp, &name, &namlen, &present)) + return FALSE; + } + while (present); + + pv = info->vars.vars + varindx; + pv->kind = IEEE_EXTERNAL; + if (pv->namlen > 0 + && debug_get_type_kind (dhandle, rtype) == DEBUG_KIND_POINTER) + { + /* Set up the return type as an indirect type pointing to + the variable slot, so that we can change it to a + reference later if appropriate. */ + pv->pslot = (debug_type *) xmalloc (sizeof *pv->pslot); + *pv->pslot = rtype; + rtype = debug_make_indirect_type (dhandle, pv->pslot, + (const char *) NULL); + } + + type = debug_make_function_type (dhandle, rtype, (debug_type *) NULL, + FALSE); + } + break; + + case 'V': + case 'v': + /* Void. This is not documented, but the MRI compiler emits it. */ + type = debug_make_void_type (dhandle); + break; + + case 'Z': + /* Array with 0 lower bound. */ + { + debug_type etype; + bfd_vma high; + + if (! ieee_read_type_index (info, pp, &etype) + || ! ieee_read_number (info, pp, &high)) + return FALSE; + + type = debug_make_array_type (dhandle, etype, + ieee_builtin_type (info, ty_code_start, + ((unsigned int) + builtin_int)), + 0, (bfd_signed_vma) high, FALSE); + } + break; + + case 'c': /* Complex. */ + case 'd': /* Double complex. */ + { + const char *name; + unsigned long namlen; + + /* FIXME: I don't know what the name means. */ + + if (! ieee_read_id (info, pp, &name, &namlen)) + return FALSE; + + type = debug_make_complex_type (dhandle, tc == 'c' ? 4 : 8); + } + break; + + case 'f': + /* Pascal file name. FIXME. */ + ieee_error (info, ty_code_start, _("Pascal file name not supported")); + return FALSE; + + case 'g': + /* Bitfield type. */ + { + bfd_vma signedp, bitsize, dummy; + const bfd_byte *hold; + bfd_boolean present; + + if (! ieee_read_number (info, pp, &signedp) + || ! ieee_read_number (info, pp, &bitsize)) + return FALSE; + + /* I think the documentation says that there is a type index, + but some actual files do not have one. */ + hold = *pp; + if (! ieee_read_optional_number (info, pp, &dummy, &present)) + return FALSE; + if (! present) + { + /* FIXME: This is just a guess. */ + type = debug_make_int_type (dhandle, 4, + signedp ? FALSE : TRUE); + } + else + { + *pp = hold; + if (! ieee_read_type_index (info, pp, &type)) + return FALSE; + } + type_bitsize = bitsize; + } + break; + + case 'n': + /* Qualifier. */ + { + bfd_vma kind; + debug_type t; + + if (! ieee_read_number (info, pp, &kind) + || ! ieee_read_type_index (info, pp, &t)) + return FALSE; + + switch (kind) + { + default: + ieee_error (info, ty_start, _("unsupported qualifier")); + return FALSE; + + case 1: + type = debug_make_const_type (dhandle, t); + break; + + case 2: + type = debug_make_volatile_type (dhandle, t); + break; + } + } + break; + + case 's': + /* Set. */ + { + bfd_vma size; + debug_type etype; + + if (! ieee_read_number (info, pp, &size) + || ! ieee_read_type_index (info, pp, &etype)) + return FALSE; + + /* FIXME: We ignore the size. */ + + type = debug_make_set_type (dhandle, etype, FALSE); + } + break; + + case 'x': + /* Procedure with compiler dependencies. */ + { + struct ieee_var *pv; + bfd_vma attr, frame_type, push_mask, nargs, level, father; + debug_type rtype; + debug_type *arg_types; + bfd_boolean varargs; + bfd_boolean present; + + /* FIXME: We ignore some of this information. */ + + pv = info->vars.vars + varindx; + + if (! ieee_read_number (info, pp, &attr) + || ! ieee_read_number (info, pp, &frame_type) + || ! ieee_read_number (info, pp, &push_mask) + || ! ieee_read_type_index (info, pp, &rtype) + || ! ieee_read_number (info, pp, &nargs)) + return FALSE; + if (nargs == (bfd_vma) -1) + { + arg_types = NULL; + varargs = FALSE; + } + else + { + unsigned int i; + + arg_types = ((debug_type *) + xmalloc ((nargs + 1) * sizeof *arg_types)); + for (i = 0; i < nargs; i++) + if (! ieee_read_type_index (info, pp, arg_types + i)) + return FALSE; + + /* If the last type is pointer to void, this is really a + varargs function. */ + varargs = FALSE; + if (nargs > 0) + { + debug_type last; + + last = arg_types[nargs - 1]; + if (debug_get_type_kind (dhandle, last) == DEBUG_KIND_POINTER + && (debug_get_type_kind (dhandle, + debug_get_target_type (dhandle, + last)) + == DEBUG_KIND_VOID)) + { + --nargs; + varargs = TRUE; + } + } + + /* If there are any pointer arguments, turn them into + indirect types in case we later need to convert them to + reference types. */ + for (i = 0; i < nargs; i++) + { + if (debug_get_type_kind (dhandle, arg_types[i]) + == DEBUG_KIND_POINTER) + { + if (arg_slots == NULL) + { + arg_slots = ((debug_type *) + xmalloc (nargs * sizeof *arg_slots)); + memset (arg_slots, 0, nargs * sizeof *arg_slots); + } + arg_slots[i] = arg_types[i]; + arg_types[i] = + debug_make_indirect_type (dhandle, + arg_slots + i, + (const char *) NULL); + } + } + + arg_types[nargs] = DEBUG_TYPE_NULL; + } + if (! ieee_read_number (info, pp, &level) + || ! ieee_read_optional_number (info, pp, &father, &present)) + return FALSE; + + /* We can't distinguish between a global function and a static + function. */ + pv->kind = IEEE_FUNCTION; + + if (pv->namlen > 0 + && debug_get_type_kind (dhandle, rtype) == DEBUG_KIND_POINTER) + { + /* Set up the return type as an indirect type pointing to + the variable slot, so that we can change it to a + reference later if appropriate. */ + pv->pslot = (debug_type *) xmalloc (sizeof *pv->pslot); + *pv->pslot = rtype; + rtype = debug_make_indirect_type (dhandle, pv->pslot, + (const char *) NULL); + } + + type = debug_make_function_type (dhandle, rtype, arg_types, varargs); + } + break; + } + + /* Record the type in the table. */ + + if (type == DEBUG_TYPE_NULL) + return FALSE; + + info->vars.vars[varindx].type = type; + + if ((tag || typdef) + && info->vars.vars[varindx].namlen > 0) + { + const char *name; + + name = savestring (info->vars.vars[varindx].name, + info->vars.vars[varindx].namlen); + if (typdef) + type = debug_name_type (dhandle, name, type); + else if (tc == 'E' || tc == 'N') + type = debug_tag_type (dhandle, name, type); + else + { + struct ieee_tag *it; + + /* We must allocate all struct tags as indirect types, so + that if we later see a definition of the tag as a C++ + record we can update the indirect slot and automatically + change all the existing references. */ + it = (struct ieee_tag *) xmalloc (sizeof *it); + memset (it, 0, sizeof *it); + it->next = info->tags; + info->tags = it; + it->name = name; + it->slot = type; + + type = debug_make_indirect_type (dhandle, &it->slot, name); + type = debug_tag_type (dhandle, name, type); + + it->type = type; + } + if (type == NULL) + return FALSE; + } + + info->types.types[typeindx].type = type; + info->types.types[typeindx].arg_slots = arg_slots; + info->types.types[typeindx].bitsize = type_bitsize; + + /* We may have already allocated type as an indirect type pointing + to slot. It does no harm to replace the indirect type with the + real type. Filling in slot as well handles the indirect types + which are already hanging around. */ + if (info->types.types[typeindx].pslot != NULL) + *info->types.types[typeindx].pslot = type; + + return TRUE; +} + +/* Parse an ATN record. */ + +static bfd_boolean +parse_ieee_atn (struct ieee_info *info, const bfd_byte **pp) +{ + const bfd_byte *atn_start, *atn_code_start; + bfd_vma varindx; + struct ieee_var *pvar; + debug_type type; + bfd_vma atn_code; + void *dhandle; + bfd_vma v, v2, v3, v4, v5; + const char *name; + unsigned long namlen; + char *namcopy; + bfd_boolean present; + int blocktype; + + atn_start = *pp; + + if (! ieee_read_number (info, pp, &varindx) + || ! ieee_read_type_index (info, pp, &type)) + return FALSE; + + atn_code_start = *pp; + + if (! ieee_read_number (info, pp, &atn_code)) + return FALSE; + + if (varindx == 0) + { + pvar = NULL; + name = ""; + namlen = 0; + } + else if (varindx < 32) + { + /* The MRI compiler reportedly sometimes emits variable lifetime + information for a register. We just ignore it. */ + if (atn_code == 9) + return ieee_read_number (info, pp, &v); + + ieee_error (info, atn_start, _("illegal variable index")); + return FALSE; + } + else + { + varindx -= 32; + if (varindx >= info->vars.alloc + || info->vars.vars[varindx].name == NULL) + { + /* The MRI compiler or linker sometimes omits the NN record + for a pmisc record. */ + if (atn_code == 62) + { + if (varindx >= info->vars.alloc) + { + unsigned int alloc; + + alloc = info->vars.alloc; + if (alloc == 0) + alloc = 4; + while (varindx >= alloc) + alloc *= 2; + info->vars.vars = ((struct ieee_var *) + xrealloc (info->vars.vars, + (alloc + * sizeof *info->vars.vars))); + memset (info->vars.vars + info->vars.alloc, 0, + ((alloc - info->vars.alloc) + * sizeof *info->vars.vars)); + info->vars.alloc = alloc; + } + + pvar = info->vars.vars + varindx; + pvar->name = ""; + pvar->namlen = 0; + } + else + { + ieee_error (info, atn_start, _("undefined variable in ATN")); + return FALSE; + } + } + + pvar = info->vars.vars + varindx; + + pvar->type = type; + + name = pvar->name; + namlen = pvar->namlen; + } + + dhandle = info->dhandle; + + /* If we are going to call debug_record_variable with a pointer + type, change the type to an indirect type so that we can later + change it to a reference type if we encounter a C++ pmisc 'R' + record. */ + if (pvar != NULL + && type != DEBUG_TYPE_NULL + && debug_get_type_kind (dhandle, type) == DEBUG_KIND_POINTER) + { + switch (atn_code) + { + case 1: + case 2: + case 3: + case 5: + case 8: + case 10: + pvar->pslot = (debug_type *) xmalloc (sizeof *pvar->pslot); + *pvar->pslot = type; + type = debug_make_indirect_type (dhandle, pvar->pslot, + (const char *) NULL); + pvar->type = type; + break; + } + } + + switch (atn_code) + { + default: + ieee_error (info, atn_code_start, _("unknown ATN type")); + return FALSE; + + case 1: + /* Automatic variable. */ + if (! ieee_read_number (info, pp, &v)) + return FALSE; + namcopy = savestring (name, namlen); + if (type == NULL) + type = debug_make_void_type (dhandle); + if (pvar != NULL) + pvar->kind = IEEE_LOCAL; + return debug_record_variable (dhandle, namcopy, type, DEBUG_LOCAL, v); + + case 2: + /* Register variable. */ + if (! ieee_read_number (info, pp, &v)) + return FALSE; + namcopy = savestring (name, namlen); + if (type == NULL) + type = debug_make_void_type (dhandle); + if (pvar != NULL) + pvar->kind = IEEE_LOCAL; + return debug_record_variable (dhandle, namcopy, type, DEBUG_REGISTER, + ieee_regno_to_genreg (info->abfd, v)); + + case 3: + /* Static variable. */ + if (! ieee_require_asn (info, pp, &v)) + return FALSE; + namcopy = savestring (name, namlen); + if (type == NULL) + type = debug_make_void_type (dhandle); + if (info->blockstack.bsp <= info->blockstack.stack) + blocktype = 0; + else + blocktype = info->blockstack.bsp[-1].kind; + if (pvar != NULL) + { + if (blocktype == 4 || blocktype == 6) + pvar->kind = IEEE_LOCAL; + else + pvar->kind = IEEE_STATIC; + } + return debug_record_variable (dhandle, namcopy, type, + (blocktype == 4 || blocktype == 6 + ? DEBUG_LOCAL_STATIC + : DEBUG_STATIC), + v); + + case 4: + /* External function. We don't currently record these. FIXME. */ + if (pvar != NULL) + pvar->kind = IEEE_EXTERNAL; + return TRUE; + + case 5: + /* External variable. We don't currently record these. FIXME. */ + if (pvar != NULL) + pvar->kind = IEEE_EXTERNAL; + return TRUE; + + case 7: + if (! ieee_read_number (info, pp, &v) + || ! ieee_read_number (info, pp, &v2) + || ! ieee_read_optional_number (info, pp, &v3, &present)) + return FALSE; + if (present) + { + if (! ieee_read_optional_number (info, pp, &v4, &present)) + return FALSE; + } + + /* We just ignore the two optional fields in v3 and v4, since + they are not defined. */ + + if (! ieee_require_asn (info, pp, &v3)) + return FALSE; + + /* We have no way to record the column number. FIXME. */ + + return debug_record_line (dhandle, v, v3); + + case 8: + /* Global variable. */ + if (! ieee_require_asn (info, pp, &v)) + return FALSE; + namcopy = savestring (name, namlen); + if (type == NULL) + type = debug_make_void_type (dhandle); + if (pvar != NULL) + pvar->kind = IEEE_GLOBAL; + return debug_record_variable (dhandle, namcopy, type, DEBUG_GLOBAL, v); + + case 9: + /* Variable lifetime information. */ + if (! ieee_read_number (info, pp, &v)) + return FALSE; + + /* We have no way to record this information. FIXME. */ + return TRUE; + + case 10: + /* Locked register. The spec says that there are two required + fields, but at least on occasion the MRI compiler only emits + one. */ + if (! ieee_read_number (info, pp, &v) + || ! ieee_read_optional_number (info, pp, &v2, &present)) + return FALSE; + + /* I think this means a variable that is both in a register and + a frame slot. We ignore the frame slot. FIXME. */ + + namcopy = savestring (name, namlen); + if (type == NULL) + type = debug_make_void_type (dhandle); + if (pvar != NULL) + pvar->kind = IEEE_LOCAL; + return debug_record_variable (dhandle, namcopy, type, DEBUG_REGISTER, v); + + case 11: + /* Reserved for FORTRAN common. */ + ieee_error (info, atn_code_start, _("unsupported ATN11")); + + /* Return TRUE to keep going. */ + return TRUE; + + case 12: + /* Based variable. */ + v3 = 0; + v4 = 0x80; + v5 = 0; + if (! ieee_read_number (info, pp, &v) + || ! ieee_read_number (info, pp, &v2) + || ! ieee_read_optional_number (info, pp, &v3, &present)) + return FALSE; + if (present) + { + if (! ieee_read_optional_number (info, pp, &v4, &present)) + return FALSE; + if (present) + { + if (! ieee_read_optional_number (info, pp, &v5, &present)) + return FALSE; + } + } + + /* We have no way to record this information. FIXME. */ + + ieee_error (info, atn_code_start, _("unsupported ATN12")); + + /* Return TRUE to keep going. */ + return TRUE; + + case 16: + /* Constant. The description of this that I have is ambiguous, + so I'm not going to try to implement it. */ + if (! ieee_read_number (info, pp, &v) + || ! ieee_read_optional_number (info, pp, &v2, &present)) + return FALSE; + if (present) + { + if (! ieee_read_optional_number (info, pp, &v2, &present)) + return FALSE; + if (present) + { + if (! ieee_read_optional_id (info, pp, &name, &namlen, &present)) + return FALSE; + } + } + + if ((ieee_record_enum_type) **pp == ieee_e2_first_byte_enum) + { + if (! ieee_require_asn (info, pp, &v3)) + return FALSE; + } + + return TRUE; + + case 19: + /* Static variable from assembler. */ + v2 = 0; + if (! ieee_read_number (info, pp, &v) + || ! ieee_read_optional_number (info, pp, &v2, &present) + || ! ieee_require_asn (info, pp, &v3)) + return FALSE; + namcopy = savestring (name, namlen); + /* We don't really handle this correctly. FIXME. */ + return debug_record_variable (dhandle, namcopy, + debug_make_void_type (dhandle), + v2 != 0 ? DEBUG_GLOBAL : DEBUG_STATIC, + v3); + + case 62: + /* Procedure miscellaneous information. */ + case 63: + /* Variable miscellaneous information. */ + case 64: + /* Module miscellaneous information. */ + if (! ieee_read_number (info, pp, &v) + || ! ieee_read_number (info, pp, &v2) + || ! ieee_read_optional_id (info, pp, &name, &namlen, &present)) + return FALSE; + + if (atn_code == 62 && v == 80) + { + if (present) + { + ieee_error (info, atn_code_start, + _("unexpected string in C++ misc")); + return FALSE; + } + return ieee_read_cxx_misc (info, pp, v2); + } + + /* We just ignore all of this stuff. FIXME. */ + + for (; v2 > 0; --v2) + { + switch ((ieee_record_enum_type) **pp) + { + default: + ieee_error (info, *pp, _("bad misc record")); + return FALSE; + + case ieee_at_record_enum: + if (! ieee_require_atn65 (info, pp, &name, &namlen)) + return FALSE; + break; + + case ieee_e2_first_byte_enum: + if (! ieee_require_asn (info, pp, &v3)) + return FALSE; + break; + } + } + + return TRUE; + } + + /*NOTREACHED*/ +} + +/* Handle C++ debugging miscellaneous records. This is called for + procedure miscellaneous records of type 80. */ + +static bfd_boolean +ieee_read_cxx_misc (struct ieee_info *info, const bfd_byte **pp, + unsigned long count) +{ + const bfd_byte *start; + bfd_vma category; + + start = *pp; + + /* Get the category of C++ misc record. */ + if (! ieee_require_asn (info, pp, &category)) + return FALSE; + --count; + + switch (category) + { + default: + ieee_error (info, start, _("unrecognized C++ misc record")); + return FALSE; + + case 'T': + if (! ieee_read_cxx_class (info, pp, count)) + return FALSE; + break; + + case 'M': + { + bfd_vma flags; + const char *name; + unsigned long namlen; + + /* The IEEE spec indicates that the 'M' record only has a + flags field. The MRI compiler also emits the name of the + function. */ + + if (! ieee_require_asn (info, pp, &flags)) + return FALSE; + if (*pp < info->pend + && (ieee_record_enum_type) **pp == ieee_at_record_enum) + { + if (! ieee_require_atn65 (info, pp, &name, &namlen)) + return FALSE; + } + + /* This is emitted for method functions, but I don't think we + care very much. It might help if it told us useful + information like the class with which this function is + associated, but it doesn't, so it isn't helpful. */ + } + break; + + case 'B': + if (! ieee_read_cxx_defaults (info, pp, count)) + return FALSE; + break; + + case 'z': + { + const char *name, *mangled, *cxx_class; + unsigned long namlen, mangledlen, classlen; + bfd_vma control; + + /* Pointer to member. */ + + if (! ieee_require_atn65 (info, pp, &name, &namlen) + || ! ieee_require_atn65 (info, pp, &mangled, &mangledlen) + || ! ieee_require_atn65 (info, pp, &cxx_class, &classlen) + || ! ieee_require_asn (info, pp, &control)) + return FALSE; + + /* FIXME: We should now track down name and change its type. */ + } + break; + + case 'R': + if (! ieee_read_reference (info, pp)) + return FALSE; + break; + } + + return TRUE; +} + +/* Read a C++ class definition. This is a pmisc type 80 record of + category 'T'. */ + +static bfd_boolean +ieee_read_cxx_class (struct ieee_info *info, const bfd_byte **pp, + unsigned long count) +{ + const bfd_byte *start; + bfd_vma cxx_class; + const char *tag; + unsigned long taglen; + struct ieee_tag *it; + void *dhandle; + debug_field *fields; + unsigned int field_count, field_alloc; + debug_baseclass *baseclasses; + unsigned int baseclasses_count, baseclasses_alloc; + const debug_field *structfields; + struct ieee_method + { + const char *name; + unsigned long namlen; + debug_method_variant *variants; + unsigned count; + unsigned int alloc; + } *methods; + unsigned int methods_count, methods_alloc; + debug_type vptrbase; + bfd_boolean ownvptr; + debug_method *dmethods; + + start = *pp; + + if (! ieee_require_asn (info, pp, &cxx_class)) + return FALSE; + --count; + + if (! ieee_require_atn65 (info, pp, &tag, &taglen)) + return FALSE; + --count; + + /* Find the C struct with this name. */ + for (it = info->tags; it != NULL; it = it->next) + if (it->name[0] == tag[0] + && strncmp (it->name, tag, taglen) == 0 + && strlen (it->name) == taglen) + break; + if (it == NULL) + { + ieee_error (info, start, _("undefined C++ object")); + return FALSE; + } + + dhandle = info->dhandle; + + fields = NULL; + field_count = 0; + field_alloc = 0; + baseclasses = NULL; + baseclasses_count = 0; + baseclasses_alloc = 0; + methods = NULL; + methods_count = 0; + methods_alloc = 0; + vptrbase = DEBUG_TYPE_NULL; + ownvptr = FALSE; + + structfields = debug_get_fields (dhandle, it->type); + + while (count > 0) + { + bfd_vma id; + const bfd_byte *spec_start; + + spec_start = *pp; + + if (! ieee_require_asn (info, pp, &id)) + return FALSE; + --count; + + switch (id) + { + default: + ieee_error (info, spec_start, _("unrecognized C++ object spec")); + return FALSE; + + case 'b': + { + bfd_vma flags, cinline; + const char *base, *fieldname; + unsigned long baselen, fieldlen; + char *basecopy; + debug_type basetype; + bfd_vma bitpos; + bfd_boolean virtualp; + enum debug_visibility visibility; + debug_baseclass baseclass; + + /* This represents a base or friend class. */ + + if (! ieee_require_asn (info, pp, &flags) + || ! ieee_require_atn65 (info, pp, &base, &baselen) + || ! ieee_require_asn (info, pp, &cinline) + || ! ieee_require_atn65 (info, pp, &fieldname, &fieldlen)) + return FALSE; + count -= 4; + + /* We have no way of recording friend information, so we + just ignore it. */ + if ((flags & BASEFLAGS_FRIEND) != 0) + break; + + /* I assume that either all of the members of the + baseclass are included in the object, starting at the + beginning of the object, or that none of them are + included. */ + + if ((fieldlen == 0) == (cinline == 0)) + { + ieee_error (info, start, _("unsupported C++ object type")); + return FALSE; + } + + basecopy = savestring (base, baselen); + basetype = debug_find_tagged_type (dhandle, basecopy, + DEBUG_KIND_ILLEGAL); + free (basecopy); + if (basetype == DEBUG_TYPE_NULL) + { + ieee_error (info, start, _("C++ base class not defined")); + return FALSE; + } + + if (fieldlen == 0) + bitpos = 0; + else + { + const debug_field *pf; + + if (structfields == NULL) + { + ieee_error (info, start, _("C++ object has no fields")); + return FALSE; + } + + for (pf = structfields; *pf != DEBUG_FIELD_NULL; pf++) + { + const char *fname; + + fname = debug_get_field_name (dhandle, *pf); + if (fname == NULL) + return FALSE; + if (fname[0] == fieldname[0] + && strncmp (fname, fieldname, fieldlen) == 0 + && strlen (fname) == fieldlen) + break; + } + if (*pf == DEBUG_FIELD_NULL) + { + ieee_error (info, start, + _("C++ base class not found in container")); + return FALSE; + } + + bitpos = debug_get_field_bitpos (dhandle, *pf); + } + + if ((flags & BASEFLAGS_VIRTUAL) != 0) + virtualp = TRUE; + else + virtualp = FALSE; + if ((flags & BASEFLAGS_PRIVATE) != 0) + visibility = DEBUG_VISIBILITY_PRIVATE; + else + visibility = DEBUG_VISIBILITY_PUBLIC; + + baseclass = debug_make_baseclass (dhandle, basetype, bitpos, + virtualp, visibility); + if (baseclass == DEBUG_BASECLASS_NULL) + return FALSE; + + if (baseclasses_count + 1 >= baseclasses_alloc) + { + baseclasses_alloc += 10; + baseclasses = ((debug_baseclass *) + xrealloc (baseclasses, + (baseclasses_alloc + * sizeof *baseclasses))); + } + + baseclasses[baseclasses_count] = baseclass; + ++baseclasses_count; + baseclasses[baseclasses_count] = DEBUG_BASECLASS_NULL; + } + break; + + case 'd': + { + bfd_vma flags; + const char *fieldname, *mangledname; + unsigned long fieldlen, mangledlen; + char *fieldcopy; + bfd_boolean staticp; + debug_type ftype; + const debug_field *pf = NULL; + enum debug_visibility visibility; + debug_field field; + + /* This represents a data member. */ + + if (! ieee_require_asn (info, pp, &flags) + || ! ieee_require_atn65 (info, pp, &fieldname, &fieldlen) + || ! ieee_require_atn65 (info, pp, &mangledname, &mangledlen)) + return FALSE; + count -= 3; + + fieldcopy = savestring (fieldname, fieldlen); + + staticp = (flags & CXXFLAGS_STATIC) != 0 ? TRUE : FALSE; + + if (staticp) + { + struct ieee_var *pv, *pvend; + + /* See if we can find a definition for this variable. */ + pv = info->vars.vars; + pvend = pv + info->vars.alloc; + for (; pv < pvend; pv++) + if (pv->namlen == mangledlen + && strncmp (pv->name, mangledname, mangledlen) == 0) + break; + if (pv < pvend) + ftype = pv->type; + else + { + /* This can happen if the variable is never used. */ + ftype = ieee_builtin_type (info, start, + (unsigned int) builtin_void); + } + } + else + { + unsigned int findx; + + if (structfields == NULL) + { + ieee_error (info, start, _("C++ object has no fields")); + return FALSE; + } + + for (pf = structfields, findx = 0; + *pf != DEBUG_FIELD_NULL; + pf++, findx++) + { + const char *fname; + + fname = debug_get_field_name (dhandle, *pf); + if (fname == NULL) + return FALSE; + if (fname[0] == mangledname[0] + && strncmp (fname, mangledname, mangledlen) == 0 + && strlen (fname) == mangledlen) + break; + } + if (*pf == DEBUG_FIELD_NULL) + { + ieee_error (info, start, + _("C++ data member not found in container")); + return FALSE; + } + + ftype = debug_get_field_type (dhandle, *pf); + + if (debug_get_type_kind (dhandle, ftype) == DEBUG_KIND_POINTER) + { + /* We might need to convert this field into a + reference type later on, so make it an indirect + type. */ + if (it->fslots == NULL) + { + unsigned int fcnt; + const debug_field *pfcnt; + + fcnt = 0; + for (pfcnt = structfields; + *pfcnt != DEBUG_FIELD_NULL; + pfcnt++) + ++fcnt; + it->fslots = ((debug_type *) + xmalloc (fcnt * sizeof *it->fslots)); + memset (it->fslots, 0, + fcnt * sizeof *it->fslots); + } + + if (ftype == DEBUG_TYPE_NULL) + return FALSE; + it->fslots[findx] = ftype; + ftype = debug_make_indirect_type (dhandle, + it->fslots + findx, + (const char *) NULL); + } + } + if (ftype == DEBUG_TYPE_NULL) + return FALSE; + + switch (flags & CXXFLAGS_VISIBILITY) + { + default: + ieee_error (info, start, _("unknown C++ visibility")); + return FALSE; + + case CXXFLAGS_VISIBILITY_PUBLIC: + visibility = DEBUG_VISIBILITY_PUBLIC; + break; + + case CXXFLAGS_VISIBILITY_PRIVATE: + visibility = DEBUG_VISIBILITY_PRIVATE; + break; + + case CXXFLAGS_VISIBILITY_PROTECTED: + visibility = DEBUG_VISIBILITY_PROTECTED; + break; + } + + if (staticp) + { + char *mangledcopy; + + mangledcopy = savestring (mangledname, mangledlen); + + field = debug_make_static_member (dhandle, fieldcopy, + ftype, mangledcopy, + visibility); + } + else + { + bfd_vma bitpos, bitsize; + + bitpos = debug_get_field_bitpos (dhandle, *pf); + bitsize = debug_get_field_bitsize (dhandle, *pf); + if (bitpos == (bfd_vma) -1 || bitsize == (bfd_vma) -1) + { + ieee_error (info, start, _("bad C++ field bit pos or size")); + return FALSE; + } + field = debug_make_field (dhandle, fieldcopy, ftype, bitpos, + bitsize, visibility); + } + + if (field == DEBUG_FIELD_NULL) + return FALSE; + + if (field_count + 1 >= field_alloc) + { + field_alloc += 10; + fields = ((debug_field *) + xrealloc (fields, field_alloc * sizeof *fields)); + } + + fields[field_count] = field; + ++field_count; + fields[field_count] = DEBUG_FIELD_NULL; + } + break; + + case 'm': + case 'v': + { + bfd_vma flags, voffset, control; + const char *name, *mangled; + unsigned long namlen, mangledlen; + struct ieee_var *pv, *pvend; + debug_type type; + enum debug_visibility visibility; + bfd_boolean constp, volatilep; + char *mangledcopy; + debug_method_variant mv; + struct ieee_method *meth; + unsigned int im; + + if (! ieee_require_asn (info, pp, &flags) + || ! ieee_require_atn65 (info, pp, &name, &namlen) + || ! ieee_require_atn65 (info, pp, &mangled, &mangledlen)) + return FALSE; + count -= 3; + if (id != 'v') + voffset = 0; + else + { + if (! ieee_require_asn (info, pp, &voffset)) + return FALSE; + --count; + } + if (! ieee_require_asn (info, pp, &control)) + return FALSE; + --count; + + /* We just ignore the control information. */ + + /* We have no way to represent friend information, so we + just ignore it. */ + if ((flags & CXXFLAGS_FRIEND) != 0) + break; + + /* We should already have seen a type for the function. */ + pv = info->vars.vars; + pvend = pv + info->vars.alloc; + for (; pv < pvend; pv++) + if (pv->namlen == mangledlen + && strncmp (pv->name, mangled, mangledlen) == 0) + break; + + if (pv >= pvend) + { + /* We won't have type information for this function if + it is not included in this file. We don't try to + handle this case. FIXME. */ + type = (debug_make_function_type + (dhandle, + ieee_builtin_type (info, start, + (unsigned int) builtin_void), + (debug_type *) NULL, + FALSE)); + } + else + { + debug_type return_type; + const debug_type *arg_types; + bfd_boolean varargs = FALSE; + + if (debug_get_type_kind (dhandle, pv->type) + != DEBUG_KIND_FUNCTION) + { + ieee_error (info, start, + _("bad type for C++ method function")); + return FALSE; + } + + return_type = debug_get_return_type (dhandle, pv->type); + arg_types = debug_get_parameter_types (dhandle, pv->type, + &varargs); + if (return_type == DEBUG_TYPE_NULL || arg_types == NULL) + { + ieee_error (info, start, + _("no type information for C++ method function")); + return FALSE; + } + + type = debug_make_method_type (dhandle, return_type, it->type, + (debug_type *) arg_types, + varargs); + } + if (type == DEBUG_TYPE_NULL) + return FALSE; + + switch (flags & CXXFLAGS_VISIBILITY) + { + default: + ieee_error (info, start, _("unknown C++ visibility")); + return FALSE; + + case CXXFLAGS_VISIBILITY_PUBLIC: + visibility = DEBUG_VISIBILITY_PUBLIC; + break; + + case CXXFLAGS_VISIBILITY_PRIVATE: + visibility = DEBUG_VISIBILITY_PRIVATE; + break; + + case CXXFLAGS_VISIBILITY_PROTECTED: + visibility = DEBUG_VISIBILITY_PROTECTED; + break; + } + + constp = (flags & CXXFLAGS_CONST) != 0 ? TRUE : FALSE; + volatilep = (flags & CXXFLAGS_VOLATILE) != 0 ? TRUE : FALSE; + + mangledcopy = savestring (mangled, mangledlen); + + if ((flags & CXXFLAGS_STATIC) != 0) + { + if (id == 'v') + { + ieee_error (info, start, _("C++ static virtual method")); + return FALSE; + } + mv = debug_make_static_method_variant (dhandle, mangledcopy, + type, visibility, + constp, volatilep); + } + else + { + debug_type vcontext; + + if (id != 'v') + vcontext = DEBUG_TYPE_NULL; + else + { + /* FIXME: How can we calculate this correctly? */ + vcontext = it->type; + } + mv = debug_make_method_variant (dhandle, mangledcopy, type, + visibility, constp, + volatilep, voffset, + vcontext); + } + if (mv == DEBUG_METHOD_VARIANT_NULL) + return FALSE; + + for (meth = methods, im = 0; im < methods_count; meth++, im++) + if (meth->namlen == namlen + && strncmp (meth->name, name, namlen) == 0) + break; + if (im >= methods_count) + { + if (methods_count >= methods_alloc) + { + methods_alloc += 10; + methods = ((struct ieee_method *) + xrealloc (methods, + methods_alloc * sizeof *methods)); + } + methods[methods_count].name = name; + methods[methods_count].namlen = namlen; + methods[methods_count].variants = NULL; + methods[methods_count].count = 0; + methods[methods_count].alloc = 0; + meth = methods + methods_count; + ++methods_count; + } + + if (meth->count + 1 >= meth->alloc) + { + meth->alloc += 10; + meth->variants = ((debug_method_variant *) + xrealloc (meth->variants, + (meth->alloc + * sizeof *meth->variants))); + } + + meth->variants[meth->count] = mv; + ++meth->count; + meth->variants[meth->count] = DEBUG_METHOD_VARIANT_NULL; + } + break; + + case 'o': + { + bfd_vma spec; + + /* We have no way to store this information, so we just + ignore it. */ + if (! ieee_require_asn (info, pp, &spec)) + return FALSE; + --count; + if ((spec & 4) != 0) + { + const char *filename; + unsigned long filenamlen; + bfd_vma lineno; + + if (! ieee_require_atn65 (info, pp, &filename, &filenamlen) + || ! ieee_require_asn (info, pp, &lineno)) + return FALSE; + count -= 2; + } + else if ((spec & 8) != 0) + { + const char *mangled; + unsigned long mangledlen; + + if (! ieee_require_atn65 (info, pp, &mangled, &mangledlen)) + return FALSE; + --count; + } + else + { + ieee_error (info, start, + _("unrecognized C++ object overhead spec")); + return FALSE; + } + } + break; + + case 'z': + { + const char *vname, *base; + unsigned long vnamelen, baselen; + bfd_vma vsize, control; + + /* A virtual table pointer. */ + + if (! ieee_require_atn65 (info, pp, &vname, &vnamelen) + || ! ieee_require_asn (info, pp, &vsize) + || ! ieee_require_atn65 (info, pp, &base, &baselen) + || ! ieee_require_asn (info, pp, &control)) + return FALSE; + count -= 4; + + /* We just ignore the control number. We don't care what + the virtual table name is. We have no way to store the + virtual table size, and I don't think we care anyhow. */ + + /* FIXME: We can't handle multiple virtual table pointers. */ + + if (baselen == 0) + ownvptr = TRUE; + else + { + char *basecopy; + + basecopy = savestring (base, baselen); + vptrbase = debug_find_tagged_type (dhandle, basecopy, + DEBUG_KIND_ILLEGAL); + free (basecopy); + if (vptrbase == DEBUG_TYPE_NULL) + { + ieee_error (info, start, _("undefined C++ vtable")); + return FALSE; + } + } + } + break; + } + } + + /* Now that we have seen all the method variants, we can call + debug_make_method for each one. */ + + if (methods_count == 0) + dmethods = NULL; + else + { + unsigned int i; + + dmethods = ((debug_method *) + xmalloc ((methods_count + 1) * sizeof *dmethods)); + for (i = 0; i < methods_count; i++) + { + char *namcopy; + + namcopy = savestring (methods[i].name, methods[i].namlen); + dmethods[i] = debug_make_method (dhandle, namcopy, + methods[i].variants); + if (dmethods[i] == DEBUG_METHOD_NULL) + return FALSE; + } + dmethods[i] = DEBUG_METHOD_NULL; + free (methods); + } + + /* The struct type was created as an indirect type pointing at + it->slot. We update it->slot to automatically update all + references to this struct. */ + it->slot = debug_make_object_type (dhandle, + cxx_class != 'u', + debug_get_type_size (dhandle, + it->slot), + fields, baseclasses, dmethods, + vptrbase, ownvptr); + if (it->slot == DEBUG_TYPE_NULL) + return FALSE; + + return TRUE; +} + +/* Read C++ default argument value and reference type information. */ + +static bfd_boolean +ieee_read_cxx_defaults (struct ieee_info *info, const bfd_byte **pp, + unsigned long count) +{ + const bfd_byte *start; + const char *fnname; + unsigned long fnlen; + bfd_vma defcount; + + start = *pp; + + /* Giving the function name before the argument count is an addendum + to the spec. The function name is demangled, though, so this + record must always refer to the current function. */ + + if (info->blockstack.bsp <= info->blockstack.stack + || info->blockstack.bsp[-1].fnindx == (unsigned int) -1) + { + ieee_error (info, start, _("C++ default values not in a function")); + return FALSE; + } + + if (! ieee_require_atn65 (info, pp, &fnname, &fnlen) + || ! ieee_require_asn (info, pp, &defcount)) + return FALSE; + count -= 2; + + while (defcount-- > 0) + { + bfd_vma type, val; + const char *strval; + unsigned long strvallen; + + if (! ieee_require_asn (info, pp, &type)) + return FALSE; + --count; + + switch (type) + { + case 0: + case 4: + break; + + case 1: + case 2: + if (! ieee_require_asn (info, pp, &val)) + return FALSE; + --count; + break; + + case 3: + case 7: + if (! ieee_require_atn65 (info, pp, &strval, &strvallen)) + return FALSE; + --count; + break; + + default: + ieee_error (info, start, _("unrecognized C++ default type")); + return FALSE; + } + + /* We have no way to record the default argument values, so we + just ignore them. FIXME. */ + } + + /* Any remaining arguments are indices of parameters that are really + reference type. */ + if (count > 0) + { + void *dhandle; + debug_type *arg_slots; + + dhandle = info->dhandle; + arg_slots = info->types.types[info->blockstack.bsp[-1].fnindx].arg_slots; + while (count-- > 0) + { + bfd_vma indx; + debug_type target; + + if (! ieee_require_asn (info, pp, &indx)) + return FALSE; + /* The index is 1 based. */ + --indx; + if (arg_slots == NULL + || arg_slots[indx] == DEBUG_TYPE_NULL + || (debug_get_type_kind (dhandle, arg_slots[indx]) + != DEBUG_KIND_POINTER)) + { + ieee_error (info, start, _("reference parameter is not a pointer")); + return FALSE; + } + + target = debug_get_target_type (dhandle, arg_slots[indx]); + arg_slots[indx] = debug_make_reference_type (dhandle, target); + if (arg_slots[indx] == DEBUG_TYPE_NULL) + return FALSE; + } + } + + return TRUE; +} + +/* Read a C++ reference definition. */ + +static bfd_boolean +ieee_read_reference (struct ieee_info *info, const bfd_byte **pp) +{ + const bfd_byte *start; + bfd_vma flags; + const char *cxx_class, *name; + unsigned long classlen, namlen; + debug_type *pslot; + debug_type target; + + start = *pp; + + if (! ieee_require_asn (info, pp, &flags)) + return FALSE; + + /* Giving the class name before the member name is in an addendum to + the spec. */ + if (flags == 3) + { + if (! ieee_require_atn65 (info, pp, &cxx_class, &classlen)) + return FALSE; + } + + if (! ieee_require_atn65 (info, pp, &name, &namlen)) + return FALSE; + + pslot = NULL; + if (flags != 3) + { + int pass; + + /* We search from the last variable indices to the first in + hopes of finding local variables correctly. We search the + local variables on the first pass, and the global variables + on the second. FIXME: This probably won't work in all cases. + On the other hand, I don't know what will. */ + for (pass = 0; pass < 2; pass++) + { + struct ieee_vars *vars; + int i; + struct ieee_var *pv = NULL; + + if (pass == 0) + vars = &info->vars; + else + { + vars = info->global_vars; + if (vars == NULL) + break; + } + + for (i = (int) vars->alloc - 1; i >= 0; i--) + { + bfd_boolean found; + + pv = vars->vars + i; + + if (pv->pslot == NULL + || pv->namlen != namlen + || strncmp (pv->name, name, namlen) != 0) + continue; + + found = FALSE; + switch (flags) + { + default: + ieee_error (info, start, + _("unrecognized C++ reference type")); + return FALSE; + + case 0: + /* Global variable or function. */ + if (pv->kind == IEEE_GLOBAL + || pv->kind == IEEE_EXTERNAL + || pv->kind == IEEE_FUNCTION) + found = TRUE; + break; + + case 1: + /* Global static variable or function. */ + if (pv->kind == IEEE_STATIC + || pv->kind == IEEE_FUNCTION) + found = TRUE; + break; + + case 2: + /* Local variable. */ + if (pv->kind == IEEE_LOCAL) + found = TRUE; + break; + } + + if (found) + break; + } + + if (i >= 0) + { + pslot = pv->pslot; + break; + } + } + } + else + { + struct ieee_tag *it; + + for (it = info->tags; it != NULL; it = it->next) + { + if (it->name[0] == cxx_class[0] + && strncmp (it->name, cxx_class, classlen) == 0 + && strlen (it->name) == classlen) + { + if (it->fslots != NULL) + { + const debug_field *pf; + unsigned int findx; + + pf = debug_get_fields (info->dhandle, it->type); + if (pf == NULL) + { + ieee_error (info, start, + "C++ reference in class with no fields"); + return FALSE; + } + + for (findx = 0; *pf != DEBUG_FIELD_NULL; pf++, findx++) + { + const char *fname; + + fname = debug_get_field_name (info->dhandle, *pf); + if (fname == NULL) + return FALSE; + if (strncmp (fname, name, namlen) == 0 + && strlen (fname) == namlen) + { + pslot = it->fslots + findx; + break; + } + } + } + + break; + } + } + } + + if (pslot == NULL) + { + ieee_error (info, start, _("C++ reference not found")); + return FALSE; + } + + /* We allocated the type of the object as an indirect type pointing + to *pslot, which we can now update to be a reference type. */ + if (debug_get_type_kind (info->dhandle, *pslot) != DEBUG_KIND_POINTER) + { + ieee_error (info, start, _("C++ reference is not pointer")); + return FALSE; + } + + target = debug_get_target_type (info->dhandle, *pslot); + *pslot = debug_make_reference_type (info->dhandle, target); + if (*pslot == DEBUG_TYPE_NULL) + return FALSE; + + return TRUE; +} + +/* Require an ASN record. */ + +static bfd_boolean +ieee_require_asn (struct ieee_info *info, const bfd_byte **pp, bfd_vma *pv) +{ + const bfd_byte *start; + ieee_record_enum_type c; + bfd_vma varindx; + + start = *pp; + + c = (ieee_record_enum_type) **pp; + if (c != ieee_e2_first_byte_enum) + { + ieee_error (info, start, _("missing required ASN")); + return FALSE; + } + ++*pp; + + c = (ieee_record_enum_type) (((unsigned int) c << 8) | **pp); + if (c != ieee_asn_record_enum) + { + ieee_error (info, start, _("missing required ASN")); + return FALSE; + } + ++*pp; + + /* Just ignore the variable index. */ + if (! ieee_read_number (info, pp, &varindx)) + return FALSE; + + return ieee_read_expression (info, pp, pv); +} + +/* Require an ATN65 record. */ + +static bfd_boolean +ieee_require_atn65 (struct ieee_info *info, const bfd_byte **pp, + const char **pname, unsigned long *pnamlen) +{ + const bfd_byte *start; + ieee_record_enum_type c; + bfd_vma name_indx, type_indx, atn_code; + + start = *pp; + + c = (ieee_record_enum_type) **pp; + if (c != ieee_at_record_enum) + { + ieee_error (info, start, _("missing required ATN65")); + return FALSE; + } + ++*pp; + + c = (ieee_record_enum_type) (((unsigned int) c << 8) | **pp); + if (c != ieee_atn_record_enum) + { + ieee_error (info, start, _("missing required ATN65")); + return FALSE; + } + ++*pp; + + if (! ieee_read_number (info, pp, &name_indx) + || ! ieee_read_number (info, pp, &type_indx) + || ! ieee_read_number (info, pp, &atn_code)) + return FALSE; + + /* Just ignore name_indx. */ + + if (type_indx != 0 || atn_code != 65) + { + ieee_error (info, start, _("bad ATN65 record")); + return FALSE; + } + + return ieee_read_id (info, pp, pname, pnamlen); +} + +/* Convert a register number in IEEE debugging information into a + generic register number. */ + +static int +ieee_regno_to_genreg (bfd *abfd, int r) +{ + switch (bfd_get_arch (abfd)) + { + case bfd_arch_m68k: + /* For some reasons stabs adds 2 to the floating point register + numbers. */ + if (r >= 16) + r += 2; + break; + + case bfd_arch_i960: + /* Stabs uses 0 to 15 for r0 to r15, 16 to 31 for g0 to g15, and + 32 to 35 for fp0 to fp3. */ + --r; + break; + + default: + break; + } + + return r; +} + +/* Convert a generic register number to an IEEE specific one. */ + +static int +ieee_genreg_to_regno (bfd *abfd, int r) +{ + switch (bfd_get_arch (abfd)) + { + case bfd_arch_m68k: + /* For some reason stabs add 2 to the floating point register + numbers. */ + if (r >= 18) + r -= 2; + break; + + case bfd_arch_i960: + /* Stabs uses 0 to 15 for r0 to r15, 16 to 31 for g0 to g15, and + 32 to 35 for fp0 to fp3. */ + ++r; + break; + + default: + break; + } + + return r; +} + +/* These routines build IEEE debugging information out of the generic + debugging information. */ + +/* We build the IEEE debugging information byte by byte. Rather than + waste time copying data around, we use a linked list of buffers to + hold the data. */ + +#define IEEE_BUFSIZE (490) + +struct ieee_buf +{ + /* Next buffer. */ + struct ieee_buf *next; + /* Number of data bytes in this buffer. */ + unsigned int c; + /* Bytes. */ + bfd_byte buf[IEEE_BUFSIZE]; +}; + +/* A list of buffers. */ + +struct ieee_buflist +{ + /* Head of list. */ + struct ieee_buf *head; + /* Tail--last buffer on list. */ + struct ieee_buf *tail; +}; + +/* In order to generate the BB11 blocks required by the HP emulator, + we keep track of ranges of addresses which correspond to a given + compilation unit. */ + +struct ieee_range +{ + /* Next range. */ + struct ieee_range *next; + /* Low address. */ + bfd_vma low; + /* High address. */ + bfd_vma high; +}; + +/* This structure holds information for a class on the type stack. */ + +struct ieee_type_class +{ + /* The name index in the debugging information. */ + unsigned int indx; + /* The pmisc records for the class. */ + struct ieee_buflist pmiscbuf; + /* The number of pmisc records. */ + unsigned int pmisccount; + /* The name of the class holding the virtual table, if not this + class. */ + const char *vclass; + /* Whether this class holds its own virtual table. */ + bfd_boolean ownvptr; + /* The largest virtual table offset seen so far. */ + bfd_vma voffset; + /* The current method. */ + const char *method; + /* Additional pmisc records used to record fields of reference type. */ + struct ieee_buflist refs; +}; + +/* This is how we store types for the writing routines. Most types + are simply represented by a type index. */ + +struct ieee_write_type +{ + /* Type index. */ + unsigned int indx; + /* The size of the type, if known. */ + unsigned int size; + /* The name of the type, if any. */ + const char *name; + /* If this is a function or method type, we build the type here, and + only add it to the output buffers if we need it. */ + struct ieee_buflist fndef; + /* If this is a struct, this is where the struct definition is + built. */ + struct ieee_buflist strdef; + /* If this is a class, this is where the class information is built. */ + struct ieee_type_class *classdef; + /* Whether the type is unsigned. */ + unsigned int unsignedp : 1; + /* Whether this is a reference type. */ + unsigned int referencep : 1; + /* Whether this is in the local type block. */ + unsigned int localp : 1; + /* Whether this is a duplicate struct definition which we are + ignoring. */ + unsigned int ignorep : 1; +}; + +/* This is the type stack used by the debug writing routines. FIXME: + We could generate more efficient output if we remembered when we + have output a particular type before. */ + +struct ieee_type_stack +{ + /* Next entry on stack. */ + struct ieee_type_stack *next; + /* Type information. */ + struct ieee_write_type type; +}; + +/* This is a list of associations between a name and some types. + These are used for typedefs and tags. */ + +struct ieee_name_type +{ + /* Next type for this name. */ + struct ieee_name_type *next; + /* ID number. For a typedef, this is the index of the type to which + this name is typedefed. */ + unsigned int id; + /* Type. */ + struct ieee_write_type type; + /* If this is a tag which has not yet been defined, this is the + kind. If the tag has been defined, this is DEBUG_KIND_ILLEGAL. */ + enum debug_type_kind kind; +}; + +/* We use a hash table to associate names and types. */ + +struct ieee_name_type_hash_table +{ + struct bfd_hash_table root; +}; + +struct ieee_name_type_hash_entry +{ + struct bfd_hash_entry root; + /* Information for this name. */ + struct ieee_name_type *types; +}; + +/* This is a list of enums. */ + +struct ieee_defined_enum +{ + /* Next enum. */ + struct ieee_defined_enum *next; + /* Type index. */ + unsigned int indx; + /* Whether this enum has been defined. */ + bfd_boolean defined; + /* Tag. */ + const char *tag; + /* Names. */ + const char **names; + /* Values. */ + bfd_signed_vma *vals; +}; + +/* We keep a list of modified versions of types, so that we don't + output them more than once. */ + +struct ieee_modified_type +{ + /* Pointer to this type. */ + unsigned int pointer; + /* Function with unknown arguments returning this type. */ + unsigned int function; + /* Const version of this type. */ + unsigned int const_qualified; + /* Volatile version of this type. */ + unsigned int volatile_qualified; + /* List of arrays of this type of various bounds. */ + struct ieee_modified_array_type *arrays; +}; + +/* A list of arrays bounds. */ + +struct ieee_modified_array_type +{ + /* Next array bounds. */ + struct ieee_modified_array_type *next; + /* Type index with these bounds. */ + unsigned int indx; + /* Low bound. */ + bfd_signed_vma low; + /* High bound. */ + bfd_signed_vma high; +}; + +/* This is a list of pending function parameter information. We don't + output them until we see the first block. */ + +struct ieee_pending_parm +{ + /* Next pending parameter. */ + struct ieee_pending_parm *next; + /* Name. */ + const char *name; + /* Type index. */ + unsigned int type; + /* Whether the type is a reference. */ + bfd_boolean referencep; + /* Kind. */ + enum debug_parm_kind kind; + /* Value. */ + bfd_vma val; +}; + +/* This is the handle passed down by debug_write. */ + +struct ieee_handle +{ + /* BFD we are writing to. */ + bfd *abfd; + /* Whether we got an error in a subroutine called via traverse or + map_over_sections. */ + bfd_boolean error; + /* Current data buffer list. */ + struct ieee_buflist *current; + /* Current data buffer. */ + struct ieee_buf *curbuf; + /* Filename of current compilation unit. */ + const char *filename; + /* Module name of current compilation unit. */ + const char *modname; + /* List of buffer for global types. */ + struct ieee_buflist global_types; + /* List of finished data buffers. */ + struct ieee_buflist data; + /* List of buffers for typedefs in the current compilation unit. */ + struct ieee_buflist types; + /* List of buffers for variables and functions in the current + compilation unit. */ + struct ieee_buflist vars; + /* List of buffers for C++ class definitions in the current + compilation unit. */ + struct ieee_buflist cxx; + /* List of buffers for line numbers in the current compilation unit. */ + struct ieee_buflist linenos; + /* Ranges for the current compilation unit. */ + struct ieee_range *ranges; + /* Ranges for all debugging information. */ + struct ieee_range *global_ranges; + /* Nested pending ranges. */ + struct ieee_range *pending_ranges; + /* Type stack. */ + struct ieee_type_stack *type_stack; + /* Next unallocated type index. */ + unsigned int type_indx; + /* Next unallocated name index. */ + unsigned int name_indx; + /* Typedefs. */ + struct ieee_name_type_hash_table typedefs; + /* Tags. */ + struct ieee_name_type_hash_table tags; + /* Enums. */ + struct ieee_defined_enum *enums; + /* Modified versions of types. */ + struct ieee_modified_type *modified; + /* Number of entries allocated in modified. */ + unsigned int modified_alloc; + /* 4 byte complex type. */ + unsigned int complex_float_index; + /* 8 byte complex type. */ + unsigned int complex_double_index; + /* The depth of block nesting. This is 0 outside a function, and 1 + just after start_function is called. */ + unsigned int block_depth; + /* The name of the current function. */ + const char *fnname; + /* List of buffers for the type of the function we are currently + writing out. */ + struct ieee_buflist fntype; + /* List of buffers for the parameters of the function we are + currently writing out. */ + struct ieee_buflist fnargs; + /* Number of arguments written to fnargs. */ + unsigned int fnargcount; + /* Pending function parameters. */ + struct ieee_pending_parm *pending_parms; + /* Current line number filename. */ + const char *lineno_filename; + /* Line number name index. */ + unsigned int lineno_name_indx; + /* Filename of pending line number. */ + const char *pending_lineno_filename; + /* Pending line number. */ + unsigned long pending_lineno; + /* Address of pending line number. */ + bfd_vma pending_lineno_addr; + /* Highest address seen at end of procedure. */ + bfd_vma highaddr; +}; + +static bfd_boolean ieee_init_buffer + (struct ieee_handle *, struct ieee_buflist *); +static bfd_boolean ieee_change_buffer + (struct ieee_handle *, struct ieee_buflist *); +static bfd_boolean ieee_append_buffer + (struct ieee_handle *, struct ieee_buflist *, struct ieee_buflist *); +static bfd_boolean ieee_real_write_byte (struct ieee_handle *, int); +static bfd_boolean ieee_write_2bytes (struct ieee_handle *, int); +static bfd_boolean ieee_write_number (struct ieee_handle *, bfd_vma); +static bfd_boolean ieee_write_id (struct ieee_handle *, const char *); +static bfd_boolean ieee_write_asn + (struct ieee_handle *, unsigned int, bfd_vma); +static bfd_boolean ieee_write_atn65 + (struct ieee_handle *, unsigned int, const char *); +static bfd_boolean ieee_push_type + (struct ieee_handle *, unsigned int, unsigned int, bfd_boolean, + bfd_boolean); +static unsigned int ieee_pop_type (struct ieee_handle *); +static void ieee_pop_unused_type (struct ieee_handle *); +static unsigned int ieee_pop_type_used (struct ieee_handle *, bfd_boolean); +static bfd_boolean ieee_add_range + (struct ieee_handle *, bfd_boolean, bfd_vma, bfd_vma); +static bfd_boolean ieee_start_range (struct ieee_handle *, bfd_vma); +static bfd_boolean ieee_end_range (struct ieee_handle *, bfd_vma); +static bfd_boolean ieee_define_type + (struct ieee_handle *, unsigned int, bfd_boolean, bfd_boolean); +static bfd_boolean ieee_define_named_type + (struct ieee_handle *, const char *, unsigned int, unsigned int, + bfd_boolean, bfd_boolean, struct ieee_buflist *); +static struct ieee_modified_type *ieee_get_modified_info + (struct ieee_handle *, unsigned int); +static struct bfd_hash_entry *ieee_name_type_newfunc + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); +static bfd_boolean ieee_write_undefined_tag + (struct ieee_name_type_hash_entry *, void *); +static bfd_boolean ieee_finish_compilation_unit (struct ieee_handle *); +static void ieee_add_bb11_blocks (bfd *, asection *, void *); +static bfd_boolean ieee_add_bb11 + (struct ieee_handle *, asection *, bfd_vma, bfd_vma); +static bfd_boolean ieee_output_pending_parms (struct ieee_handle *); +static unsigned int ieee_vis_to_flags (enum debug_visibility); +static bfd_boolean ieee_class_method_var + (struct ieee_handle *, const char *, enum debug_visibility, bfd_boolean, + bfd_boolean, bfd_boolean, bfd_vma, bfd_boolean); + +static bfd_boolean ieee_start_compilation_unit (void *, const char *); +static bfd_boolean ieee_start_source (void *, const char *); +static bfd_boolean ieee_empty_type (void *); +static bfd_boolean ieee_void_type (void *); +static bfd_boolean ieee_int_type (void *, unsigned int, bfd_boolean); +static bfd_boolean ieee_float_type (void *, unsigned int); +static bfd_boolean ieee_complex_type (void *, unsigned int); +static bfd_boolean ieee_bool_type (void *, unsigned int); +static bfd_boolean ieee_enum_type + (void *, const char *, const char **, bfd_signed_vma *); +static bfd_boolean ieee_pointer_type (void *); +static bfd_boolean ieee_function_type (void *, int, bfd_boolean); +static bfd_boolean ieee_reference_type (void *); +static bfd_boolean ieee_range_type (void *, bfd_signed_vma, bfd_signed_vma); +static bfd_boolean ieee_array_type + (void *, bfd_signed_vma, bfd_signed_vma, bfd_boolean); +static bfd_boolean ieee_set_type (void *, bfd_boolean); +static bfd_boolean ieee_offset_type (void *); +static bfd_boolean ieee_method_type (void *, bfd_boolean, int, bfd_boolean); +static bfd_boolean ieee_const_type (void *); +static bfd_boolean ieee_volatile_type (void *); +static bfd_boolean ieee_start_struct_type + (void *, const char *, unsigned int, bfd_boolean, unsigned int); +static bfd_boolean ieee_struct_field + (void *, const char *, bfd_vma, bfd_vma, enum debug_visibility); +static bfd_boolean ieee_end_struct_type (void *); +static bfd_boolean ieee_start_class_type + (void *, const char *, unsigned int, bfd_boolean, unsigned int, bfd_boolean, + bfd_boolean); +static bfd_boolean ieee_class_static_member + (void *, const char *, const char *, enum debug_visibility); +static bfd_boolean ieee_class_baseclass + (void *, bfd_vma, bfd_boolean, enum debug_visibility); +static bfd_boolean ieee_class_start_method (void *, const char *); +static bfd_boolean ieee_class_method_variant + (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean, + bfd_vma, bfd_boolean); +static bfd_boolean ieee_class_static_method_variant + (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean); +static bfd_boolean ieee_class_end_method (void *); +static bfd_boolean ieee_end_class_type (void *); +static bfd_boolean ieee_typedef_type (void *, const char *); +static bfd_boolean ieee_tag_type + (void *, const char *, unsigned int, enum debug_type_kind); +static bfd_boolean ieee_typdef (void *, const char *); +static bfd_boolean ieee_tag (void *, const char *); +static bfd_boolean ieee_int_constant (void *, const char *, bfd_vma); +static bfd_boolean ieee_float_constant (void *, const char *, double); +static bfd_boolean ieee_typed_constant (void *, const char *, bfd_vma); +static bfd_boolean ieee_variable + (void *, const char *, enum debug_var_kind, bfd_vma); +static bfd_boolean ieee_start_function (void *, const char *, bfd_boolean); +static bfd_boolean ieee_function_parameter + (void *, const char *, enum debug_parm_kind, bfd_vma); +static bfd_boolean ieee_start_block (void *, bfd_vma); +static bfd_boolean ieee_end_block (void *, bfd_vma); +static bfd_boolean ieee_end_function (void *); +static bfd_boolean ieee_lineno (void *, const char *, unsigned long, bfd_vma); + +static const struct debug_write_fns ieee_fns = +{ + ieee_start_compilation_unit, + ieee_start_source, + ieee_empty_type, + ieee_void_type, + ieee_int_type, + ieee_float_type, + ieee_complex_type, + ieee_bool_type, + ieee_enum_type, + ieee_pointer_type, + ieee_function_type, + ieee_reference_type, + ieee_range_type, + ieee_array_type, + ieee_set_type, + ieee_offset_type, + ieee_method_type, + ieee_const_type, + ieee_volatile_type, + ieee_start_struct_type, + ieee_struct_field, + ieee_end_struct_type, + ieee_start_class_type, + ieee_class_static_member, + ieee_class_baseclass, + ieee_class_start_method, + ieee_class_method_variant, + ieee_class_static_method_variant, + ieee_class_end_method, + ieee_end_class_type, + ieee_typedef_type, + ieee_tag_type, + ieee_typdef, + ieee_tag, + ieee_int_constant, + ieee_float_constant, + ieee_typed_constant, + ieee_variable, + ieee_start_function, + ieee_function_parameter, + ieee_start_block, + ieee_end_block, + ieee_end_function, + ieee_lineno +}; + +/* Initialize a buffer to be empty. */ + +static bfd_boolean +ieee_init_buffer (struct ieee_handle *info ATTRIBUTE_UNUSED, + struct ieee_buflist *buflist) +{ + buflist->head = NULL; + buflist->tail = NULL; + return TRUE; +} + +/* See whether a buffer list has any data. */ + +#define ieee_buffer_emptyp(buflist) ((buflist)->head == NULL) + +/* Change the current buffer to a specified buffer chain. */ + +static bfd_boolean +ieee_change_buffer (struct ieee_handle *info, struct ieee_buflist *buflist) +{ + if (buflist->head == NULL) + { + struct ieee_buf *buf; + + buf = (struct ieee_buf *) xmalloc (sizeof *buf); + buf->next = NULL; + buf->c = 0; + buflist->head = buf; + buflist->tail = buf; + } + + info->current = buflist; + info->curbuf = buflist->tail; + + return TRUE; +} + +/* Append a buffer chain. */ + +static bfd_boolean +ieee_append_buffer (struct ieee_handle *info ATTRIBUTE_UNUSED, + struct ieee_buflist *mainbuf, + struct ieee_buflist *newbuf) +{ + if (newbuf->head != NULL) + { + if (mainbuf->head == NULL) + mainbuf->head = newbuf->head; + else + mainbuf->tail->next = newbuf->head; + mainbuf->tail = newbuf->tail; + } + return TRUE; +} + +/* Write a byte into the buffer. We use a macro for speed and a + function for the complex cases. */ + +#define ieee_write_byte(info, b) \ + ((info)->curbuf->c < IEEE_BUFSIZE \ + ? ((info)->curbuf->buf[(info)->curbuf->c++] = (b), TRUE) \ + : ieee_real_write_byte ((info), (b))) + +static bfd_boolean +ieee_real_write_byte (struct ieee_handle *info, int b) +{ + if (info->curbuf->c >= IEEE_BUFSIZE) + { + struct ieee_buf *n; + + n = (struct ieee_buf *) xmalloc (sizeof *n); + n->next = NULL; + n->c = 0; + if (info->current->head == NULL) + info->current->head = n; + else + info->current->tail->next = n; + info->current->tail = n; + info->curbuf = n; + } + + info->curbuf->buf[info->curbuf->c] = b; + ++info->curbuf->c; + + return TRUE; +} + +/* Write out two bytes. */ + +static bfd_boolean +ieee_write_2bytes (struct ieee_handle *info, int i) +{ + return (ieee_write_byte (info, i >> 8) + && ieee_write_byte (info, i & 0xff)); +} + +/* Write out an integer. */ + +static bfd_boolean +ieee_write_number (struct ieee_handle *info, bfd_vma v) +{ + bfd_vma t; + bfd_byte ab[20]; + bfd_byte *p; + unsigned int c; + + if (v <= (bfd_vma) ieee_number_end_enum) + return ieee_write_byte (info, (int) v); + + t = v; + p = ab + sizeof ab; + while (t != 0) + { + *--p = t & 0xff; + t >>= 8; + } + c = (ab + 20) - p; + + if (c > (unsigned int) (ieee_number_repeat_end_enum + - ieee_number_repeat_start_enum)) + { + fprintf (stderr, _("IEEE numeric overflow: 0x")); + fprintf_vma (stderr, v); + fprintf (stderr, "\n"); + return FALSE; + } + + if (! ieee_write_byte (info, (int) ieee_number_repeat_start_enum + c)) + return FALSE; + for (; c > 0; --c, ++p) + { + if (! ieee_write_byte (info, *p)) + return FALSE; + } + + return TRUE; +} + +/* Write out a string. */ + +static bfd_boolean +ieee_write_id (struct ieee_handle *info, const char *s) +{ + unsigned int len; + + len = strlen (s); + if (len <= 0x7f) + { + if (! ieee_write_byte (info, len)) + return FALSE; + } + else if (len <= 0xff) + { + if (! ieee_write_byte (info, (int) ieee_extension_length_1_enum) + || ! ieee_write_byte (info, len)) + return FALSE; + } + else if (len <= 0xffff) + { + if (! ieee_write_byte (info, (int) ieee_extension_length_2_enum) + || ! ieee_write_2bytes (info, len)) + return FALSE; + } + else + { + fprintf (stderr, _("IEEE string length overflow: %u\n"), len); + return FALSE; + } + + for (; *s != '\0'; s++) + if (! ieee_write_byte (info, *s)) + return FALSE; + + return TRUE; +} + +/* Write out an ASN record. */ + +static bfd_boolean +ieee_write_asn (struct ieee_handle *info, unsigned int indx, bfd_vma val) +{ + return (ieee_write_2bytes (info, (int) ieee_asn_record_enum) + && ieee_write_number (info, indx) + && ieee_write_number (info, val)); +} + +/* Write out an ATN65 record. */ + +static bfd_boolean +ieee_write_atn65 (struct ieee_handle *info, unsigned int indx, const char *s) +{ + return (ieee_write_2bytes (info, (int) ieee_atn_record_enum) + && ieee_write_number (info, indx) + && ieee_write_number (info, 0) + && ieee_write_number (info, 65) + && ieee_write_id (info, s)); +} + +/* Push a type index onto the type stack. */ + +static bfd_boolean +ieee_push_type (struct ieee_handle *info, unsigned int indx, + unsigned int size, bfd_boolean unsignedp, bfd_boolean localp) +{ + struct ieee_type_stack *ts; + + ts = (struct ieee_type_stack *) xmalloc (sizeof *ts); + memset (ts, 0, sizeof *ts); + + ts->type.indx = indx; + ts->type.size = size; + ts->type.unsignedp = unsignedp; + ts->type.localp = localp; + + ts->next = info->type_stack; + info->type_stack = ts; + + return TRUE; +} + +/* Pop a type index off the type stack. */ + +static unsigned int +ieee_pop_type (struct ieee_handle *info) +{ + return ieee_pop_type_used (info, TRUE); +} + +/* Pop an unused type index off the type stack. */ + +static void +ieee_pop_unused_type (struct ieee_handle *info) +{ + (void) ieee_pop_type_used (info, FALSE); +} + +/* Pop a used or unused type index off the type stack. */ + +static unsigned int +ieee_pop_type_used (struct ieee_handle *info, bfd_boolean used) +{ + struct ieee_type_stack *ts; + unsigned int ret; + + ts = info->type_stack; + assert (ts != NULL); + + /* If this is a function type, and we need it, we need to append the + actual definition to the typedef block now. */ + if (used && ! ieee_buffer_emptyp (&ts->type.fndef)) + { + struct ieee_buflist *buflist; + + if (ts->type.localp) + { + /* Make sure we have started the types block. */ + if (ieee_buffer_emptyp (&info->types)) + { + if (! ieee_change_buffer (info, &info->types) + || ! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 1) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, info->modname)) + return FALSE; + } + buflist = &info->types; + } + else + { + /* Make sure we started the global type block. */ + if (ieee_buffer_emptyp (&info->global_types)) + { + if (! ieee_change_buffer (info, &info->global_types) + || ! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 2) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, "")) + return FALSE; + } + buflist = &info->global_types; + } + + if (! ieee_append_buffer (info, buflist, &ts->type.fndef)) + return FALSE; + } + + ret = ts->type.indx; + info->type_stack = ts->next; + free (ts); + return ret; +} + +/* Add a range of bytes included in the current compilation unit. */ + +static bfd_boolean +ieee_add_range (struct ieee_handle *info, bfd_boolean global, bfd_vma low, + bfd_vma high) +{ + struct ieee_range **plist, *r, **pr; + + if (low == (bfd_vma) -1 || high == (bfd_vma) -1 || low == high) + return TRUE; + + if (global) + plist = &info->global_ranges; + else + plist = &info->ranges; + + for (r = *plist; r != NULL; r = r->next) + { + if (high >= r->low && low <= r->high) + { + /* The new range overlaps r. */ + if (low < r->low) + r->low = low; + if (high > r->high) + r->high = high; + pr = &r->next; + while (*pr != NULL && (*pr)->low <= r->high) + { + struct ieee_range *n; + + if ((*pr)->high > r->high) + r->high = (*pr)->high; + n = (*pr)->next; + free (*pr); + *pr = n; + } + return TRUE; + } + } + + r = (struct ieee_range *) xmalloc (sizeof *r); + memset (r, 0, sizeof *r); + + r->low = low; + r->high = high; + + /* Store the ranges sorted by address. */ + for (pr = plist; *pr != NULL; pr = &(*pr)->next) + if ((*pr)->low > high) + break; + r->next = *pr; + *pr = r; + + return TRUE; +} + +/* Start a new range for which we only have the low address. */ + +static bfd_boolean +ieee_start_range (struct ieee_handle *info, bfd_vma low) +{ + struct ieee_range *r; + + r = (struct ieee_range *) xmalloc (sizeof *r); + memset (r, 0, sizeof *r); + r->low = low; + r->next = info->pending_ranges; + info->pending_ranges = r; + return TRUE; +} + +/* Finish a range started by ieee_start_range. */ + +static bfd_boolean +ieee_end_range (struct ieee_handle *info, bfd_vma high) +{ + struct ieee_range *r; + bfd_vma low; + + assert (info->pending_ranges != NULL); + r = info->pending_ranges; + low = r->low; + info->pending_ranges = r->next; + free (r); + return ieee_add_range (info, FALSE, low, high); +} + +/* Start defining a type. */ + +static bfd_boolean +ieee_define_type (struct ieee_handle *info, unsigned int size, + bfd_boolean unsignedp, bfd_boolean localp) +{ + return ieee_define_named_type (info, (const char *) NULL, + (unsigned int) -1, size, unsignedp, + localp, (struct ieee_buflist *) NULL); +} + +/* Start defining a named type. */ + +static bfd_boolean +ieee_define_named_type (struct ieee_handle *info, const char *name, + unsigned int indx, unsigned int size, + bfd_boolean unsignedp, bfd_boolean localp, + struct ieee_buflist *buflist) +{ + unsigned int type_indx; + unsigned int name_indx; + + if (indx != (unsigned int) -1) + type_indx = indx; + else + { + type_indx = info->type_indx; + ++info->type_indx; + } + + name_indx = info->name_indx; + ++info->name_indx; + + if (name == NULL) + name = ""; + + /* If we were given a buffer, use it; otherwise, use either the + local or the global type information, and make sure that the type + block is started. */ + if (buflist != NULL) + { + if (! ieee_change_buffer (info, buflist)) + return FALSE; + } + else if (localp) + { + if (! ieee_buffer_emptyp (&info->types)) + { + if (! ieee_change_buffer (info, &info->types)) + return FALSE; + } + else + { + if (! ieee_change_buffer (info, &info->types) + || ! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 1) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, info->modname)) + return FALSE; + } + } + else + { + if (! ieee_buffer_emptyp (&info->global_types)) + { + if (! ieee_change_buffer (info, &info->global_types)) + return FALSE; + } + else + { + if (! ieee_change_buffer (info, &info->global_types) + || ! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 2) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, "")) + return FALSE; + } + } + + /* Push the new type on the type stack, write out an NN record, and + write out the start of a TY record. The caller will then finish + the TY record. */ + if (! ieee_push_type (info, type_indx, size, unsignedp, localp)) + return FALSE; + + return (ieee_write_byte (info, (int) ieee_nn_record) + && ieee_write_number (info, name_indx) + && ieee_write_id (info, name) + && ieee_write_byte (info, (int) ieee_ty_record_enum) + && ieee_write_number (info, type_indx) + && ieee_write_byte (info, 0xce) + && ieee_write_number (info, name_indx)); +} + +/* Get an entry to the list of modified versions of a type. */ + +static struct ieee_modified_type * +ieee_get_modified_info (struct ieee_handle *info, unsigned int indx) +{ + if (indx >= info->modified_alloc) + { + unsigned int nalloc; + + nalloc = info->modified_alloc; + if (nalloc == 0) + nalloc = 16; + while (indx >= nalloc) + nalloc *= 2; + info->modified = ((struct ieee_modified_type *) + xrealloc (info->modified, + nalloc * sizeof *info->modified)); + memset (info->modified + info->modified_alloc, 0, + (nalloc - info->modified_alloc) * sizeof *info->modified); + info->modified_alloc = nalloc; + } + + return info->modified + indx; +} + +/* Routines for the hash table mapping names to types. */ + +/* Initialize an entry in the hash table. */ + +static struct bfd_hash_entry * +ieee_name_type_newfunc (struct bfd_hash_entry *entry, + struct bfd_hash_table *table, const char *string) +{ + struct ieee_name_type_hash_entry *ret = + (struct ieee_name_type_hash_entry *) entry; + + /* Allocate the structure if it has not already been allocated by a + subclass. */ + if (ret == NULL) + ret = ((struct ieee_name_type_hash_entry *) + bfd_hash_allocate (table, sizeof *ret)); + if (ret == NULL) + return NULL; + + /* Call the allocation method of the superclass. */ + ret = ((struct ieee_name_type_hash_entry *) + bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); + if (ret) + { + /* Set local fields. */ + ret->types = NULL; + } + + return (struct bfd_hash_entry *) ret; +} + +/* Look up an entry in the hash table. */ + +#define ieee_name_type_hash_lookup(table, string, create, copy) \ + ((struct ieee_name_type_hash_entry *) \ + bfd_hash_lookup (&(table)->root, (string), (create), (copy))) + +/* Traverse the hash table. */ + +#define ieee_name_type_hash_traverse(table, func, info) \ + (bfd_hash_traverse \ + (&(table)->root, \ + (bfd_boolean (*) (struct bfd_hash_entry *, void *)) (func), \ + (info))) + +/* The general routine to write out IEEE debugging information. */ + +bfd_boolean +write_ieee_debugging_info (bfd *abfd, void *dhandle) +{ + struct ieee_handle info; + asection *s; + const char *err; + struct ieee_buf *b; + + memset (&info, 0, sizeof info); + info.abfd = abfd; + info.type_indx = 256; + info.name_indx = 32; + + if (!bfd_hash_table_init (&info.typedefs.root, ieee_name_type_newfunc, + sizeof (struct ieee_name_type_hash_entry)) + || !bfd_hash_table_init (&info.tags.root, ieee_name_type_newfunc, + sizeof (struct ieee_name_type_hash_entry))) + return FALSE; + + if (! ieee_init_buffer (&info, &info.global_types) + || ! ieee_init_buffer (&info, &info.data) + || ! ieee_init_buffer (&info, &info.types) + || ! ieee_init_buffer (&info, &info.vars) + || ! ieee_init_buffer (&info, &info.cxx) + || ! ieee_init_buffer (&info, &info.linenos) + || ! ieee_init_buffer (&info, &info.fntype) + || ! ieee_init_buffer (&info, &info.fnargs)) + return FALSE; + + if (! debug_write (dhandle, &ieee_fns, (void *) &info)) + return FALSE; + + if (info.filename != NULL) + { + if (! ieee_finish_compilation_unit (&info)) + return FALSE; + } + + /* Put any undefined tags in the global typedef information. */ + info.error = FALSE; + ieee_name_type_hash_traverse (&info.tags, + ieee_write_undefined_tag, + (void *) &info); + if (info.error) + return FALSE; + + /* Prepend the global typedef information to the other data. */ + if (! ieee_buffer_emptyp (&info.global_types)) + { + /* The HP debugger seems to have a bug in which it ignores the + last entry in the global types, so we add a dummy entry. */ + if (! ieee_change_buffer (&info, &info.global_types) + || ! ieee_write_byte (&info, (int) ieee_nn_record) + || ! ieee_write_number (&info, info.name_indx) + || ! ieee_write_id (&info, "") + || ! ieee_write_byte (&info, (int) ieee_ty_record_enum) + || ! ieee_write_number (&info, info.type_indx) + || ! ieee_write_byte (&info, 0xce) + || ! ieee_write_number (&info, info.name_indx) + || ! ieee_write_number (&info, 'P') + || ! ieee_write_number (&info, (int) builtin_void + 32) + || ! ieee_write_byte (&info, (int) ieee_be_record_enum)) + return FALSE; + + if (! ieee_append_buffer (&info, &info.global_types, &info.data)) + return FALSE; + info.data = info.global_types; + } + + /* Make sure that we have declare BB11 blocks for each range in the + file. They are added to info->vars. */ + info.error = FALSE; + if (! ieee_init_buffer (&info, &info.vars)) + return FALSE; + bfd_map_over_sections (abfd, ieee_add_bb11_blocks, (void *) &info); + if (info.error) + return FALSE; + if (! ieee_buffer_emptyp (&info.vars)) + { + if (! ieee_change_buffer (&info, &info.vars) + || ! ieee_write_byte (&info, (int) ieee_be_record_enum)) + return FALSE; + + if (! ieee_append_buffer (&info, &info.data, &info.vars)) + return FALSE; + } + + /* Now all the data is in info.data. Write it out to the BFD. We + normally would need to worry about whether all the other sections + are set up yet, but the IEEE backend will handle this particular + case correctly regardless. */ + if (ieee_buffer_emptyp (&info.data)) + { + /* There is no debugging information. */ + return TRUE; + } + err = NULL; + s = bfd_make_section_with_flags (abfd, ".debug", + SEC_DEBUGGING | SEC_HAS_CONTENTS); + if (s == NULL) + err = "bfd_make_section"; + if (err == NULL) + { + bfd_size_type size; + + size = 0; + for (b = info.data.head; b != NULL; b = b->next) + size += b->c; + if (! bfd_set_section_size (abfd, s, size)) + err = "bfd_set_section_size"; + } + if (err == NULL) + { + file_ptr offset; + + offset = 0; + for (b = info.data.head; b != NULL; b = b->next) + { + if (! bfd_set_section_contents (abfd, s, b->buf, offset, b->c)) + { + err = "bfd_set_section_contents"; + break; + } + offset += b->c; + } + } + + if (err != NULL) + { + fprintf (stderr, "%s: %s: %s\n", bfd_get_filename (abfd), err, + bfd_errmsg (bfd_get_error ())); + return FALSE; + } + + bfd_hash_table_free (&info.typedefs.root); + bfd_hash_table_free (&info.tags.root); + + return TRUE; +} + +/* Write out information for an undefined tag. This is called via + ieee_name_type_hash_traverse. */ + +static bfd_boolean +ieee_write_undefined_tag (struct ieee_name_type_hash_entry *h, void *p) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + struct ieee_name_type *nt; + + for (nt = h->types; nt != NULL; nt = nt->next) + { + unsigned int name_indx; + char code; + + if (nt->kind == DEBUG_KIND_ILLEGAL) + continue; + + if (ieee_buffer_emptyp (&info->global_types)) + { + if (! ieee_change_buffer (info, &info->global_types) + || ! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 2) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, "")) + { + info->error = TRUE; + return FALSE; + } + } + else + { + if (! ieee_change_buffer (info, &info->global_types)) + { + info->error = TRUE; + return FALSE; + } + } + + name_indx = info->name_indx; + ++info->name_indx; + if (! ieee_write_byte (info, (int) ieee_nn_record) + || ! ieee_write_number (info, name_indx) + || ! ieee_write_id (info, nt->type.name) + || ! ieee_write_byte (info, (int) ieee_ty_record_enum) + || ! ieee_write_number (info, nt->type.indx) + || ! ieee_write_byte (info, 0xce) + || ! ieee_write_number (info, name_indx)) + { + info->error = TRUE; + return FALSE; + } + + switch (nt->kind) + { + default: + abort (); + info->error = TRUE; + return FALSE; + case DEBUG_KIND_STRUCT: + case DEBUG_KIND_CLASS: + code = 'S'; + break; + case DEBUG_KIND_UNION: + case DEBUG_KIND_UNION_CLASS: + code = 'U'; + break; + case DEBUG_KIND_ENUM: + code = 'E'; + break; + } + if (! ieee_write_number (info, code) + || ! ieee_write_number (info, 0)) + { + info->error = TRUE; + return FALSE; + } + } + + return TRUE; +} + +/* Start writing out information for a compilation unit. */ + +static bfd_boolean +ieee_start_compilation_unit (void *p, const char *filename) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + const char *modname; +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + const char *backslash; +#endif + char *c, *s; + + if (info->filename != NULL) + { + if (! ieee_finish_compilation_unit (info)) + return FALSE; + } + + info->filename = filename; + modname = strrchr (filename, '/'); +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + /* We could have a mixed forward/back slash case. */ + backslash = strrchr (filename, '\\'); + if (modname == NULL || (backslash != NULL && backslash > modname)) + modname = backslash; +#endif + + if (modname != NULL) + ++modname; +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + else if (filename[0] && filename[1] == ':') + modname = filename + 2; +#endif + else + modname = filename; + + c = xstrdup (modname); + s = strrchr (c, '.'); + if (s != NULL) + *s = '\0'; + info->modname = c; + + if (! ieee_init_buffer (info, &info->types) + || ! ieee_init_buffer (info, &info->vars) + || ! ieee_init_buffer (info, &info->cxx) + || ! ieee_init_buffer (info, &info->linenos)) + return FALSE; + info->ranges = NULL; + + /* Always include a BB1 and a BB3 block. That is what the output of + the MRI linker seems to look like. */ + if (! ieee_change_buffer (info, &info->types) + || ! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 1) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, info->modname)) + return FALSE; + + ++info->name_indx; + if (! ieee_change_buffer (info, &info->vars) + || ! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 3) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, info->modname)) + return FALSE; + + return TRUE; +} + +/* Finish up a compilation unit. */ + +static bfd_boolean +ieee_finish_compilation_unit (struct ieee_handle *info) +{ + struct ieee_range *r; + + if (! ieee_buffer_emptyp (&info->types)) + { + if (! ieee_change_buffer (info, &info->types) + || ! ieee_write_byte (info, (int) ieee_be_record_enum)) + return FALSE; + } + + if (! ieee_buffer_emptyp (&info->cxx)) + { + /* Append any C++ information to the global function and + variable information. */ + assert (! ieee_buffer_emptyp (&info->vars)); + if (! ieee_change_buffer (info, &info->vars)) + return FALSE; + + /* We put the pmisc records in a dummy procedure, just as the + MRI compiler does. */ + if (! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 6) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, "__XRYCPP") + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, info->highaddr - 1) + || ! ieee_append_buffer (info, &info->vars, &info->cxx) + || ! ieee_change_buffer (info, &info->vars) + || ! ieee_write_byte (info, (int) ieee_be_record_enum) + || ! ieee_write_number (info, info->highaddr - 1)) + return FALSE; + } + + if (! ieee_buffer_emptyp (&info->vars)) + { + if (! ieee_change_buffer (info, &info->vars) + || ! ieee_write_byte (info, (int) ieee_be_record_enum)) + return FALSE; + } + + if (info->pending_lineno_filename != NULL) + { + /* Force out the pending line number. */ + if (! ieee_lineno ((void *) info, (const char *) NULL, 0, (bfd_vma) -1)) + return FALSE; + } + if (! ieee_buffer_emptyp (&info->linenos)) + { + if (! ieee_change_buffer (info, &info->linenos) + || ! ieee_write_byte (info, (int) ieee_be_record_enum)) + return FALSE; + if (filename_cmp (info->filename, info->lineno_filename) != 0) + { + /* We were not in the main file. We just closed the + included line number block, and now we must close the + main line number block. */ + if (! ieee_write_byte (info, (int) ieee_be_record_enum)) + return FALSE; + } + } + + if (! ieee_append_buffer (info, &info->data, &info->types) + || ! ieee_append_buffer (info, &info->data, &info->vars) + || ! ieee_append_buffer (info, &info->data, &info->linenos)) + return FALSE; + + /* Build BB10/BB11 blocks based on the ranges we recorded. */ + if (! ieee_change_buffer (info, &info->data)) + return FALSE; + + if (! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 10) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, info->modname) + || ! ieee_write_id (info, "") + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, "GNU objcopy")) + return FALSE; + + for (r = info->ranges; r != NULL; r = r->next) + { + bfd_vma low, high; + asection *s; + int kind; + + low = r->low; + high = r->high; + + /* Find the section corresponding to this range. */ + for (s = info->abfd->sections; s != NULL; s = s->next) + { + if (bfd_get_section_vma (info->abfd, s) <= low + && high <= (bfd_get_section_vma (info->abfd, s) + + bfd_section_size (info->abfd, s))) + break; + } + + if (s == NULL) + { + /* Just ignore this range. */ + continue; + } + + /* Coalesce ranges if it seems reasonable. */ + while (r->next != NULL + && high + 0x1000 >= r->next->low + && (r->next->high + <= (bfd_get_section_vma (info->abfd, s) + + bfd_section_size (info->abfd, s)))) + { + r = r->next; + high = r->high; + } + + if ((s->flags & SEC_CODE) != 0) + kind = 1; + else if ((s->flags & SEC_READONLY) != 0) + kind = 3; + else + kind = 2; + + if (! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 11) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, "") + || ! ieee_write_number (info, kind) + || ! ieee_write_number (info, s->index + IEEE_SECTION_NUMBER_BASE) + || ! ieee_write_number (info, low) + || ! ieee_write_byte (info, (int) ieee_be_record_enum) + || ! ieee_write_number (info, high - low)) + return FALSE; + + /* Add this range to the list of global ranges. */ + if (! ieee_add_range (info, TRUE, low, high)) + return FALSE; + } + + if (! ieee_write_byte (info, (int) ieee_be_record_enum)) + return FALSE; + + return TRUE; +} + +/* Add BB11 blocks describing each range that we have not already + described. */ + +static void +ieee_add_bb11_blocks (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *data) +{ + struct ieee_handle *info = (struct ieee_handle *) data; + bfd_vma low, high; + struct ieee_range *r; + + low = bfd_get_section_vma (abfd, sec); + high = low + bfd_section_size (abfd, sec); + + /* Find the first range at or after this section. The ranges are + sorted by address. */ + for (r = info->global_ranges; r != NULL; r = r->next) + if (r->high > low) + break; + + while (low < high) + { + if (r == NULL || r->low >= high) + { + if (! ieee_add_bb11 (info, sec, low, high)) + info->error = TRUE; + return; + } + + if (low < r->low + && r->low - low > 0x100) + { + if (! ieee_add_bb11 (info, sec, low, r->low)) + { + info->error = TRUE; + return; + } + } + low = r->high; + + r = r->next; + } +} + +/* Add a single BB11 block for a range. We add it to info->vars. */ + +static bfd_boolean +ieee_add_bb11 (struct ieee_handle *info, asection *sec, bfd_vma low, + bfd_vma high) +{ + int kind; + + if (! ieee_buffer_emptyp (&info->vars)) + { + if (! ieee_change_buffer (info, &info->vars)) + return FALSE; + } + else + { + const char *filename, *modname; +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + const char *backslash; +#endif + char *c, *s; + + /* Start the enclosing BB10 block. */ + filename = bfd_get_filename (info->abfd); + modname = strrchr (filename, '/'); +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + backslash = strrchr (filename, '\\'); + if (modname == NULL || (backslash != NULL && backslash > modname)) + modname = backslash; +#endif + + if (modname != NULL) + ++modname; +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + else if (filename[0] && filename[1] == ':') + modname = filename + 2; +#endif + else + modname = filename; + + c = xstrdup (modname); + s = strrchr (c, '.'); + if (s != NULL) + *s = '\0'; + + if (! ieee_change_buffer (info, &info->vars) + || ! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 10) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, c) + || ! ieee_write_id (info, "") + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, "GNU objcopy")) + { + free (c); + return FALSE; + } + + free (c); + } + + if ((sec->flags & SEC_CODE) != 0) + kind = 1; + else if ((sec->flags & SEC_READONLY) != 0) + kind = 3; + else + kind = 2; + + if (! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 11) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, "") + || ! ieee_write_number (info, kind) + || ! ieee_write_number (info, sec->index + IEEE_SECTION_NUMBER_BASE) + || ! ieee_write_number (info, low) + || ! ieee_write_byte (info, (int) ieee_be_record_enum) + || ! ieee_write_number (info, high - low)) + return FALSE; + + return TRUE; +} + +/* Start recording information from a particular source file. This is + used to record which file defined which types, variables, etc. It + is not used for line numbers, since the lineno entry point passes + down the file name anyhow. IEEE debugging information doesn't seem + to store this information anywhere. */ + +static bfd_boolean +ieee_start_source (void *p ATTRIBUTE_UNUSED, + const char *filename ATTRIBUTE_UNUSED) +{ + return TRUE; +} + +/* Make an empty type. */ + +static bfd_boolean +ieee_empty_type (void *p) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + return ieee_push_type (info, (int) builtin_unknown, 0, FALSE, FALSE); +} + +/* Make a void type. */ + +static bfd_boolean +ieee_void_type (void *p) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + return ieee_push_type (info, (int) builtin_void, 0, FALSE, FALSE); +} + +/* Make an integer type. */ + +static bfd_boolean +ieee_int_type (void *p, unsigned int size, bfd_boolean unsignedp) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + unsigned int indx; + + switch (size) + { + case 1: + indx = (int) builtin_signed_char; + break; + case 2: + indx = (int) builtin_signed_short_int; + break; + case 4: + indx = (int) builtin_signed_long; + break; + case 8: + indx = (int) builtin_signed_long_long; + break; + default: + fprintf (stderr, _("IEEE unsupported integer type size %u\n"), size); + return FALSE; + } + + if (unsignedp) + ++indx; + + return ieee_push_type (info, indx, size, unsignedp, FALSE); +} + +/* Make a floating point type. */ + +static bfd_boolean +ieee_float_type (void *p, unsigned int size) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + unsigned int indx; + + switch (size) + { + case 4: + indx = (int) builtin_float; + break; + case 8: + indx = (int) builtin_double; + break; + case 12: + /* FIXME: This size really depends upon the processor. */ + indx = (int) builtin_long_double; + break; + case 16: + indx = (int) builtin_long_long_double; + break; + default: + fprintf (stderr, _("IEEE unsupported float type size %u\n"), size); + return FALSE; + } + + return ieee_push_type (info, indx, size, FALSE, FALSE); +} + +/* Make a complex type. */ + +static bfd_boolean +ieee_complex_type (void *p, unsigned int size) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + char code; + + switch (size) + { + case 4: + if (info->complex_float_index != 0) + return ieee_push_type (info, info->complex_float_index, size * 2, + FALSE, FALSE); + code = 'c'; + break; + case 12: + case 16: + /* These cases can be output by gcc -gstabs. Outputting the + wrong type is better than crashing. */ + case 8: + if (info->complex_double_index != 0) + return ieee_push_type (info, info->complex_double_index, size * 2, + FALSE, FALSE); + code = 'd'; + break; + default: + fprintf (stderr, _("IEEE unsupported complex type size %u\n"), size); + return FALSE; + } + + /* FIXME: I don't know what the string is for. */ + if (! ieee_define_type (info, size * 2, FALSE, FALSE) + || ! ieee_write_number (info, code) + || ! ieee_write_id (info, "")) + return FALSE; + + if (size == 4) + info->complex_float_index = info->type_stack->type.indx; + else + info->complex_double_index = info->type_stack->type.indx; + + return TRUE; +} + +/* Make a boolean type. IEEE doesn't support these, so we just make + an integer type instead. */ + +static bfd_boolean +ieee_bool_type (void *p, unsigned int size) +{ + return ieee_int_type (p, size, TRUE); +} + +/* Make an enumeration. */ + +static bfd_boolean +ieee_enum_type (void *p, const char *tag, const char **names, + bfd_signed_vma *vals) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + struct ieee_defined_enum *e; + bfd_boolean localp, simple; + unsigned int indx; + int i = 0; + + localp = FALSE; + indx = (unsigned int) -1; + for (e = info->enums; e != NULL; e = e->next) + { + if (tag == NULL) + { + if (e->tag != NULL) + continue; + } + else + { + if (e->tag == NULL + || tag[0] != e->tag[0] + || strcmp (tag, e->tag) != 0) + continue; + } + + if (! e->defined) + { + /* This enum tag has been seen but not defined. */ + indx = e->indx; + break; + } + + if (names != NULL && e->names != NULL) + { + for (i = 0; names[i] != NULL && e->names[i] != NULL; i++) + { + if (names[i][0] != e->names[i][0] + || vals[i] != e->vals[i] + || strcmp (names[i], e->names[i]) != 0) + break; + } + } + + if ((names == NULL && e->names == NULL) + || (names != NULL + && e->names != NULL + && names[i] == NULL + && e->names[i] == NULL)) + { + /* We've seen this enum before. */ + return ieee_push_type (info, e->indx, 0, TRUE, FALSE); + } + + if (tag != NULL) + { + /* We've already seen an enum of the same name, so we must make + sure to output this one locally. */ + localp = TRUE; + break; + } + } + + /* If this is a simple enumeration, in which the values start at 0 + and always increment by 1, we can use type E. Otherwise we must + use type N. */ + + simple = TRUE; + if (names != NULL) + { + for (i = 0; names[i] != NULL; i++) + { + if (vals[i] != i) + { + simple = FALSE; + break; + } + } + } + + if (! ieee_define_named_type (info, tag, indx, 0, TRUE, localp, + (struct ieee_buflist *) NULL) + || ! ieee_write_number (info, simple ? 'E' : 'N')) + return FALSE; + if (simple) + { + /* FIXME: This is supposed to be the enumeration size, but we + don't store that. */ + if (! ieee_write_number (info, 4)) + return FALSE; + } + if (names != NULL) + { + for (i = 0; names[i] != NULL; i++) + { + if (! ieee_write_id (info, names[i])) + return FALSE; + if (! simple) + { + if (! ieee_write_number (info, vals[i])) + return FALSE; + } + } + } + + if (! localp) + { + if (indx == (unsigned int) -1) + { + e = (struct ieee_defined_enum *) xmalloc (sizeof *e); + memset (e, 0, sizeof *e); + e->indx = info->type_stack->type.indx; + e->tag = tag; + + e->next = info->enums; + info->enums = e; + } + + e->names = names; + e->vals = vals; + e->defined = TRUE; + } + + return TRUE; +} + +/* Make a pointer type. */ + +static bfd_boolean +ieee_pointer_type (void *p) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + bfd_boolean localp; + unsigned int indx; + struct ieee_modified_type *m = NULL; + + localp = info->type_stack->type.localp; + indx = ieee_pop_type (info); + + /* A pointer to a simple builtin type can be obtained by adding 32. + FIXME: Will this be a short pointer, and will that matter? */ + if (indx < 32) + return ieee_push_type (info, indx + 32, 0, TRUE, FALSE); + + if (! localp) + { + m = ieee_get_modified_info ((struct ieee_handle *) p, indx); + if (m == NULL) + return FALSE; + + /* FIXME: The size should depend upon the architecture. */ + if (m->pointer > 0) + return ieee_push_type (info, m->pointer, 4, TRUE, FALSE); + } + + if (! ieee_define_type (info, 4, TRUE, localp) + || ! ieee_write_number (info, 'P') + || ! ieee_write_number (info, indx)) + return FALSE; + + if (! localp) + m->pointer = info->type_stack->type.indx; + + return TRUE; +} + +/* Make a function type. This will be called for a method, but we + don't want to actually add it to the type table in that case. We + handle this by defining the type in a private buffer, and only + adding that buffer to the typedef block if we are going to use it. */ + +static bfd_boolean +ieee_function_type (void *p, int argcount, bfd_boolean varargs) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + bfd_boolean localp; + unsigned int *args = NULL; + int i; + unsigned int retindx; + struct ieee_buflist fndef; + struct ieee_modified_type *m; + + localp = FALSE; + + if (argcount > 0) + { + args = (unsigned int *) xmalloc (argcount * sizeof *args); + for (i = argcount - 1; i >= 0; i--) + { + if (info->type_stack->type.localp) + localp = TRUE; + args[i] = ieee_pop_type (info); + } + } + else if (argcount < 0) + varargs = FALSE; + + if (info->type_stack->type.localp) + localp = TRUE; + retindx = ieee_pop_type (info); + + m = NULL; + if (argcount < 0 && ! localp) + { + m = ieee_get_modified_info ((struct ieee_handle *) p, retindx); + if (m == NULL) + return FALSE; + + if (m->function > 0) + return ieee_push_type (info, m->function, 0, TRUE, FALSE); + } + + /* An attribute of 0x41 means that the frame and push mask are + unknown. */ + if (! ieee_init_buffer (info, &fndef) + || ! ieee_define_named_type (info, (const char *) NULL, + (unsigned int) -1, 0, TRUE, localp, + &fndef) + || ! ieee_write_number (info, 'x') + || ! ieee_write_number (info, 0x41) + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, retindx) + || ! ieee_write_number (info, (bfd_vma) argcount + (varargs ? 1 : 0))) + { + free (args); + return FALSE; + } + if (argcount > 0) + { + for (i = 0; i < argcount; i++) + if (! ieee_write_number (info, args[i])) + return FALSE; + free (args); + } + if (varargs) + { + /* A varargs function is represented by writing out the last + argument as type void *, although this makes little sense. */ + if (! ieee_write_number (info, (bfd_vma) builtin_void + 32)) + return FALSE; + } + + if (! ieee_write_number (info, 0)) + return FALSE; + + /* We wrote the information into fndef, in case we don't need it. + It will be appended to info->types by ieee_pop_type. */ + info->type_stack->type.fndef = fndef; + + if (m != NULL) + m->function = info->type_stack->type.indx; + + return TRUE; +} + +/* Make a reference type. */ + +static bfd_boolean +ieee_reference_type (void *p) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + /* IEEE appears to record a normal pointer type, and then use a + pmisc record to indicate that it is really a reference. */ + + if (! ieee_pointer_type (p)) + return FALSE; + info->type_stack->type.referencep = TRUE; + return TRUE; +} + +/* Make a range type. */ + +static bfd_boolean +ieee_range_type (void *p, bfd_signed_vma low, bfd_signed_vma high) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + unsigned int size; + bfd_boolean unsignedp, localp; + + size = info->type_stack->type.size; + unsignedp = info->type_stack->type.unsignedp; + localp = info->type_stack->type.localp; + ieee_pop_unused_type (info); + return (ieee_define_type (info, size, unsignedp, localp) + && ieee_write_number (info, 'R') + && ieee_write_number (info, (bfd_vma) low) + && ieee_write_number (info, (bfd_vma) high) + && ieee_write_number (info, unsignedp ? 0 : 1) + && ieee_write_number (info, size)); +} + +/* Make an array type. */ + +static bfd_boolean +ieee_array_type (void *p, bfd_signed_vma low, bfd_signed_vma high, + bfd_boolean stringp ATTRIBUTE_UNUSED) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + unsigned int eleindx; + bfd_boolean localp; + unsigned int size; + struct ieee_modified_type *m = NULL; + struct ieee_modified_array_type *a; + + /* IEEE does not store the range, so we just ignore it. */ + ieee_pop_unused_type (info); + localp = info->type_stack->type.localp; + size = info->type_stack->type.size; + eleindx = ieee_pop_type (info); + + /* If we don't know the range, treat the size as exactly one + element. */ + if (low < high) + size *= (high - low) + 1; + + if (! localp) + { + m = ieee_get_modified_info (info, eleindx); + if (m == NULL) + return FALSE; + + for (a = m->arrays; a != NULL; a = a->next) + { + if (a->low == low && a->high == high) + return ieee_push_type (info, a->indx, size, FALSE, FALSE); + } + } + + if (! ieee_define_type (info, size, FALSE, localp) + || ! ieee_write_number (info, low == 0 ? 'Z' : 'C') + || ! ieee_write_number (info, eleindx)) + return FALSE; + if (low != 0) + { + if (! ieee_write_number (info, low)) + return FALSE; + } + + if (! ieee_write_number (info, high + 1)) + return FALSE; + + if (! localp) + { + a = (struct ieee_modified_array_type *) xmalloc (sizeof *a); + memset (a, 0, sizeof *a); + + a->indx = info->type_stack->type.indx; + a->low = low; + a->high = high; + + a->next = m->arrays; + m->arrays = a; + } + + return TRUE; +} + +/* Make a set type. */ + +static bfd_boolean +ieee_set_type (void *p, bfd_boolean bitstringp ATTRIBUTE_UNUSED) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + bfd_boolean localp; + unsigned int eleindx; + + localp = info->type_stack->type.localp; + eleindx = ieee_pop_type (info); + + /* FIXME: We don't know the size, so we just use 4. */ + + return (ieee_define_type (info, 0, TRUE, localp) + && ieee_write_number (info, 's') + && ieee_write_number (info, 4) + && ieee_write_number (info, eleindx)); +} + +/* Make an offset type. */ + +static bfd_boolean +ieee_offset_type (void *p) +{ + /* FIXME: The MRI C++ compiler does not appear to generate any + useful type information about an offset type. It just records a + pointer to member as an integer. The MRI/HP IEEE spec does + describe a pmisc record which can be used for a pointer to + member. Unfortunately, it does not describe the target type, + which seems pretty important. I'm going to punt this for now. */ + + return ieee_int_type (p, 4, TRUE); +} + +/* Make a method type. */ + +static bfd_boolean +ieee_method_type (void *p, bfd_boolean domain, int argcount, + bfd_boolean varargs) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + /* FIXME: The MRI/HP IEEE spec defines a pmisc record to use for a + method, but the definition is incomplete. We just output an 'x' + type. */ + + if (domain) + ieee_pop_unused_type (info); + + return ieee_function_type (p, argcount, varargs); +} + +/* Make a const qualified type. */ + +static bfd_boolean +ieee_const_type (void *p) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + unsigned int size; + bfd_boolean unsignedp, localp; + unsigned int indx; + struct ieee_modified_type *m = NULL; + + size = info->type_stack->type.size; + unsignedp = info->type_stack->type.unsignedp; + localp = info->type_stack->type.localp; + indx = ieee_pop_type (info); + + if (! localp) + { + m = ieee_get_modified_info (info, indx); + if (m == NULL) + return FALSE; + + if (m->const_qualified > 0) + return ieee_push_type (info, m->const_qualified, size, unsignedp, + FALSE); + } + + if (! ieee_define_type (info, size, unsignedp, localp) + || ! ieee_write_number (info, 'n') + || ! ieee_write_number (info, 1) + || ! ieee_write_number (info, indx)) + return FALSE; + + if (! localp) + m->const_qualified = info->type_stack->type.indx; + + return TRUE; +} + +/* Make a volatile qualified type. */ + +static bfd_boolean +ieee_volatile_type (void *p) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + unsigned int size; + bfd_boolean unsignedp, localp; + unsigned int indx; + struct ieee_modified_type *m = NULL; + + size = info->type_stack->type.size; + unsignedp = info->type_stack->type.unsignedp; + localp = info->type_stack->type.localp; + indx = ieee_pop_type (info); + + if (! localp) + { + m = ieee_get_modified_info (info, indx); + if (m == NULL) + return FALSE; + + if (m->volatile_qualified > 0) + return ieee_push_type (info, m->volatile_qualified, size, unsignedp, + FALSE); + } + + if (! ieee_define_type (info, size, unsignedp, localp) + || ! ieee_write_number (info, 'n') + || ! ieee_write_number (info, 2) + || ! ieee_write_number (info, indx)) + return FALSE; + + if (! localp) + m->volatile_qualified = info->type_stack->type.indx; + + return TRUE; +} + +/* Convert an enum debug_visibility into a CXXFLAGS value. */ + +static unsigned int +ieee_vis_to_flags (enum debug_visibility visibility) +{ + switch (visibility) + { + default: + abort (); + case DEBUG_VISIBILITY_PUBLIC: + return CXXFLAGS_VISIBILITY_PUBLIC; + case DEBUG_VISIBILITY_PRIVATE: + return CXXFLAGS_VISIBILITY_PRIVATE; + case DEBUG_VISIBILITY_PROTECTED: + return CXXFLAGS_VISIBILITY_PROTECTED; + } + /*NOTREACHED*/ +} + +/* Start defining a struct type. We build it in the strdef field on + the stack, to avoid confusing type definitions required by the + fields with the struct type itself. */ + +static bfd_boolean +ieee_start_struct_type (void *p, const char *tag, unsigned int id, + bfd_boolean structp, unsigned int size) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + bfd_boolean localp, ignorep; + bfd_boolean copy; + char ab[20]; + const char *look; + struct ieee_name_type_hash_entry *h; + struct ieee_name_type *nt, *ntlook; + struct ieee_buflist strdef; + + localp = FALSE; + ignorep = FALSE; + + /* We need to create a tag for internal use even if we don't want + one for external use. This will let us refer to an anonymous + struct. */ + if (tag != NULL) + { + look = tag; + copy = FALSE; + } + else + { + sprintf (ab, "__anon%u", id); + look = ab; + copy = TRUE; + } + + /* If we already have references to the tag, we must use the + existing type index. */ + h = ieee_name_type_hash_lookup (&info->tags, look, TRUE, copy); + if (h == NULL) + return FALSE; + + nt = NULL; + for (ntlook = h->types; ntlook != NULL; ntlook = ntlook->next) + { + if (ntlook->id == id) + nt = ntlook; + else if (! ntlook->type.localp) + { + /* We are creating a duplicate definition of a globally + defined tag. Force it to be local to avoid + confusion. */ + localp = TRUE; + } + } + + if (nt != NULL) + { + assert (localp == nt->type.localp); + if (nt->kind == DEBUG_KIND_ILLEGAL && ! localp) + { + /* We've already seen a global definition of the type. + Ignore this new definition. */ + ignorep = TRUE; + } + } + else + { + nt = (struct ieee_name_type *) xmalloc (sizeof *nt); + memset (nt, 0, sizeof *nt); + nt->id = id; + nt->type.name = h->root.string; + nt->next = h->types; + h->types = nt; + nt->type.indx = info->type_indx; + ++info->type_indx; + } + + nt->kind = DEBUG_KIND_ILLEGAL; + + if (! ieee_init_buffer (info, &strdef) + || ! ieee_define_named_type (info, tag, nt->type.indx, size, TRUE, + localp, &strdef) + || ! ieee_write_number (info, structp ? 'S' : 'U') + || ! ieee_write_number (info, size)) + return FALSE; + + if (! ignorep) + { + const char *hold; + + /* We never want nt->type.name to be NULL. We want the rest of + the type to be the object set up on the type stack; it will + have a NULL name if tag is NULL. */ + hold = nt->type.name; + nt->type = info->type_stack->type; + nt->type.name = hold; + } + + info->type_stack->type.name = tag; + info->type_stack->type.strdef = strdef; + info->type_stack->type.ignorep = ignorep; + + return TRUE; +} + +/* Add a field to a struct. */ + +static bfd_boolean +ieee_struct_field (void *p, const char *name, bfd_vma bitpos, bfd_vma bitsize, + enum debug_visibility visibility) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + unsigned int size; + bfd_boolean unsignedp; + bfd_boolean referencep; + bfd_boolean localp; + unsigned int indx; + bfd_vma offset; + + assert (info->type_stack != NULL + && info->type_stack->next != NULL + && ! ieee_buffer_emptyp (&info->type_stack->next->type.strdef)); + + /* If we are ignoring this struct definition, just pop and ignore + the type. */ + if (info->type_stack->next->type.ignorep) + { + ieee_pop_unused_type (info); + return TRUE; + } + + size = info->type_stack->type.size; + unsignedp = info->type_stack->type.unsignedp; + referencep = info->type_stack->type.referencep; + localp = info->type_stack->type.localp; + indx = ieee_pop_type (info); + + if (localp) + info->type_stack->type.localp = TRUE; + + if (info->type_stack->type.classdef != NULL) + { + unsigned int flags; + unsigned int nindx; + + /* This is a class. We must add a description of this field to + the class records we are building. */ + + flags = ieee_vis_to_flags (visibility); + nindx = info->type_stack->type.classdef->indx; + if (! ieee_change_buffer (info, + &info->type_stack->type.classdef->pmiscbuf) + || ! ieee_write_asn (info, nindx, 'd') + || ! ieee_write_asn (info, nindx, flags) + || ! ieee_write_atn65 (info, nindx, name) + || ! ieee_write_atn65 (info, nindx, name)) + return FALSE; + info->type_stack->type.classdef->pmisccount += 4; + + if (referencep) + { + /* We need to output a record recording that this field is + really of reference type. We put this on the refs field + of classdef, so that it can be appended to the C++ + records after the class is defined. */ + + nindx = info->name_indx; + ++info->name_indx; + + if (! ieee_change_buffer (info, + &info->type_stack->type.classdef->refs) + || ! ieee_write_byte (info, (int) ieee_nn_record) + || ! ieee_write_number (info, nindx) + || ! ieee_write_id (info, "") + || ! ieee_write_2bytes (info, (int) ieee_atn_record_enum) + || ! ieee_write_number (info, nindx) + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, 62) + || ! ieee_write_number (info, 80) + || ! ieee_write_number (info, 4) + || ! ieee_write_asn (info, nindx, 'R') + || ! ieee_write_asn (info, nindx, 3) + || ! ieee_write_atn65 (info, nindx, info->type_stack->type.name) + || ! ieee_write_atn65 (info, nindx, name)) + return FALSE; + } + } + + /* If the bitsize doesn't match the expected size, we need to output + a bitfield type. */ + if (size == 0 || bitsize == 0 || bitsize == size * 8) + offset = bitpos / 8; + else + { + if (! ieee_define_type (info, 0, unsignedp, + info->type_stack->type.localp) + || ! ieee_write_number (info, 'g') + || ! ieee_write_number (info, unsignedp ? 0 : 1) + || ! ieee_write_number (info, bitsize) + || ! ieee_write_number (info, indx)) + return FALSE; + indx = ieee_pop_type (info); + offset = bitpos; + } + + /* Switch to the struct we are building in order to output this + field definition. */ + return (ieee_change_buffer (info, &info->type_stack->type.strdef) + && ieee_write_id (info, name) + && ieee_write_number (info, indx) + && ieee_write_number (info, offset)); +} + +/* Finish up a struct type. */ + +static bfd_boolean +ieee_end_struct_type (void *p) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + struct ieee_buflist *pb; + + assert (info->type_stack != NULL + && ! ieee_buffer_emptyp (&info->type_stack->type.strdef)); + + /* If we were ignoring this struct definition because it was a + duplicate definition, just through away whatever bytes we have + accumulated. Leave the type on the stack. */ + if (info->type_stack->type.ignorep) + return TRUE; + + /* If this is not a duplicate definition of this tag, then localp + will be FALSE, and we can put it in the global type block. + FIXME: We should avoid outputting duplicate definitions which are + the same. */ + if (! info->type_stack->type.localp) + { + /* Make sure we have started the global type block. */ + if (ieee_buffer_emptyp (&info->global_types)) + { + if (! ieee_change_buffer (info, &info->global_types) + || ! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 2) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, "")) + return FALSE; + } + pb = &info->global_types; + } + else + { + /* Make sure we have started the types block. */ + if (ieee_buffer_emptyp (&info->types)) + { + if (! ieee_change_buffer (info, &info->types) + || ! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 1) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, info->modname)) + return FALSE; + } + pb = &info->types; + } + + /* Append the struct definition to the types. */ + if (! ieee_append_buffer (info, pb, &info->type_stack->type.strdef) + || ! ieee_init_buffer (info, &info->type_stack->type.strdef)) + return FALSE; + + /* Leave the struct on the type stack. */ + + return TRUE; +} + +/* Start a class type. */ + +static bfd_boolean +ieee_start_class_type (void *p, const char *tag, unsigned int id, + bfd_boolean structp, unsigned int size, + bfd_boolean vptr, bfd_boolean ownvptr) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + const char *vclass; + struct ieee_buflist pmiscbuf; + unsigned int indx; + struct ieee_type_class *classdef; + + /* A C++ class is output as a C++ struct along with a set of pmisc + records describing the class. */ + + /* We need to have a name so that we can associate the struct and + the class. */ + if (tag == NULL) + { + char *t; + + t = (char *) xmalloc (20); + sprintf (t, "__anon%u", id); + tag = t; + } + + /* We can't write out the virtual table information until we have + finished the class, because we don't know the virtual table size. + We get the size from the largest voffset we see. */ + vclass = NULL; + if (vptr && ! ownvptr) + { + vclass = info->type_stack->type.name; + assert (vclass != NULL); + /* We don't call ieee_pop_unused_type, since the class should + get defined. */ + (void) ieee_pop_type (info); + } + + if (! ieee_start_struct_type (p, tag, id, structp, size)) + return FALSE; + + indx = info->name_indx; + ++info->name_indx; + + /* We write out pmisc records into the classdef field. We will + write out the pmisc start after we know the number of records we + need. */ + if (! ieee_init_buffer (info, &pmiscbuf) + || ! ieee_change_buffer (info, &pmiscbuf) + || ! ieee_write_asn (info, indx, 'T') + || ! ieee_write_asn (info, indx, structp ? 'o' : 'u') + || ! ieee_write_atn65 (info, indx, tag)) + return FALSE; + + classdef = (struct ieee_type_class *) xmalloc (sizeof *classdef); + memset (classdef, 0, sizeof *classdef); + + classdef->indx = indx; + classdef->pmiscbuf = pmiscbuf; + classdef->pmisccount = 3; + classdef->vclass = vclass; + classdef->ownvptr = ownvptr; + + info->type_stack->type.classdef = classdef; + + return TRUE; +} + +/* Add a static member to a class. */ + +static bfd_boolean +ieee_class_static_member (void *p, const char *name, const char *physname, + enum debug_visibility visibility) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + unsigned int flags; + unsigned int nindx; + + /* We don't care about the type. Hopefully there will be a call to + ieee_variable declaring the physical name and the type, since + that is where an IEEE consumer must get the type. */ + ieee_pop_unused_type (info); + + assert (info->type_stack != NULL + && info->type_stack->type.classdef != NULL); + + flags = ieee_vis_to_flags (visibility); + flags |= CXXFLAGS_STATIC; + + nindx = info->type_stack->type.classdef->indx; + + if (! ieee_change_buffer (info, &info->type_stack->type.classdef->pmiscbuf) + || ! ieee_write_asn (info, nindx, 'd') + || ! ieee_write_asn (info, nindx, flags) + || ! ieee_write_atn65 (info, nindx, name) + || ! ieee_write_atn65 (info, nindx, physname)) + return FALSE; + info->type_stack->type.classdef->pmisccount += 4; + + return TRUE; +} + +/* Add a base class to a class. */ + +static bfd_boolean +ieee_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean is_virtual, + enum debug_visibility visibility) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + const char *bname; + bfd_boolean localp; + unsigned int bindx; + char *fname; + unsigned int flags; + unsigned int nindx; + + assert (info->type_stack != NULL + && info->type_stack->type.name != NULL + && info->type_stack->next != NULL + && info->type_stack->next->type.classdef != NULL + && ! ieee_buffer_emptyp (&info->type_stack->next->type.strdef)); + + bname = info->type_stack->type.name; + localp = info->type_stack->type.localp; + bindx = ieee_pop_type (info); + + /* We are currently defining both a struct and a class. We must + write out a field definition in the struct which holds the base + class. The stabs debugging reader will create a field named + _vb$CLASS for a virtual base class, so we just use that. FIXME: + we should not depend upon a detail of stabs debugging. */ + if (is_virtual) + { + fname = (char *) xmalloc (strlen (bname) + sizeof "_vb$"); + sprintf (fname, "_vb$%s", bname); + flags = BASEFLAGS_VIRTUAL; + } + else + { + if (localp) + info->type_stack->type.localp = TRUE; + + fname = (char *) xmalloc (strlen (bname) + sizeof "_b$"); + sprintf (fname, "_b$%s", bname); + + if (! ieee_change_buffer (info, &info->type_stack->type.strdef) + || ! ieee_write_id (info, fname) + || ! ieee_write_number (info, bindx) + || ! ieee_write_number (info, bitpos / 8)) + { + free (fname); + return FALSE; + } + flags = 0; + } + + if (visibility == DEBUG_VISIBILITY_PRIVATE) + flags |= BASEFLAGS_PRIVATE; + + nindx = info->type_stack->type.classdef->indx; + + if (! ieee_change_buffer (info, &info->type_stack->type.classdef->pmiscbuf) + || ! ieee_write_asn (info, nindx, 'b') + || ! ieee_write_asn (info, nindx, flags) + || ! ieee_write_atn65 (info, nindx, bname) + || ! ieee_write_asn (info, nindx, 0) + || ! ieee_write_atn65 (info, nindx, fname)) + { + free (fname); + return FALSE; + } + info->type_stack->type.classdef->pmisccount += 5; + + free (fname); + + return TRUE; +} + +/* Start building a method for a class. */ + +static bfd_boolean +ieee_class_start_method (void *p, const char *name) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + assert (info->type_stack != NULL + && info->type_stack->type.classdef != NULL + && info->type_stack->type.classdef->method == NULL); + + info->type_stack->type.classdef->method = name; + + return TRUE; +} + +/* Define a new method variant, either static or not. */ + +static bfd_boolean +ieee_class_method_var (struct ieee_handle *info, const char *physname, + enum debug_visibility visibility, + bfd_boolean staticp, bfd_boolean constp, + bfd_boolean volatilep, bfd_vma voffset, + bfd_boolean context) +{ + unsigned int flags; + unsigned int nindx; + bfd_boolean is_virtual; + + /* We don't need the type of the method. An IEEE consumer which + wants the type must track down the function by the physical name + and get the type from that. */ + ieee_pop_unused_type (info); + + /* We don't use the context. FIXME: We probably ought to use it to + adjust the voffset somehow, but I don't really know how. */ + if (context) + ieee_pop_unused_type (info); + + assert (info->type_stack != NULL + && info->type_stack->type.classdef != NULL + && info->type_stack->type.classdef->method != NULL); + + flags = ieee_vis_to_flags (visibility); + + /* FIXME: We never set CXXFLAGS_OVERRIDE, CXXFLAGS_OPERATOR, + CXXFLAGS_CTORDTOR, CXXFLAGS_CTOR, or CXXFLAGS_INLINE. */ + + if (staticp) + flags |= CXXFLAGS_STATIC; + if (constp) + flags |= CXXFLAGS_CONST; + if (volatilep) + flags |= CXXFLAGS_VOLATILE; + + nindx = info->type_stack->type.classdef->indx; + + is_virtual = context || voffset > 0; + + if (! ieee_change_buffer (info, + &info->type_stack->type.classdef->pmiscbuf) + || ! ieee_write_asn (info, nindx, is_virtual ? 'v' : 'm') + || ! ieee_write_asn (info, nindx, flags) + || ! ieee_write_atn65 (info, nindx, + info->type_stack->type.classdef->method) + || ! ieee_write_atn65 (info, nindx, physname)) + return FALSE; + + if (is_virtual) + { + if (voffset > info->type_stack->type.classdef->voffset) + info->type_stack->type.classdef->voffset = voffset; + if (! ieee_write_asn (info, nindx, voffset)) + return FALSE; + ++info->type_stack->type.classdef->pmisccount; + } + + if (! ieee_write_asn (info, nindx, 0)) + return FALSE; + + info->type_stack->type.classdef->pmisccount += 5; + + return TRUE; +} + +/* Define a new method variant. */ + +static bfd_boolean +ieee_class_method_variant (void *p, const char *physname, + enum debug_visibility visibility, + bfd_boolean constp, bfd_boolean volatilep, + bfd_vma voffset, bfd_boolean context) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + return ieee_class_method_var (info, physname, visibility, FALSE, constp, + volatilep, voffset, context); +} + +/* Define a new static method variant. */ + +static bfd_boolean +ieee_class_static_method_variant (void *p, const char *physname, + enum debug_visibility visibility, + bfd_boolean constp, bfd_boolean volatilep) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + return ieee_class_method_var (info, physname, visibility, TRUE, constp, + volatilep, 0, FALSE); +} + +/* Finish up a method. */ + +static bfd_boolean +ieee_class_end_method (void *p) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + assert (info->type_stack != NULL + && info->type_stack->type.classdef != NULL + && info->type_stack->type.classdef->method != NULL); + + info->type_stack->type.classdef->method = NULL; + + return TRUE; +} + +/* Finish up a class. */ + +static bfd_boolean +ieee_end_class_type (void *p) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + unsigned int nindx; + + assert (info->type_stack != NULL + && info->type_stack->type.classdef != NULL); + + /* If we were ignoring this class definition because it was a + duplicate definition, just through away whatever bytes we have + accumulated. Leave the type on the stack. */ + if (info->type_stack->type.ignorep) + return TRUE; + + nindx = info->type_stack->type.classdef->indx; + + /* If we have a virtual table, we can write out the information now. */ + if (info->type_stack->type.classdef->vclass != NULL + || info->type_stack->type.classdef->ownvptr) + { + if (! ieee_change_buffer (info, + &info->type_stack->type.classdef->pmiscbuf) + || ! ieee_write_asn (info, nindx, 'z') + || ! ieee_write_atn65 (info, nindx, "") + || ! ieee_write_asn (info, nindx, + info->type_stack->type.classdef->voffset)) + return FALSE; + if (info->type_stack->type.classdef->ownvptr) + { + if (! ieee_write_atn65 (info, nindx, "")) + return FALSE; + } + else + { + if (! ieee_write_atn65 (info, nindx, + info->type_stack->type.classdef->vclass)) + return FALSE; + } + if (! ieee_write_asn (info, nindx, 0)) + return FALSE; + info->type_stack->type.classdef->pmisccount += 5; + } + + /* Now that we know the number of pmisc records, we can write out + the atn62 which starts the pmisc records, and append them to the + C++ buffers. */ + + if (! ieee_change_buffer (info, &info->cxx) + || ! ieee_write_byte (info, (int) ieee_nn_record) + || ! ieee_write_number (info, nindx) + || ! ieee_write_id (info, "") + || ! ieee_write_2bytes (info, (int) ieee_atn_record_enum) + || ! ieee_write_number (info, nindx) + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, 62) + || ! ieee_write_number (info, 80) + || ! ieee_write_number (info, + info->type_stack->type.classdef->pmisccount)) + return FALSE; + + if (! ieee_append_buffer (info, &info->cxx, + &info->type_stack->type.classdef->pmiscbuf)) + return FALSE; + if (! ieee_buffer_emptyp (&info->type_stack->type.classdef->refs)) + { + if (! ieee_append_buffer (info, &info->cxx, + &info->type_stack->type.classdef->refs)) + return FALSE; + } + + return ieee_end_struct_type (p); +} + +/* Push a previously seen typedef onto the type stack. */ + +static bfd_boolean +ieee_typedef_type (void *p, const char *name) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + struct ieee_name_type_hash_entry *h; + struct ieee_name_type *nt; + + h = ieee_name_type_hash_lookup (&info->typedefs, name, FALSE, FALSE); + + /* h should never be NULL, since that would imply that the generic + debugging code has asked for a typedef which it has not yet + defined. */ + assert (h != NULL); + + /* We always use the most recently defined type for this name, which + will be the first one on the list. */ + + nt = h->types; + if (! ieee_push_type (info, nt->type.indx, nt->type.size, + nt->type.unsignedp, nt->type.localp)) + return FALSE; + + /* Copy over any other type information we may have. */ + info->type_stack->type = nt->type; + + return TRUE; +} + +/* Push a tagged type onto the type stack. */ + +static bfd_boolean +ieee_tag_type (void *p, const char *name, unsigned int id, + enum debug_type_kind kind) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + bfd_boolean localp; + bfd_boolean copy; + char ab[20]; + struct ieee_name_type_hash_entry *h; + struct ieee_name_type *nt; + + if (kind == DEBUG_KIND_ENUM) + { + struct ieee_defined_enum *e; + + if (name == NULL) + abort (); + for (e = info->enums; e != NULL; e = e->next) + if (e->tag != NULL && strcmp (e->tag, name) == 0) + return ieee_push_type (info, e->indx, 0, TRUE, FALSE); + + e = (struct ieee_defined_enum *) xmalloc (sizeof *e); + memset (e, 0, sizeof *e); + + e->indx = info->type_indx; + ++info->type_indx; + e->tag = name; + e->defined = FALSE; + + e->next = info->enums; + info->enums = e; + + return ieee_push_type (info, e->indx, 0, TRUE, FALSE); + } + + localp = FALSE; + + copy = FALSE; + if (name == NULL) + { + sprintf (ab, "__anon%u", id); + name = ab; + copy = TRUE; + } + + h = ieee_name_type_hash_lookup (&info->tags, name, TRUE, copy); + if (h == NULL) + return FALSE; + + for (nt = h->types; nt != NULL; nt = nt->next) + { + if (nt->id == id) + { + if (! ieee_push_type (info, nt->type.indx, nt->type.size, + nt->type.unsignedp, nt->type.localp)) + return FALSE; + /* Copy over any other type information we may have. */ + info->type_stack->type = nt->type; + return TRUE; + } + + if (! nt->type.localp) + { + /* This is a duplicate of a global type, so it must be + local. */ + localp = TRUE; + } + } + + nt = (struct ieee_name_type *) xmalloc (sizeof *nt); + memset (nt, 0, sizeof *nt); + + nt->id = id; + nt->type.name = h->root.string; + nt->type.indx = info->type_indx; + nt->type.localp = localp; + ++info->type_indx; + nt->kind = kind; + + nt->next = h->types; + h->types = nt; + + if (! ieee_push_type (info, nt->type.indx, 0, FALSE, localp)) + return FALSE; + + info->type_stack->type.name = h->root.string; + + return TRUE; +} + +/* Output a typedef. */ + +static bfd_boolean +ieee_typdef (void *p, const char *name) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + struct ieee_write_type type; + unsigned int indx; + bfd_boolean found; + bfd_boolean localp; + struct ieee_name_type_hash_entry *h; + struct ieee_name_type *nt; + + type = info->type_stack->type; + indx = type.indx; + + /* If this is a simple builtin type using a builtin name, we don't + want to output the typedef itself. We also want to change the + type index to correspond to the name being used. We recognize + names used in stabs debugging output even if they don't exactly + correspond to the names used for the IEEE builtin types. */ + found = FALSE; + if (indx <= (unsigned int) builtin_bcd_float) + { + switch ((enum builtin_types) indx) + { + default: + break; + + case builtin_void: + if (strcmp (name, "void") == 0) + found = TRUE; + break; + + case builtin_signed_char: + case builtin_char: + if (strcmp (name, "signed char") == 0) + { + indx = (unsigned int) builtin_signed_char; + found = TRUE; + } + else if (strcmp (name, "char") == 0) + { + indx = (unsigned int) builtin_char; + found = TRUE; + } + break; + + case builtin_unsigned_char: + if (strcmp (name, "unsigned char") == 0) + found = TRUE; + break; + + case builtin_signed_short_int: + case builtin_short: + case builtin_short_int: + case builtin_signed_short: + if (strcmp (name, "signed short int") == 0) + { + indx = (unsigned int) builtin_signed_short_int; + found = TRUE; + } + else if (strcmp (name, "short") == 0) + { + indx = (unsigned int) builtin_short; + found = TRUE; + } + else if (strcmp (name, "short int") == 0) + { + indx = (unsigned int) builtin_short_int; + found = TRUE; + } + else if (strcmp (name, "signed short") == 0) + { + indx = (unsigned int) builtin_signed_short; + found = TRUE; + } + break; + + case builtin_unsigned_short_int: + case builtin_unsigned_short: + if (strcmp (name, "unsigned short int") == 0 + || strcmp (name, "short unsigned int") == 0) + { + indx = builtin_unsigned_short_int; + found = TRUE; + } + else if (strcmp (name, "unsigned short") == 0) + { + indx = builtin_unsigned_short; + found = TRUE; + } + break; + + case builtin_signed_long: + case builtin_int: /* FIXME: Size depends upon architecture. */ + case builtin_long: + if (strcmp (name, "signed long") == 0) + { + indx = builtin_signed_long; + found = TRUE; + } + else if (strcmp (name, "int") == 0) + { + indx = builtin_int; + found = TRUE; + } + else if (strcmp (name, "long") == 0 + || strcmp (name, "long int") == 0) + { + indx = builtin_long; + found = TRUE; + } + break; + + case builtin_unsigned_long: + case builtin_unsigned: /* FIXME: Size depends upon architecture. */ + case builtin_unsigned_int: /* FIXME: Like builtin_unsigned. */ + if (strcmp (name, "unsigned long") == 0 + || strcmp (name, "long unsigned int") == 0) + { + indx = builtin_unsigned_long; + found = TRUE; + } + else if (strcmp (name, "unsigned") == 0) + { + indx = builtin_unsigned; + found = TRUE; + } + else if (strcmp (name, "unsigned int") == 0) + { + indx = builtin_unsigned_int; + found = TRUE; + } + break; + + case builtin_signed_long_long: + if (strcmp (name, "signed long long") == 0 + || strcmp (name, "long long int") == 0) + found = TRUE; + break; + + case builtin_unsigned_long_long: + if (strcmp (name, "unsigned long long") == 0 + || strcmp (name, "long long unsigned int") == 0) + found = TRUE; + break; + + case builtin_float: + if (strcmp (name, "float") == 0) + found = TRUE; + break; + + case builtin_double: + if (strcmp (name, "double") == 0) + found = TRUE; + break; + + case builtin_long_double: + if (strcmp (name, "long double") == 0) + found = TRUE; + break; + + case builtin_long_long_double: + if (strcmp (name, "long long double") == 0) + found = TRUE; + break; + } + + if (found) + type.indx = indx; + } + + h = ieee_name_type_hash_lookup (&info->typedefs, name, TRUE, FALSE); + if (h == NULL) + return FALSE; + + /* See if we have already defined this type with this name. */ + localp = type.localp; + for (nt = h->types; nt != NULL; nt = nt->next) + { + if (nt->id == indx) + { + /* If this is a global definition, then we don't need to + do anything here. */ + if (! nt->type.localp) + { + ieee_pop_unused_type (info); + return TRUE; + } + } + else + { + /* This is a duplicate definition, so make this one local. */ + localp = TRUE; + } + } + + /* We need to add a new typedef for this type. */ + + nt = (struct ieee_name_type *) xmalloc (sizeof *nt); + memset (nt, 0, sizeof *nt); + nt->id = indx; + nt->type = type; + nt->type.name = name; + nt->type.localp = localp; + nt->kind = DEBUG_KIND_ILLEGAL; + + nt->next = h->types; + h->types = nt; + + if (found) + { + /* This is one of the builtin typedefs, so we don't need to + actually define it. */ + ieee_pop_unused_type (info); + return TRUE; + } + + indx = ieee_pop_type (info); + + if (! ieee_define_named_type (info, name, (unsigned int) -1, type.size, + type.unsignedp, localp, + (struct ieee_buflist *) NULL) + || ! ieee_write_number (info, 'T') + || ! ieee_write_number (info, indx)) + return FALSE; + + /* Remove the type we just added to the type stack. This should not + be ieee_pop_unused_type, since the type is used, we just don't + need it now. */ + (void) ieee_pop_type (info); + + return TRUE; +} + +/* Output a tag for a type. We don't have to do anything here. */ + +static bfd_boolean +ieee_tag (void *p, const char *name ATTRIBUTE_UNUSED) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + /* This should not be ieee_pop_unused_type, since we want the type + to be defined. */ + (void) ieee_pop_type (info); + return TRUE; +} + +/* Output an integer constant. */ + +static bfd_boolean +ieee_int_constant (void *p ATTRIBUTE_UNUSED, const char *name ATTRIBUTE_UNUSED, + bfd_vma val ATTRIBUTE_UNUSED) +{ + /* FIXME. */ + return TRUE; +} + +/* Output a floating point constant. */ + +static bfd_boolean +ieee_float_constant (void *p ATTRIBUTE_UNUSED, + const char *name ATTRIBUTE_UNUSED, + double val ATTRIBUTE_UNUSED) +{ + /* FIXME. */ + return TRUE; +} + +/* Output a typed constant. */ + +static bfd_boolean +ieee_typed_constant (void *p, const char *name ATTRIBUTE_UNUSED, + bfd_vma val ATTRIBUTE_UNUSED) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + /* FIXME. */ + ieee_pop_unused_type (info); + return TRUE; +} + +/* Output a variable. */ + +static bfd_boolean +ieee_variable (void *p, const char *name, enum debug_var_kind kind, + bfd_vma val) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + unsigned int name_indx; + unsigned int size; + bfd_boolean referencep; + unsigned int type_indx; + bfd_boolean asn; + int refflag; + + size = info->type_stack->type.size; + referencep = info->type_stack->type.referencep; + type_indx = ieee_pop_type (info); + + assert (! ieee_buffer_emptyp (&info->vars)); + if (! ieee_change_buffer (info, &info->vars)) + return FALSE; + + name_indx = info->name_indx; + ++info->name_indx; + + /* Write out an NN and an ATN record for this variable. */ + if (! ieee_write_byte (info, (int) ieee_nn_record) + || ! ieee_write_number (info, name_indx) + || ! ieee_write_id (info, name) + || ! ieee_write_2bytes (info, (int) ieee_atn_record_enum) + || ! ieee_write_number (info, name_indx) + || ! ieee_write_number (info, type_indx)) + return FALSE; + switch (kind) + { + default: + abort (); + return FALSE; + case DEBUG_GLOBAL: + if (! ieee_write_number (info, 8) + || ! ieee_add_range (info, FALSE, val, val + size)) + return FALSE; + refflag = 0; + asn = TRUE; + break; + case DEBUG_STATIC: + if (! ieee_write_number (info, 3) + || ! ieee_add_range (info, FALSE, val, val + size)) + return FALSE; + refflag = 1; + asn = TRUE; + break; + case DEBUG_LOCAL_STATIC: + if (! ieee_write_number (info, 3) + || ! ieee_add_range (info, FALSE, val, val + size)) + return FALSE; + refflag = 2; + asn = TRUE; + break; + case DEBUG_LOCAL: + if (! ieee_write_number (info, 1) + || ! ieee_write_number (info, val)) + return FALSE; + refflag = 2; + asn = FALSE; + break; + case DEBUG_REGISTER: + if (! ieee_write_number (info, 2) + || ! ieee_write_number (info, + ieee_genreg_to_regno (info->abfd, val))) + return FALSE; + refflag = 2; + asn = FALSE; + break; + } + + if (asn) + { + if (! ieee_write_asn (info, name_indx, val)) + return FALSE; + } + + /* If this is really a reference type, then we just output it with + pointer type, and must now output a C++ record indicating that it + is really reference type. */ + if (referencep) + { + unsigned int nindx; + + nindx = info->name_indx; + ++info->name_indx; + + /* If this is a global variable, we want to output the misc + record in the C++ misc record block. Otherwise, we want to + output it just after the variable definition, which is where + the current buffer is. */ + if (refflag != 2) + { + if (! ieee_change_buffer (info, &info->cxx)) + return FALSE; + } + + if (! ieee_write_byte (info, (int) ieee_nn_record) + || ! ieee_write_number (info, nindx) + || ! ieee_write_id (info, "") + || ! ieee_write_2bytes (info, (int) ieee_atn_record_enum) + || ! ieee_write_number (info, nindx) + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, 62) + || ! ieee_write_number (info, 80) + || ! ieee_write_number (info, 3) + || ! ieee_write_asn (info, nindx, 'R') + || ! ieee_write_asn (info, nindx, refflag) + || ! ieee_write_atn65 (info, nindx, name)) + return FALSE; + } + + return TRUE; +} + +/* Start outputting information for a function. */ + +static bfd_boolean +ieee_start_function (void *p, const char *name, bfd_boolean global) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + bfd_boolean referencep; + unsigned int retindx, typeindx; + + referencep = info->type_stack->type.referencep; + retindx = ieee_pop_type (info); + + /* Besides recording a BB4 or BB6 block, we record the type of the + function in the BB1 typedef block. We can't write out the full + type until we have seen all the parameters, so we accumulate it + in info->fntype and info->fnargs. */ + if (! ieee_buffer_emptyp (&info->fntype)) + { + /* FIXME: This might happen someday if we support nested + functions. */ + abort (); + } + + info->fnname = name; + + /* An attribute of 0x40 means that the push mask is unknown. */ + if (! ieee_define_named_type (info, name, (unsigned int) -1, 0, FALSE, TRUE, + &info->fntype) + || ! ieee_write_number (info, 'x') + || ! ieee_write_number (info, 0x40) + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, retindx)) + return FALSE; + + typeindx = ieee_pop_type (info); + + if (! ieee_init_buffer (info, &info->fnargs)) + return FALSE; + info->fnargcount = 0; + + /* If the function return value is actually a reference type, we + must add a record indicating that. */ + if (referencep) + { + unsigned int nindx; + + nindx = info->name_indx; + ++info->name_indx; + if (! ieee_change_buffer (info, &info->cxx) + || ! ieee_write_byte (info, (int) ieee_nn_record) + || ! ieee_write_number (info, nindx) + || ! ieee_write_id (info, "") + || ! ieee_write_2bytes (info, (int) ieee_atn_record_enum) + || ! ieee_write_number (info, nindx) + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, 62) + || ! ieee_write_number (info, 80) + || ! ieee_write_number (info, 3) + || ! ieee_write_asn (info, nindx, 'R') + || ! ieee_write_asn (info, nindx, global ? 0 : 1) + || ! ieee_write_atn65 (info, nindx, name)) + return FALSE; + } + + assert (! ieee_buffer_emptyp (&info->vars)); + if (! ieee_change_buffer (info, &info->vars)) + return FALSE; + + /* The address is written out as the first block. */ + + ++info->block_depth; + + return (ieee_write_byte (info, (int) ieee_bb_record_enum) + && ieee_write_byte (info, global ? 4 : 6) + && ieee_write_number (info, 0) + && ieee_write_id (info, name) + && ieee_write_number (info, 0) + && ieee_write_number (info, typeindx)); +} + +/* Add a function parameter. This will normally be called before the + first block, so we postpone them until we see the block. */ + +static bfd_boolean +ieee_function_parameter (void *p, const char *name, enum debug_parm_kind kind, + bfd_vma val) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + struct ieee_pending_parm *m, **pm; + + assert (info->block_depth == 1); + + m = (struct ieee_pending_parm *) xmalloc (sizeof *m); + memset (m, 0, sizeof *m); + + m->next = NULL; + m->name = name; + m->referencep = info->type_stack->type.referencep; + m->type = ieee_pop_type (info); + m->kind = kind; + m->val = val; + + for (pm = &info->pending_parms; *pm != NULL; pm = &(*pm)->next) + ; + *pm = m; + + /* Add the type to the fnargs list. */ + if (! ieee_change_buffer (info, &info->fnargs) + || ! ieee_write_number (info, m->type)) + return FALSE; + ++info->fnargcount; + + return TRUE; +} + +/* Output pending function parameters. */ + +static bfd_boolean +ieee_output_pending_parms (struct ieee_handle *info) +{ + struct ieee_pending_parm *m; + unsigned int refcount; + + refcount = 0; + for (m = info->pending_parms; m != NULL; m = m->next) + { + enum debug_var_kind vkind; + + switch (m->kind) + { + default: + abort (); + return FALSE; + case DEBUG_PARM_STACK: + case DEBUG_PARM_REFERENCE: + vkind = DEBUG_LOCAL; + break; + case DEBUG_PARM_REG: + case DEBUG_PARM_REF_REG: + vkind = DEBUG_REGISTER; + break; + } + + if (! ieee_push_type (info, m->type, 0, FALSE, FALSE)) + return FALSE; + info->type_stack->type.referencep = m->referencep; + if (m->referencep) + ++refcount; + if (! ieee_variable ((void *) info, m->name, vkind, m->val)) + return FALSE; + } + + /* If there are any reference parameters, we need to output a + miscellaneous record indicating them. */ + if (refcount > 0) + { + unsigned int nindx, varindx; + + /* FIXME: The MRI compiler outputs the demangled function name + here, but we are outputting the mangled name. */ + nindx = info->name_indx; + ++info->name_indx; + if (! ieee_change_buffer (info, &info->vars) + || ! ieee_write_byte (info, (int) ieee_nn_record) + || ! ieee_write_number (info, nindx) + || ! ieee_write_id (info, "") + || ! ieee_write_2bytes (info, (int) ieee_atn_record_enum) + || ! ieee_write_number (info, nindx) + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, 62) + || ! ieee_write_number (info, 80) + || ! ieee_write_number (info, refcount + 3) + || ! ieee_write_asn (info, nindx, 'B') + || ! ieee_write_atn65 (info, nindx, info->fnname) + || ! ieee_write_asn (info, nindx, 0)) + return FALSE; + for (m = info->pending_parms, varindx = 1; + m != NULL; + m = m->next, varindx++) + { + if (m->referencep) + { + if (! ieee_write_asn (info, nindx, varindx)) + return FALSE; + } + } + } + + m = info->pending_parms; + while (m != NULL) + { + struct ieee_pending_parm *next; + + next = m->next; + free (m); + m = next; + } + + info->pending_parms = NULL; + + return TRUE; +} + +/* Start a block. If this is the first block, we output the address + to finish the BB4 or BB6, and then output the function parameters. */ + +static bfd_boolean +ieee_start_block (void *p, bfd_vma addr) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + if (! ieee_change_buffer (info, &info->vars)) + return FALSE; + + if (info->block_depth == 1) + { + if (! ieee_write_number (info, addr) + || ! ieee_output_pending_parms (info)) + return FALSE; + } + else + { + if (! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 6) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, "") + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, addr)) + return FALSE; + } + + if (! ieee_start_range (info, addr)) + return FALSE; + + ++info->block_depth; + + return TRUE; +} + +/* End a block. */ + +static bfd_boolean +ieee_end_block (void *p, bfd_vma addr) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + /* The address we are given is the end of the block, but IEEE seems + to want to the address of the last byte in the block, so we + subtract one. */ + if (! ieee_change_buffer (info, &info->vars) + || ! ieee_write_byte (info, (int) ieee_be_record_enum) + || ! ieee_write_number (info, addr - 1)) + return FALSE; + + if (! ieee_end_range (info, addr)) + return FALSE; + + --info->block_depth; + + if (addr > info->highaddr) + info->highaddr = addr; + + return TRUE; +} + +/* End a function. */ + +static bfd_boolean +ieee_end_function (void *p) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + assert (info->block_depth == 1); + + --info->block_depth; + + /* Now we can finish up fntype, and add it to the typdef section. + At this point, fntype is the 'x' type up to the argument count, + and fnargs is the argument types. We must add the argument + count, and we must add the level. FIXME: We don't record varargs + functions correctly. In fact, stabs debugging does not give us + enough information to do so. */ + if (! ieee_change_buffer (info, &info->fntype) + || ! ieee_write_number (info, info->fnargcount) + || ! ieee_change_buffer (info, &info->fnargs) + || ! ieee_write_number (info, 0)) + return FALSE; + + /* Make sure the typdef block has been started. */ + if (ieee_buffer_emptyp (&info->types)) + { + if (! ieee_change_buffer (info, &info->types) + || ! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 1) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, info->modname)) + return FALSE; + } + + if (! ieee_append_buffer (info, &info->types, &info->fntype) + || ! ieee_append_buffer (info, &info->types, &info->fnargs)) + return FALSE; + + info->fnname = NULL; + if (! ieee_init_buffer (info, &info->fntype) + || ! ieee_init_buffer (info, &info->fnargs)) + return FALSE; + info->fnargcount = 0; + + return TRUE; +} + +/* Record line number information. */ + +static bfd_boolean +ieee_lineno (void *p, const char *filename, unsigned long lineno, bfd_vma addr) +{ + struct ieee_handle *info = (struct ieee_handle *) p; + + assert (info->filename != NULL); + + /* The HP simulator seems to get confused when more than one line is + listed for the same address, at least if they are in different + files. We handle this by always listing the last line for a + given address, since that seems to be the one that gdb uses. */ + if (info->pending_lineno_filename != NULL + && addr != info->pending_lineno_addr) + { + /* Make sure we have a line number block. */ + if (! ieee_buffer_emptyp (&info->linenos)) + { + if (! ieee_change_buffer (info, &info->linenos)) + return FALSE; + } + else + { + info->lineno_name_indx = info->name_indx; + ++info->name_indx; + if (! ieee_change_buffer (info, &info->linenos) + || ! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 5) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, info->filename) + || ! ieee_write_byte (info, (int) ieee_nn_record) + || ! ieee_write_number (info, info->lineno_name_indx) + || ! ieee_write_id (info, "")) + return FALSE; + info->lineno_filename = info->filename; + } + + if (filename_cmp (info->pending_lineno_filename, + info->lineno_filename) != 0) + { + if (filename_cmp (info->filename, info->lineno_filename) != 0) + { + /* We were not in the main file. Close the block for the + included file. */ + if (! ieee_write_byte (info, (int) ieee_be_record_enum)) + return FALSE; + if (filename_cmp (info->filename, + info->pending_lineno_filename) == 0) + { + /* We need a new NN record, and we aren't about to + output one. */ + info->lineno_name_indx = info->name_indx; + ++info->name_indx; + if (! ieee_write_byte (info, (int) ieee_nn_record) + || ! ieee_write_number (info, info->lineno_name_indx) + || ! ieee_write_id (info, "")) + return FALSE; + } + } + if (filename_cmp (info->filename, + info->pending_lineno_filename) != 0) + { + /* We are not changing to the main file. Open a block for + the new included file. */ + info->lineno_name_indx = info->name_indx; + ++info->name_indx; + if (! ieee_write_byte (info, (int) ieee_bb_record_enum) + || ! ieee_write_byte (info, 5) + || ! ieee_write_number (info, 0) + || ! ieee_write_id (info, info->pending_lineno_filename) + || ! ieee_write_byte (info, (int) ieee_nn_record) + || ! ieee_write_number (info, info->lineno_name_indx) + || ! ieee_write_id (info, "")) + return FALSE; + } + info->lineno_filename = info->pending_lineno_filename; + } + + if (! ieee_write_2bytes (info, (int) ieee_atn_record_enum) + || ! ieee_write_number (info, info->lineno_name_indx) + || ! ieee_write_number (info, 0) + || ! ieee_write_number (info, 7) + || ! ieee_write_number (info, info->pending_lineno) + || ! ieee_write_number (info, 0) + || ! ieee_write_asn (info, info->lineno_name_indx, + info->pending_lineno_addr)) + return FALSE; + } + + info->pending_lineno_filename = filename; + info->pending_lineno = lineno; + info->pending_lineno_addr = addr; + + return TRUE; +} diff --git a/support/sdbinutils/binutils/is-ranlib.c b/support/sdbinutils/binutils/is-ranlib.c new file mode 100644 index 0000000..31e3eef --- /dev/null +++ b/support/sdbinutils/binutils/is-ranlib.c @@ -0,0 +1,22 @@ +/* Copyright (C) 2007-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Linked with ar.o to flag that this program is 'ranlib' (not 'ar'). */ + +int is_ranlib = 1; diff --git a/support/sdbinutils/binutils/is-strip.c b/support/sdbinutils/binutils/is-strip.c new file mode 100644 index 0000000..cad4308 --- /dev/null +++ b/support/sdbinutils/binutils/is-strip.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2007-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Linked with objcopy.o to flag that this program is 'strip' (not + 'objcopy'). */ + +int is_strip = 1; diff --git a/support/sdbinutils/binutils/libtool b/support/sdbinutils/binutils/libtool new file mode 100755 index 0000000..cb8396f --- /dev/null +++ b/support/sdbinutils/binutils/libtool @@ -0,0 +1,9129 @@ +#! /bin/bash + +# libtool - Provide generalized library-building support services. +# Generated automatically by config.status (binutils) 2.30 +# Libtool was configured on host xavier-asus: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is part of GNU Libtool. +# +# GNU Libtool 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. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or +# obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +# The names of the tagged configurations supported by this script. +available_tags="" + +# ### BEGIN LIBTOOL CONFIG + +# Which release of libtool.m4 was used? +macro_version=2.2.7a +macro_revision=1.3134 + +# Whether or not to build shared libraries. +build_libtool_libs=yes + +# Whether or not to build static libraries. +build_old_libs=yes + +# What type of objects to build. +pic_mode=default + +# Whether or not to optimize for fast installation. +fast_install=needless + +# Shell to use when invoking shell scripts. +SHELL="/bin/bash" + +# An echo program that protects backslashes. +ECHO="printf %s\\n" + +# The host system. +host_alias=x86_64-pc-linux-gnu +host=x86_64-pc-linux-gnu +host_os=linux-gnu + +# The build system. +build_alias=x86_64-pc-linux-gnu +build=x86_64-pc-linux-gnu +build_os=linux-gnu + +# A sed program that does not truncate output. +SED="/bin/sed" + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="$SED -e 1s/^X//" + +# A grep program that handles long lines. +GREP="/bin/grep" + +# An ERE matcher. +EGREP="/bin/grep -E" + +# A literal string matcher. +FGREP="/bin/grep -F" + +# A BSD- or MS-compatible name lister. +NM="nm" + +# Whether we need soft or hard links. +LN_S="ln -s" + +# What is the maximum length of a command? +max_cmd_len=1572864 + +# Object file suffix (normally "o"). +objext=o + +# Executable file suffix (normally ""). +exeext= + +# whether the shell understands "unset". +lt_unset=unset + +# turn spaces into newlines. +SP2NL="tr \\040 \\012" + +# turn newlines into spaces. +NL2SP="tr \\015\\012 \\040\\040" + +# An object symbol dumper. +OBJDUMP="objdump" + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method="pass_all" + +# Command to use when deplibs_check_method == "file_magic". +file_magic_cmd="\$MAGIC_CMD" + +# The archiver. +AR="ar" +AR_FLAGS="rc" + +# A symbol stripping program. +STRIP="strip" + +# Commands used to install an old-style archive. +RANLIB="ranlib" +old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$oldlib" +old_postuninstall_cmds="" + +# Whether to use a lock for old archive extraction. +lock_old_archive_extraction=no + +# A C compiler. +LTCC="gcc" + +# LTCC compiler flags. +LTCFLAGS="-g -O2" + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe="sed -n -e 's/^.*[ ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][ ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p'" + +# Transform the output of nm in a proper C declaration. +global_symbol_to_cdecl="sed -n -e 's/^T .* \\(.*\\)\$/extern int \\1();/p' -e 's/^[ABCDGIRSTW]* .* \\(.*\\)\$/extern char \\1;/p'" + +# Transform the output of nm in a C name address pair. +global_symbol_to_c_name_address="sed -n -e 's/^: \\([^ ]*\\) \$/ {\\\"\\1\\\", (void *) 0},/p' -e 's/^[ABCDGIRSTW]* \\([^ ]*\\) \\([^ ]*\\)\$/ {\"\\2\", (void *) \\&\\2},/p'" + +# Transform the output of nm in a C name address pair when lib prefix is needed. +global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \\([^ ]*\\) \$/ {\\\"\\1\\\", (void *) 0},/p' -e 's/^[ABCDGIRSTW]* \\([^ ]*\\) \\(lib[^ ]*\\)\$/ {\"\\2\", (void *) \\&\\2},/p' -e 's/^[ABCDGIRSTW]* \\([^ ]*\\) \\([^ ]*\\)\$/ {\"lib\\2\", (void *) \\&\\2},/p'" + +# The name of the directory that contains temporary libtool files. +objdir=.libs + +# Used to examine libraries when file_magic_cmd begins with "file". +MAGIC_CMD=file + +# Must we lock files when doing compilation? +need_locks="no" + +# Tool to manipulate archived DWARF debug symbol files on Mac OS X. +DSYMUTIL="" + +# Tool to change global to local symbols on Mac OS X. +NMEDIT="" + +# Tool to manipulate fat objects and archives on Mac OS X. +LIPO="" + +# ldd/readelf like tool for Mach-O binaries on Mac OS X. +OTOOL="" + +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. +OTOOL64="" + +# Old archive suffix (normally "a"). +libext=a + +# Shared library suffix (normally ".so"). +shrext_cmds=".so" + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds="" + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at link time. +variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" + +# Do we need the "lib" prefix for modules? +need_lib_prefix=no + +# Do we need a version for libraries? +need_version=no + +# Library versioning type. +version_type=linux + +# Shared library runtime path variable. +runpath_var=LD_RUN_PATH + +# Shared library path variable. +shlibpath_var=LD_LIBRARY_PATH + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=yes + +# Format of library name prefix. +libname_spec="lib\$name" + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME +library_names_spec="\${libname}\${release}\${shared_ext}\$versuffix \${libname}\${release}\${shared_ext}\$major \$libname\${shared_ext}" + +# The coded name of the library, if different from the real name. +soname_spec="\${libname}\${release}\${shared_ext}\$major" + +# Permission mode override for installation of shared libraries. +install_override_mode="" + +# Command to use after installation of a shared archive. +postinstall_cmds="" + +# Command to use after uninstallation of a shared archive. +postuninstall_cmds="" + +# Commands used to finish a libtool library installation in a directory. +finish_cmds="PATH=\\\"\\\$PATH:/sbin\\\" ldconfig -n \$libdir" + +# As "finish_cmds", except a single script fragment to be evaled but +# not shown. +finish_eval="" + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=yes + +# Compile-time system search path for libraries. +sys_lib_search_path_spec="/usr/lib/gcc/x86_64-linux-gnu/7 /usr/lib/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib " + +# Run-time system search path for libraries. +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/x86_64-linux-gnu/libfakeroot /usr/local/lib/i386-linux-gnu /lib/i386-linux-gnu /usr/lib/i386-linux-gnu /usr/local/lib/i686-linux-gnu /lib/i686-linux-gnu /usr/lib/i686-linux-gnu /usr/local/lib /usr/local/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu /lib32 /usr/lib32 " + +# Whether dlopen is supported. +dlopen_support=unknown + +# Whether dlopen of programs is supported. +dlopen_self=unknown + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=unknown + +# Commands to strip libraries. +old_striplib="strip --strip-debug" +striplib="strip --strip-unneeded" + + +# The linker used to build libraries. +LD="ld -m elf_x86_64" + +# How to create reloadable object files. +reload_flag=" -r" +reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs" + +# Commands used to build an old-style archive. +old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$oldlib" + +# A language specific compiler. +CC="gcc" + +# Is the compiler the GNU compiler? +with_gcc=yes + +# Compiler flag to turn off builtin functions. +no_builtin_flag=" -fno-builtin" + +# How to pass a linker flag through the compiler. +wl="-Wl," + +# Additional compiler flags for building library objects. +pic_flag=" -fPIC -DPIC" + +# Compiler flag to prevent dynamic linking. +link_static_flag="-static" + +# Does compiler simultaneously support -c and -o options? +compiler_c_o="yes" + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=no + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=no + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec="\${wl}--export-dynamic" + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec="\${wl}--whole-archive\$convenience \${wl}--no-whole-archive" + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object="no" + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds="" + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds="" + +# Commands used to build a shared archive. +archive_cmds="\$CC -shared \$pic_flag \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname -o \$lib" +archive_expsym_cmds="echo \\\"{ global:\\\" > \$output_objdir/\$libname.ver~ + cat \$export_symbols | sed -e \\\"s/\\\\(.*\\\\)/\\\\1;/\\\" >> \$output_objdir/\$libname.ver~ + echo \\\"local: *; };\\\" >> \$output_objdir/\$libname.ver~ + \$CC -shared \$pic_flag \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname \${wl}-version-script \${wl}\$output_objdir/\$libname.ver -o \$lib" + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds="" +module_expsym_cmds="" + +# Whether we are building with GNU ld or not. +with_gnu_ld="yes" + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag="" + +# Flag that enforces no undefined symbols. +no_undefined_flag="" + +# Flag to hardcode $libdir into a binary during linking. +# This must work even if $libdir does not exist +hardcode_libdir_flag_spec="\${wl}-rpath \${wl}\$libdir" + +# If ld is used when linking, flag to hardcode $libdir into a binary +# during linking. This must work even if $libdir does not exist. +hardcode_libdir_flag_spec_ld="" + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator="" + +# Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=no + +# Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting ${shlibpath_var} if the +# library is relocated. +hardcode_direct_absolute=no + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=no + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=unsupported + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=no + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=no + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=unknown + +# Fix the shell variable $srcfile for the compiler. +fix_srcfile_path="" + +# Set to "yes" if exported symbols are required. +always_export_symbols=no + +# The commands to list exported symbols. +export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols" + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms="_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*" + +# Symbols that must always be exported. +include_expsyms="" + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds="" + +# Specify filename containing input files. +file_list_spec="" + +# How to hardcode a shared library path into an executable. +hardcode_action=immediate + +# ### END LIBTOOL CONFIG + +# Generated from ltmain.m4sh. + +# libtool (GNU libtool 1.3134 2009-11-29) 2.2.7a +# Written by Gordon Matzigkeit , 1996 + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, +# 2007, 2008, 2009 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool 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. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, +# or obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Usage: $progname [OPTION]... [MODE-ARG]... +# +# Provide generalized library-building support services. +# +# --config show all configuration variables +# --debug enable verbose shell tracing +# -n, --dry-run display commands without modifying any files +# --features display basic configuration information and exit +# --mode=MODE use operation mode MODE +# --no-finish let install mode avoid finish commands +# --preserve-dup-deps don't remove duplicate dependency libraries +# --quiet, --silent don't print informational messages +# --no-quiet, --no-silent +# print informational messages (default) +# --tag=TAG use configuration variables from tag TAG +# -v, --verbose print more informational messages than default +# --no-verbose don't print the extra informational messages +# --version print version information +# -h, --help, --help-all print short, long, or detailed help message +# +# MODE must be one of the following: +# +# clean remove files from the build directory +# compile compile a source file into a libtool object +# execute automatically set library path, then run a program +# finish complete the installation of libtool libraries +# install install libraries or executables +# link create a library or an executable +# uninstall remove libraries from an installed directory +# +# MODE-ARGS vary depending on the MODE. When passed as first option, +# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. +# Try `$progname --help --mode=MODE' for a more detailed description of MODE. +# +# When reporting a bug, please describe a test case to reproduce it and +# include the following information: +# +# host-triplet: $host +# shell: $SHELL +# compiler: $LTCC +# compiler flags: $LTCFLAGS +# linker: $LD (gnu? $with_gnu_ld) +# $progname: (GNU libtool 1.3134 2009-11-29) 2.2.7a +# automake: $automake_version +# autoconf: $autoconf_version +# +# Report bugs to . + +PROGRAM=libtool +PACKAGE=libtool +VERSION=2.2.7a +TIMESTAMP=" 1.3134 2009-11-29" +package_revision=1.3134 + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + +# NLS nuisances: We save the old values to restore during execute mode. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +lt_user_locale= +lt_safe_locale= +for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES +do + eval "if test \"\${$lt_var+set}\" = set; then + save_$lt_var=\$$lt_var + $lt_var=C + export $lt_var + lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" + lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" + fi" +done + +$lt_unset CDPATH + + + + + + + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath="$0" + + + +: ${CP="cp -f"} +: ${ECHO=$as_echo} +: ${EGREP="/bin/grep -E"} +: ${FGREP="/bin/grep -F"} +: ${GREP="/bin/grep"} +: ${LN_S="ln -s"} +: ${MAKE="make"} +: ${MKDIR="mkdir"} +: ${MV="mv -f"} +: ${RM="rm -f"} +: ${SED="/mount/endor/wildenhu/local-x86_64/bin/sed"} +: ${SHELL="${CONFIG_SHELL-/bin/sh}"} +: ${Xsed="$SED -e 1s/^X//"} + +# Global variables: +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. +EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. + +exit_status=$EXIT_SUCCESS + +# Make sure IFS has a sensible default +lt_nl=' +' +IFS=" $lt_nl" + +dirname="s,/[^/]*$,," +basename="s,^.*/,," + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi + func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` +} + +# Generated shell functions inserted here. + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac +} + +# func_basename file +func_basename () +{ + func_basename_result="${1##*/}" +} + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}" +} + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +func_stripname () +{ + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"} +} + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=${1%%=*} + func_opt_split_arg=${1#*=} +} + +# func_lo2o object +func_lo2o () +{ + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=${1%.*}.lo +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=$(( $* )) +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=${#1} +} + + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$1+=\$2" +} +# Generated shell functions inserted here. + +# These SED scripts presuppose an absolute path with a trailing slash. +pathcar='s,^/\([^/]*\).*$,\1,' +pathcdr='s,^/[^/]*,,' +removedotparts=':dotsl + s@/\./@/@g + t dotsl + s,/\.$,/,' +collapseslashes='s@/\{1,\}@/@g' +finalslash='s,/*$,/,' + +# func_normal_abspath PATH +# Remove doubled-up and trailing slashes, "." path components, +# and cancel out any ".." path components in PATH after making +# it an absolute path. +# value returned in "$func_normal_abspath_result" +func_normal_abspath () +{ + # Start from root dir and reassemble the path. + func_normal_abspath_result= + func_normal_abspath_tpath=$1 + func_normal_abspath_altnamespace= + case $func_normal_abspath_tpath in + "") + # Empty path, that just means $cwd. + func_stripname '' '/' "`pwd`" + func_normal_abspath_result=$func_stripname_result + return + ;; + # The next three entries are used to spot a run of precisely + # two leading slashes without using negated character classes; + # we take advantage of case's first-match behaviour. + ///*) + # Unusual form of absolute path, do nothing. + ;; + //*) + # Not necessarily an ordinary path; POSIX reserves leading '//' + # and for example Cygwin uses it to access remote file shares + # over CIFS/SMB, so we conserve a leading double slash if found. + func_normal_abspath_altnamespace=/ + ;; + /*) + # Absolute path, do nothing. + ;; + *) + # Relative path, prepend $cwd. + func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath + ;; + esac + # Cancel out all the simple stuff to save iterations. We also want + # the path to end with a slash for ease of parsing, so make sure + # there is one (and only one) here. + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` + while :; do + # Processed it all yet? + if test "$func_normal_abspath_tpath" = / ; then + # If we ascended to the root using ".." the result may be empty now. + if test -z "$func_normal_abspath_result" ; then + func_normal_abspath_result=/ + fi + break + fi + func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$pathcar"` + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$pathcdr"` + # Figure out what to do with it + case $func_normal_abspath_tcomponent in + "") + # Trailing empty path component, ignore it. + ;; + ..) + # Parent dir; strip last assembled component from result. + func_dirname "$func_normal_abspath_result" + func_normal_abspath_result=$func_dirname_result + ;; + *) + # Actual path component, append it. + func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent + ;; + esac + done + # Restore leading double-slash if one was found on entry. + func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result +} + +# func_relative_path SRCDIR DSTDIR +# generates a relative path from SRCDIR to DSTDIR, with a trailing +# slash if non-empty, suitable for immediately appending a filename +# without needing to append a separator. +# value returned in "$func_relative_path_result" +func_relative_path () +{ + func_relative_path_result= + func_normal_abspath "$1" + func_relative_path_tlibdir=$func_normal_abspath_result + func_normal_abspath "$2" + func_relative_path_tbindir=$func_normal_abspath_result + + # Ascend the tree starting from libdir + while :; do + # check if we have found a prefix of bindir + case $func_relative_path_tbindir in + $func_relative_path_tlibdir) + # found an exact match + func_relative_path_tcancelled= + break + ;; + $func_relative_path_tlibdir*) + # found a matching prefix + func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" + func_relative_path_tcancelled=$func_stripname_result + if test -z "$func_relative_path_result"; then + func_relative_path_result=. + fi + break + ;; + *) + func_dirname $func_relative_path_tlibdir + func_relative_path_tlibdir=${func_dirname_result} + if test "x$func_relative_path_tlibdir" = x ; then + # Have to descend all the way to the root! + func_relative_path_result=../$func_relative_path_result + func_relative_path_tcancelled=$func_relative_path_tbindir + break + fi + func_relative_path_result=../$func_relative_path_result + ;; + esac + done + + # Now calculate path; take care to avoid doubling-up slashes. + func_stripname '' '/' "$func_relative_path_result" + func_relative_path_result=$func_stripname_result + func_stripname '/' '/' "$func_relative_path_tcancelled" + if test "x$func_stripname_result" != x ; then + func_relative_path_result=${func_relative_path_result}/${func_stripname_result} + fi + + # Normalisation. If bindir is libdir, return empty string, + # else relative path ending with a slash; either way, target + # file name can be directly appended. + if test ! -z "$func_relative_path_result"; then + func_stripname './' '' "$func_relative_path_result/" + func_relative_path_result=$func_stripname_result + fi +} + +# The name of this program: +func_dirname_and_basename "$progpath" +progname=$func_basename_result + +# Make sure we have an absolute path for reexecution: +case $progpath in + [\\/]*|[A-Za-z]:\\*) ;; + *[\\/]*) + progdir=$func_dirname_result + progdir=`cd "$progdir" && pwd` + progpath="$progdir/$progname" + ;; + *) + save_IFS="$IFS" + IFS=: + for progdir in $PATH; do + IFS="$save_IFS" + test -x "$progdir/$progname" && break + done + IFS="$save_IFS" + test -n "$progdir" || progdir=`pwd` + progpath="$progdir/$progname" + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed="${SED}"' -e 1s/^X//' +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Re-`\' parameter expansions in output of double_quote_subst that were +# `\'-ed in input to the same. If an odd number of `\' preceded a '$' +# in input to double_quote_subst, that '$' was protected from expansion. +# Since each input `\' is now two `\'s, look for any number of runs of +# four `\'s followed by two `\'s and then a '$'. `\' that '$'. +bs='\\' +bs2='\\\\' +bs4='\\\\\\\\' +dollar='\$' +sed_double_backslash="\ + s/$bs4/&\\ +/g + s/^$bs2$dollar/$bs&/ + s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g + s/\n//g" + +# Standard options: +opt_dry_run=false +opt_help=false +opt_quiet=false +opt_verbose=false +opt_warning=: + +# func_echo arg... +# Echo program name prefixed message, along with the current mode +# name if it has been set yet. +func_echo () +{ + $ECHO "$progname${mode+: }$mode: $*" +} + +# func_verbose arg... +# Echo program name prefixed message in verbose mode only. +func_verbose () +{ + $opt_verbose && func_echo ${1+"$@"} + + # A bug in bash halts the script if the last line of a function + # fails when set -e is in force, so we need another command to + # work around that: + : +} + +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "$*" +} + +# func_error arg... +# Echo program name prefixed message to standard error. +func_error () +{ + $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 +} + +# func_warning arg... +# Echo program name prefixed warning message to standard error. +func_warning () +{ + $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 + + # bash bug again: + : +} + +# func_fatal_error arg... +# Echo program name prefixed message to standard error, and exit. +func_fatal_error () +{ + func_error ${1+"$@"} + exit $EXIT_FAILURE +} + +# func_fatal_help arg... +# Echo program name prefixed message to standard error, followed by +# a help hint, and exit. +func_fatal_help () +{ + func_error ${1+"$@"} + func_fatal_error "$help" +} +help="Try \`$progname --help' for more information." ## default + + +# func_grep expression filename +# Check whether EXPRESSION matches any line of FILENAME, without output. +func_grep () +{ + $GREP "$1" "$2" >/dev/null 2>&1 +} + + +# func_mkdir_p directory-path +# Make sure the entire path to DIRECTORY-PATH is available. +func_mkdir_p () +{ + my_directory_path="$1" + my_dir_list= + + if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then + + # Protect directory names starting with `-' + case $my_directory_path in + -*) my_directory_path="./$my_directory_path" ;; + esac + + # While some portion of DIR does not yet exist... + while test ! -d "$my_directory_path"; do + # ...make a list in topmost first order. Use a colon delimited + # list incase some portion of path contains whitespace. + my_dir_list="$my_directory_path:$my_dir_list" + + # If the last portion added has no slash in it, the list is done + case $my_directory_path in */*) ;; *) break ;; esac + + # ...otherwise throw away the child directory and loop + my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` + done + my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` + + save_mkdir_p_IFS="$IFS"; IFS=':' + for my_dir in $my_dir_list; do + IFS="$save_mkdir_p_IFS" + # mkdir can fail with a `File exist' error if two processes + # try to create one of the directories concurrently. Don't + # stop in that case! + $MKDIR "$my_dir" 2>/dev/null || : + done + IFS="$save_mkdir_p_IFS" + + # Bail out if we (or some other process) failed to create a directory. + test -d "$my_directory_path" || \ + func_fatal_error "Failed to create \`$1'" + fi +} + + +# func_mktempdir [string] +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, STRING is the basename for that directory. +func_mktempdir () +{ + my_template="${TMPDIR-/tmp}/${1-$progname}" + + if test "$opt_dry_run" = ":"; then + # Return a directory name, but don't create it in dry-run mode + my_tmpdir="${my_template}-$$" + else + + # If mktemp works, use that first and foremost + my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` + + if test ! -d "$my_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + my_tmpdir="${my_template}-${RANDOM-0}$$" + + save_mktempdir_umask=`umask` + umask 0077 + $MKDIR "$my_tmpdir" + umask $save_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$my_tmpdir" || \ + func_fatal_error "cannot create temporary directory \`$my_tmpdir'" + fi + + $ECHO "$my_tmpdir" +} + + +# func_quote_for_eval arg +# Aesthetically quote ARG to be evaled later. +# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT +# is double-quoted, suitable for a subsequent eval, whereas +# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters +# which are still active within double quotes backslashified. +func_quote_for_eval () +{ + case $1 in + *[\\\`\"\$]*) + func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; + *) + func_quote_for_eval_unquoted_result="$1" ;; + esac + + case $func_quote_for_eval_unquoted_result in + # Double-quote args containing shell metacharacters to delay + # word splitting, command substitution and and variable + # expansion for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" + ;; + *) + func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" + esac +} + + +# func_quote_for_expand arg +# Aesthetically quote ARG to be evaled later; same as above, +# but do not quote variable references. +func_quote_for_expand () +{ + case $1 in + *[\\\`\"]*) + my_arg=`$ECHO "$1" | $SED \ + -e "$double_quote_subst" -e "$sed_double_backslash"` ;; + *) + my_arg="$1" ;; + esac + + case $my_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting and command substitution for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + my_arg="\"$my_arg\"" + ;; + esac + + func_quote_for_expand_result="$my_arg" +} + + +# func_show_eval cmd [fail_exp] +# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. +func_show_eval () +{ + my_cmd="$1" + my_fail_exp="${2-:}" + + ${opt_silent-false} || { + func_quote_for_expand "$my_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + if ${opt_dry_run-false}; then :; else + eval "$my_cmd" + my_status=$? + if test "$my_status" -eq 0; then :; else + eval "(exit $my_status); $my_fail_exp" + fi + fi +} + + +# func_show_eval_locale cmd [fail_exp] +# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. Use the saved locale for evaluation. +func_show_eval_locale () +{ + my_cmd="$1" + my_fail_exp="${2-:}" + + ${opt_silent-false} || { + func_quote_for_expand "$my_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + if ${opt_dry_run-false}; then :; else + eval "$lt_user_locale + $my_cmd" + my_status=$? + eval "$lt_safe_locale" + if test "$my_status" -eq 0; then :; else + eval "(exit $my_status); $my_fail_exp" + fi + fi +} + + + + + +# func_version +# Echo version message to standard output and exit. +func_version () +{ + $SED -n '/(C)/!b go + :more + /\./!{ + N + s/\n# // + b more + } + :go + /^# '$PROGRAM' (GNU /,/# warranty; / { + s/^# // + s/^# *$// + s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ + p + }' < "$progpath" + exit $? +} + +# func_usage +# Echo short help message to standard output and exit. +func_usage () +{ + $SED -n '/^# Usage:/,/^# *-h/ { + s/^# // + s/^# *$// + s/\$progname/'$progname'/ + p + }' < "$progpath" + echo + $ECHO "run \`$progname --help | more' for full usage" + exit $? +} + +# func_help [NOEXIT] +# Echo long help message to standard output and exit, +# unless 'noexit' is passed as argument. +func_help () +{ + $SED -n '/^# Usage:/,/# Report bugs to/ { + s/^# // + s/^# *$// + s*\$progname*'$progname'* + s*\$host*'"$host"'* + s*\$SHELL*'"$SHELL"'* + s*\$LTCC*'"$LTCC"'* + s*\$LTCFLAGS*'"$LTCFLAGS"'* + s*\$LD*'"$LD"'* + s/\$with_gnu_ld/'"$with_gnu_ld"'/ + s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ + s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ + p + }' < "$progpath" + ret=$? + if test -z "$1"; then + exit $ret + fi +} + +# func_missing_arg argname +# Echo program name prefixed message to standard error and set global +# exit_cmd. +func_missing_arg () +{ + func_error "missing argument for $1" + exit_cmd=exit +} + +exit_cmd=: + + + + + + +magic="%%%MAGIC variable%%%" +magic_exe="%%%MAGIC EXE variable%%%" + +# Global variables. +# $mode is unset +nonopt= +execute_dlfiles= +preserve_args= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" +extracted_archives= +extracted_serial=0 + +opt_dry_run=false +opt_finish=: +opt_duplicate_deps=false +opt_silent=false +opt_debug=: + +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + +# func_fatal_configuration arg... +# Echo program name prefixed message to standard error, followed by +# a configuration failure hint, and exit. +func_fatal_configuration () +{ + func_error ${1+"$@"} + func_error "See the $PACKAGE documentation for more information." + func_fatal_error "Fatal configuration error." +} + + +# func_config +# Display the configuration for all the tags in this script. +func_config () +{ + re_begincf='^# ### BEGIN LIBTOOL' + re_endcf='^# ### END LIBTOOL' + + # Default configuration. + $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" + + # Now print the configurations for the tags. + for tagname in $taglist; do + $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" + done + + exit $? +} + +# func_features +# Display the features supported by this script. +func_features () +{ + echo "host: $host" + if test "$build_libtool_libs" = yes; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + echo "enable static libraries" + else + echo "disable static libraries" + fi + + exit $? +} + +# func_enable_tag tagname +# Verify that TAGNAME is valid, and either flag an error and exit, or +# enable the TAGNAME tag. We also add TAGNAME to the global $taglist +# variable here. +func_enable_tag () +{ + # Global variable: + tagname="$1" + + re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" + re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" + sed_extractcf="/$re_begincf/,/$re_endcf/p" + + # Validate tagname. + case $tagname in + *[!-_A-Za-z0-9,/]*) + func_fatal_error "invalid tag name: $tagname" + ;; + esac + + # Don't test for the "default" C tag, as we know it's + # there but not specially marked. + case $tagname in + CC) ;; + *) + if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then + taglist="$taglist $tagname" + + # Evaluate the configuration. Be careful to quote the path + # and the sed script, to avoid splitting on whitespace, but + # also don't use non-portable quotes within backquotes within + # quotes we have to do it in 2 steps: + extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` + eval "$extractedcf" + else + func_error "ignoring unknown tag $tagname" + fi + ;; + esac +} + +# Parse options once, thoroughly. This comes as soon as possible in +# the script to make things like `libtool --version' happen quickly. +{ + + # Shorthand for --mode=foo, only valid as the first argument + case $1 in + clean|clea|cle|cl) + shift; set dummy --mode clean ${1+"$@"}; shift + ;; + compile|compil|compi|comp|com|co|c) + shift; set dummy --mode compile ${1+"$@"}; shift + ;; + execute|execut|execu|exec|exe|ex|e) + shift; set dummy --mode execute ${1+"$@"}; shift + ;; + finish|finis|fini|fin|fi|f) + shift; set dummy --mode finish ${1+"$@"}; shift + ;; + install|instal|insta|inst|ins|in|i) + shift; set dummy --mode install ${1+"$@"}; shift + ;; + link|lin|li|l) + shift; set dummy --mode link ${1+"$@"}; shift + ;; + uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) + shift; set dummy --mode uninstall ${1+"$@"}; shift + ;; + esac + + # Parse non-mode specific arguments: + while test "$#" -gt 0; do + opt="$1" + shift + + case $opt in + --config) func_config ;; + + --debug) preserve_args="$preserve_args $opt" + func_echo "enabling shell trace mode" + opt_debug='set -x' + $opt_debug + ;; + + -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break + execute_dlfiles="$execute_dlfiles $1" + shift + ;; + + --dry-run | -n) opt_dry_run=: ;; + --features) func_features ;; + --finish) mode="finish" ;; + --no-finish) opt_finish=false ;; + + --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break + case $1 in + # Valid mode arguments: + clean) ;; + compile) ;; + execute) ;; + finish) ;; + install) ;; + link) ;; + relink) ;; + uninstall) ;; + + # Catch anything else as an error + *) func_error "invalid argument for $opt" + exit_cmd=exit + break + ;; + esac + + mode="$1" + shift + ;; + + --preserve-dup-deps) + opt_duplicate_deps=: ;; + + --quiet|--silent) preserve_args="$preserve_args $opt" + opt_silent=: + opt_verbose=false + ;; + + --no-quiet|--no-silent) + preserve_args="$preserve_args $opt" + opt_silent=false + ;; + + --verbose| -v) preserve_args="$preserve_args $opt" + opt_silent=false + opt_verbose=: + ;; + + --no-verbose) preserve_args="$preserve_args $opt" + opt_verbose=false + ;; + + --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break + preserve_args="$preserve_args $opt $1" + func_enable_tag "$1" # tagname is set here + shift + ;; + + # Separate optargs to long options: + -dlopen=*|--mode=*|--tag=*) + func_opt_split "$opt" + set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} + shift + ;; + + -\?|-h) func_usage ;; + --help) opt_help=: ;; + --help-all) opt_help=': help-all' ;; + --version) func_version ;; + + -*) func_fatal_help "unrecognized option \`$opt'" ;; + + *) nonopt="$opt" + break + ;; + esac + done + + + case $host in + *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* ) + # don't eliminate duplications in $postdeps and $predeps + opt_duplicate_compiler_generated_deps=: + ;; + *) + opt_duplicate_compiler_generated_deps=$opt_duplicate_deps + ;; + esac + + # Having warned about all mis-specified options, bail out if + # anything was wrong. + $exit_cmd $EXIT_FAILURE +} + +# func_check_version_match +# Ensure that we are using m4 macros, and libtool script from the same +# release of libtool. +func_check_version_match () +{ + if test "$package_revision" != "$macro_revision"; then + if test "$VERSION" != "$macro_version"; then + if test -z "$macro_version"; then + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from an older release. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + fi + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, +$progname: but the definition of this LT_INIT comes from revision $macro_revision. +$progname: You should recreate aclocal.m4 with macros from revision $package_revision +$progname: of $PACKAGE $VERSION and run autoconf again. +_LT_EOF + fi + + exit $EXIT_MISMATCH + fi +} + + +## ----------- ## +## Main. ## +## ----------- ## + +$opt_help || { + # Sanity checks first: + func_check_version_match + + if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + func_fatal_configuration "not configured to build any kind of library" + fi + + test -z "$mode" && func_fatal_error "error: you must specify a MODE." + + + # Darwin sucks + eval "std_shrext=\"$shrext_cmds\"" + + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + func_error "unrecognized option \`-dlopen'" + $ECHO "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$progname --help --mode=$mode' for more information." +} + + +# func_lalib_p file +# True iff FILE is a libtool `.la' library or `.lo' object file. +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_lalib_p () +{ + test -f "$1" && + $SED -e 4q "$1" 2>/dev/null \ + | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 +} + +# func_lalib_unsafe_p file +# True iff FILE is a libtool `.la' library or `.lo' object file. +# This function implements the same check as func_lalib_p without +# resorting to external programs. To this end, it redirects stdin and +# closes it afterwards, without saving the original file descriptor. +# As a safety measure, use it only where a negative result would be +# fatal anyway. Works if `file' does not exist. +func_lalib_unsafe_p () +{ + lalib_p=no + if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then + for lalib_p_l in 1 2 3 4 + do + read lalib_p_line + case "$lalib_p_line" in + \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; + esac + done + exec 0<&5 5<&- + fi + test "$lalib_p" = yes +} + +# func_ltwrapper_script_p file +# True iff FILE is a libtool wrapper script +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_script_p () +{ + func_lalib_p "$1" +} + +# func_ltwrapper_executable_p file +# True iff FILE is a libtool wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_executable_p () +{ + func_ltwrapper_exec_suffix= + case $1 in + *.exe) ;; + *) func_ltwrapper_exec_suffix=.exe ;; + esac + $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 +} + +# func_ltwrapper_scriptname file +# Assumes file is an ltwrapper_executable +# uses $file to determine the appropriate filename for a +# temporary ltwrapper_script. +func_ltwrapper_scriptname () +{ + func_ltwrapper_scriptname_result="" + if func_ltwrapper_executable_p "$1"; then + func_dirname_and_basename "$1" "" "." + func_stripname '' '.exe' "$func_basename_result" + func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" + fi +} + +# func_ltwrapper_p file +# True iff FILE is a libtool wrapper script or wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_p () +{ + func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" +} + + +# func_execute_cmds commands fail_cmd +# Execute tilde-delimited COMMANDS. +# If FAIL_CMD is given, eval that upon failure. +# FAIL_CMD may read-access the current command in variable CMD! +func_execute_cmds () +{ + $opt_debug + save_ifs=$IFS; IFS='~' + for cmd in $1; do + IFS=$save_ifs + eval "cmd=\"$cmd\"" + func_show_eval "$cmd" "${2-:}" + done + IFS=$save_ifs +} + + +# func_source file +# Source FILE, adding directory component if necessary. +# Note that it is not necessary on cygwin/mingw to append a dot to +# FILE even if both FILE and FILE.exe exist: automatic-append-.exe +# behavior happens only for exec(3), not for open(2)! Also, sourcing +# `FILE.' does not work on cygwin managed mounts. +func_source () +{ + $opt_debug + case $1 in + */* | *\\*) . "$1" ;; + *) . "./$1" ;; + esac +} + + +# func_infer_tag arg +# Infer tagged configuration to use if any are available and +# if one wasn't chosen via the "--tag" command line option. +# Only attempt this if the compiler in the base compile +# command doesn't match the default compiler. +# arg is usually of the form 'gcc ...' +func_infer_tag () +{ + $opt_debug + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + func_quote_for_eval "$arg" + CC_quoted="$CC_quoted $func_quote_for_eval_result" + done + CC_expanded=`func_echo_all $CC` + CC_quoted_expanded=`func_echo_all $CC_quoted` + case $@ in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ + " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + CC_quoted= + for arg in $CC; do + # Double-quote args containing other shell metacharacters. + func_quote_for_eval "$arg" + CC_quoted="$CC_quoted $func_quote_for_eval_result" + done + CC_expanded=`func_echo_all $CC` + CC_quoted_expanded=`func_echo_all $CC_quoted` + case "$@ " in + " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ + " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + func_echo "unable to infer tagged configuration" + func_fatal_error "specify a tag with \`--tag'" +# else +# func_verbose "using $tagname tagged configuration" + fi + ;; + esac + fi +} + + + +# func_write_libtool_object output_name pic_name nonpic_name +# Create a libtool object file (analogous to a ".la" file), +# but don't create it if we're doing a dry run. +func_write_libtool_object () +{ + write_libobj=${1} + if test "$build_libtool_libs" = yes; then + write_lobj=\'${2}\' + else + write_lobj=none + fi + + if test "$build_old_libs" = yes; then + write_oldobj=\'${3}\' + else + write_oldobj=none + fi + + $opt_dry_run || { + cat >${write_libobj}T <?"'"'"' &()|`$[]' \ + && func_warning "libobj name \`$libobj' may not contain shell special characters." + func_dirname_and_basename "$obj" "/" "" + objname="$func_basename_result" + xdir="$func_dirname_result" + lobj=${xdir}$objdir/$objname + + test -z "$base_compile" && \ + func_fatal_help "you must specify a compilation command" + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2* | cegcc*) + pic_mode=default + ;; + esac + if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} + lockfile="$output_obj.lock" + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + $ECHO "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + removelist="$removelist $output_obj" + $ECHO "$srcfile" > "$lockfile" + fi + + $opt_dry_run || $RM $removelist + removelist="$removelist $lockfile" + trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 + + if test -n "$fix_srcfile_path"; then + eval "srcfile=\"$fix_srcfile_path\"" + fi + func_quote_for_eval "$srcfile" + qsrcfile=$func_quote_for_eval_result + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + if test "$pic_mode" != no; then + command="$base_compile $qsrcfile $pic_flag" + else + # Don't build PIC code + command="$base_compile $qsrcfile" + fi + + func_mkdir_p "$xdir$objdir" + + if test -z "$output_obj"; then + # Place PIC objects in $objdir + command="$command -o $lobj" + fi + + func_show_eval_locale "$command" \ + 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' + + if test "$need_locks" = warn && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + func_show_eval '$MV "$output_obj" "$lobj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + + # Allow error messages only from the first compilation. + if test "$suppress_opt" = yes; then + suppress_output=' >/dev/null 2>&1' + fi + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + if test "$pic_mode" != yes; then + # Don't build PIC code + command="$base_compile $qsrcfile$pie_flag" + else + command="$base_compile $qsrcfile $pic_flag" + fi + if test "$compiler_c_o" = yes; then + command="$command -o $obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + command="$command$suppress_output" + func_show_eval_locale "$command" \ + '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' + + if test "$need_locks" = warn && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + func_show_eval '$MV "$output_obj" "$obj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + fi + + $opt_dry_run || { + func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" + + # Unlock the critical section if it was locked + if test "$need_locks" != no; then + removelist=$lockfile + $RM "$lockfile" + fi + } + + exit $EXIT_SUCCESS +} + +$opt_help || { + test "$mode" = compile && func_mode_compile ${1+"$@"} +} + +func_mode_help () +{ + # We need to display help for each of the modes. + case $mode in + "") + # Generic help is extracted from the usage comments + # at the start of this file. + func_help + ;; + + clean) + $ECHO \ +"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + + compile) + $ECHO \ +"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -no-suppress do not suppress compiler output for multiple passes + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only + -shared do not build a \`.o' file suitable for static linking + -static only build a \`.o' file suitable for static linking + -Wc,FLAG pass FLAG directly to the compiler + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + + execute) + $ECHO \ +"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + + finish) + $ECHO \ +"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + + install) + $ECHO \ +"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The following components of INSTALL-COMMAND are treated specially: + + -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + + link) + $ECHO \ +"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -bindir BINDIR specify path to binaries directory (for systems where + libraries must be found in the PATH setting at runtime) + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE Use a list of object files found in FILE to specify objects + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -shared only do dynamic linking of libtool libraries + -shrext SUFFIX override the standard shared library file extension + -static do not do any dynamic linking of uninstalled libtool libraries + -static-libtool-libs + do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + -weak LIBNAME declare that the target provides the LIBNAME interface + -Wc,FLAG + -Xcompiler FLAG pass linker-specific FLAG directly to the compiler + -Wl,FLAG + -Xlinker FLAG pass linker-specific FLAG directly to the linker + -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + + uninstall) + $ECHO \ +"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + + *) + func_fatal_help "invalid operation mode \`$mode'" + ;; + esac + + echo + $ECHO "Try \`$progname --help' for more information about other modes." +} + +# Now that we've collected a possible --mode arg, show help if necessary +if $opt_help; then + if test "$opt_help" = :; then + func_mode_help + else + { + func_help noexit + for mode in compile link execute install finish uninstall clean; do + func_mode_help + done + } | sed -n '1p; 2,$s/^Usage:/ or: /p' + { + func_help noexit + for mode in compile link execute install finish uninstall clean; do + echo + func_mode_help + done + } | + sed '1d + /^When reporting/,/^Report/{ + H + d + } + $x + /information about other modes/d + /more detailed .*MODE/d + s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' + fi + exit $? +fi + + +# func_mode_execute arg... +func_mode_execute () +{ + $opt_debug + # The first argument is the command name. + cmd="$nonopt" + test -z "$cmd" && \ + func_fatal_help "you must specify a COMMAND" + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + test -f "$file" \ + || func_fatal_help "\`$file' is not a file" + + dir= + case $file in + *.la) + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "\`$lib' is not a valid libtool archive" + + # Read the libtool library. + dlname= + library_names= + func_source "$file" + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && \ + func_warning "\`$file' was not linked with \`-export-dynamic'" + continue + fi + + func_dirname "$file" "" "." + dir="$func_dirname_result" + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + if test ! -f "$dir/$dlname"; then + func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" + fi + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + func_dirname "$file" "" "." + dir="$func_dirname_result" + ;; + + *) + func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval test -z \"\$$shlibpath_var\"; then + eval $shlibpath_var=\$dir + else + eval $shlibpath_var=\$dir:\$$shlibpath_var + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -* | *.la | *.lo ) ;; + *) + # Do a test to see if this is really a libtool program. + if func_ltwrapper_script_p "$file"; then + func_source "$file" + # Transform arg to wrapped name. + file="$progdir/$program" + elif func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + func_source "$func_ltwrapper_scriptname_result" + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + func_quote_for_eval "$file" + args="$args $func_quote_for_eval_result" + done + + if test "X$opt_dry_run" = Xfalse; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES + do + eval "if test \"\${save_$lt_var+set}\" = set; then + $lt_var=\$save_$lt_var; export $lt_var + else + $lt_unset $lt_var + fi" + done + + # Now prepare to actually exec the command. + exec_cmd="\$cmd$args" + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" + echo "export $shlibpath_var" + fi + $ECHO "$cmd$args" + exit $EXIT_SUCCESS + fi +} + +test "$mode" = execute && func_mode_execute ${1+"$@"} + + +# func_mode_finish arg... +func_mode_finish () +{ + $opt_debug + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + func_execute_cmds "$finish_cmds" 'admincmds="$admincmds +'"$cmd"'"' + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $opt_dry_run || eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + $opt_silent && exit $EXIT_SUCCESS + + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + $ECHO " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use the \`-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval "flag=\"$hardcode_libdir_flag_spec\"" + + $ECHO " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + $ECHO " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + echo + + echo "See any operating system documentation about shared libraries for" + case $host in + solaris2.[6789]|solaris2.1[0-9]) + echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" + echo "pages." + ;; + *) + echo "more information, such as the ld(1) and ld.so(8) manual pages." + ;; + esac + echo "----------------------------------------------------------------------" + exit $EXIT_SUCCESS +} + +test "$mode" = finish && func_mode_finish ${1+"$@"} + + +# func_mode_install arg... +func_mode_install () +{ + $opt_debug + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || + # Allow the use of GNU shtool's install command. + case $nonopt in *shtool*) :;; *) false;; esac; then + # Aesthetically quote it. + func_quote_for_eval "$nonopt" + install_prog="$func_quote_for_eval_result " + arg=$1 + shift + else + install_prog= + arg=$nonopt + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + func_quote_for_eval "$arg" + install_prog="$install_prog$func_quote_for_eval_result" + install_shared_prog=$install_prog + case " $install_prog " in + *[\\\ /]cp\ *) install_cp=: ;; + *) install_cp=false ;; + esac + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + no_mode=: + for arg + do + arg2= + if test -n "$dest"; then + files="$files $dest" + dest=$arg + continue + fi + + case $arg in + -d) isdir=yes ;; + -f) + if $install_cp; then :; else + prev=$arg + fi + ;; + -g | -m | -o) + prev=$arg + ;; + -s) + stripme=" -s" + continue + ;; + -*) + ;; + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + if test "x$prev" = x-m && test -n "$install_override_mode"; then + arg2=$install_override_mode + no_mode=false + fi + prev= + else + dest=$arg + continue + fi + ;; + esac + + # Aesthetically quote the argument. + func_quote_for_eval "$arg" + install_prog="$install_prog $func_quote_for_eval_result" + if test -n "$arg2"; then + func_quote_for_eval "$arg2" + fi + install_shared_prog="$install_shared_prog $func_quote_for_eval_result" + done + + test -z "$install_prog" && \ + func_fatal_help "you must specify an install program" + + test -n "$prev" && \ + func_fatal_help "the \`$prev' option requires an argument" + + if test -n "$install_override_mode" && $no_mode; then + if $install_cp; then :; else + func_quote_for_eval "$install_override_mode" + install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result" + fi + fi + + if test -z "$files"; then + if test -z "$dest"; then + func_fatal_help "no file or destination specified" + else + func_fatal_help "you must specify a destination" + fi + fi + + # Strip any trailing slash from the destination. + func_stripname '' '/' "$dest" + dest=$func_stripname_result + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + func_dirname_and_basename "$dest" "" "." + destdir="$func_dirname_result" + destname="$func_basename_result" + + # Not a directory, so check to see that there is only one file specified. + set dummy $files; shift + test "$#" -gt 1 && \ + func_fatal_help "\`$dest' is not a directory" + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + func_fatal_help "\`$destdir' must be an absolute directory name" + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "\`$file' is not a valid libtool archive" + + library_names= + old_library= + relink_command= + func_source "$file" + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + func_dirname "$file" "/" "" + dir="$func_dirname_result" + dir="$dir$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + test "$inst_prefix_dir" = "$destdir" && \ + func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` + fi + + func_warning "relinking \`$file'" + func_show_eval "$relink_command" \ + 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' + fi + + # See the names of the shared library. + set dummy $library_names; shift + if test -n "$1"; then + realname="$1" + shift + + srcname="$realname" + test -n "$relink_command" && srcname="$realname"T + + # Install the shared library and build the symlinks. + func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ + 'exit $?' + tstripme="$stripme" + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + case $realname in + *.dll.a) + tstripme="" + ;; + esac + ;; + esac + if test -n "$tstripme" && test -n "$striplib"; then + func_show_eval "$striplib $destdir/$realname" 'exit $?' + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + # Try `ln -sf' first, because the `ln' binary might depend on + # the symlink we replace! Solaris /bin/ln does not understand -f, + # so we also need to try rm && ln -s. + for linkname + do + test "$linkname" != "$realname" \ + && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + func_execute_cmds "$postinstall_cmds" 'exit $?' + fi + + # Install the pseudo-library for information purposes. + func_basename "$file" + name="$func_basename_result" + instname="$dir/$name"i + func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + func_basename "$file" + destfile="$func_basename_result" + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + func_lo2o "$destfile" + staticdest=$func_lo2o_result + ;; + *.$objext) + staticdest="$destfile" + destfile= + ;; + *) + func_fatal_help "cannot copy a libtool object to \`$destfile'" + ;; + esac + + # Install the libtool object if requested. + test -n "$destfile" && \ + func_show_eval "$install_prog $file $destfile" 'exit $?' + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + func_lo2o "$file" + staticobj=$func_lo2o_result + func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' + fi + exit $EXIT_SUCCESS + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + func_basename "$file" + destfile="$func_basename_result" + destfile="$destdir/$destfile" + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext="" + case $file in + *.exe) + if test ! -f "$file"; then + func_stripname '' '.exe' "$file" + file=$func_stripname_result + stripped_ext=".exe" + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin* | *mingw*) + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + wrapper=$func_ltwrapper_scriptname_result + else + func_stripname '' '.exe' "$file" + wrapper=$func_stripname_result + fi + ;; + *) + wrapper=$file + ;; + esac + if func_ltwrapper_script_p "$wrapper"; then + notinst_deplibs= + relink_command= + + func_source "$wrapper" + + # Check the variables that should have been set. + test -z "$generated_by_libtool_version" && \ + func_fatal_error "invalid libtool wrapper script \`$wrapper'" + + finalize=yes + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + func_source "$lib" + fi + libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test + if test -n "$libdir" && test ! -f "$libfile"; then + func_warning "\`$lib' has not been installed in \`$libdir'" + finalize=no + fi + done + + relink_command= + func_source "$wrapper" + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + $opt_dry_run || { + if test "$finalize" = yes; then + tmpdir=`func_mktempdir` + func_basename "$file$stripped_ext" + file="$func_basename_result" + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` + + $opt_silent || { + func_quote_for_expand "$relink_command" + eval "func_echo $func_quote_for_expand_result" + } + if eval "$relink_command"; then : + else + func_error "error: relink \`$file' with the above command before installing it" + $opt_dry_run || ${RM}r "$tmpdir" + continue + fi + file="$outputname" + else + func_warning "cannot relink \`$file'" + fi + } + else + # Install the binary that we compiled earlier. + file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyway + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + func_stripname '' '.exe' "$destfile" + destfile=$func_stripname_result + ;; + esac + ;; + esac + func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' + $opt_dry_run || if test -n "$outputname"; then + ${RM}r "$tmpdir" + fi + ;; + esac + done + + for file in $staticlibs; do + func_basename "$file" + name="$func_basename_result" + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + func_show_eval "$install_prog \$file \$oldlib" 'exit $?' + + if test -n "$stripme" && test -n "$old_striplib"; then + func_show_eval "$old_striplib $oldlib" 'exit $?' + fi + + # Do each command in the postinstall commands. + func_execute_cmds "$old_postinstall_cmds" 'exit $?' + done + + test -n "$future_libdirs" && \ + func_warning "remember to run \`$progname --finish$future_libdirs'" + + if test -n "$current_libdirs" && $opt_finish; then + # Maybe just do a dry run. + $opt_dry_run && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi +} + +test "$mode" = install && func_mode_install ${1+"$@"} + + +# func_generate_dlsyms outputname originator pic_p +# Extract symbols from dlprefiles and create ${outputname}S.o with +# a dlpreopen symbol table. +func_generate_dlsyms () +{ + $opt_debug + my_outputname="$1" + my_originator="$2" + my_pic_p="${3-no}" + my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` + my_dlsyms= + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + my_dlsyms="${my_outputname}S.c" + else + func_error "not configured to extract global symbols from dlpreopened files" + fi + fi + + if test -n "$my_dlsyms"; then + case $my_dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${my_outputname}.nm" + + func_show_eval "$RM $nlist ${nlist}S ${nlist}T" + + # Parse the name list into a source file. + func_verbose "creating $output_objdir/$my_dlsyms" + + $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ +/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ +/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) +#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" +#endif + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + func_verbose "generating symbol list for \`$output'" + + $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` + for progfile in $progfiles; do + func_verbose "extracting global C symbols from \`$progfile'" + $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $opt_dry_run || { + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $MV "$nlist"T "$nlist" + } + fi + + if test -n "$export_symbols_regex"; then + $opt_dry_run || { + $EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T + $MV "$nlist"T "$nlist" + } + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$outputname.exp" + $opt_dry_run || { + $RM $export_symbols + ${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' < "$nlist" > "$export_symbols" + case $host in + *cygwin* | *mingw* | *cegcc* ) + echo EXPORTS > "$output_objdir/$outputname.def" + cat "$export_symbols" >> "$output_objdir/$outputname.def" + ;; + esac + } + else + $opt_dry_run || { + ${SED} -e 's/\([].[*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/' < "$export_symbols" > "$output_objdir/$outputname.exp" + $GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T + $MV "$nlist"T "$nlist" + case $host in + *cygwin* | *mingw* | *cegcc* ) + echo EXPORTS > "$output_objdir/$outputname.def" + cat "$nlist" >> "$output_objdir/$outputname.def" + ;; + esac + } + fi + fi + + for dlprefile in $dlprefiles; do + func_verbose "extracting global C symbols from \`$dlprefile'" + func_basename "$dlprefile" + name="$func_basename_result" + $opt_dry_run || { + $ECHO ": $name " >> "$nlist" + eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + done + + $opt_dry_run || { + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $MV "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if $GREP -v "^: " < "$nlist" | + if sort -k 3 /dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + $GREP -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' + else + echo '/* NONE */' >> "$output_objdir/$my_dlsyms" + fi + + echo >> "$output_objdir/$my_dlsyms" "\ + +/* The mapping between symbol names and symbols. */ +typedef struct { + const char *name; + void *address; +} lt_dlsymlist; +" + case $host in + *cygwin* | *mingw* | *cegcc* ) + echo >> "$output_objdir/$my_dlsyms" "\ +/* DATA imports from DLLs on WIN32 con't be const, because + runtime relocations are performed -- see ld's documentation + on pseudo-relocs. */" + lt_dlsym_const= ;; + *osf5*) + echo >> "$output_objdir/$my_dlsyms" "\ +/* This system does not cope well with relocations in const data */" + lt_dlsym_const= ;; + *) + lt_dlsym_const=const ;; + esac + + echo >> "$output_objdir/$my_dlsyms" "\ +extern $lt_dlsym_const lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[]; +$lt_dlsym_const lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[] = +{\ + { \"$my_originator\", (void *) 0 }," + + case $need_lib_prefix in + no) + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + *) + eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + esac + echo >> "$output_objdir/$my_dlsyms" "\ + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_${my_prefix}_LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + } # !$opt_dry_run + + pic_flag_for_symtable= + case "$compile_command " in + *" -static "*) ;; + *) + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; + *-*-hpux*) + pic_flag_for_symtable=" $pic_flag" ;; + *) + if test "X$my_pic_p" != Xno; then + pic_flag_for_symtable=" $pic_flag" + fi + ;; + esac + ;; + esac + symtab_cflags= + for arg in $LTCFLAGS; do + case $arg in + -pie | -fpie | -fPIE) ;; + *) symtab_cflags="$symtab_cflags $arg" ;; + esac + done + + # Now compile the dynamic symbol file. + func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' + + # Clean up the generated files. + func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' + + # Transform the symbol file into the correct name. + symfileobj="$output_objdir/${my_outputname}S.$objext" + case $host in + *cygwin* | *mingw* | *cegcc* ) + if test -f "$output_objdir/$my_outputname.def"; then + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + else + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` + fi + ;; + *) + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` + ;; + esac + ;; + *) + func_fatal_error "unknown suffix for \`$my_dlsyms'" + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` + fi +} + +# func_win32_libid arg +# return the library type of file 'arg' +# +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +# Despite the name, also deal with 64 bit binaries. +func_win32_libid () +{ + $opt_debug + win32_libid_type="unknown" + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + if $OBJDUMP -f "$1" | $SED -e '10q' 2>/dev/null | + $EGREP 'file format (pe-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then + win32_nmres=`$NM -f posix -A "$1" | + $SED -n -e ' + 1,100{ + / I /{ + s,.*,import, + p + q + } + }'` + case $win32_nmres in + import*) win32_libid_type="x86 archive import";; + *) win32_libid_type="x86 archive static";; + esac + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $ECHO "$win32_libid_type" +} + + + +# func_extract_an_archive dir oldlib +func_extract_an_archive () +{ + $opt_debug + f_ex_an_ar_dir="$1"; shift + f_ex_an_ar_oldlib="$1" + if test "$lock_old_archive_extraction" = yes; then + lockfile=$f_ex_an_ar_oldlib.lock + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + fi + func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ + 'stat=$?; rm -f "$lockfile"; exit $stat' + if test "$lock_old_archive_extraction" = yes; then + $opt_dry_run || rm -f "$lockfile" + fi + if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then + : + else + func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" + fi +} + + +# func_extract_archives gentop oldlib ... +func_extract_archives () +{ + $opt_debug + my_gentop="$1"; shift + my_oldlibs=${1+"$@"} + my_oldobjs="" + my_xlib="" + my_xabs="" + my_xdir="" + + for my_xlib in $my_oldlibs; do + # Extract the objects. + case $my_xlib in + [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; + *) my_xabs=`pwd`"/$my_xlib" ;; + esac + func_basename "$my_xlib" + my_xlib="$func_basename_result" + my_xlib_u=$my_xlib + while :; do + case " $extracted_archives " in + *" $my_xlib_u "*) + func_arith $extracted_serial + 1 + extracted_serial=$func_arith_result + my_xlib_u=lt$extracted_serial-$my_xlib ;; + *) break ;; + esac + done + extracted_archives="$extracted_archives $my_xlib_u" + my_xdir="$my_gentop/$my_xlib_u" + + func_mkdir_p "$my_xdir" + + case $host in + *-darwin*) + func_verbose "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + $opt_dry_run || { + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + darwin_base_archive=`basename "$darwin_archive"` + darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` + if test -n "$darwin_arches"; then + darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches ; do + func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" + $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" + cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" + func_extract_an_archive "`pwd`" "${darwin_base_archive}" + cd "$darwin_curdir" + $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" + done # $darwin_arches + ## Okay now we've a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` + darwin_file= + darwin_files= + for darwin_file in $darwin_filelist; do + darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` + $LIPO -create -output "$darwin_file" $darwin_files + done # $darwin_filelist + $RM -rf unfat-$$ + cd "$darwin_orig_dir" + else + cd $darwin_orig_dir + func_extract_an_archive "$my_xdir" "$my_xabs" + fi # $darwin_arches + } # !$opt_dry_run + ;; + *) + func_extract_an_archive "$my_xdir" "$my_xabs" + ;; + esac + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + done + + func_extract_archives_result="$my_oldobjs" +} + + +# func_emit_wrapper [arg=no] +# +# Emit a libtool wrapper script on stdout. +# Don't directly open a file because we may want to +# incorporate the script contents within a cygwin/mingw +# wrapper executable. Must ONLY be called from within +# func_mode_link because it depends on a number of variables +# set therein. +# +# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR +# variable will take. If 'yes', then the emitted script +# will assume that the directory in which it is stored is +# the $objdir directory. This is a cygwin/mingw-specific +# behavior. +func_emit_wrapper () +{ + func_emit_wrapper_arg1=${1-no} + + $ECHO "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='$sed_quote_subst' + +# Be Bourne compatible +if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variables: + generated_by_libtool_version='$macro_version' + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$ECHO are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + file=\"\$0\"" + + qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` + $ECHO "\ + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$1 +_LTECHO_EOF' +} + ECHO=\"$qECHO\" + fi\ + + # Find the directory that this script lives in. + thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 + if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then + # special case for '.' + if test \"\$thisdir\" = \".\"; then + thisdir=\`pwd\` + fi + # remove .libs from thisdir + case \"\$thisdir\" in + *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; + $objdir ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + $ECHO "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $MKDIR \"\$progdir\" + else + $RM \"\$progdir/\$file\" + fi" + + $ECHO "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \"\$relink_command\" 2>&1\`; then : + else + $ECHO \"\$relink_command_output\" >&2 + $RM \"\$progdir/\$file\" + exit 1 + fi + fi + + $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $RM \"\$progdir/\$program\"; + $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $RM \"\$progdir/\$file\" + fi" + else + $ECHO "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $ECHO "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $ECHO "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $ECHO "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $ECHO "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2* | *-cegcc*) + $ECHO "\ + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} +" + ;; + + *) + $ECHO "\ + exec \"\$progdir/\$program\" \${1+\"\$@\"} +" + ;; + esac + $ECHO "\ + \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 + exit 1 + fi + else + # The program doesn't exist. + \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 + \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 + \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" +} + + +# func_to_host_path arg +# +# Convert paths to host format when used with build tools. +# Intended for use with "native" mingw (where libtool itself +# is running under the msys shell), or in the following cross- +# build environments: +# $build $host +# mingw (msys) mingw [e.g. native] +# cygwin mingw +# *nix + wine mingw +# where wine is equipped with the `winepath' executable. +# In the native mingw case, the (msys) shell automatically +# converts paths for any non-msys applications it launches, +# but that facility isn't available from inside the cwrapper. +# Similar accommodations are necessary for $host mingw and +# $build cygwin. Calling this function does no harm for other +# $host/$build combinations not listed above. +# +# ARG is the path (on $build) that should be converted to +# the proper representation for $host. The result is stored +# in $func_to_host_path_result. +func_to_host_path () +{ + func_to_host_path_result="$1" + if test -n "$1"; then + case $host in + *mingw* ) + lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + case $build in + *mingw* ) # actually, msys + # awkward: cmd appends spaces to result + func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null | + $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` + ;; + *cygwin* ) + func_to_host_path_result=`cygpath -w "$1" | + $SED -e "$lt_sed_naive_backslashify"` + ;; + * ) + # Unfortunately, winepath does not exit with a non-zero + # error code, so we are forced to check the contents of + # stdout. On the other hand, if the command is not + # found, the shell will set an exit code of 127 and print + # *an error message* to stdout. So we must check for both + # error code of zero AND non-empty stdout, which explains + # the odd construction: + func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` + if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then + func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" | + $SED -e "$lt_sed_naive_backslashify"` + else + # Allow warning below. + func_to_host_path_result= + fi + ;; + esac + if test -z "$func_to_host_path_result" ; then + func_error "Could not determine host path corresponding to" + func_error " \`$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback: + func_to_host_path_result="$1" + fi + ;; + esac + fi +} +# end: func_to_host_path + +# func_to_host_pathlist arg +# +# Convert pathlists to host format when used with build tools. +# See func_to_host_path(), above. This function supports the +# following $build/$host combinations (but does no harm for +# combinations not listed here): +# $build $host +# mingw (msys) mingw [e.g. native] +# cygwin mingw +# *nix + wine mingw +# +# Path separators are also converted from $build format to +# $host format. If ARG begins or ends with a path separator +# character, it is preserved (but converted to $host format) +# on output. +# +# ARG is a pathlist (on $build) that should be converted to +# the proper representation on $host. The result is stored +# in $func_to_host_pathlist_result. +func_to_host_pathlist () +{ + func_to_host_pathlist_result="$1" + if test -n "$1"; then + case $host in + *mingw* ) + lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + # Remove leading and trailing path separator characters from + # ARG. msys behavior is inconsistent here, cygpath turns them + # into '.;' and ';.', and winepath ignores them completely. + func_stripname : : "$1" + func_to_host_pathlist_tmp1=$func_stripname_result + case $build in + *mingw* ) # Actually, msys. + # Awkward: cmd appends spaces to result. + func_to_host_pathlist_result=` + ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null | + $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` + ;; + *cygwin* ) + func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" | + $SED -e "$lt_sed_naive_backslashify"` + ;; + * ) + # unfortunately, winepath doesn't convert pathlists + func_to_host_pathlist_result="" + func_to_host_pathlist_oldIFS=$IFS + IFS=: + for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do + IFS=$func_to_host_pathlist_oldIFS + if test -n "$func_to_host_pathlist_f" ; then + func_to_host_path "$func_to_host_pathlist_f" + if test -n "$func_to_host_path_result" ; then + if test -z "$func_to_host_pathlist_result" ; then + func_to_host_pathlist_result="$func_to_host_path_result" + else + func_append func_to_host_pathlist_result ";$func_to_host_path_result" + fi + fi + fi + done + IFS=$func_to_host_pathlist_oldIFS + ;; + esac + if test -z "$func_to_host_pathlist_result"; then + func_error "Could not determine the host path(s) corresponding to" + func_error " \`$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback. This may break if $1 contains DOS-style drive + # specifications. The fix is not to complicate the expression + # below, but for the user to provide a working wine installation + # with winepath so that path translation in the cross-to-mingw + # case works properly. + lt_replace_pathsep_nix_to_dos="s|:|;|g" + func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ + $SED -e "$lt_replace_pathsep_nix_to_dos"` + fi + # Now, add the leading and trailing path separators back + case "$1" in + :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" + ;; + esac + case "$1" in + *: ) func_append func_to_host_pathlist_result ";" + ;; + esac + ;; + esac + fi +} +# end: func_to_host_pathlist + +# func_emit_cwrapperexe_src +# emit the source code for a wrapper executable on stdout +# Must ONLY be called from within func_mode_link because +# it depends on a number of variable set therein. +func_emit_cwrapperexe_src () +{ + cat < +#include +#ifdef _MSC_VER +# include +# include +# include +#else +# include +# include +# ifdef __CYGWIN__ +# include +# endif +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +/* declarations of non-ANSI functions */ +#if defined(__MINGW32__) +# ifdef __STRICT_ANSI__ +int _putenv (const char *); +# endif +#elif defined(__CYGWIN__) +# ifdef __STRICT_ANSI__ +char *realpath (const char *, char *); +int putenv (char *); +int setenv (const char *, const char *, int); +# endif +/* #elif defined (other platforms) ... */ +#endif + +/* portability defines, excluding path handling macros */ +#if defined(_MSC_VER) +# define setmode _setmode +# define stat _stat +# define chmod _chmod +# define getcwd _getcwd +# define putenv _putenv +# define S_IXUSR _S_IEXEC +# ifndef _INTPTR_T_DEFINED +# define _INTPTR_T_DEFINED +# define intptr_t int +# endif +#elif defined(__MINGW32__) +# define setmode _setmode +# define stat _stat +# define chmod _chmod +# define getcwd _getcwd +# define putenv _putenv +#elif defined(__CYGWIN__) +# define HAVE_SETENV +# define FOPEN_WB "wb" +/* #elif defined (other platforms) ... */ +#endif + +#if defined(PATH_MAX) +# define LT_PATHMAX PATH_MAX +#elif defined(MAXPATHLEN) +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef S_IXOTH +# define S_IXOTH 0 +#endif +#ifndef S_IXGRP +# define S_IXGRP 0 +#endif + +/* path handling portability macros */ +#ifndef DIR_SEPARATOR +# define DIR_SEPARATOR '/' +# define PATH_SEPARATOR ':' +#endif + +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ + defined (__OS2__) +# define HAVE_DOS_BASED_FILE_SYSTEM +# define FOPEN_WB "wb" +# ifndef DIR_SEPARATOR_2 +# define DIR_SEPARATOR_2 '\\' +# endif +# ifndef PATH_SEPARATOR_2 +# define PATH_SEPARATOR_2 ';' +# endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#ifndef PATH_SEPARATOR_2 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) +#else /* PATH_SEPARATOR_2 */ +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) +#endif /* PATH_SEPARATOR_2 */ + +#ifndef FOPEN_WB +# define FOPEN_WB "w" +#endif +#ifndef _O_BINARY +# define _O_BINARY 0 +#endif + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free ((void *) stale); stale = 0; } \ +} while (0) + +#undef LTWRAPPER_DEBUGPRINTF +#if defined LT_DEBUGWRAPPER +# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args +static void +ltwrapper_debugprintf (const char *fmt, ...) +{ + va_list args; + va_start (args, fmt); + (void) vfprintf (stderr, fmt, args); + va_end (args); +} +#else +# define LTWRAPPER_DEBUGPRINTF(args) +#endif + +const char *program_name = NULL; + +void *xmalloc (size_t num); +char *xstrdup (const char *string); +const char *base_name (const char *name); +char *find_executable (const char *wrapper); +char *chase_symlinks (const char *pathspec); +int make_executable (const char *path); +int check_executable (const char *path); +char *strendzap (char *str, const char *pat); +void lt_fatal (const char *message, ...); +void lt_setenv (const char *name, const char *value); +char *lt_extend_str (const char *orig_value, const char *add, int to_end); +void lt_update_exe_path (const char *name, const char *value); +void lt_update_lib_path (const char *name, const char *value); +char **prepare_spawn (char **argv); +void lt_dump_script (FILE *f); +EOF + + cat <"))); + for (i = 0; i < newargc; i++) + { + LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : ""))); + } + +EOF + + case $host_os in + mingw*) + cat <<"EOF" + /* execv doesn't actually work on mingw as expected on unix */ + newargz = prepare_spawn (newargz); + rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); + if (rval == -1) + { + /* failed to start process */ + LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno)); + return 127; + } + return rval; +EOF + ;; + *) + cat <<"EOF" + execv (lt_argv_zero, newargz); + return rval; /* =127, but avoids unused variable warning */ +EOF + ;; + esac + + cat <<"EOF" +} + +void * +xmalloc (size_t num) +{ + void *p = (void *) malloc (num); + if (!p) + lt_fatal ("Memory exhausted"); + + return p; +} + +char * +xstrdup (const char *string) +{ + return string ? strcpy ((char *) xmalloc (strlen (string) + 1), + string) : NULL; +} + +const char * +base_name (const char *name) +{ + const char *base; + +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + /* Skip over the disk name in MSDOS pathnames. */ + if (isalpha ((unsigned char) name[0]) && name[1] == ':') + name += 2; +#endif + + for (base = name; *name; name++) + if (IS_DIR_SEPARATOR (*name)) + base = name + 1; + return base; +} + +int +check_executable (const char *path) +{ + struct stat st; + + LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n", + path ? (*path ? path : "EMPTY!") : "NULL!")); + if ((!path) || (!*path)) + return 0; + + if ((stat (path, &st) >= 0) + && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) + return 1; + else + return 0; +} + +int +make_executable (const char *path) +{ + int rval = 0; + struct stat st; + + LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n", + path ? (*path ? path : "EMPTY!") : "NULL!")); + if ((!path) || (!*path)) + return 0; + + if (stat (path, &st) >= 0) + { + rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); + } + return rval; +} + +/* Searches for the full path of the wrapper. Returns + newly allocated full path name if found, NULL otherwise + Does not chase symlinks, even on platforms that support them. +*/ +char * +find_executable (const char *wrapper) +{ + int has_slash = 0; + const char *p; + const char *p_next; + /* static buffer for getcwd */ + char tmp[LT_PATHMAX + 1]; + int tmp_len; + char *concat_name; + + LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n", + wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!")); + + if ((wrapper == NULL) || (*wrapper == '\0')) + return NULL; + + /* Absolute path? */ +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + else + { +#endif + if (IS_DIR_SEPARATOR (wrapper[0])) + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + } +#endif + + for (p = wrapper; *p; p++) + if (*p == '/') + { + has_slash = 1; + break; + } + if (!has_slash) + { + /* no slashes; search PATH */ + const char *path = getenv ("PATH"); + if (path != NULL) + { + for (p = path; *p; p = p_next) + { + const char *q; + size_t p_len; + for (q = p; *q; q++) + if (IS_PATH_SEPARATOR (*q)) + break; + p_len = q - p; + p_next = (*q == '\0' ? q : q + 1); + if (p_len == 0) + { + /* empty path: current directory */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen (tmp); + concat_name = + XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + } + else + { + concat_name = + XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, wrapper); + } + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + } + /* not found in PATH; assume curdir */ + } + /* Relative path | not found in path: prepend cwd */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen (tmp); + concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + return NULL; +} + +char * +chase_symlinks (const char *pathspec) +{ +#ifndef S_ISLNK + return xstrdup (pathspec); +#else + char buf[LT_PATHMAX]; + struct stat s; + char *tmp_pathspec = xstrdup (pathspec); + char *p; + int has_symlinks = 0; + while (strlen (tmp_pathspec) && !has_symlinks) + { + LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n", + tmp_pathspec)); + if (lstat (tmp_pathspec, &s) == 0) + { + if (S_ISLNK (s.st_mode) != 0) + { + has_symlinks = 1; + break; + } + + /* search backwards for last DIR_SEPARATOR */ + p = tmp_pathspec + strlen (tmp_pathspec) - 1; + while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + p--; + if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + { + /* no more DIR_SEPARATORS left */ + break; + } + *p = '\0'; + } + else + { + char *errstr = strerror (errno); + lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr); + } + } + XFREE (tmp_pathspec); + + if (!has_symlinks) + { + return xstrdup (pathspec); + } + + tmp_pathspec = realpath (pathspec, buf); + if (tmp_pathspec == 0) + { + lt_fatal ("Could not follow symlinks for %s", pathspec); + } + return xstrdup (tmp_pathspec); +#endif +} + +char * +strendzap (char *str, const char *pat) +{ + size_t len, patlen; + + assert (str != NULL); + assert (pat != NULL); + + len = strlen (str); + patlen = strlen (pat); + + if (patlen <= len) + { + str += len - patlen; + if (strcmp (str, pat) == 0) + *str = '\0'; + } + return str; +} + +static void +lt_error_core (int exit_status, const char *mode, + const char *message, va_list ap) +{ + fprintf (stderr, "%s: %s: ", program_name, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, "FATAL", message, ap); + va_end (ap); +} + +void +lt_setenv (const char *name, const char *value) +{ + LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n", + (name ? name : ""), + (value ? value : ""))); + { +#ifdef HAVE_SETENV + /* always make a copy, for consistency with !HAVE_SETENV */ + char *str = xstrdup (value); + setenv (name, str, 1); +#else + int len = strlen (name) + 1 + strlen (value) + 1; + char *str = XMALLOC (char, len); + sprintf (str, "%s=%s", name, value); + if (putenv (str) != EXIT_SUCCESS) + { + XFREE (str); + } +#endif + } +} + +char * +lt_extend_str (const char *orig_value, const char *add, int to_end) +{ + char *new_value; + if (orig_value && *orig_value) + { + int orig_value_len = strlen (orig_value); + int add_len = strlen (add); + new_value = XMALLOC (char, add_len + orig_value_len + 1); + if (to_end) + { + strcpy (new_value, orig_value); + strcpy (new_value + orig_value_len, add); + } + else + { + strcpy (new_value, add); + strcpy (new_value + add_len, orig_value); + } + } + else + { + new_value = xstrdup (add); + } + return new_value; +} + +void +lt_update_exe_path (const char *name, const char *value) +{ + LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n", + (name ? name : ""), + (value ? value : ""))); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + /* some systems can't cope with a ':'-terminated path #' */ + int len = strlen (new_value); + while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) + { + new_value[len-1] = '\0'; + } + lt_setenv (name, new_value); + XFREE (new_value); + } +} + +void +lt_update_lib_path (const char *name, const char *value) +{ + LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n", + (name ? name : ""), + (value ? value : ""))); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + lt_setenv (name, new_value); + XFREE (new_value); + } +} + +EOF + case $host_os in + mingw*) + cat <<"EOF" + +/* Prepares an argument vector before calling spawn(). + Note that spawn() does not by itself call the command interpreter + (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : + ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&v); + v.dwPlatformId == VER_PLATFORM_WIN32_NT; + }) ? "cmd.exe" : "command.com"). + Instead it simply concatenates the arguments, separated by ' ', and calls + CreateProcess(). We must quote the arguments since Win32 CreateProcess() + interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a + special way: + - Space and tab are interpreted as delimiters. They are not treated as + delimiters if they are surrounded by double quotes: "...". + - Unescaped double quotes are removed from the input. Their only effect is + that within double quotes, space and tab are treated like normal + characters. + - Backslashes not followed by double quotes are not special. + - But 2*n+1 backslashes followed by a double quote become + n backslashes followed by a double quote (n >= 0): + \" -> " + \\\" -> \" + \\\\\" -> \\" + */ +#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" +#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" +char ** +prepare_spawn (char **argv) +{ + size_t argc; + char **new_argv; + size_t i; + + /* Count number of arguments. */ + for (argc = 0; argv[argc] != NULL; argc++) + ; + + /* Allocate new argument vector. */ + new_argv = XMALLOC (char *, argc + 1); + + /* Put quoted arguments into the new argument vector. */ + for (i = 0; i < argc; i++) + { + const char *string = argv[i]; + + if (string[0] == '\0') + new_argv[i] = xstrdup ("\"\""); + else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) + { + int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); + size_t length; + unsigned int backslashes; + const char *s; + char *quoted_string; + char *p; + + length = 0; + backslashes = 0; + if (quote_around) + length++; + for (s = string; *s != '\0'; s++) + { + char c = *s; + if (c == '"') + length += backslashes + 1; + length++; + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + length += backslashes + 1; + + quoted_string = XMALLOC (char, length + 1); + + p = quoted_string; + backslashes = 0; + if (quote_around) + *p++ = '"'; + for (s = string; *s != '\0'; s++) + { + char c = *s; + if (c == '"') + { + unsigned int j; + for (j = backslashes + 1; j > 0; j--) + *p++ = '\\'; + } + *p++ = c; + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + { + unsigned int j; + for (j = backslashes; j > 0; j--) + *p++ = '\\'; + *p++ = '"'; + } + *p = '\0'; + + new_argv[i] = quoted_string; + } + else + new_argv[i] = (char *) string; + } + new_argv[argc] = NULL; + + return new_argv; +} +EOF + ;; + esac + + cat <<"EOF" +void lt_dump_script (FILE* f) +{ +EOF + func_emit_wrapper yes | + $SED -e 's/\([\\"]\)/\\\1/g' \ + -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' + + cat <<"EOF" +} +EOF +} +# end: func_emit_cwrapperexe_src + +# func_win32_import_lib_p ARG +# True if ARG is an import lib, as indicated by $file_magic_cmd +func_win32_import_lib_p () +{ + $opt_debug + case `eval "$file_magic_cmd \"\$1\" 2>/dev/null" | $SED -e 10q` in + *import*) : ;; + *) false ;; + esac +} + +# func_mode_link arg... +func_mode_link () +{ + $opt_debug + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # which system we are compiling for in order to pass an extra + # flag for every libtool invocation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll which has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + ;; + *) + allow_undefined=yes + ;; + esac + libtool_args=$nonopt + base_compile="$nonopt $@" + compile_command=$nonopt + finalize_command=$nonopt + + compile_rpath= + finalize_rpath= + compile_shlibpath= + finalize_shlibpath= + convenience= + old_convenience= + deplibs= + old_deplibs= + compiler_flags= + linker_flags= + dllsearchpath= + lib_search_path=`pwd` + inst_prefix_dir= + new_inherited_linker_flags= + + avoid_version=no + bindir= + dlfiles= + dlprefiles= + dlself=no + export_dynamic=no + export_symbols= + export_symbols_regex= + generated= + libobjs= + ltlibs= + module=no + no_install=no + objs= + non_pic_objects= + precious_files_regex= + prefer_static_libs=no + preload=no + prev= + prevarg= + release= + rpath= + xrpath= + perm_rpath= + temp_rpath= + thread_safe=no + vinfo= + vinfo_number=no + weak_libs= + single_module="${wl}-single_module" + func_infer_tag $base_compile + + # We need to know -static, to get the right output filenames. + for arg + do + case $arg in + -shared) + test "$build_libtool_libs" != yes && \ + func_fatal_configuration "can not build a shared library" + build_old_libs=no + break + ;; + -all-static | -static | -static-libtool-libs) + case $arg in + -all-static) + if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + func_warning "complete static linking is impossible in this configuration" + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + -static) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=built + ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + esac + build_libtool_libs=no + build_old_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg="$1" + shift + func_quote_for_eval "$arg" + qarg=$func_quote_for_eval_unquoted_result + func_append libtool_args " $func_quote_for_eval_result" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + func_append compile_command " @OUTPUT@" + func_append finalize_command " @OUTPUT@" + ;; + esac + + case $prev in + bindir) + bindir="$arg" + prev= + continue + ;; + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + func_append compile_command " @SYMFILE@" + func_append finalize_command " @SYMFILE@" + preload=yes + fi + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols="$arg" + test -f "$arg" \ + || func_fatal_error "symbol file \`$arg' does not exist" + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + framework) + case $host in + *-*-darwin*) + case "$deplibs " in + *" $qarg.ltframework "*) ;; + *) deplibs="$deplibs $qarg.ltframework" # this is fixed later + ;; + esac + ;; + esac + prev= + continue + ;; + inst_prefix) + inst_prefix_dir="$arg" + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat "$save_arg"` + do +# moreargs="$moreargs $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test "$pic_object" = none && + test "$non_pic_object" = none; then + func_fatal_error "cannot find name of object for \`$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "\`$arg' is not a valid libtool object" + fi + fi + done + else + func_fatal_error "link input file \`$arg' does not exist" + fi + arg=$save_arg + prev= + continue + ;; + precious_regex) + precious_files_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + shrext) + shrext_cmds="$arg" + prev= + continue + ;; + weak) + weak_libs="$weak_libs $arg" + prev= + continue + ;; + xcclinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xcompiler) + compiler_flags="$compiler_flags $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xlinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $wl$qarg" + prev= + func_append compile_command " $wl$qarg" + func_append finalize_command " $wl$qarg" + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg="$arg" + + case $arg in + -all-static) + if test -n "$link_static_flag"; then + # See comment for -static flag below, for more details. + func_append compile_command " $link_static_flag" + func_append finalize_command " $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + func_fatal_error "\`-allow-undefined' must not be used because it is the default" + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -bindir) + prev=bindir + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + func_fatal_error "more than one -exported-symbols argument is not allowed" + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -framework) + prev=framework + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + func_append compile_command " $arg" + func_append finalize_command " $arg" + ;; + esac + continue + ;; + + -L*) + func_stripname '-L' '' "$arg" + dir=$func_stripname_result + if test -z "$dir"; then + if test "$#" -gt 0; then + func_fatal_error "require no space between \`-L' and \`$1'" + else + func_fatal_error "need path for \`-L' option" + fi + fi + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + test -z "$absdir" && \ + func_fatal_error "cannot determine absolute directory name of \`$dir'" + dir="$absdir" + ;; + esac + case "$deplibs " in + *" -L$dir "*) ;; + *) + deplibs="$deplibs -L$dir" + lib_search_path="$lib_search_path $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; + ::) dllsearchpath=$dir;; + *) dllsearchpath="$dllsearchpath:$dir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac + ;; + esac + continue + ;; + + -l*) + if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-os2*) + # These systems don't actually have a C library (as such) + test "X$arg" = "X-lc" && continue + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + deplibs="$deplibs System.ltframework" + continue + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + test "X$arg" = "X-lc" && continue + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + test "X$arg" = "X-lc" && continue + ;; + *-*-linux*) + test "X$arg" = "X-lc" && continue + ;; + esac + elif test "X$arg" = "X-lc_r"; then + case $host in + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + deplibs="$deplibs $arg" + continue + ;; + + -module) + module=yes + continue + ;; + + # Tru64 UNIX uses -model [arg] to determine the layout of C++ + # classes, name mangling, and exception handling. + # Darwin uses the -arch flag to determine output architecture. + -model|-arch|-isysroot) + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + prev=xcompiler + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case "$new_inherited_linker_flags " in + *" $arg "*) ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; + esac + continue + ;; + + -multi_module) + single_module="${wl}-multi_module" + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) + # The PATH hackery in wrapper scripts is required on Windows + # and Darwin in order for the loader to find any dlls it needs. + func_warning "\`-no-install' is ignored for $host" + func_warning "assuming \`-no-fast-install' instead" + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + func_stripname '-R' '' "$arg" + dir=$func_stripname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -shared) + # The effects of -shared are defined in a previous loop. + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -static | -static-libtool-libs) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -weak) + prev=weak + continue + ;; + + -Wc,*) + func_stripname '-Wc,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + func_quote_for_eval "$flag" + arg="$arg $func_quote_for_eval_result" + compiler_flags="$compiler_flags $func_quote_for_eval_result" + done + IFS="$save_ifs" + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Wl,*) + func_stripname '-Wl,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + func_quote_for_eval "$flag" + arg="$arg $wl$func_quote_for_eval_result" + compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" + linker_flags="$linker_flags $func_quote_for_eval_result" + done + IFS="$save_ifs" + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # -msg_* for osf cc + -msg_*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + ;; + + # -64, -mips[0-9] enable 64-bit mode on the SGI compiler + # -r[0-9][0-9]* specifies the processor on the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler + # +DA*, +DD* enable 64-bit mode on the HP compiler + # -q* pass through compiler args for the IBM compiler + # -m*, -t[45]*, -txscale* pass through architecture-specific + # compiler args for GCC + # -F/path gives path to uninstalled frameworks, gcc on darwin + # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC + # @file GCC response files + # -tp=* Portland pgcc target processor selection + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + func_append compile_command " $arg" + func_append finalize_command " $arg" + compiler_flags="$compiler_flags $arg" + continue + ;; + + # Some other compiler flag. + -* | +*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + ;; + + *.$objext) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test "$pic_object" = none && + test "$non_pic_object" = none; then + func_fatal_error "cannot find name of object for \`$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "\`$arg' is not a valid libtool object" + fi + fi + ;; + + *.$libext) + # An archive. + deplibs="$deplibs $arg" + old_deplibs="$old_deplibs $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + if test "$prev" = dlfiles; then + # This library was specified with -dlopen. + dlfiles="$dlfiles $arg" + prev= + elif test "$prev" = dlprefiles; then + # The library was specified with -dlpreopen. + dlprefiles="$dlprefiles $arg" + prev= + else + deplibs="$deplibs $arg" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + done # argument parsing loop + + test -n "$prev" && \ + func_fatal_help "the \`$prevarg' option requires an argument" + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval "arg=\"$export_dynamic_flag_spec\"" + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + func_basename "$output" + outputname="$func_basename_result" + libobjs_save="$libobjs" + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval "sys_lib_search_path=\"$sys_lib_search_path_spec\"" + eval "sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"" + + func_dirname "$output" "/" "" + output_objdir="$func_dirname_result$objdir" + # Create the object directory. + func_mkdir_p "$output_objdir" + + # Determine the type of output + case $output in + "") + func_fatal_help "you must specify an output file" + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if $opt_duplicate_deps ; then + case "$libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + libs="$libs $deplib" + done + + if test "$linkmode" = lib; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if $opt_duplicate_compiler_generated_deps; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; + esac + pre_post_deps="$pre_post_deps $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries + + case $linkmode in + lib) + passes="conv dlpreopen link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=no + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + + for pass in $passes; do + # The preopen pass in lib mode reverses $deplibs; put it back here + # so that -L comes before libs that need it for instance... + if test "$linkmode,$pass" = "lib,link"; then + ## FIXME: Find the place where the list is rebuilt in the wrong + ## order, and fix it there properly + tmp_deplibs= + for deplib in $deplibs; do + tmp_deplibs="$deplib $tmp_deplibs" + done + deplibs="$tmp_deplibs" + fi + + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan"; then + libs="$deplibs" + deplibs= + fi + if test "$linkmode" = prog; then + case $pass in + dlopen) libs="$dlfiles" ;; + dlpreopen) libs="$dlprefiles" ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + if test "$linkmode,$pass" = "lib,dlpreopen"; then + # Collect and forward deplibs of preopened libtool libs + for lib in $dlprefiles; do + # Ignore non-libtool-libs + dependency_libs= + case $lib in + *.la) func_source "$lib" ;; + esac + + # Collect preopened libtool deplibs, except any this library + # has declared as weak libs + for deplib in $dependency_libs; do + func_basename "$deplib" + deplib_base=$func_basename_result + case " $weak_libs " in + *" $deplib_base "*) ;; + *) deplibs="$deplibs $deplib" ;; + esac + done + done + libs="$dlprefiles" + fi + if test "$pass" = dlopen; then + # Collect dlpreopened libraries + save_deplibs="$deplibs" + deplibs= + fi + + for deplib in $libs; do + lib= + found=no + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + compiler_flags="$compiler_flags $deplib" + if test "$linkmode" = lib ; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; + esac + fi + fi + continue + ;; + -l*) + if test "$linkmode" != lib && test "$linkmode" != prog; then + func_warning "\`-l' is ignored for archives/objects" + continue + fi + func_stripname '-l' '' "$deplib" + name=$func_stripname_result + if test "$linkmode" = lib; then + searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" + else + searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" + fi + for searchdir in $searchdirs; do + for search_ext in .la $std_shrext .so .a; do + # Search the libtool library + lib="$searchdir/lib${name}${search_ext}" + if test -f "$lib"; then + if test "$search_ext" = ".la"; then + found=yes + else + found=no + fi + break 2 + fi + done + done + if test "$found" != yes; then + # deplib doesn't seem to be a libtool library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + else # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $deplib "*) + if func_lalib_p "$lib"; then + library_names= + old_library= + func_source "$lib" + for l in $old_library $library_names; do + ll="$l" + done + if test "X$ll" = "X$old_library" ; then # only static version available + found=no + func_dirname "$lib" "" "." + ladir="$func_dirname_result" + lib=$ladir/$old_library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + fi + ;; # -l + *.ltframework) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + if test "$linkmode" = lib ; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; + esac + fi + fi + continue + ;; + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test "$pass" = conv && continue + newdependency_libs="$deplib $newdependency_libs" + func_stripname '-L' '' "$deplib" + newlib_search_path="$newlib_search_path $func_stripname_result" + ;; + prog) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + if test "$pass" = scan; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + func_stripname '-L' '' "$deplib" + newlib_search_path="$newlib_search_path $func_stripname_result" + ;; + *) + func_warning "\`-L' is ignored for archives/objects" + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test "$pass" = link; then + func_stripname '-R' '' "$deplib" + dir=$func_stripname_result + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) lib="$deplib" ;; + *.$libext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + # Linking convenience modules into shared libraries is allowed, + # but linking other static libraries is non-portable. + case " $dlpreconveniencelibs " in + *" $deplib "*) ;; + *) + valid_a_lib=no + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + valid_a_lib=yes + fi + ;; + pass_all) + valid_a_lib=yes + ;; + esac + if test "$valid_a_lib" != yes; then + echo + $ECHO "*** Warning: Trying to link with static lib archive $deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because the file extensions .$libext of this argument makes me believe" + echo "*** that it is just a static archive that I should not use here." + else + echo + $ECHO "*** Warning: Linking the shared library $output against the" + $ECHO "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + fi + ;; + esac + continue + ;; + prog) + if test "$pass" != link; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + elif test "$linkmode" = prog; then + if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + newdlprefiles="$newdlprefiles $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + newdlfiles="$newdlfiles $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=yes + continue + ;; + esac # case $deplib + + if test "$found" = yes || test -f "$lib"; then : + else + func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" + fi + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$lib" \ + || func_fatal_error "\`$lib' is not a valid libtool archive" + + func_dirname "$lib" "" "." + ladir="$func_dirname_result" + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + inherited_linker_flags= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + avoidtemprpath= + + + # Read the .la file + func_source "$lib" + + # Convert "-framework foo" to "foo.ltframework" + if test -n "$inherited_linker_flags"; then + tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` + for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do + case " $new_inherited_linker_flags " in + *" $tmp_inherited_linker_flag "*) ;; + *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; + esac + done + fi + dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan" || + { test "$linkmode" != prog && test "$linkmode" != lib; }; then + test -n "$dlopen" && dlfiles="$dlfiles $dlopen" + test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" + fi + + if test "$pass" = conv; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + func_fatal_error "cannot find name of link library for \`$lib'" + fi + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" + elif test "$linkmode" != prog && test "$linkmode" != lib; then + func_fatal_error "\`$lib' is not a convenience library" + fi + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if $opt_duplicate_deps ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + if test -z "$linklib"; then + func_fatal_error "cannot find name of link library for \`$lib'" + fi + + # This library was specified with -dlopen. + if test "$pass" = dlopen; then + if test -z "$libdir"; then + func_fatal_error "cannot -dlopen a convenience library: \`$lib'" + fi + if test -z "$dlname" || + test "$dlopen_support" != yes || + test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + dlprefiles="$dlprefiles $lib $dependency_libs" + else + newdlfiles="$newdlfiles $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + func_warning "cannot determine absolute directory name of \`$ladir'" + func_warning "passing it literally to the linker, although it might fail" + abs_ladir="$ladir" + fi + ;; + esac + func_basename "$lib" + laname="$func_basename_result" + + # Find the relevant object directory and library name. + if test "X$installed" = Xyes; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + func_warning "library \`$lib' was moved." + dir="$ladir" + absdir="$abs_ladir" + libdir="$abs_ladir" + else + dir="$libdir" + absdir="$libdir" + fi + test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes + else + if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then + dir="$ladir" + absdir="$abs_ladir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + fi + fi # $installed = yes + func_stripname 'lib' '.la' "$laname" + name=$func_stripname_result + + # This library was specified with -dlpreopen. + if test "$pass" = dlpreopen; then + if test -z "$libdir" && test "$linkmode" = prog; then + func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" + fi + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + newdlprefiles="$newdlprefiles $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + newdlprefiles="$newdlprefiles $dir/$dlname" + else + newdlprefiles="$newdlprefiles $dir/$linklib" + fi + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test "$linkmode" = lib; then + deplibs="$dir/$old_library $deplibs" + elif test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test "$linkmode" = prog && test "$pass" != link; then + newlib_search_path="$newlib_search_path $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=no + if test "$link_all_deplibs" != no || test -z "$library_names" || + test "$build_libtool_libs" = no; then + linkalldeplibs=yes + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) func_stripname '-L' '' "$deplib" + newlib_search_path="$newlib_search_path $func_stripname_result" + ;; + esac + # Need to link against all dependency_libs? + if test "$linkalldeplibs" = yes; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if $opt_duplicate_deps ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test "$linkmode,$pass" = "prog,link"; then + if test -n "$library_names" && + { { test "$prefer_static_libs" = no || + test "$prefer_static_libs,$installed" = "built,yes"; } || + test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath:" in + *"$absdir:"*) ;; + *) temp_rpath="$temp_rpath$absdir:" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + use_static_libs=$prefer_static_libs + if test "$use_static_libs" = built && test "$installed" = yes; then + use_static_libs=no + fi + if test -n "$library_names" && + { test "$use_static_libs" = no || test -z "$old_library"; }; then + case $host in + *cygwin* | *mingw* | *cegcc*) + # No point in relinking DLLs because paths are not encoded + notinst_deplibs="$notinst_deplibs $lib" + need_relink=no + ;; + *) + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" + need_relink=yes + fi + ;; + esac + # This is a shared library + + # Warn about portability, can't link against -module's on some + # systems (darwin). Don't bleat about dlopened modules though! + dlopenmodule="" + for dlpremoduletest in $dlprefiles; do + if test "X$dlpremoduletest" = "X$lib"; then + dlopenmodule="$dlpremoduletest" + break + fi + done + if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then + echo + if test "$linkmode" = prog; then + $ECHO "*** Warning: Linking the executable $output against the loadable module" + else + $ECHO "*** Warning: Linking the shared library $output against the loadable module" + fi + $ECHO "*** $linklib is not portable!" + fi + if test "$linkmode" = lib && + test "$hardcode_into_libs" = yes; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + shift + realname="$1" + shift + eval "libname=\"$libname_spec\"" + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname="$dlname" + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw* | *cegcc*) + func_arith $current - $age + major=$func_arith_result + versuffix="-$major" + ;; + esac + eval "soname=\"$soname_spec\"" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot="$soname" + func_basename "$soroot" + soname="$func_basename_result" + func_stripname 'lib' '.dll' "$soname" + newlib=libimp-$func_stripname_result.a + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + func_verbose "extracting exported symbol list from \`$soname'" + func_execute_cmds "$extract_expsyms_cmds" 'exit $?' + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + func_verbose "generating import library for \`$soname'" + func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test "$linkmode" = prog || test "$mode" != relink; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test "$hardcode_direct" = no; then + add="$dir/$linklib" + case $host in + *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; + *-*-sysv4*uw2*) add_dir="-L$dir" ;; + *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ + *-*-unixware7*) add_dir="-L$dir" ;; + *-*-darwin* ) + # if the lib is a (non-dlopened) module then we can not + # link against it, someone is ignoring the earlier warnings + if /usr/bin/file -L $add 2> /dev/null | + $GREP ": [^:]* bundle" >/dev/null ; then + if test "X$dlopenmodule" != "X$lib"; then + $ECHO "*** Warning: lib $linklib is a module, not a shared library" + if test -z "$old_library" ; then + echo + echo "*** And there doesn't seem to be a static archive available" + echo "*** The link will probably fail, sorry" + else + add="$dir/$old_library" + fi + elif test -n "$old_library"; then + add="$dir/$old_library" + fi + fi + esac + elif test "$hardcode_minus_L" = no; then + case $host in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + relink) + if test "$hardcode_direct" = yes && + test "$hardcode_direct_absolute" = no; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$absdir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; then + func_fatal_configuration "unsupported hardcode properties" + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; + esac + fi + if test "$linkmode" = prog; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test "$hardcode_direct" != yes && + test "$hardcode_minus_L" != yes && + test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + fi + fi + fi + + if test "$linkmode" = prog || test "$mode" = relink; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes && + test "$hardcode_direct_absolute" = no; then + add="$libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + add="-l$name" + elif test "$hardcode_automatic" = yes; then + if test -n "$inst_prefix_dir" && + test -f "$inst_prefix_dir$libdir/$linklib" ; then + add="$inst_prefix_dir$libdir/$linklib" + else + add="$libdir/$linklib" + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir="-L$libdir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + fi + + if test "$linkmode" = prog; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test "$linkmode" = prog; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test "$build_libtool_libs" = yes; then + # Not a shared library + if test "$deplibs_check_method" != pass_all; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + echo + $ECHO "*** Warning: This system can not link to static lib archive $lib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + if test "$module" = yes; then + echo "*** But as you try to build a module library, libtool will still create " + echo "*** a static module, that should work as long as the dlopening application" + echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test "$linkmode" = lib; then + if test -n "$dependency_libs" && + { test "$hardcode_into_libs" != yes || + test "$build_old_libs" = yes || + test "$link_static" = yes; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) func_stripname '-R' '' "$libdir" + temp_xrpath=$func_stripname_result + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + *) temp_deplibs="$temp_deplibs $libdir";; + esac + done + dependency_libs="$temp_deplibs" + fi + + newlib_search_path="$newlib_search_path $absdir" + # Link against this library + test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + if $opt_duplicate_deps ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + + if test "$link_all_deplibs" != no; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + path= + case $deplib in + -L*) path="$deplib" ;; + *.la) + func_dirname "$deplib" "" "." + dir="$func_dirname_result" + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + func_warning "cannot determine absolute directory name of \`$dir'" + absdir="$dir" + fi + ;; + esac + if $GREP "^installed=no" $deplib > /dev/null; then + case $host in + *-*-darwin*) + depdepl= + deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names" ; then + for tmp in $deplibrary_names ; do + depdepl=$tmp + done + if test -f "$absdir/$objdir/$depdepl" ; then + depdepl="$absdir/$objdir/$depdepl" + darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + if test -z "$darwin_install_name"; then + darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + fi + compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" + linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" + path= + fi + fi + ;; + *) + path="-L$absdir/$objdir" + ;; + esac + else + libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + test -z "$libdir" && \ + func_fatal_error "\`$deplib' is not a valid libtool archive" + test "$absdir" != "$libdir" && \ + func_warning "\`$deplib' seems to be moved" + + path="-L$absdir" + fi + ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + if test "$pass" = link; then + if test "$linkmode" = "prog"; then + compile_deplibs="$new_inherited_linker_flags $compile_deplibs" + finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" + else + compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + fi + fi + dependency_libs="$newdependency_libs" + if test "$pass" = dlpreopen; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test "$pass" != dlopen; then + if test "$pass" != conv; then + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir" ;; + esac + done + newlib_search_path= + fi + + if test "$linkmode,$pass" != "prog,link"; then + vars="deplibs" + else + vars="compile_deplibs finalize_deplibs" + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\$$var + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + done + eval $var=\$tmp_libs + done # for var + fi + # Last step: remove runtime libs from dependency_libs + # (they stay in deplibs) + tmp_libs= + for i in $dependency_libs ; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i="" + ;; + esac + if test -n "$i" ; then + tmp_libs="$tmp_libs $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test "$linkmode" = prog; then + dlfiles="$newdlfiles" + fi + if test "$linkmode" = prog || test "$linkmode" = lib; then + dlprefiles="$newdlprefiles" + fi + + case $linkmode in + oldlib) + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + func_warning "\`-dlopen' is ignored for archives" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "\`-l' and \`-L' are ignored for archives" ;; + esac + + test -n "$rpath" && \ + func_warning "\`-rpath' is ignored for archives" + + test -n "$xrpath" && \ + func_warning "\`-R' is ignored for archives" + + test -n "$vinfo" && \ + func_warning "\`-version-info/-version-number' is ignored for archives" + + test -n "$release" && \ + func_warning "\`-release' is ignored for archives" + + test -n "$export_symbols$export_symbols_regex" && \ + func_warning "\`-export-symbols' is ignored for archives" + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + objs="$objs$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form `libNAME.la'. + case $outputname in + lib*) + func_stripname 'lib' '.la' "$outputname" + name=$func_stripname_result + eval "shared_ext=\"$shrext_cmds\"" + eval "libname=\"$libname_spec\"" + ;; + *) + test "$module" = no && \ + func_fatal_help "libtool library \`$output' must begin with \`lib'" + + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + func_stripname '' '.la' "$outputname" + name=$func_stripname_result + eval "shared_ext=\"$shrext_cmds\"" + eval "libname=\"$libname_spec\"" + else + func_stripname '' '.la' "$outputname" + libname=$func_stripname_result + fi + ;; + esac + + if test -n "$objs"; then + if test "$deplibs_check_method" != pass_all; then + func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" + else + echo + $ECHO "*** Warning: Linking the shared library $output against the non-libtool" + $ECHO "*** objects $objs is not portable!" + libobjs="$libobjs $objs" + fi + fi + + test "$dlself" != no && \ + func_warning "\`-dlopen self' is ignored for libtool libraries" + + set dummy $rpath + shift + test "$#" -gt 1 && \ + func_warning "ignoring multiple \`-rpath's for a libtool library" + + install_libdir="$1" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + # Some compilers have problems with a `.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + test -n "$vinfo" && \ + func_warning "\`-version-info/-version-number' is ignored for convenience libraries" + + test -n "$release" && \ + func_warning "\`-release' is ignored for convenience libraries" + else + + # Parse the version information argument. + save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + shift + IFS="$save_ifs" + + test -n "$7" && \ + func_fatal_help "too many parameters to \`-version-info'" + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major="$1" + number_minor="$2" + number_revision="$3" + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # which has an extra 1 added just for fun + # + case $version_type in + darwin|linux|osf|windows|none) + func_arith $number_major + $number_minor + current=$func_arith_result + age="$number_minor" + revision="$number_revision" + ;; + freebsd-aout|freebsd-elf|qnx|sunos) + current="$number_major" + revision="$number_minor" + age="0" + ;; + irix|nonstopux) + func_arith $number_major + $number_minor + current=$func_arith_result + age="$number_minor" + revision="$number_minor" + lt_irix_increment=no + ;; + esac + ;; + no) + current="$1" + revision="$2" + age="$3" + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "CURRENT \`$current' must be a nonnegative integer" + func_fatal_error "\`$vinfo' is not valid version information" + ;; + esac + + case $revision in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "REVISION \`$revision' must be a nonnegative integer" + func_fatal_error "\`$vinfo' is not valid version information" + ;; + esac + + case $age in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "AGE \`$age' must be a nonnegative integer" + func_fatal_error "\`$vinfo' is not valid version information" + ;; + esac + + if test "$age" -gt "$current"; then + func_error "AGE \`$age' is greater than the current interface number \`$current'" + func_fatal_error "\`$vinfo' is not valid version information" + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + func_arith $current - $age + major=.$func_arith_result + versuffix="$major.$age.$revision" + # Darwin ld doesn't like 0 for these options... + func_arith $current + 1 + minor_current=$func_arith_result + xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current" + ;; + + irix | nonstopux) + if test "X$lt_irix_increment" = "Xno"; then + func_arith $current - $age + else + func_arith $current - $age + 1 + fi + major=$func_arith_result + + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring="$verstring_prefix$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test "$loop" -ne 0; do + func_arith $revision - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring="$verstring_prefix$major.$iface:$verstring" + done + + # Before this point, $major must not contain `.'. + major=.$major + versuffix="$major.$revision" + ;; + + linux) + func_arith $current - $age + major=.$func_arith_result + versuffix="$major.$age.$revision" + ;; + + osf) + func_arith $current - $age + major=.$func_arith_result + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test "$loop" -ne 0; do + func_arith $current - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + qnx) + major=".$current" + versuffix=".$current" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 filesystems. + func_arith $current - $age + major=$func_arith_result + versuffix="-$major" + ;; + + *) + func_fatal_configuration "unknown library version type \`$version_type'" + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring="0.0" + ;; + esac + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + func_warning "undefined symbols not allowed in $host shared libraries" + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + + fi + + func_generate_dlsyms "$libname" "$libname" "yes" + libobjs="$libobjs $symfileobj" + test "X$libobjs" = "X " && libobjs= + + if test "$mode" != relink; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$ECHO "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext | *.gcno) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) + if test "X$precious_files_regex" != "X"; then + if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + fi + removelist="$removelist $p" + ;; + *) ;; + esac + done + test -n "$removelist" && \ + func_show_eval "${RM}r \$removelist" + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + #for path in $notinst_path; do + # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` + # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` + # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` + #done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles="$dlfiles" + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) dlfiles="$dlfiles $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles="$dlprefiles" + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) dlprefiles="$dlprefiles $lib" ;; + esac + done + + if test "$build_libtool_libs" = yes; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + deplibs="$deplibs System.ltframework" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test "$build_libtool_need_lc" = "yes"; then + deplibs="$deplibs -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $opt_dry_run || $RM conftest.c + cat > conftest.c </dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null | + $GREP " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval "$file_magic_cmd \"\$potlib\"" 2>/dev/null | + $SED -e 10q | + $EGREP "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + echo + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $ECHO "*** with $libname but no candidates were found. (...for file magic test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a file magic. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + for a_deplib in $deplibs; do + case $a_deplib in + -l*) + func_stripname -l '' "$a_deplib" + name=$func_stripname_result + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + eval "libname=\"$libname_spec\"" + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib="$potent_lib" # see symlink-check above in file_magic test + if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ + $EGREP "$match_pattern_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + echo + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a regex pattern. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + for i in $predeps $postdeps ; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` + done + fi + case $tmp_deplibs in + *[!\ \ ]*) + echo + if test "X$deplibs_check_method" = "Xnone"; then + echo "*** Warning: inter-library dependencies are not supported in this platform." + else + echo "*** Warning: inter-library dependencies are not known to be supported." + fi + echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + ;; + esac + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library with the System framework + newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` + ;; + esac + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + echo + echo "*** Warning: libtool could not satisfy all declared inter-library" + $ECHO "*** dependencies of module $libname. Therefore, libtool will create" + echo "*** a static module, that should work as long as the dlopening" + echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + echo "*** The inter-library dependencies that have been dropped here will be" + echo "*** automatically added whenever a program is linked with this library" + echo "*** or is declared to -dlopen it." + + if test "$allow_undefined" = no; then + echo + echo "*** Since this library must not contain undefined symbols," + echo "*** because either the platform does not support them or" + echo "*** it was explicitly requested with -no-undefined," + echo "*** libtool will only create a static version of it." + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + case $host in + *-*-darwin*) + newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + deplibs="$new_libs" + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + if test "$hardcode_into_libs" = yes; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath="$finalize_rpath" + test "$mode" != relink && rpath="$compile_rpath$rpath" + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval "flag=\"$hardcode_libdir_flag_spec\"" + dep_rpath="$dep_rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + if test -n "$hardcode_libdir_flag_spec_ld"; then + eval "dep_rpath=\"$hardcode_libdir_flag_spec_ld\"" + else + eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" + fi + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + eval $runpath_var=\$rpath\$$runpath_var + export $runpath_var + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath="$finalize_shlibpath" + test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + if test -n "$shlibpath"; then + eval $shlibpath_var=\$shlibpath\$$shlibpath_var + export $shlibpath_var + fi + + # Get the real and link names of the library. + eval "shared_ext=\"$shrext_cmds\"" + eval "library_names=\"$library_names_spec\"" + set dummy $library_names + shift + realname="$1" + shift + + if test -n "$soname_spec"; then + eval "soname=\"$soname_spec\"" + else + soname="$realname" + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib="$output_objdir/$realname" + linknames= + for link + do + linknames="$linknames $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` + test "X$libobjs" = "X " && libobjs= + + delfiles= + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" + export_symbols="$output_objdir/$libname.uexp" + delfiles="$delfiles $export_symbols" + fi + + orig_export_symbols= + case $host_os in + cygwin* | mingw* | cegcc*) + if test -n "$export_symbols" && test -z "$export_symbols_regex"; then + # exporting using user supplied symfile + if test "x`$SED 1q $export_symbols`" != xEXPORTS; then + # and it's NOT already a .def file. Must figure out + # which of the given symbols are data symbols and tag + # them as such. So, trigger use of export_symbols_cmds. + # export_symbols gets reassigned inside the "prepare + # the list of exported symbols" if statement, so the + # include_expsyms logic still works. + orig_export_symbols="$export_symbols" + export_symbols= + always_export_symbols=yes + fi + fi + ;; + esac + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + func_verbose "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $opt_dry_run || $RM $export_symbols + cmds=$export_symbols_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval "cmd=\"$cmd\"" + func_len " $cmd" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + func_show_eval "$cmd" 'exit $?' + skipped_export=false + else + # The command line is too long to execute in one step. + func_verbose "using reloadable object file for export list..." + skipped_export=: + # Break out early, otherwise skipped_export may be + # set to false by a later but shorter cmd. + break + fi + done + IFS="$save_ifs" + if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols="$export_symbols" + test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" + $opt_dry_run || $ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols" + fi + + if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + tmp_deplibs="$tmp_deplibs $test_deplib" + ;; + esac + done + deplibs="$tmp_deplibs" + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec" && + test "$compiler_needs_object" = yes && + test -z "$libobjs"; then + # extract the archives, so we have objects to list. + # TODO: could optimize this to just extract one archive. + whole_archive_flag_spec= + fi + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval "libobjs=\"\$libobjs $whole_archive_flag_spec\"" + test "X$libobjs" = "X " && libobjs= + else + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + libobjs="$libobjs $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval "flag=\"$thread_safe_flag_spec\"" + linker_flags="$linker_flags $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test "$mode" = relink; then + $opt_dry_run || (cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U) || exit $? + fi + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval "test_cmds=\"$module_expsym_cmds\"" + cmds=$module_expsym_cmds + else + eval "test_cmds=\"$module_cmds\"" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval "test_cmds=\"$archive_expsym_cmds\"" + cmds=$archive_expsym_cmds + else + eval "test_cmds=\"$archive_cmds\"" + cmds=$archive_cmds + fi + fi + + if test "X$skipped_export" != "X:" && + func_len " $test_cmds" && + len=$func_len_result && + test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise + # or, if using GNU ld and skipped_export is not :, use a linker + # script. + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + func_basename "$output" + output_la=$func_basename_result + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + last_robj= + k=1 + + if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then + output=${output_objdir}/${output_la}.lnkscript + func_verbose "creating GNU ld script: $output" + echo 'INPUT (' > $output + for obj in $save_libobjs + do + $ECHO "$obj" >> $output + done + echo ')' >> $output + delfiles="$delfiles $output" + elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then + output=${output_objdir}/${output_la}.lnk + func_verbose "creating linker input file list: $output" + : > $output + set x $save_libobjs + shift + firstobj= + if test "$compiler_needs_object" = yes; then + firstobj="$1 " + shift + fi + for obj + do + $ECHO "$obj" >> $output + done + delfiles="$delfiles $output" + output=$firstobj\"$file_list_spec$output\" + else + if test -n "$save_libobjs"; then + func_verbose "creating reloadable object files..." + output=$output_objdir/$output_la-${k}.$objext + eval "test_cmds=\"$reload_cmds\"" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + if test "X$objlist" = X || + test "$len" -lt "$max_cmd_len"; then + func_append objlist " $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test "$k" -eq 1 ; then + # The first file doesn't have a previous command to add. + reload_objs=$objlist + eval "concat_cmds=\"$reload_cmds\"" + else + # All subsequent reloadable object files will link in + # the last one created. + reload_objs="$objlist $last_robj" + eval "concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"" + fi + last_robj=$output_objdir/$output_la-${k}.$objext + func_arith $k + 1 + k=$func_arith_result + output=$output_objdir/$output_la-${k}.$objext + objlist=" $obj" + func_len " $last_robj" + func_arith $len0 + $func_len_result + len=$func_arith_result + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + reload_objs="$objlist $last_robj" + eval "concat_cmds=\"\${concat_cmds}$reload_cmds\"" + if test -n "$last_robj"; then + eval "concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"" + fi + delfiles="$delfiles $output" + + else + output= + fi + + if ${skipped_export-false}; then + func_verbose "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $opt_dry_run || $RM $export_symbols + libobjs=$output + # Append the command to create the export file. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval "concat_cmds=\"\$concat_cmds$export_symbols_cmds\"" + if test -n "$last_robj"; then + eval "concat_cmds=\"\$concat_cmds~\$RM $last_robj\"" + fi + fi + + test -n "$save_libobjs" && + func_verbose "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs="$IFS"; IFS='~' + for cmd in $concat_cmds; do + IFS="$save_ifs" + $opt_silent || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + + if test -n "$export_symbols_regex" && ${skipped_export-false}; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + + if ${skipped_export-false}; then + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols="$export_symbols" + test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" + $opt_dry_run || $ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols" + fi + + if test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + fi + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval "libobjs=\"\$libobjs $whole_archive_flag_spec\"" + test "X$libobjs" = "X " && libobjs= + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + fi + + if test -n "$delfiles"; then + # Append the command to remove temporary files to $cmds. + eval "cmds=\"\$cmds~\$RM $delfiles\"" + fi + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $dlprefiles + libobjs="$libobjs $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval "cmd=\"$cmd\"" + $opt_silent || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $opt_dry_run || (cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname) || exit $? + + if test -n "$convenience"; then + if test -z "$whole_archive_flag_spec"; then + func_show_eval '${RM}r "$gentop"' + fi + fi + + exit $EXIT_SUCCESS + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + obj) + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + func_warning "\`-dlopen' is ignored for objects" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "\`-l' and \`-L' are ignored for objects" ;; + esac + + test -n "$rpath" && \ + func_warning "\`-rpath' is ignored for objects" + + test -n "$xrpath" && \ + func_warning "\`-R' is ignored for objects" + + test -n "$vinfo" && \ + func_warning "\`-version-info' is ignored for objects" + + test -n "$release" && \ + func_warning "\`-release' is ignored for objects" + + case $output in + *.lo) + test -n "$objs$old_deplibs" && \ + func_fatal_error "cannot build library object \`$output' from non-libtool objects" + + libobj=$output + func_lo2o "$libobj" + obj=$func_lo2o_result + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $opt_dry_run || $RM $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec and hope we can get by with + # turning comma into space.. + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval "tmp_whole_archive_flags=\"$whole_archive_flag_spec\"" + reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` + else + gentop="$output_objdir/${obj}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + reload_conv_objs="$reload_objs $func_extract_archives_result" + fi + fi + + # Create the old-style object. + reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + + output="$obj" + func_execute_cmds "$reload_cmds" 'exit $?' + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $opt_dry_run || echo timestamp > $libobj || exit $? + exit $EXIT_SUCCESS + fi + + if test -n "$pic_flag" || test "$pic_mode" != default; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + func_execute_cmds "$reload_cmds" 'exit $?' + fi + + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) func_stripname '' '.exe' "$output" + output=$func_stripname_result.exe;; + esac + test -n "$vinfo" && \ + func_warning "\`-version-info' is ignored for programs" + + test -n "$release" && \ + func_warning "\`-release' is ignored for programs" + + test "$preload" = yes \ + && test "$dlopen_support" = unknown \ + && test "$dlopen_self" = unknown \ + && test "$dlopen_self_static" = unknown && \ + func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` + finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` + ;; + esac + + case $host in + *-*-darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + # But is supposedly fixed on 10.4 or later (yay!). + if test "$tagname" = CXX ; then + case ${MACOSX_DEPLOYMENT_TARGET-10.0} in + 10.[0123]) + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" + ;; + esac + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $compile_deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $compile_deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + compile_deplibs="$new_libs" + + + compile_command="$compile_command $compile_deplibs" + finalize_command="$finalize_command $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval "flag=\"$hardcode_libdir_flag_spec\"" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; + ::) dllsearchpath=$libdir;; + *) dllsearchpath="$dllsearchpath:$libdir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval "rpath=\" $hardcode_libdir_flag_spec\"" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval "flag=\"$hardcode_libdir_flag_spec\"" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval "rpath=\" $hardcode_libdir_flag_spec\"" + fi + finalize_rpath="$rpath" + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` + finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` + fi + + func_generate_dlsyms "$outputname" "@PROGRAM@" "no" + + # template prelinking step + if test -n "$prelink_cmds"; then + func_execute_cmds "$prelink_cmds" 'exit $?' + fi + + wrappers_required=yes + case $host in + *cegcc* | *mingw32ce*) + # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. + wrappers_required=no + ;; + *cygwin* | *mingw* ) + if test "$build_libtool_libs" != yes; then + wrappers_required=no + fi + ;; + *) + if test "$need_relink" = no || test "$build_libtool_libs" != yes; then + wrappers_required=no + fi + ;; + esac + if test "$wrappers_required" = no; then + # Replace the output file specification. + compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + exit_status=0 + func_show_eval "$link_command" 'exit_status=$?' + + # Delete the generated files. + if test -f "$output_objdir/${outputname}S.${objext}"; then + func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' + fi + + exit $exit_status + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$no_install" = yes; then + # We don't need to create a wrapper script. + link_command="$compile_var$compile_command$compile_rpath" + # Replace the output file specification. + link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $opt_dry_run || $RM $output + # Link the executable and exit + func_show_eval "$link_command" 'exit $?' + exit $EXIT_SUCCESS + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + func_warning "this platform does not like uninstalled shared libraries" + func_warning "\`$output' will be relinked during installation" + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname + + func_show_eval "$link_command" 'exit $?' + + # Now create the wrapper script. + func_verbose "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + fi + + # Only actually do things if not in dry run mode. + $opt_dry_run || { + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) func_stripname '' '.exe' "$output" + output=$func_stripname_result ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + func_stripname '' '.exe' "$outputname" + outputname=$func_stripname_result ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + func_dirname_and_basename "$output" "" "." + output_name=$func_basename_result + output_path=$func_dirname_result + cwrappersource="$output_path/$objdir/lt-$output_name.c" + cwrapper="$output_path/$output_name.exe" + $RM $cwrappersource $cwrapper + trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + + func_emit_cwrapperexe_src > $cwrappersource + + # The wrapper executable is built using the $host compiler, + # because it contains $host paths and files. If cross- + # compiling, it, like the target executable, must be + # executed on the $host or under an emulation environment. + $opt_dry_run || { + $LTCC $LTCFLAGS -o $cwrapper $cwrappersource + $STRIP $cwrapper + } + + # Now, create the wrapper script for func_source use: + func_ltwrapper_scriptname $cwrapper + $RM $func_ltwrapper_scriptname_result + trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 + $opt_dry_run || { + # note: this script will not be executed, so do not chmod. + if test "x$build" = "x$host" ; then + $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result + else + func_emit_wrapper no > $func_ltwrapper_scriptname_result + fi + } + ;; + * ) + $RM $output + trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 + + func_emit_wrapper no > $output + chmod +x $output + ;; + esac + } + exit $EXIT_SUCCESS + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save $symfileobj" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$old_deplibs $non_pic_objects" + if test "$preload" = yes && test -f "$symfileobj"; then + oldobjs="$oldobjs $symfileobj" + fi + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $addlibs + oldobjs="$oldobjs $func_extract_archives_result" + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + cmds=$old_archive_from_new_cmds + else + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $dlprefiles + oldobjs="$oldobjs $func_extract_archives_result" + fi + + # POSIX demands no paths to be encoded in archives. We have + # to avoid creating archives with duplicate basenames if we + # might have to extract them afterwards, e.g., when creating a + # static archive out of a convenience library, or when linking + # the entirety of a libtool archive into another (currently + # not supported by libtool). + if (for obj in $oldobjs + do + func_basename "$obj" + $ECHO "$func_basename_result" + done | sort | sort -uc >/dev/null 2>&1); then + : + else + echo "copying selected object files to avoid basename conflicts..." + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + func_mkdir_p "$gentop" + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + func_basename "$obj" + objbase="$func_basename_result" + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + func_arith $counter + 1 + counter=$func_arith_result + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + oldobjs="$oldobjs $gentop/$newobj" + ;; + *) oldobjs="$oldobjs $obj" ;; + esac + done + fi + eval "cmds=\"$old_archive_cmds\"" + + func_len " $cmds" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + func_verbose "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + oldobjs= + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + eval "test_cmds=\"$old_archive_cmds\"" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + for obj in $save_oldobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + func_append objlist " $obj" + if test "$len" -lt "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj" ; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval "concat_cmds=\"\${concat_cmds}$old_archive_cmds\"" + objlist= + len=$len0 + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test "X$oldobjs" = "X" ; then + eval "cmds=\"\$concat_cmds\"" + else + eval "cmds=\"\$concat_cmds~\$old_archive_cmds\"" + fi + fi + fi + func_execute_cmds "$cmds" 'exit $?' + done + + test -n "$generated" && \ + func_show_eval "${RM}r$generated" + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + func_verbose "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + if test "$hardcode_automatic" = yes ; then + relink_command= + fi + + # Only create the output if not a dry run. + $opt_dry_run || { + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + func_basename "$deplib" + name="$func_basename_result" + libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + test -z "$libdir" && \ + func_fatal_error "\`$deplib' is not a valid libtool archive" + newdependency_libs="$newdependency_libs $libdir/$name" + ;; + *) newdependency_libs="$newdependency_libs $deplib" ;; + esac + done + dependency_libs="$newdependency_libs" + newdlfiles= + + for lib in $dlfiles; do + case $lib in + *.la) + func_basename "$lib" + name="$func_basename_result" + libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "\`$lib' is not a valid libtool archive" + newdlfiles="$newdlfiles $libdir/$name" + ;; + *) newdlfiles="$newdlfiles $lib" ;; + esac + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + *.la) + # Only pass preopened files to the pseudo-archive (for + # eventual linking with the app. that links it) if we + # didn't already link the preopened objects directly into + # the library: + func_basename "$lib" + name="$func_basename_result" + libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "\`$lib' is not a valid libtool archive" + newdlprefiles="$newdlprefiles $libdir/$name" + ;; + esac + done + dlprefiles="$newdlprefiles" + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlfiles="$newdlfiles $abs" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlprefiles="$newdlprefiles $abs" + done + dlprefiles="$newdlprefiles" + fi + $RM $output + # place dlname in correct position for cygwin + # In fact, it would be nice if we could use this code for all target + # systems that can't hard-code library paths into their executables + # and that have no shared library path variable independent of PATH, + # but it turns out we can't easily determine that from inspecting + # libtool variables, so we have to hard-code the OSs to which it + # applies here; at the moment, that means platforms that use the PE + # object format with DLL files. See the long comment at the top of + # tests/bindir.at for full details. + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) + # If a -bindir argument was supplied, place the dll there. + if test "x$bindir" != x ; + then + func_relative_path "$install_libdir" "$bindir" + tdlname=$func_relative_path_result$dlname + else + # Otherwise fall back on heuristic. + tdlname=../bin/$dlname + fi + ;; + esac + $ECHO > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Linker flags that can not go in dependency_libs. +inherited_linker_flags='$new_inherited_linker_flags' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Names of additional weak libraries provided by this library +weak_library_names='$weak_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test "$installed" = no && test "$need_relink" = yes; then + $ECHO >> $output "\ +relink_command=\"$relink_command\"" + fi + done + } + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' + ;; + esac + exit $EXIT_SUCCESS +} + +{ test "$mode" = link || test "$mode" = relink; } && + func_mode_link ${1+"$@"} + + +# func_mode_uninstall arg... +func_mode_uninstall () +{ + $opt_debug + RM="$nonopt" + files= + rmforce= + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + for arg + do + case $arg in + -f) RM="$RM $arg"; rmforce=yes ;; + -*) RM="$RM $arg" ;; + *) files="$files $arg" ;; + esac + done + + test -z "$RM" && \ + func_fatal_help "you must specify an RM program" + + rmdirs= + + origobjdir="$objdir" + for file in $files; do + func_dirname "$file" "" "." + dir="$func_dirname_result" + if test "X$dir" = X.; then + objdir="$origobjdir" + else + objdir="$dir/$origobjdir" + fi + func_basename "$file" + name="$func_basename_result" + test "$mode" = uninstall && objdir="$dir" + + # Remember objdir for removal later, being careful to avoid duplicates + if test "$mode" = clean; then + case " $rmdirs " in + *" $objdir "*) ;; + *) rmdirs="$rmdirs $objdir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if { test -L "$file"; } >/dev/null 2>&1 || + { test -h "$file"; } >/dev/null 2>&1 || + test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif test "$rmforce" = yes; then + continue + fi + + rmfiles="$file" + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if func_lalib_p "$file"; then + func_source $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $objdir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + + case "$mode" in + clean) + case " $library_names " in + # " " in the beginning catches empty $dlname + *" $dlname "*) ;; + *) rmfiles="$rmfiles $objdir/$dlname" ;; + esac + test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + ;; + uninstall) + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' + fi + # FIXME: should reinstall the best remaining shared library. + ;; + esac + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if func_lalib_p "$file"; then + + # Read the .lo file + func_source $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" && + test "$pic_object" != none; then + rmfiles="$rmfiles $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" && + test "$non_pic_object" != none; then + rmfiles="$rmfiles $dir/$non_pic_object" + fi + fi + ;; + + *) + if test "$mode" = clean ; then + noexename=$name + case $file in + *.exe) + func_stripname '' '.exe' "$file" + file=$func_stripname_result + func_stripname '' '.exe' "$name" + noexename=$func_stripname_result + # $file with .exe has already been added to rmfiles, + # add $file without .exe + rmfiles="$rmfiles $file" + ;; + esac + # Do a test to see if this is a libtool program. + if func_ltwrapper_p "$file"; then + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + relink_command= + func_source $func_ltwrapper_scriptname_result + rmfiles="$rmfiles $func_ltwrapper_scriptname_result" + else + relink_command= + func_source $dir/$noexename + fi + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + if test "$fast_install" = yes && test -n "$relink_command"; then + rmfiles="$rmfiles $objdir/lt-$name" + fi + if test "X$noexename" != "X$name" ; then + rmfiles="$rmfiles $objdir/lt-${noexename}.c" + fi + fi + fi + ;; + esac + func_show_eval "$RM $rmfiles" 'exit_status=1' + done + objdir="$origobjdir" + + # Try to remove the ${objdir}s in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + func_show_eval "rmdir $dir >/dev/null 2>&1" + fi + done + + exit $exit_status +} + +{ test "$mode" = uninstall || test "$mode" = clean; } && + func_mode_uninstall ${1+"$@"} + +test -z "$mode" && { + help="$generic_help" + func_fatal_help "you must specify a MODE" +} + +test -z "$exec_cmd" && \ + func_fatal_help "invalid operation mode \`$mode'" + +if test -n "$exec_cmd"; then + eval exec "$exec_cmd" + exit $EXIT_FAILURE +fi + +exit $exit_status + + +# The TAGs below are defined such that we never get into a situation +# in which we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +build_libtool_libs=no +build_old_libs=yes +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: +# vi:sw=2 + diff --git a/support/sdbinutils/binutils/makefile.vms b/support/sdbinutils/binutils/makefile.vms new file mode 100644 index 0000000..088ac3b --- /dev/null +++ b/support/sdbinutils/binutils/makefile.vms @@ -0,0 +1,90 @@ +# +# Makefile for binutils under openVMS (Alpha and Itanium) +# +# For use with gnu-make for vms +# +# Created by Klaus Kaempf, kkaempf@rmi.de +# +# Copyright (C) 2012-2018 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . +# + +DEFS=/define=("OBJDUMP_PRIVATE_VECTORS=") +OPT=/noopt/debug +CFLAGS=$(OPT)/include=([],"../include",[-.bfd])$(DEFS)\ + /name=(as_is,shortened)\ + /prefix=(all,except=("getopt","optarg","optopt","optind","opterr"))\ + /warns=(info=(ptrmismatch,shiftcount)) + +LIBBFD = [-.bfd]libbfd.olb/lib +LIBBFD_DEP = [-.bfd]libbfd.olb +LIBIBERTY_DEP = [-.libiberty]libiberty.olb +LIBIBERTY = [-.libiberty]libiberty.olb/lib +OPCODES_DEP = [-.opcodes]libopcodes.olb +OPCODES = [-.opcodes]libopcodes.olb/lib + +DEBUG_OBJS = rddbg.obj,debug.obj,stabs.obj,ieee.obj,rdcoff.obj,dwarf.obj,\ + elfcomm.obj + +BULIBS = bucomm.obj,version.obj,filemode.obj + +ADDL_DEPS = $(BULIBS),$(LIBBFD_DEP),$(LIBIBERTY_DEP) +ADDL_LIBS = $(BULIBS),$(LIBBFD),$(LIBIBERTY) + +SIZEOBJS = $(ADDL_DEPS),size.obj + +STRINGSOBJS = $(ADDL_DEPS),strings.obj + +NMOBJS = $(ADDL_DEPS),nm.obj + +ADDR2LINEOBJS = $(ADDL_DEPS),addr2line.obj + +OBJDUMPOBJS = objdump.obj,prdbg.obj,$(DEBUG_OBJS),$(ADDL_DEPS),$(OPCODES_DEP) + +READELFOBJS = readelf.obj,dwarf.obj,unwind-ia64.obj,$(ADDL_DEPS) + +all: config.h size.exe strings.exe objdump.exe nm.exe addr2line.exe + +size.exe: $(SIZEOBJS) + link/exe=$@ size.obj,$(ADDL_LIBS) + +strings.exe: $(STRINGSOBJS) + link/exe=$@ strings.obj,$(ADDL_LIBS) + +nm.exe: $(NMOBJS) + link/exe=$@ nm.obj,$(ADDL_LIBS) + +addr2line.exe: $(ADDR2LINEOBJS) + link/exe=$@ addr2line.obj,$(ADDL_LIBS) + +objdump.exe: $(OBJDUMPOBJS) + link/exe=$@ objdump.obj,prdbg.obj,$(DEBUG_OBJS),$(ADDL_LIBS),$(OPCODES) + +readelf.exe: $(READELFOBJS) + link/exe=$@ readelf.obj,dwarf.obj,unwind-ia64.obj,$(ADDL_LIBS) + +config.h: + $$ @configure + $(MAKE) -f makefile.vms "CC=$(CC)" + +clean: + $$ purge + $(RM) *.obj; + $(RM) *.exe; + +distclean: clean + $(RM) config.h; + $(RM) makefile.vms; diff --git a/support/sdbinutils/binutils/maybe-ranlib.c b/support/sdbinutils/binutils/maybe-ranlib.c new file mode 100644 index 0000000..d5252f4 --- /dev/null +++ b/support/sdbinutils/binutils/maybe-ranlib.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2007-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Linked with ar.o to flag that this program decides at runtime + (using argv[0] if it is is 'ar' or 'ranlib'. */ + +int is_ranlib = -1; diff --git a/support/sdbinutils/binutils/maybe-strip.c b/support/sdbinutils/binutils/maybe-strip.c new file mode 100644 index 0000000..49f4bd2 --- /dev/null +++ b/support/sdbinutils/binutils/maybe-strip.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2007-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Linked with objcopy.o to flag that this program decides at runtime + (using argv[0] if it is is 'strip' or 'objcopy'. */ + +int is_strip = -1; diff --git a/support/sdbinutils/binutils/mclex.c b/support/sdbinutils/binutils/mclex.c new file mode 100644 index 0000000..c1560b6 --- /dev/null +++ b/support/sdbinutils/binutils/mclex.c @@ -0,0 +1,440 @@ +/* mclex.c -- lexer for Windows mc files parser. + Copyright (C) 2007-2018 Free Software Foundation, Inc. + + Written by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* This is a lexer used by the Windows rc file parser. + It basically just recognized a bunch of keywords. */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" +#include "libiberty.h" +#include "safe-ctype.h" +#include "windmc.h" +#include "mcparse.h" + +#include + +/* Exported globals. */ +bfd_boolean mclex_want_nl = FALSE; +bfd_boolean mclex_want_line = FALSE; +bfd_boolean mclex_want_filename = FALSE; + +/* Local globals. */ +static unichar *input_stream = NULL; +static unichar *input_stream_pos = NULL; +static int input_line = 1; +static const char *input_filename = NULL; + +void +mc_set_content (const unichar *src) +{ + if (!src) + return; + input_stream = input_stream_pos = unichar_dup (src); +} + +void +mc_set_inputfile (const char *name) +{ + if (! name || *name == 0) + input_filename = "-"; + else + { + const char *s1 = strrchr (name, '/'); + const char *s2 = strrchr (name, '\\'); + + if (! s1) + s1 = s2; + if (s1 && s2 && s1 < s2) + s1 = s2; + if (! s1) + s1 = name; + else + s1++; + s1 = xstrdup (s1); + input_filename = s1; + } +} + +static void +show_msg (const char *kind, const char *msg, va_list argp) +{ + fprintf (stderr, "In %s at line %d: %s: ", input_filename, input_line, kind); + vfprintf (stderr, msg, argp); + fprintf (stderr, ".\n"); +} + +void +mc_warn (const char *s, ...) +{ + va_list argp; + va_start (argp, s); + show_msg ("warning", s, argp); + va_end (argp); +} + +void +mc_fatal (const char *s, ...) +{ + va_list argp; + va_start (argp, s); + show_msg ("fatal", s, argp); + va_end (argp); + xexit (1); +} + + +int +yyerror (const char *s, ...) +{ + va_list argp; + va_start (argp, s); + show_msg ("parser", s, argp); + va_end (argp); + return 1; +} + +static unichar * +get_diff (unichar *end, unichar *start) +{ + unichar *ret; + unichar save = *end; + + *end = 0; + ret = unichar_dup (start); + *end = save; + return ret; +} + +static rc_uint_type +parse_digit (unichar ch) +{ + rc_uint_type base = 10, v = 0, c; + + if (ch == '0') + { + base = 8; + switch (input_stream_pos[0]) + { + case 'x': case 'X': base = 16; input_stream_pos++; break; + case 'o': case 'O': base = 8; input_stream_pos++; break; + case 'b': case 'B': base = 2; input_stream_pos++; break; + } + } + else + v = (rc_uint_type) (ch - '0'); + + while ((ch = input_stream_pos[0]) != 0) + { + if (ch >= 'A' && ch <= 'F') + c = (rc_uint_type) (ch - 'A') + 10; + else if (ch >= 'a' && ch <= 'f') + c = (rc_uint_type) (ch - 'a') + 10; + else if (ch >= '0' && ch <= '9') + c = (rc_uint_type) (ch - '0'); + else + break; + v *= base; + v += c; + ++input_stream_pos; + } + if (input_stream_pos[0] == 'U' || input_stream_pos[0] == 'u') + input_stream_pos++; + if (input_stream_pos[0] == 'L' || input_stream_pos[0] == 'l') + input_stream_pos++; + if (input_stream_pos[0] == 'L' || input_stream_pos[0] == 'l') + input_stream_pos++; + return v; +} + +static mc_keyword *keyword_top = NULL; + +const mc_keyword * +enum_facility (int e) +{ + mc_keyword *h = keyword_top; + + while (h != NULL) + { + while (h && strcmp (h->group_name, "facility") != 0) + h = h->next; + if (e == 0) + return h; + --e; + if (h) + h = h->next; + } + return h; +} + +const mc_keyword * +enum_severity (int e) +{ + mc_keyword *h = keyword_top; + + while (h != NULL) + { + while (h && strcmp (h->group_name, "severity") != 0) + h = h->next; + if (e == 0) + return h; + --e; + if (h) + h = h->next; + } + return h; +} + +static void +mc_add_keyword_ascii (const char *sz, int rid, const char *grp, rc_uint_type nv, const char *sv) +{ + unichar *usz, *usv = NULL; + rc_uint_type usz_len; + + unicode_from_codepage (&usz_len, &usz, sz, CP_ACP); + if (sv) + unicode_from_codepage (&usz_len, &usv, sv, CP_ACP); + mc_add_keyword (usz, rid, grp, nv, usv); +} + +void +mc_add_keyword (unichar *usz, int rid, const char *grp, rc_uint_type nv, unichar *sv) +{ + mc_keyword *p, *c, *n; + size_t len = unichar_len (usz); + + c = keyword_top; + p = NULL; + while (c != NULL) + { + if (c->len > len) + break; + if (c->len == len) + { + int e = memcmp (usz, c->usz, len * sizeof (unichar)); + + if (e < 0) + break; + if (! e) + { + if (! strcmp (grp, "keyword") || strcmp (c->group_name, grp) != 0) + fatal (_("Duplicate symbol entered into keyword list.")); + c->rid = rid; + c->nval = nv; + c->sval = (!sv ? NULL : unichar_dup (sv)); + if (! strcmp (grp, "language")) + { + const wind_language_t *lag = wind_find_language_by_id ((unsigned) nv); + + if (lag == NULL) + fatal ("Language ident 0x%lx is not resolvable.\n", (long) nv); + memcpy (&c->lang_info, lag, sizeof (*lag)); + } + return; + } + } + c = (p = c)->next; + } + n = xmalloc (sizeof (mc_keyword)); + n->next = c; + n->len = len; + n->group_name = grp; + n->usz = usz; + n->rid = rid; + n->nval = nv; + n->sval = (!sv ? NULL : unichar_dup (sv)); + if (! strcmp (grp, "language")) + { + const wind_language_t *lag = wind_find_language_by_id ((unsigned) nv); + if (lag == NULL) + fatal ("Language ident 0x%lx is not resolvable.\n", (long) nv); + memcpy (&n->lang_info, lag, sizeof (*lag)); + } + if (! p) + keyword_top = n; + else + p->next = n; +} + +static int +mc_token (const unichar *t, size_t len) +{ + static int was_init = 0; + mc_keyword *k; + + if (! was_init) + { + was_init = 1; + mc_add_keyword_ascii ("OutputBase", MCOUTPUTBASE, "keyword", 0, NULL); + mc_add_keyword_ascii ("MessageIdTypedef", MCMESSAGEIDTYPEDEF, "keyword", 0, NULL); + mc_add_keyword_ascii ("SeverityNames", MCSEVERITYNAMES, "keyword", 0, NULL); + mc_add_keyword_ascii ("FacilityNames", MCFACILITYNAMES, "keyword", 0, NULL); + mc_add_keyword_ascii ("LanguageNames", MCLANGUAGENAMES, "keyword", 0, NULL); + mc_add_keyword_ascii ("MessageId", MCMESSAGEID, "keyword", 0, NULL); + mc_add_keyword_ascii ("Severity", MCSEVERITY, "keyword", 0, NULL); + mc_add_keyword_ascii ("Facility", MCFACILITY, "keyword", 0, NULL); + mc_add_keyword_ascii ("SymbolicName", MCSYMBOLICNAME, "keyword", 0, NULL); + mc_add_keyword_ascii ("Language", MCLANGUAGE, "keyword", 0, NULL); + mc_add_keyword_ascii ("Success", MCTOKEN, "severity", 0, NULL); + mc_add_keyword_ascii ("Informational", MCTOKEN, "severity", 1, NULL); + mc_add_keyword_ascii ("Warning", MCTOKEN, "severity", 2, NULL); + mc_add_keyword_ascii ("Error", MCTOKEN, "severity", 3, NULL); + mc_add_keyword_ascii ("System", MCTOKEN, "facility", 0xff, NULL); + mc_add_keyword_ascii ("Application", MCTOKEN, "facility", 0xfff, NULL); + mc_add_keyword_ascii ("English", MCTOKEN, "language", 0x409, "MSG00001"); + } + k = keyword_top; + if (!len || !t || *t == 0) + return -1; + while (k != NULL) + { + if (k->len > len) + break; + if (k->len == len) + { + if (! memcmp (k->usz, t, len * sizeof (unichar))) + { + if (k->rid == MCTOKEN) + yylval.tok = k; + return k->rid; + } + } + k = k->next; + } + return -1; +} + +int +yylex (void) +{ + unichar *start_token; + unichar ch; + + if (! input_stream_pos) + { + fatal ("Input stream not setuped.\n"); + return -1; + } + if (mclex_want_line) + { + start_token = input_stream_pos; + if (input_stream_pos[0] == '.' + && (input_stream_pos[1] == '\n' + || (input_stream_pos[1] == '\r' && input_stream_pos[2] == '\n'))) + { + mclex_want_line = FALSE; + while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n') + ++input_stream_pos; + if (input_stream_pos[0] == '\n') + ++input_stream_pos; + return MCENDLINE; + } + while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n') + ++input_stream_pos; + if (input_stream_pos[0] == '\n') + ++input_stream_pos; + yylval.ustr = get_diff (input_stream_pos, start_token); + return MCLINE; + } + while ((ch = input_stream_pos[0]) <= 0x20) + { + if (ch == 0) + return -1; + ++input_stream_pos; + if (ch == '\n') + input_line += 1; + if (mclex_want_nl && ch == '\n') + { + mclex_want_nl = FALSE; + return NL; + } + } + start_token = input_stream_pos; + ++input_stream_pos; + if (mclex_want_filename) + { + mclex_want_filename = FALSE; + if (ch == '"') + { + start_token++; + while ((ch = input_stream_pos[0]) != 0) + { + if (ch == '"') + break; + ++input_stream_pos; + } + yylval.ustr = get_diff (input_stream_pos, start_token); + if (ch == '"') + ++input_stream_pos; + } + else + { + while ((ch = input_stream_pos[0]) != 0) + { + if (ch <= 0x20 || ch == ')') + break; + ++input_stream_pos; + } + yylval.ustr = get_diff (input_stream_pos, start_token); + } + return MCFILENAME; + } + switch (ch) + { + case ';': + ++start_token; + while (input_stream_pos[0] != '\n' && input_stream_pos[0] != 0) + ++input_stream_pos; + if (input_stream_pos[0] == '\n') + input_stream_pos++; + yylval.ustr = get_diff (input_stream_pos, start_token); + return MCCOMMENT; + case '=': + return '='; + case '(': + return '('; + case ')': + return ')'; + case '+': + return '+'; + case ':': + return ':'; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + yylval.ival = parse_digit (ch); + return MCNUMBER; + default: + if (ch >= 0x40) + { + int ret; + while (input_stream_pos[0] >= 0x40 || (input_stream_pos[0] >= '0' && input_stream_pos[0] <= '9')) + ++input_stream_pos; + ret = mc_token (start_token, (size_t) (input_stream_pos - start_token)); + if (ret != -1) + return ret; + yylval.ustr = get_diff (input_stream_pos, start_token); + return MCIDENT; + } + yyerror ("illegal character 0x%x.", ch); + } + return -1; +} diff --git a/support/sdbinutils/binutils/mcparse.c b/support/sdbinutils/binutils/mcparse.c new file mode 100644 index 0000000..05697bd --- /dev/null +++ b/support/sdbinutils/binutils/mcparse.c @@ -0,0 +1,2095 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "3.0.4" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* Copy the first part of user declarations. */ +#line 1 "mcparse.y" /* yacc.c:339 */ + /* mcparse.y -- parser for Windows mc files + Copyright (C) 2007-2018 Free Software Foundation, Inc. + + Parser for Windows mc files + Written by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* This is a parser for Windows rc files. It is based on the parser + by Gunther Ebert . */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" +#include "libiberty.h" +#include "windmc.h" +#include "safe-ctype.h" + +static rc_uint_type mc_last_id = 0; +static rc_uint_type mc_sefa_val = 0; +static unichar *mc_last_symbol = NULL; +static const mc_keyword *mc_cur_severity = NULL; +static const mc_keyword *mc_cur_facility = NULL; +static mc_node *cur_node = NULL; + + +#line 108 "mcparse.c" /* yacc.c:339 */ + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* In a future release of Bison, this section will be replaced + by #include "y.tab.h". */ +#ifndef YY_YY_MCPARSE_H_INCLUDED +# define YY_YY_MCPARSE_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + NL = 258, + MCIDENT = 259, + MCFILENAME = 260, + MCLINE = 261, + MCCOMMENT = 262, + MCTOKEN = 263, + MCENDLINE = 264, + MCLANGUAGENAMES = 265, + MCFACILITYNAMES = 266, + MCSEVERITYNAMES = 267, + MCOUTPUTBASE = 268, + MCMESSAGEIDTYPEDEF = 269, + MCLANGUAGE = 270, + MCMESSAGEID = 271, + MCSEVERITY = 272, + MCFACILITY = 273, + MCSYMBOLICNAME = 274, + MCNUMBER = 275 + }; +#endif +/* Tokens. */ +#define NL 258 +#define MCIDENT 259 +#define MCFILENAME 260 +#define MCLINE 261 +#define MCCOMMENT 262 +#define MCTOKEN 263 +#define MCENDLINE 264 +#define MCLANGUAGENAMES 265 +#define MCFACILITYNAMES 266 +#define MCSEVERITYNAMES 267 +#define MCOUTPUTBASE 268 +#define MCMESSAGEIDTYPEDEF 269 +#define MCLANGUAGE 270 +#define MCMESSAGEID 271 +#define MCSEVERITY 272 +#define MCFACILITY 273 +#define MCSYMBOLICNAME 274 +#define MCNUMBER 275 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 44 "mcparse.y" /* yacc.c:355 */ + + rc_uint_type ival; + unichar *ustr; + const mc_keyword *tok; + mc_node *nod; + +#line 195 "mcparse.c" /* yacc.c:355 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_MCPARSE_H_INCLUDED */ + +/* Copy the second part of user declarations. */ + +#line 212 "mcparse.c" /* yacc.c:358 */ + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 114 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 26 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 29 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 82 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 125 + +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 275 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 22, 23, 2, 25, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 24, 2, + 2, 21, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20 +}; + +#if YYDEBUG + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 66, 66, 69, 71, 73, 74, 75, 80, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 102, 106, 110, 117, 118, 119, 123, 127, + 128, 132, 133, 134, 138, 142, 143, 147, 148, 149, + 153, 157, 158, 159, 160, 165, 168, 172, 177, 176, + 189, 190, 191, 195, 198, 202, 206, 211, 218, 224, + 230, 238, 246, 254, 261, 262, 266, 276, 280, 292, + 293, 296, 297, 311, 315, 320, 325, 330, 337, 338, + 342, 346, 350 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || 0 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NL", "MCIDENT", "MCFILENAME", "MCLINE", + "MCCOMMENT", "MCTOKEN", "MCENDLINE", "MCLANGUAGENAMES", + "MCFACILITYNAMES", "MCSEVERITYNAMES", "MCOUTPUTBASE", + "MCMESSAGEIDTYPEDEF", "MCLANGUAGE", "MCMESSAGEID", "MCSEVERITY", + "MCFACILITY", "MCSYMBOLICNAME", "MCNUMBER", "'='", "'('", "')'", "':'", + "'+'", "$accept", "input", "entities", "entity", "global_section", + "severitymaps", "severitymap", "facilitymaps", "facilitymap", "langmaps", + "langmap", "alias_name", "message", "$@1", "id", "vid", "sefasy_def", + "severity", "facility", "symbol", "lang_entities", "lang_entity", + "lines", "comments", "lang", "token", "lex_want_nl", "lex_want_line", + "lex_want_filename", YY_NULLPTR +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 61, 40, 41, 58, 43 +}; +# endif + +#define YYPACT_NINF -34 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-34))) + +#define YYTABLE_NINF -83 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int8 yypact[] = +{ + -34, 62, 70, -34, -34, -34, 15, 22, 30, -15, + 34, 37, -34, -34, -34, -34, 56, -34, 10, -34, + 12, -34, 20, 25, -34, 52, -34, 0, 80, -34, + -34, 71, -34, 84, -34, 86, -34, -34, -34, -34, + -34, 45, -34, 1, 68, 74, 76, -34, -34, -34, + -34, -34, -34, 4, -34, 38, -34, 6, -34, 39, + -34, 29, -34, 40, -34, -34, 93, 94, 99, 43, + 76, -34, -34, -34, -34, -34, -34, 46, -34, -34, + -34, -34, 47, -34, -34, -34, -34, 49, -34, -34, + -34, -34, 83, -34, 3, -34, 2, -34, 81, -34, + 81, 92, -34, -34, 48, -34, 82, 72, -34, -34, + -34, 104, 105, 108, -34, -34, -34, 73, -34, -34, + -34, -34, -34, -34, -34 +}; + + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 3, 0, 0, 1, 8, 71, 0, 0, 0, 0, + 0, 0, 4, 5, 6, 57, 7, 16, 0, 20, + 0, 12, 0, 0, 24, 0, 52, 0, 48, 72, + 15, 0, 19, 0, 11, 0, 21, 23, 22, 51, + 54, 0, 50, 0, 0, 0, 0, 58, 59, 60, + 39, 78, 79, 0, 37, 0, 33, 0, 31, 0, + 27, 0, 25, 0, 56, 55, 0, 0, 0, 0, + 49, 64, 81, 14, 13, 38, 44, 0, 18, 17, + 32, 36, 0, 10, 9, 26, 30, 0, 61, 62, + 63, 77, 0, 65, 0, 43, 0, 35, 45, 29, + 45, 0, 69, 67, 0, 42, 0, 0, 34, 28, + 76, 78, 79, 0, 70, 68, 66, 0, 47, 46, + 74, 73, 75, 41, 40 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -34, -34, -34, -34, -34, -34, 50, -34, 53, -34, + 59, 13, -34, -34, -34, -34, -34, -34, -34, -34, + -34, 44, -34, -34, -34, -33, -34, -34, -34 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 1, 2, 12, 13, 61, 62, 57, 58, 53, + 54, 108, 14, 46, 15, 42, 28, 47, 48, 49, + 70, 71, 104, 16, 72, 55, 92, 94, 106 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int8 yytable[] = +{ + 59, 39, 63, 105, 102, 73, 23, 78, 51, 103, + 51, 30, 52, 32, 52, -53, 17, -53, -53, -53, + 40, 34, 66, 19, 59, 41, -82, 74, 63, 79, + 83, 21, 31, 51, 33, 24, 18, 52, 26, 76, + 81, 86, 35, 20, 91, 36, 64, 95, 97, 114, + 99, 22, 84, 37, 115, 25, 38, 116, 27, 77, + 82, 87, 3, 29, -80, 65, 96, 98, 113, 100, + -2, 4, 50, 118, 123, 51, 119, 5, 124, 52, + 6, 7, 8, 9, 10, 56, 11, 60, 51, 67, + 51, 69, 52, 110, 52, 68, 111, 43, 44, 45, + 112, 88, 89, 90, 101, 107, 117, 120, 121, 122, + 80, 85, 75, 109, 93 +}; + +static const yytype_uint8 yycheck[] = +{ + 33, 1, 35, 1, 1, 1, 21, 1, 4, 6, + 4, 1, 8, 1, 8, 15, 1, 17, 18, 19, + 20, 1, 21, 1, 57, 25, 24, 23, 61, 23, + 1, 1, 22, 4, 22, 1, 21, 8, 1, 1, + 1, 1, 22, 21, 1, 20, 1, 1, 1, 1, + 1, 21, 23, 1, 6, 21, 4, 9, 21, 21, + 21, 21, 0, 7, 21, 20, 20, 20, 101, 20, + 0, 1, 1, 1, 1, 4, 4, 7, 5, 8, + 10, 11, 12, 13, 14, 1, 16, 1, 4, 21, + 4, 15, 8, 1, 8, 21, 4, 17, 18, 19, + 8, 8, 8, 4, 21, 24, 24, 3, 3, 1, + 57, 61, 53, 100, 70 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 27, 28, 0, 1, 7, 10, 11, 12, 13, + 14, 16, 29, 30, 38, 40, 49, 1, 21, 1, + 21, 1, 21, 21, 1, 21, 1, 21, 42, 7, + 1, 22, 1, 22, 1, 22, 20, 1, 4, 1, + 20, 25, 41, 17, 18, 19, 39, 43, 44, 45, + 1, 4, 8, 35, 36, 51, 1, 33, 34, 51, + 1, 31, 32, 51, 1, 20, 21, 21, 21, 15, + 46, 47, 50, 1, 23, 36, 1, 21, 1, 23, + 34, 1, 21, 1, 23, 32, 1, 21, 8, 8, + 4, 1, 52, 47, 53, 1, 20, 1, 20, 1, + 20, 21, 1, 6, 48, 1, 54, 24, 37, 37, + 1, 4, 8, 51, 1, 6, 9, 24, 1, 4, + 3, 3, 1, 1, 5 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 26, 27, 28, 28, 29, 29, 29, 29, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 31, 31, 31, 32, 32, + 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, + 36, 36, 36, 36, 36, 37, 37, 37, 39, 38, + 40, 40, 40, 41, 41, 41, 41, 42, 42, 42, + 42, 43, 44, 45, 46, 46, 47, 48, 48, 48, + 48, 49, 49, 50, 50, 50, 50, 50, 51, 51, + 52, 53, 54 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 2, 1, 1, 1, 1, 5, + 5, 3, 2, 5, 5, 3, 2, 5, 5, 3, + 2, 3, 3, 3, 2, 1, 2, 1, 4, 3, + 2, 1, 2, 1, 4, 3, 2, 1, 2, 1, + 6, 6, 4, 3, 2, 0, 2, 2, 0, 4, + 3, 3, 2, 0, 1, 2, 2, 0, 2, 2, + 2, 3, 3, 3, 1, 2, 4, 1, 2, 1, + 2, 1, 2, 5, 5, 5, 4, 2, 1, 1, + 0, 0, 0 +}; + + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +{ + unsigned long int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +yystrlen (const char *yystr) +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +yystpcpy (char *yydest, const char *yysrc) +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +{ + YYUSE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 7: +#line 76 "mcparse.y" /* yacc.c:1646 */ + { + cur_node = mc_add_node (); + cur_node->user_text = (yyvsp[0].ustr); + } +#line 1379 "mcparse.c" /* yacc.c:1646 */ + break; + + case 8: +#line 80 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("syntax error"); } +#line 1385 "mcparse.c" /* yacc.c:1646 */ + break; + + case 10: +#line 85 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing ')' in SeverityNames"); } +#line 1391 "mcparse.c" /* yacc.c:1646 */ + break; + + case 11: +#line 86 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing '(' in SeverityNames"); } +#line 1397 "mcparse.c" /* yacc.c:1646 */ + break; + + case 12: +#line 87 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing '=' for SeverityNames"); } +#line 1403 "mcparse.c" /* yacc.c:1646 */ + break; + + case 14: +#line 89 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing ')' in LanguageNames"); } +#line 1409 "mcparse.c" /* yacc.c:1646 */ + break; + + case 15: +#line 90 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing '(' in LanguageNames"); } +#line 1415 "mcparse.c" /* yacc.c:1646 */ + break; + + case 16: +#line 91 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing '=' for LanguageNames"); } +#line 1421 "mcparse.c" /* yacc.c:1646 */ + break; + + case 18: +#line 93 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing ')' in FacilityNames"); } +#line 1427 "mcparse.c" /* yacc.c:1646 */ + break; + + case 19: +#line 94 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing '(' in FacilityNames"); } +#line 1433 "mcparse.c" /* yacc.c:1646 */ + break; + + case 20: +#line 95 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing '=' for FacilityNames"); } +#line 1439 "mcparse.c" /* yacc.c:1646 */ + break; + + case 21: +#line 97 "mcparse.y" /* yacc.c:1646 */ + { + if ((yyvsp[0].ival) != 10 && (yyvsp[0].ival) != 16) + mc_fatal ("OutputBase allows 10 or 16 as value"); + mcset_out_values_are_decimal = ((yyvsp[0].ival) == 10 ? 1 : 0); + } +#line 1449 "mcparse.c" /* yacc.c:1646 */ + break; + + case 22: +#line 103 "mcparse.y" /* yacc.c:1646 */ + { + mcset_msg_id_typedef = (yyvsp[0].ustr); + } +#line 1457 "mcparse.c" /* yacc.c:1646 */ + break; + + case 23: +#line 107 "mcparse.y" /* yacc.c:1646 */ + { + mc_fatal ("MessageIdTypedef expects an identifier"); + } +#line 1465 "mcparse.c" /* yacc.c:1646 */ + break; + + case 24: +#line 111 "mcparse.y" /* yacc.c:1646 */ + { + mc_fatal ("missing '=' for MessageIdTypedef"); + } +#line 1473 "mcparse.c" /* yacc.c:1646 */ + break; + + case 27: +#line 119 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("severity ident missing"); } +#line 1479 "mcparse.c" /* yacc.c:1646 */ + break; + + case 28: +#line 124 "mcparse.y" /* yacc.c:1646 */ + { + mc_add_keyword ((yyvsp[-3].ustr), MCTOKEN, "severity", (yyvsp[-1].ival), (yyvsp[0].ustr)); + } +#line 1487 "mcparse.c" /* yacc.c:1646 */ + break; + + case 29: +#line 127 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("severity number missing"); } +#line 1493 "mcparse.c" /* yacc.c:1646 */ + break; + + case 30: +#line 128 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("severity missing '='"); } +#line 1499 "mcparse.c" /* yacc.c:1646 */ + break; + + case 33: +#line 134 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing ident in FacilityNames"); } +#line 1505 "mcparse.c" /* yacc.c:1646 */ + break; + + case 34: +#line 139 "mcparse.y" /* yacc.c:1646 */ + { + mc_add_keyword ((yyvsp[-3].ustr), MCTOKEN, "facility", (yyvsp[-1].ival), (yyvsp[0].ustr)); + } +#line 1513 "mcparse.c" /* yacc.c:1646 */ + break; + + case 35: +#line 142 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("facility number missing"); } +#line 1519 "mcparse.c" /* yacc.c:1646 */ + break; + + case 36: +#line 143 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("facility missing '='"); } +#line 1525 "mcparse.c" /* yacc.c:1646 */ + break; + + case 39: +#line 149 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing ident in LanguageNames"); } +#line 1531 "mcparse.c" /* yacc.c:1646 */ + break; + + case 40: +#line 154 "mcparse.y" /* yacc.c:1646 */ + { + mc_add_keyword ((yyvsp[-5].ustr), MCTOKEN, "language", (yyvsp[-3].ival), (yyvsp[0].ustr)); + } +#line 1539 "mcparse.c" /* yacc.c:1646 */ + break; + + case 41: +#line 157 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing filename in LanguageNames"); } +#line 1545 "mcparse.c" /* yacc.c:1646 */ + break; + + case 42: +#line 158 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing ':' in LanguageNames"); } +#line 1551 "mcparse.c" /* yacc.c:1646 */ + break; + + case 43: +#line 159 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing language code in LanguageNames"); } +#line 1557 "mcparse.c" /* yacc.c:1646 */ + break; + + case 44: +#line 160 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing '=' for LanguageNames"); } +#line 1563 "mcparse.c" /* yacc.c:1646 */ + break; + + case 45: +#line 165 "mcparse.y" /* yacc.c:1646 */ + { + (yyval.ustr) = NULL; + } +#line 1571 "mcparse.c" /* yacc.c:1646 */ + break; + + case 46: +#line 169 "mcparse.y" /* yacc.c:1646 */ + { + (yyval.ustr) = (yyvsp[0].ustr); + } +#line 1579 "mcparse.c" /* yacc.c:1646 */ + break; + + case 47: +#line 172 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("illegal token in identifier"); (yyval.ustr) = NULL; } +#line 1585 "mcparse.c" /* yacc.c:1646 */ + break; + + case 48: +#line 177 "mcparse.y" /* yacc.c:1646 */ + { + cur_node = mc_add_node (); + cur_node->symbol = mc_last_symbol; + cur_node->facility = mc_cur_facility; + cur_node->severity = mc_cur_severity; + cur_node->id = ((yyvsp[-1].ival) & 0xffffUL); + cur_node->vid = ((yyvsp[-1].ival) & 0xffffUL) | mc_sefa_val; + mc_last_id = (yyvsp[-1].ival); + } +#line 1599 "mcparse.c" /* yacc.c:1646 */ + break; + + case 50: +#line 189 "mcparse.y" /* yacc.c:1646 */ + { (yyval.ival) = (yyvsp[0].ival); } +#line 1605 "mcparse.c" /* yacc.c:1646 */ + break; + + case 51: +#line 190 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing number in MessageId"); (yyval.ival) = 0; } +#line 1611 "mcparse.c" /* yacc.c:1646 */ + break; + + case 52: +#line 191 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing '=' for MessageId"); (yyval.ival) = 0; } +#line 1617 "mcparse.c" /* yacc.c:1646 */ + break; + + case 53: +#line 195 "mcparse.y" /* yacc.c:1646 */ + { + (yyval.ival) = ++mc_last_id; + } +#line 1625 "mcparse.c" /* yacc.c:1646 */ + break; + + case 54: +#line 199 "mcparse.y" /* yacc.c:1646 */ + { + (yyval.ival) = (yyvsp[0].ival); + } +#line 1633 "mcparse.c" /* yacc.c:1646 */ + break; + + case 55: +#line 203 "mcparse.y" /* yacc.c:1646 */ + { + (yyval.ival) = mc_last_id + (yyvsp[0].ival); + } +#line 1641 "mcparse.c" /* yacc.c:1646 */ + break; + + case 56: +#line 206 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing number after MessageId '+'"); } +#line 1647 "mcparse.c" /* yacc.c:1646 */ + break; + + case 57: +#line 211 "mcparse.y" /* yacc.c:1646 */ + { + (yyval.ival) = 0; + mc_sefa_val = (mcset_custom_bit ? 1 : 0) << 29; + mc_last_symbol = NULL; + mc_cur_severity = NULL; + mc_cur_facility = NULL; + } +#line 1659 "mcparse.c" /* yacc.c:1646 */ + break; + + case 58: +#line 219 "mcparse.y" /* yacc.c:1646 */ + { + if ((yyvsp[-1].ival) & 1) + mc_warn (_("duplicate definition of Severity")); + (yyval.ival) = (yyvsp[-1].ival) | 1; + } +#line 1669 "mcparse.c" /* yacc.c:1646 */ + break; + + case 59: +#line 225 "mcparse.y" /* yacc.c:1646 */ + { + if ((yyvsp[-1].ival) & 2) + mc_warn (_("duplicate definition of Facility")); + (yyval.ival) = (yyvsp[-1].ival) | 2; + } +#line 1679 "mcparse.c" /* yacc.c:1646 */ + break; + + case 60: +#line 231 "mcparse.y" /* yacc.c:1646 */ + { + if ((yyvsp[-1].ival) & 4) + mc_warn (_("duplicate definition of SymbolicName")); + (yyval.ival) = (yyvsp[-1].ival) | 4; + } +#line 1689 "mcparse.c" /* yacc.c:1646 */ + break; + + case 61: +#line 239 "mcparse.y" /* yacc.c:1646 */ + { + mc_sefa_val &= ~ (0x3UL << 30); + mc_sefa_val |= (((yyvsp[0].tok)->nval & 0x3UL) << 30); + mc_cur_severity = (yyvsp[0].tok); + } +#line 1699 "mcparse.c" /* yacc.c:1646 */ + break; + + case 62: +#line 247 "mcparse.y" /* yacc.c:1646 */ + { + mc_sefa_val &= ~ (0xfffUL << 16); + mc_sefa_val |= (((yyvsp[0].tok)->nval & 0xfffUL) << 16); + mc_cur_facility = (yyvsp[0].tok); + } +#line 1709 "mcparse.c" /* yacc.c:1646 */ + break; + + case 63: +#line 255 "mcparse.y" /* yacc.c:1646 */ + { + mc_last_symbol = (yyvsp[0].ustr); + } +#line 1717 "mcparse.c" /* yacc.c:1646 */ + break; + + case 66: +#line 267 "mcparse.y" /* yacc.c:1646 */ + { + mc_node_lang *h; + h = mc_add_node_lang (cur_node, (yyvsp[-3].tok), cur_node->vid); + h->message = (yyvsp[-1].ustr); + if (mcset_max_message_length != 0 && unichar_len (h->message) > mcset_max_message_length) + mc_warn ("message length to long"); + } +#line 1729 "mcparse.c" /* yacc.c:1646 */ + break; + + case 67: +#line 277 "mcparse.y" /* yacc.c:1646 */ + { + (yyval.ustr) = (yyvsp[0].ustr); + } +#line 1737 "mcparse.c" /* yacc.c:1646 */ + break; + + case 68: +#line 281 "mcparse.y" /* yacc.c:1646 */ + { + unichar *h; + rc_uint_type l1,l2; + l1 = unichar_len ((yyvsp[-1].ustr)); + l2 = unichar_len ((yyvsp[0].ustr)); + h = (unichar *) res_alloc ((l1 + l2 + 1) * sizeof (unichar)); + if (l1) memcpy (h, (yyvsp[-1].ustr), l1 * sizeof (unichar)); + if (l2) memcpy (&h[l1], (yyvsp[0].ustr), l2 * sizeof (unichar)); + h[l1 + l2] = 0; + (yyval.ustr) = h; + } +#line 1753 "mcparse.c" /* yacc.c:1646 */ + break; + + case 69: +#line 292 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing end of message text"); (yyval.ustr) = NULL; } +#line 1759 "mcparse.c" /* yacc.c:1646 */ + break; + + case 70: +#line 293 "mcparse.y" /* yacc.c:1646 */ + { mc_fatal ("missing end of message text"); (yyval.ustr) = (yyvsp[-1].ustr); } +#line 1765 "mcparse.c" /* yacc.c:1646 */ + break; + + case 71: +#line 296 "mcparse.y" /* yacc.c:1646 */ + { (yyval.ustr) = (yyvsp[0].ustr); } +#line 1771 "mcparse.c" /* yacc.c:1646 */ + break; + + case 72: +#line 298 "mcparse.y" /* yacc.c:1646 */ + { + unichar *h; + rc_uint_type l1,l2; + l1 = unichar_len ((yyvsp[-1].ustr)); + l2 = unichar_len ((yyvsp[0].ustr)); + h = (unichar *) res_alloc ((l1 + l2 + 1) * sizeof (unichar)); + if (l1) memcpy (h, (yyvsp[-1].ustr), l1 * sizeof (unichar)); + if (l2) memcpy (&h[l1], (yyvsp[0].ustr), l2 * sizeof (unichar)); + h[l1 + l2] = 0; + (yyval.ustr) = h; + } +#line 1787 "mcparse.c" /* yacc.c:1646 */ + break; + + case 73: +#line 312 "mcparse.y" /* yacc.c:1646 */ + { + (yyval.tok) = (yyvsp[-1].tok); + } +#line 1795 "mcparse.c" /* yacc.c:1646 */ + break; + + case 74: +#line 316 "mcparse.y" /* yacc.c:1646 */ + { + (yyval.tok) = NULL; + mc_fatal (_("undeclared language identifier")); + } +#line 1804 "mcparse.c" /* yacc.c:1646 */ + break; + + case 75: +#line 321 "mcparse.y" /* yacc.c:1646 */ + { + (yyval.tok) = NULL; + mc_fatal ("missing newline after Language"); + } +#line 1813 "mcparse.c" /* yacc.c:1646 */ + break; + + case 76: +#line 326 "mcparse.y" /* yacc.c:1646 */ + { + (yyval.tok) = NULL; + mc_fatal ("missing ident for Language"); + } +#line 1822 "mcparse.c" /* yacc.c:1646 */ + break; + + case 77: +#line 331 "mcparse.y" /* yacc.c:1646 */ + { + (yyval.tok) = NULL; + mc_fatal ("missing '=' for Language"); + } +#line 1831 "mcparse.c" /* yacc.c:1646 */ + break; + + case 78: +#line 337 "mcparse.y" /* yacc.c:1646 */ + { (yyval.ustr) = (yyvsp[0].ustr); } +#line 1837 "mcparse.c" /* yacc.c:1646 */ + break; + + case 79: +#line 338 "mcparse.y" /* yacc.c:1646 */ + { (yyval.ustr) = (yyvsp[0].tok)->usz; } +#line 1843 "mcparse.c" /* yacc.c:1646 */ + break; + + case 80: +#line 342 "mcparse.y" /* yacc.c:1646 */ + { mclex_want_nl = 1; } +#line 1849 "mcparse.c" /* yacc.c:1646 */ + break; + + case 81: +#line 346 "mcparse.y" /* yacc.c:1646 */ + { mclex_want_line = 1; } +#line 1855 "mcparse.c" /* yacc.c:1646 */ + break; + + case 82: +#line 350 "mcparse.y" /* yacc.c:1646 */ + { mclex_want_filename = 1; } +#line 1861 "mcparse.c" /* yacc.c:1646 */ + break; + + +#line 1865 "mcparse.c" /* yacc.c:1646 */ + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} +#line 353 "mcparse.y" /* yacc.c:1906 */ + + +/* Something else. */ diff --git a/support/sdbinutils/binutils/mcparse.h b/support/sdbinutils/binutils/mcparse.h new file mode 100644 index 0000000..14174f7 --- /dev/null +++ b/support/sdbinutils/binutils/mcparse.h @@ -0,0 +1,113 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef YY_YY_MCPARSE_H_INCLUDED +# define YY_YY_MCPARSE_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + NL = 258, + MCIDENT = 259, + MCFILENAME = 260, + MCLINE = 261, + MCCOMMENT = 262, + MCTOKEN = 263, + MCENDLINE = 264, + MCLANGUAGENAMES = 265, + MCFACILITYNAMES = 266, + MCSEVERITYNAMES = 267, + MCOUTPUTBASE = 268, + MCMESSAGEIDTYPEDEF = 269, + MCLANGUAGE = 270, + MCMESSAGEID = 271, + MCSEVERITY = 272, + MCFACILITY = 273, + MCSYMBOLICNAME = 274, + MCNUMBER = 275 + }; +#endif +/* Tokens. */ +#define NL 258 +#define MCIDENT 259 +#define MCFILENAME 260 +#define MCLINE 261 +#define MCCOMMENT 262 +#define MCTOKEN 263 +#define MCENDLINE 264 +#define MCLANGUAGENAMES 265 +#define MCFACILITYNAMES 266 +#define MCSEVERITYNAMES 267 +#define MCOUTPUTBASE 268 +#define MCMESSAGEIDTYPEDEF 269 +#define MCLANGUAGE 270 +#define MCMESSAGEID 271 +#define MCSEVERITY 272 +#define MCFACILITY 273 +#define MCSYMBOLICNAME 274 +#define MCNUMBER 275 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 44 "mcparse.y" /* yacc.c:1909 */ + + rc_uint_type ival; + unichar *ustr; + const mc_keyword *tok; + mc_node *nod; + +#line 101 "mcparse.h" /* yacc.c:1909 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_MCPARSE_H_INCLUDED */ diff --git a/support/sdbinutils/binutils/mcparse.y b/support/sdbinutils/binutils/mcparse.y new file mode 100644 index 0000000..62955fc --- /dev/null +++ b/support/sdbinutils/binutils/mcparse.y @@ -0,0 +1,355 @@ +%{ /* mcparse.y -- parser for Windows mc files + Copyright (C) 2007-2018 Free Software Foundation, Inc. + + Parser for Windows mc files + Written by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* This is a parser for Windows rc files. It is based on the parser + by Gunther Ebert . */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" +#include "libiberty.h" +#include "windmc.h" +#include "safe-ctype.h" + +static rc_uint_type mc_last_id = 0; +static rc_uint_type mc_sefa_val = 0; +static unichar *mc_last_symbol = NULL; +static const mc_keyword *mc_cur_severity = NULL; +static const mc_keyword *mc_cur_facility = NULL; +static mc_node *cur_node = NULL; + +%} + +%union +{ + rc_uint_type ival; + unichar *ustr; + const mc_keyword *tok; + mc_node *nod; +}; + +%start input + +%token NL +%token MCIDENT MCFILENAME MCLINE MCCOMMENT +%token MCTOKEN +%token MCENDLINE +%token MCLANGUAGENAMES MCFACILITYNAMES MCSEVERITYNAMES MCOUTPUTBASE MCMESSAGEIDTYPEDEF +%token MCLANGUAGE MCMESSAGEID MCSEVERITY MCFACILITY MCSYMBOLICNAME +%token MCNUMBER + +%type id vid sefasy_def +%type alias_name token lines comments +%type lang + +%% +input: entities + ; + +entities: + /* empty */ + | entities entity + ; +entity: global_section + | message + | comments + { + cur_node = mc_add_node (); + cur_node->user_text = $1; + } + | error { mc_fatal ("syntax error"); } +; + +global_section: + MCSEVERITYNAMES '=' '(' severitymaps ')' + | MCSEVERITYNAMES '=' '(' severitymaps error { mc_fatal ("missing ')' in SeverityNames"); } + | MCSEVERITYNAMES '=' error { mc_fatal ("missing '(' in SeverityNames"); } + | MCSEVERITYNAMES error { mc_fatal ("missing '=' for SeverityNames"); } + | MCLANGUAGENAMES '=' '(' langmaps ')' + | MCLANGUAGENAMES '=' '(' langmaps error { mc_fatal ("missing ')' in LanguageNames"); } + | MCLANGUAGENAMES '=' error { mc_fatal ("missing '(' in LanguageNames"); } + | MCLANGUAGENAMES error { mc_fatal ("missing '=' for LanguageNames"); } + | MCFACILITYNAMES '=' '(' facilitymaps ')' + | MCFACILITYNAMES '=' '(' facilitymaps error { mc_fatal ("missing ')' in FacilityNames"); } + | MCFACILITYNAMES '=' error { mc_fatal ("missing '(' in FacilityNames"); } + | MCFACILITYNAMES error { mc_fatal ("missing '=' for FacilityNames"); } + | MCOUTPUTBASE '=' MCNUMBER + { + if ($3 != 10 && $3 != 16) + mc_fatal ("OutputBase allows 10 or 16 as value"); + mcset_out_values_are_decimal = ($3 == 10 ? 1 : 0); + } + | MCMESSAGEIDTYPEDEF '=' MCIDENT + { + mcset_msg_id_typedef = $3; + } + | MCMESSAGEIDTYPEDEF '=' error + { + mc_fatal ("MessageIdTypedef expects an identifier"); + } + | MCMESSAGEIDTYPEDEF error + { + mc_fatal ("missing '=' for MessageIdTypedef"); + } +; + +severitymaps: + severitymap + | severitymaps severitymap + | error { mc_fatal ("severity ident missing"); } +; + +severitymap: + token '=' MCNUMBER alias_name + { + mc_add_keyword ($1, MCTOKEN, "severity", $3, $4); + } + | token '=' error { mc_fatal ("severity number missing"); } + | token error { mc_fatal ("severity missing '='"); } +; + +facilitymaps: + facilitymap + | facilitymaps facilitymap + | error { mc_fatal ("missing ident in FacilityNames"); } +; + +facilitymap: + token '=' MCNUMBER alias_name + { + mc_add_keyword ($1, MCTOKEN, "facility", $3, $4); + } + | token '=' error { mc_fatal ("facility number missing"); } + | token error { mc_fatal ("facility missing '='"); } +; + +langmaps: + langmap + | langmaps langmap + | error { mc_fatal ("missing ident in LanguageNames"); } +; + +langmap: + token '=' MCNUMBER lex_want_filename ':' MCFILENAME + { + mc_add_keyword ($1, MCTOKEN, "language", $3, $6); + } + | token '=' MCNUMBER lex_want_filename ':' error { mc_fatal ("missing filename in LanguageNames"); } + | token '=' MCNUMBER error { mc_fatal ("missing ':' in LanguageNames"); } + | token '=' error { mc_fatal ("missing language code in LanguageNames"); } + | token error { mc_fatal ("missing '=' for LanguageNames"); } +; + +alias_name: + /* empty */ + { + $$ = NULL; + } + | ':' MCIDENT + { + $$ = $2; + } + | ':' error { mc_fatal ("illegal token in identifier"); $$ = NULL; } +; + +message: + id sefasy_def + { + cur_node = mc_add_node (); + cur_node->symbol = mc_last_symbol; + cur_node->facility = mc_cur_facility; + cur_node->severity = mc_cur_severity; + cur_node->id = ($1 & 0xffffUL); + cur_node->vid = ($1 & 0xffffUL) | mc_sefa_val; + mc_last_id = $1; + } + lang_entities +; + +id: MCMESSAGEID '=' vid { $$ = $3; } + | MCMESSAGEID '=' error { mc_fatal ("missing number in MessageId"); $$ = 0; } + | MCMESSAGEID error { mc_fatal ("missing '=' for MessageId"); $$ = 0; } +; + +vid: /* empty */ + { + $$ = ++mc_last_id; + } + | MCNUMBER + { + $$ = $1; + } + | '+' MCNUMBER + { + $$ = mc_last_id + $2; + } + | '+' error { mc_fatal ("missing number after MessageId '+'"); } +; + +sefasy_def: + /* empty */ + { + $$ = 0; + mc_sefa_val = (mcset_custom_bit ? 1 : 0) << 29; + mc_last_symbol = NULL; + mc_cur_severity = NULL; + mc_cur_facility = NULL; + } + | sefasy_def severity + { + if ($1 & 1) + mc_warn (_("duplicate definition of Severity")); + $$ = $1 | 1; + } + | sefasy_def facility + { + if ($1 & 2) + mc_warn (_("duplicate definition of Facility")); + $$ = $1 | 2; + } + | sefasy_def symbol + { + if ($1 & 4) + mc_warn (_("duplicate definition of SymbolicName")); + $$ = $1 | 4; + } +; + +severity: MCSEVERITY '=' MCTOKEN + { + mc_sefa_val &= ~ (0x3UL << 30); + mc_sefa_val |= (($3->nval & 0x3UL) << 30); + mc_cur_severity = $3; + } +; + +facility: MCFACILITY '=' MCTOKEN + { + mc_sefa_val &= ~ (0xfffUL << 16); + mc_sefa_val |= (($3->nval & 0xfffUL) << 16); + mc_cur_facility = $3; + } +; + +symbol: MCSYMBOLICNAME '=' MCIDENT + { + mc_last_symbol = $3; + } +; + +lang_entities: + lang_entity + | lang_entities lang_entity +; + +lang_entity: + lang lex_want_line lines MCENDLINE + { + mc_node_lang *h; + h = mc_add_node_lang (cur_node, $1, cur_node->vid); + h->message = $3; + if (mcset_max_message_length != 0 && unichar_len (h->message) > mcset_max_message_length) + mc_warn ("message length to long"); + } +; + +lines: MCLINE + { + $$ = $1; + } + | lines MCLINE + { + unichar *h; + rc_uint_type l1,l2; + l1 = unichar_len ($1); + l2 = unichar_len ($2); + h = (unichar *) res_alloc ((l1 + l2 + 1) * sizeof (unichar)); + if (l1) memcpy (h, $1, l1 * sizeof (unichar)); + if (l2) memcpy (&h[l1], $2, l2 * sizeof (unichar)); + h[l1 + l2] = 0; + $$ = h; + } + | error { mc_fatal ("missing end of message text"); $$ = NULL; } + | lines error { mc_fatal ("missing end of message text"); $$ = $1; } +; + +comments: MCCOMMENT { $$ = $1; } + | comments MCCOMMENT + { + unichar *h; + rc_uint_type l1,l2; + l1 = unichar_len ($1); + l2 = unichar_len ($2); + h = (unichar *) res_alloc ((l1 + l2 + 1) * sizeof (unichar)); + if (l1) memcpy (h, $1, l1 * sizeof (unichar)); + if (l2) memcpy (&h[l1], $2, l2 * sizeof (unichar)); + h[l1 + l2] = 0; + $$ = h; + } +; + +lang: MCLANGUAGE lex_want_nl '=' MCTOKEN NL + { + $$ = $4; + } + | MCLANGUAGE lex_want_nl '=' MCIDENT NL + { + $$ = NULL; + mc_fatal (_("undeclared language identifier")); + } + | MCLANGUAGE lex_want_nl '=' token error + { + $$ = NULL; + mc_fatal ("missing newline after Language"); + } + | MCLANGUAGE lex_want_nl '=' error + { + $$ = NULL; + mc_fatal ("missing ident for Language"); + } + | MCLANGUAGE error + { + $$ = NULL; + mc_fatal ("missing '=' for Language"); + } +; + +token: MCIDENT { $$ = $1; } + | MCTOKEN { $$ = $1->usz; } +; + +lex_want_nl: + /* Empty */ { mclex_want_nl = 1; } +; + +lex_want_line: + /* Empty */ { mclex_want_line = 1; } +; + +lex_want_filename: + /* Empty */ { mclex_want_filename = 1; } +; + +%% + +/* Something else. */ diff --git a/support/sdbinutils/binutils/nlmconv.c b/support/sdbinutils/binutils/nlmconv.c new file mode 100644 index 0000000..68941f8 --- /dev/null +++ b/support/sdbinutils/binutils/nlmconv.c @@ -0,0 +1,2166 @@ +/* nlmconv.c -- NLM conversion program + Copyright (C) 1993-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + + +/* Written by Ian Lance Taylor . + + This program can be used to convert any appropriate object file + into a NetWare Loadable Module (an NLM). It will accept a linker + specification file which is identical to that accepted by the + NetWare linker, NLMLINK. */ + +/* AIX requires this to be the first thing in the file. */ +#ifndef __GNUC__ +# ifdef _AIX + #pragma alloca +#endif +#endif + +#include "sysdep.h" +#include "bfd.h" +#include "libiberty.h" +#include "filenames.h" +#include "safe-ctype.h" + +#include "ansidecl.h" +#include +#include +#include "getopt.h" + +/* Internal BFD NLM header. */ +#include "libnlm.h" +#include "nlmconv.h" + +#ifdef NLMCONV_ALPHA +#include "coff/sym.h" +#include "coff/ecoff.h" +#endif + +#include "bucomm.h" + +/* If strerror is just a macro, we want to use the one from libiberty + since it will handle undefined values. */ +#undef strerror +extern char *strerror (int); + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +#ifndef R_OK +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 +#endif + +/* Global variables. */ + +/* The name used to invoke the program. */ +char *program_name; + +/* Local variables. */ + +/* Whether to print out debugging information (currently just controls + whether it prints the linker command if there is one). */ +static int debug; + +/* The symbol table. */ +static asymbol **symbols; + +/* A section we create in the output file to hold pointers to where + the sections of the input file end up. We will put a pointer to + this section in the NLM header. These is an entry for each input + section. The format is + null terminated section name + zeroes to adjust to 4 byte boundary + 4 byte section data file pointer + 4 byte section size + We don't need a version number. The way we find this information + is by finding a stamp in the NLM header information. If we need to + change the format of this information, we can simply change the + stamp. */ +static asection *secsec; + +/* A temporary file name to be unlinked on exit. Actually, for most + errors, we leave it around. It's not clear whether that is helpful + or not. */ +static char *unlink_on_exit; + +/* The list of long options. */ +static struct option long_options[] = +{ + { "debug", no_argument, 0, 'd' }, + { "header-file", required_argument, 0, 'T' }, + { "help", no_argument, 0, 'h' }, + { "input-target", required_argument, 0, 'I' }, + { "input-format", required_argument, 0, 'I' }, /* Obsolete */ + { "linker", required_argument, 0, 'l' }, + { "output-target", required_argument, 0, 'O' }, + { "output-format", required_argument, 0, 'O' }, /* Obsolete */ + { "version", no_argument, 0, 'V' }, + { NULL, no_argument, 0, 0 } +}; + +/* Local routines. */ + +int main (int, char **); + +static void show_usage (FILE *, int); +static const char *select_output_format + (enum bfd_architecture, unsigned long, bfd_boolean); +static void setup_sections (bfd *, asection *, void *); +static void copy_sections (bfd *, asection *, void *); +static void mangle_relocs + (bfd *, asection *, arelent ***, long *, char *, bfd_size_type); +static void default_mangle_relocs + (bfd *, asection *, arelent ***, long *, char *, bfd_size_type); +static char *link_inputs (struct string_list *, char *, char *); + +#ifdef NLMCONV_I386 +static void i386_mangle_relocs (bfd *, asection *, arelent ***, long *, char *, bfd_size_type); +#endif + +#ifdef NLMCONV_ALPHA +static void alpha_mangle_relocs (bfd *, asection *, arelent ***, long *, char *, bfd_size_type); +#endif + +#ifdef NLMCONV_POWERPC +static void powerpc_build_stubs (bfd *, bfd *, asymbol ***, long *); +static void powerpc_resolve_stubs (bfd *, bfd *); +static void powerpc_mangle_relocs (bfd *, asection *, arelent ***, long *, char *, bfd_size_type); +#endif + +/* The main routine. */ + +int +main (int argc, char **argv) +{ + int opt; + char *input_file = NULL; + const char *input_format = NULL; + const char *output_format = NULL; + const char *header_file = NULL; + char *ld_arg = NULL; + Nlm_Internal_Fixed_Header fixed_hdr_struct; + Nlm_Internal_Variable_Header var_hdr_struct; + Nlm_Internal_Version_Header version_hdr_struct; + Nlm_Internal_Copyright_Header copyright_hdr_struct; + Nlm_Internal_Extended_Header extended_hdr_struct; + bfd *inbfd; + bfd *outbfd; + asymbol **newsyms, **outsyms; + long symcount, newsymalloc, newsymcount; + long symsize; + asection *text_sec, *bss_sec, *data_sec; + bfd_vma vma; + bfd_size_type align; + asymbol *endsym; + long i; + char inlead, outlead; + bfd_boolean gotstart, gotexit, gotcheck; + struct stat st; + FILE *custom_data = NULL; + FILE *help_data = NULL; + FILE *message_data = NULL; + FILE *rpc_data = NULL; + FILE *shared_data = NULL; + size_t custom_size = 0; + size_t help_size = 0; + size_t message_size = 0; + size_t module_size = 0; + size_t rpc_size = 0; + asection *custom_section = NULL; + asection *help_section = NULL; + asection *message_section = NULL; + asection *module_section = NULL; + asection *rpc_section = NULL; + asection *shared_section = NULL; + bfd *sharedbfd; + size_t shared_offset = 0; + size_t shared_size = 0; + static Nlm_Internal_Fixed_Header sharedhdr; + int len; + char *modname; + char **matching; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + program_name = argv[0]; + xmalloc_set_program_name (program_name); + bfd_set_error_program_name (program_name); + + expandargv (&argc, &argv); + + bfd_init (); + set_default_bfd_target (); + + while ((opt = getopt_long (argc, argv, "dHhI:l:O:T:Vv", long_options, + (int *) NULL)) + != EOF) + { + switch (opt) + { + case 'd': + debug = 1; + break; + case 'H': + case 'h': + show_usage (stdout, 0); + break; + case 'I': + input_format = optarg; + break; + case 'l': + ld_arg = optarg; + break; + case 'O': + output_format = optarg; + break; + case 'T': + header_file = optarg; + break; + case 'v': + case 'V': + print_version ("nlmconv"); + break; + case 0: + break; + default: + show_usage (stderr, 1); + break; + } + } + + /* The input and output files may be named on the command line. */ + output_file = NULL; + if (optind < argc) + { + input_file = argv[optind]; + ++optind; + if (optind < argc) + { + output_file = argv[optind]; + ++optind; + if (optind < argc) + show_usage (stderr, 1); + if (filename_cmp (input_file, output_file) == 0) + { + fatal (_("input and output files must be different")); + } + } + } + + /* Initialize the header information to default values. */ + fixed_hdr = &fixed_hdr_struct; + memset ((void *) &fixed_hdr_struct, 0, sizeof fixed_hdr_struct); + var_hdr = &var_hdr_struct; + memset ((void *) &var_hdr_struct, 0, sizeof var_hdr_struct); + version_hdr = &version_hdr_struct; + memset ((void *) &version_hdr_struct, 0, sizeof version_hdr_struct); + copyright_hdr = ©right_hdr_struct; + memset ((void *) ©right_hdr_struct, 0, sizeof copyright_hdr_struct); + extended_hdr = &extended_hdr_struct; + memset ((void *) &extended_hdr_struct, 0, sizeof extended_hdr_struct); + check_procedure = NULL; + custom_file = NULL; + debug_info = FALSE; + exit_procedure = "_Stop"; + export_symbols = NULL; + map_file = NULL; + full_map = FALSE; + help_file = NULL; + import_symbols = NULL; + message_file = NULL; + modules = NULL; + sharelib_file = NULL; + start_procedure = "_Prelude"; + verbose = FALSE; + rpc_file = NULL; + + parse_errors = 0; + + /* Parse the header file (if there is one). */ + if (header_file != NULL) + { + if (! nlmlex_file (header_file) + || yyparse () != 0 + || parse_errors != 0) + exit (1); + } + + if (input_files != NULL) + { + if (input_file != NULL) + { + fatal (_("input file named both on command line and with INPUT")); + } + if (input_files->next == NULL) + input_file = input_files->string; + else + input_file = link_inputs (input_files, ld_arg, map_file); + } + else if (input_file == NULL) + { + non_fatal (_("no input file")); + show_usage (stderr, 1); + } + + inbfd = bfd_openr (input_file, input_format); + if (inbfd == NULL) + bfd_fatal (input_file); + + if (! bfd_check_format_matches (inbfd, bfd_object, &matching)) + { + bfd_nonfatal (input_file); + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (matching); + free (matching); + } + exit (1); + } + + if (output_format == NULL) + output_format = select_output_format (bfd_get_arch (inbfd), + bfd_get_mach (inbfd), + bfd_big_endian (inbfd)); + + assert (output_format != NULL); + + /* Use the output file named on the command line if it exists. + Otherwise use the file named in the OUTPUT statement. */ + if (output_file == NULL) + { + non_fatal (_("no name for output file")); + show_usage (stderr, 1); + } + + outbfd = bfd_openw (output_file, output_format); + if (outbfd == NULL) + bfd_fatal (output_file); + if (! bfd_set_format (outbfd, bfd_object)) + bfd_fatal (output_file); + + assert (bfd_get_flavour (outbfd) == bfd_target_nlm_flavour); + + /* XXX: Should we accept the unknown bfd format here ? */ + if (bfd_arch_get_compatible (inbfd, outbfd, TRUE) == NULL) + non_fatal (_("warning: input and output formats are not compatible")); + + /* Move the values read from the command file into outbfd. */ + *nlm_fixed_header (outbfd) = fixed_hdr_struct; + *nlm_variable_header (outbfd) = var_hdr_struct; + *nlm_version_header (outbfd) = version_hdr_struct; + *nlm_copyright_header (outbfd) = copyright_hdr_struct; + *nlm_extended_header (outbfd) = extended_hdr_struct; + + /* Start copying the input BFD to the output BFD. */ + if (! bfd_set_file_flags (outbfd, bfd_get_file_flags (inbfd))) + bfd_fatal (bfd_get_filename (outbfd)); + + symsize = bfd_get_symtab_upper_bound (inbfd); + if (symsize < 0) + bfd_fatal (input_file); + symbols = (asymbol **) xmalloc (symsize); + symcount = bfd_canonicalize_symtab (inbfd, symbols); + if (symcount < 0) + bfd_fatal (input_file); + + /* Make sure we have a .bss section. */ + bss_sec = bfd_get_section_by_name (outbfd, NLM_UNINITIALIZED_DATA_NAME); + if (bss_sec == NULL) + { + bss_sec = bfd_make_section_with_flags (outbfd, + NLM_UNINITIALIZED_DATA_NAME, + SEC_ALLOC); + if (bss_sec == NULL + || ! bfd_set_section_alignment (outbfd, bss_sec, 1)) + bfd_fatal (_("make .bss section")); + } + + /* We store the original section names in the .nlmsections section, + so that programs which understand it can resurrect the original + sections from the NLM. We will put a pointer to .nlmsections in + the NLM header area. */ + secsec = bfd_make_section_with_flags (outbfd, ".nlmsections", + SEC_HAS_CONTENTS); + if (secsec == NULL) + bfd_fatal (_("make .nlmsections section")); + +#ifdef NLMCONV_POWERPC + /* For PowerPC NetWare we need to build stubs for calls to undefined + symbols. Because each stub requires an entry in the TOC section + which must be at the same location as other entries in the TOC + section, we must do this before determining where the TOC section + goes in setup_sections. */ + if (bfd_get_arch (inbfd) == bfd_arch_powerpc) + powerpc_build_stubs (inbfd, outbfd, &symbols, &symcount); +#endif + + /* Set up the sections. */ + bfd_map_over_sections (inbfd, setup_sections, (void *) outbfd); + + text_sec = bfd_get_section_by_name (outbfd, NLM_CODE_NAME); + + /* The .bss section immediately follows the .data section. */ + data_sec = bfd_get_section_by_name (outbfd, NLM_INITIALIZED_DATA_NAME); + if (data_sec != NULL) + { + bfd_size_type add; + + vma = bfd_get_section_size (data_sec); + align = 1 << bss_sec->alignment_power; + add = ((vma + align - 1) &~ (align - 1)) - vma; + vma += add; + if (! bfd_set_section_vma (outbfd, bss_sec, vma)) + bfd_fatal (_("set .bss vma")); + if (add != 0) + { + bfd_size_type data_size; + + data_size = bfd_get_section_size (data_sec); + if (! bfd_set_section_size (outbfd, data_sec, data_size + add)) + bfd_fatal (_("set .data size")); + } + } + + /* Adjust symbol information. */ + inlead = bfd_get_symbol_leading_char (inbfd); + outlead = bfd_get_symbol_leading_char (outbfd); + gotstart = FALSE; + gotexit = FALSE; + gotcheck = FALSE; + newsymalloc = 10; + newsyms = (asymbol **) xmalloc (newsymalloc * sizeof (asymbol *)); + newsymcount = 0; + endsym = NULL; + for (i = 0; i < symcount; i++) + { + asymbol *sym; + + sym = symbols[i]; + + /* Add or remove a leading underscore. */ + if (inlead != outlead) + { + if (inlead != '\0') + { + if (bfd_asymbol_name (sym)[0] == inlead) + { + if (outlead == '\0') + ++sym->name; + else + { + char *new_name; + + new_name = xmalloc (strlen (bfd_asymbol_name (sym)) + 1); + new_name[0] = outlead; + strcpy (new_name + 1, bfd_asymbol_name (sym) + 1); + sym->name = new_name; + } + } + } + else + { + char *new_name; + + new_name = xmalloc (strlen (bfd_asymbol_name (sym)) + 2); + new_name[0] = outlead; + strcpy (new_name + 1, bfd_asymbol_name (sym)); + sym->name = new_name; + } + } + + /* NLM's have an uninitialized data section, but they do not + have a common section in the Unix sense. Move all common + symbols into the .bss section, and mark them as exported. */ + if (bfd_is_com_section (bfd_get_section (sym))) + { + bfd_vma size = sym->value; + + sym->section = bss_sec; + sym->value = bfd_get_section_size (bss_sec); + size += sym->value; + align = 1 << bss_sec->alignment_power; + size = (size + align - 1) & ~(align - 1); + bfd_set_section_size (outbfd, bss_sec, size); + sym->flags |= BSF_EXPORT | BSF_GLOBAL; + } + else if (bfd_get_section (sym)->output_section != NULL) + { + /* Move the symbol into the output section. */ + sym->value += bfd_get_section (sym)->output_offset; + sym->section = bfd_get_section (sym)->output_section; + /* This is no longer a section symbol. */ + sym->flags &=~ BSF_SECTION_SYM; + } + + /* Force _edata and _end to be defined. This would normally be + done by the linker, but the manipulation of the common + symbols will confuse it. */ + if ((sym->flags & BSF_DEBUGGING) == 0 + && bfd_asymbol_name (sym)[0] == '_' + && bfd_is_und_section (bfd_get_section (sym))) + { + if (strcmp (bfd_asymbol_name (sym), "_edata") == 0) + { + sym->section = bss_sec; + sym->value = 0; + } + if (strcmp (bfd_asymbol_name (sym), "_end") == 0) + { + sym->section = bss_sec; + endsym = sym; + } + +#ifdef NLMCONV_POWERPC + /* For PowerPC NetWare, we define __GOT0. This is the start + of the .got section. */ + if (bfd_get_arch (inbfd) == bfd_arch_powerpc + && strcmp (bfd_asymbol_name (sym), "__GOT0") == 0) + { + asection *got_sec; + + got_sec = bfd_get_section_by_name (inbfd, ".got"); + assert (got_sec != (asection *) NULL); + sym->value = got_sec->output_offset; + sym->section = got_sec->output_section; + } +#endif + } + + /* If this is a global symbol, check the export list. */ + if ((sym->flags & (BSF_EXPORT | BSF_GLOBAL)) != 0) + { + struct string_list *l; + int found_simple; + + /* Unfortunately, a symbol can appear multiple times on the + export list, with and without prefixes. */ + found_simple = 0; + for (l = export_symbols; l != NULL; l = l->next) + { + if (strcmp (l->string, bfd_asymbol_name (sym)) == 0) + found_simple = 1; + else + { + char *zbase; + + zbase = strchr (l->string, '@'); + if (zbase != NULL + && strcmp (zbase + 1, bfd_asymbol_name (sym)) == 0) + { + /* We must add a symbol with this prefix. */ + if (newsymcount >= newsymalloc) + { + newsymalloc += 10; + newsyms = ((asymbol **) + xrealloc ((void *) newsyms, + (newsymalloc + * sizeof (asymbol *)))); + } + newsyms[newsymcount] = + (asymbol *) xmalloc (sizeof (asymbol)); + *newsyms[newsymcount] = *sym; + newsyms[newsymcount]->name = l->string; + ++newsymcount; + } + } + } + if (! found_simple) + { + /* The unmodified symbol is actually not exported at + all. */ + sym->flags &=~ (BSF_GLOBAL | BSF_EXPORT); + sym->flags |= BSF_LOCAL; + } + } + + /* If it's an undefined symbol, see if it's on the import list. + Change the prefix if necessary. */ + if (bfd_is_und_section (bfd_get_section (sym))) + { + struct string_list *l; + + for (l = import_symbols; l != NULL; l = l->next) + { + if (strcmp (l->string, bfd_asymbol_name (sym)) == 0) + break; + else + { + char *zbase; + + zbase = strchr (l->string, '@'); + if (zbase != NULL + && strcmp (zbase + 1, bfd_asymbol_name (sym)) == 0) + { + sym->name = l->string; + break; + } + } + } + if (l == NULL) + non_fatal (_("warning: symbol %s imported but not in import list"), + bfd_asymbol_name (sym)); + } + + /* See if it's one of the special named symbols. */ + if ((sym->flags & BSF_DEBUGGING) == 0) + { + bfd_vma val; + + /* FIXME: If these symbols are not in the .text section, we + add the .text section size to the value. This may not be + correct for all targets. I'm not sure how this should + really be handled. */ + if (strcmp (bfd_asymbol_name (sym), start_procedure) == 0) + { + val = bfd_asymbol_value (sym); + if (bfd_get_section (sym) == data_sec + && text_sec != (asection *) NULL) + val += bfd_section_size (outbfd, text_sec); + if (! bfd_set_start_address (outbfd, val)) + bfd_fatal (_("set start address")); + gotstart = TRUE; + } + if (strcmp (bfd_asymbol_name (sym), exit_procedure) == 0) + { + val = bfd_asymbol_value (sym); + if (bfd_get_section (sym) == data_sec + && text_sec != (asection *) NULL) + val += bfd_section_size (outbfd, text_sec); + nlm_fixed_header (outbfd)->exitProcedureOffset = val; + gotexit = TRUE; + } + if (check_procedure != NULL + && strcmp (bfd_asymbol_name (sym), check_procedure) == 0) + { + val = bfd_asymbol_value (sym); + if (bfd_get_section (sym) == data_sec + && text_sec != (asection *) NULL) + val += bfd_section_size (outbfd, text_sec); + nlm_fixed_header (outbfd)->checkUnloadProcedureOffset = val; + gotcheck = TRUE; + } + } + } + + if (endsym != NULL) + { + endsym->value = bfd_get_section_size (bss_sec); + + /* FIXME: If any relocs referring to _end use inplace addends, + then I think they need to be updated. This is handled by + i386_mangle_relocs. Is it needed for any other object + formats? */ + } + + if (newsymcount == 0) + outsyms = symbols; + else + { + outsyms = (asymbol **) xmalloc ((symcount + newsymcount + 1) + * sizeof (asymbol *)); + memcpy (outsyms, symbols, symcount * sizeof (asymbol *)); + memcpy (outsyms + symcount, newsyms, newsymcount * sizeof (asymbol *)); + outsyms[symcount + newsymcount] = NULL; + } + + bfd_set_symtab (outbfd, outsyms, symcount + newsymcount); + + if (! gotstart) + non_fatal (_("warning: START procedure %s not defined"), start_procedure); + if (! gotexit) + non_fatal (_("warning: EXIT procedure %s not defined"), exit_procedure); + if (check_procedure != NULL && ! gotcheck) + non_fatal (_("warning: CHECK procedure %s not defined"), check_procedure); + + /* Add additional sections required for the header information. */ + if (custom_file != NULL) + { + custom_data = fopen (custom_file, "r"); + if (custom_data == NULL + || fstat (fileno (custom_data), &st) < 0) + { + fprintf (stderr, "%s:%s: %s\n", program_name, custom_file, + strerror (errno)); + custom_file = NULL; + } + else + { + custom_size = st.st_size; + custom_section = bfd_make_section_with_flags (outbfd, ".nlmcustom", + SEC_HAS_CONTENTS); + if (custom_section == NULL + || ! bfd_set_section_size (outbfd, custom_section, custom_size)) + bfd_fatal (_("custom section")); + } + } + if (help_file != NULL) + { + help_data = fopen (help_file, "r"); + if (help_data == NULL + || fstat (fileno (help_data), &st) < 0) + { + fprintf (stderr, "%s:%s: %s\n", program_name, help_file, + strerror (errno)); + help_file = NULL; + } + else + { + help_size = st.st_size; + help_section = bfd_make_section_with_flags (outbfd, ".nlmhelp", + SEC_HAS_CONTENTS); + if (help_section == NULL + || ! bfd_set_section_size (outbfd, help_section, help_size)) + bfd_fatal (_("help section")); + LITMEMCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs"); + } + } + if (message_file != NULL) + { + message_data = fopen (message_file, "r"); + if (message_data == NULL + || fstat (fileno (message_data), &st) < 0) + { + fprintf (stderr, "%s:%s: %s\n", program_name, message_file, + strerror (errno)); + message_file = NULL; + } + else + { + message_size = st.st_size; + message_section = bfd_make_section_with_flags (outbfd, + ".nlmmessages", + SEC_HAS_CONTENTS); + if (message_section == NULL + || ! bfd_set_section_size (outbfd, message_section, message_size)) + bfd_fatal (_("message section")); + LITMEMCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs"); + } + } + if (modules != NULL) + { + struct string_list *l; + + module_size = 0; + for (l = modules; l != NULL; l = l->next) + module_size += strlen (l->string) + 1; + module_section = bfd_make_section_with_flags (outbfd, ".nlmmodules", + SEC_HAS_CONTENTS); + if (module_section == NULL + || ! bfd_set_section_size (outbfd, module_section, module_size)) + bfd_fatal (_("module section")); + } + if (rpc_file != NULL) + { + rpc_data = fopen (rpc_file, "r"); + if (rpc_data == NULL + || fstat (fileno (rpc_data), &st) < 0) + { + fprintf (stderr, "%s:%s: %s\n", program_name, rpc_file, + strerror (errno)); + rpc_file = NULL; + } + else + { + rpc_size = st.st_size; + rpc_section = bfd_make_section_with_flags (outbfd, ".nlmrpc", + SEC_HAS_CONTENTS); + if (rpc_section == NULL + || ! bfd_set_section_size (outbfd, rpc_section, rpc_size)) + bfd_fatal (_("rpc section")); + LITMEMCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs"); + } + } + if (sharelib_file != NULL) + { + sharedbfd = bfd_openr (sharelib_file, output_format); + if (sharedbfd == NULL + || ! bfd_check_format (sharedbfd, bfd_object)) + { + fprintf (stderr, "%s:%s: %s\n", program_name, sharelib_file, + bfd_errmsg (bfd_get_error ())); + sharelib_file = NULL; + } + else + { + sharedhdr = *nlm_fixed_header (sharedbfd); + bfd_close (sharedbfd); + shared_data = fopen (sharelib_file, "r"); + if (shared_data == NULL + || (fstat (fileno (shared_data), &st) < 0)) + { + fprintf (stderr, "%s:%s: %s\n", program_name, sharelib_file, + strerror (errno)); + sharelib_file = NULL; + } + else + { + /* If we were clever, we could just copy out the + sections of the shared library which we actually + need. However, we would have to figure out the sizes + of the external and public information, and that can + not be done without reading through them. */ + if (sharedhdr.uninitializedDataSize > 0) + { + /* There is no place to record this information. */ + non_fatal (_("%s: warning: shared libraries can not have uninitialized data"), + sharelib_file); + } + shared_offset = st.st_size; + if (shared_offset > (size_t) sharedhdr.codeImageOffset) + shared_offset = sharedhdr.codeImageOffset; + if (shared_offset > (size_t) sharedhdr.dataImageOffset) + shared_offset = sharedhdr.dataImageOffset; + if (shared_offset > (size_t) sharedhdr.relocationFixupOffset) + shared_offset = sharedhdr.relocationFixupOffset; + if (shared_offset > (size_t) sharedhdr.externalReferencesOffset) + shared_offset = sharedhdr.externalReferencesOffset; + if (shared_offset > (size_t) sharedhdr.publicsOffset) + shared_offset = sharedhdr.publicsOffset; + shared_size = st.st_size - shared_offset; + shared_section = bfd_make_section_with_flags (outbfd, + ".nlmshared", + SEC_HAS_CONTENTS); + if (shared_section == NULL + || ! bfd_set_section_size (outbfd, shared_section, + shared_size)) + bfd_fatal (_("shared section")); + LITMEMCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs"); + } + } + } + + /* Check whether a version was given. */ + if (!CONST_STRNEQ (version_hdr->stamp, "VeRsIoN#")) + non_fatal (_("warning: No version number given")); + + /* At least for now, always create an extended header, because that + is what NLMLINK does. */ + LITMEMCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs"); + + LITMEMCPY (nlm_cygnus_ext_header (outbfd)->stamp, "CyGnUsEx"); + + /* If the date was not given, force it in. */ + if (nlm_version_header (outbfd)->month == 0 + && nlm_version_header (outbfd)->day == 0 + && nlm_version_header (outbfd)->year == 0) + { + time_t now; + struct tm *ptm; + + time (&now); + ptm = localtime (&now); + nlm_version_header (outbfd)->month = ptm->tm_mon + 1; + nlm_version_header (outbfd)->day = ptm->tm_mday; + nlm_version_header (outbfd)->year = ptm->tm_year + 1900; + LITMEMCPY (version_hdr->stamp, "VeRsIoN#"); + } + +#ifdef NLMCONV_POWERPC + /* Resolve the stubs we build for PowerPC NetWare. */ + if (bfd_get_arch (inbfd) == bfd_arch_powerpc) + powerpc_resolve_stubs (inbfd, outbfd); +#endif + + /* Copy over the sections. */ + bfd_map_over_sections (inbfd, copy_sections, (void *) outbfd); + + /* Finish up the header information. */ + if (custom_file != NULL) + { + void *data; + + data = xmalloc (custom_size); + if (fread (data, 1, custom_size, custom_data) != custom_size) + non_fatal (_("%s: read: %s"), custom_file, strerror (errno)); + else + { + if (! bfd_set_section_contents (outbfd, custom_section, data, + (file_ptr) 0, custom_size)) + bfd_fatal (_("custom section")); + nlm_fixed_header (outbfd)->customDataOffset = + custom_section->filepos; + nlm_fixed_header (outbfd)->customDataSize = custom_size; + } + free (data); + } + if (! debug_info) + { + /* As a special hack, the backend recognizes a debugInfoOffset + of -1 to mean that it should not output any debugging + information. This can not be handling by fiddling with the + symbol table because exported symbols appear in both the + export information and the debugging information. */ + nlm_fixed_header (outbfd)->debugInfoOffset = (file_ptr) -1; + } + if (full_map) + non_fatal (_("warning: FULLMAP is not supported; try ld -M")); + if (help_file != NULL) + { + void *data; + + data = xmalloc (help_size); + if (fread (data, 1, help_size, help_data) != help_size) + non_fatal (_("%s: read: %s"), help_file, strerror (errno)); + else + { + if (! bfd_set_section_contents (outbfd, help_section, data, + (file_ptr) 0, help_size)) + bfd_fatal (_("help section")); + nlm_extended_header (outbfd)->helpFileOffset = + help_section->filepos; + nlm_extended_header (outbfd)->helpFileLength = help_size; + } + free (data); + } + if (message_file != NULL) + { + void *data; + + data = xmalloc (message_size); + if (fread (data, 1, message_size, message_data) != message_size) + non_fatal (_("%s: read: %s"), message_file, strerror (errno)); + else + { + if (! bfd_set_section_contents (outbfd, message_section, data, + (file_ptr) 0, message_size)) + bfd_fatal (_("message section")); + nlm_extended_header (outbfd)->messageFileOffset = + message_section->filepos; + nlm_extended_header (outbfd)->messageFileLength = message_size; + + /* FIXME: Are these offsets correct on all platforms? Are + they 32 bits on all platforms? What endianness? */ + nlm_extended_header (outbfd)->languageID = + bfd_h_get_32 (outbfd, (bfd_byte *) data + 106); + nlm_extended_header (outbfd)->messageCount = + bfd_h_get_32 (outbfd, (bfd_byte *) data + 110); + } + free (data); + } + if (modules != NULL) + { + void *data; + unsigned char *set; + struct string_list *l; + bfd_size_type c; + + data = xmalloc (module_size); + c = 0; + set = (unsigned char *) data; + for (l = modules; l != NULL; l = l->next) + { + *set = strlen (l->string); + strncpy ((char *) set + 1, l->string, *set); + set += *set + 1; + ++c; + } + if (! bfd_set_section_contents (outbfd, module_section, data, + (file_ptr) 0, module_size)) + bfd_fatal (_("module section")); + nlm_fixed_header (outbfd)->moduleDependencyOffset = + module_section->filepos; + nlm_fixed_header (outbfd)->numberOfModuleDependencies = c; + } + if (rpc_file != NULL) + { + void *data; + + data = xmalloc (rpc_size); + if (fread (data, 1, rpc_size, rpc_data) != rpc_size) + non_fatal (_("%s: read: %s"), rpc_file, strerror (errno)); + else + { + if (! bfd_set_section_contents (outbfd, rpc_section, data, + (file_ptr) 0, rpc_size)) + bfd_fatal (_("rpc section")); + nlm_extended_header (outbfd)->RPCDataOffset = + rpc_section->filepos; + nlm_extended_header (outbfd)->RPCDataLength = rpc_size; + } + free (data); + } + if (sharelib_file != NULL) + { + void *data; + + data = xmalloc (shared_size); + if (fseek (shared_data, shared_offset, SEEK_SET) != 0 + || fread (data, 1, shared_size, shared_data) != shared_size) + non_fatal (_("%s: read: %s"), sharelib_file, strerror (errno)); + else + { + if (! bfd_set_section_contents (outbfd, shared_section, data, + (file_ptr) 0, shared_size)) + bfd_fatal (_("shared section")); + } + nlm_extended_header (outbfd)->sharedCodeOffset = + sharedhdr.codeImageOffset - shared_offset + shared_section->filepos; + nlm_extended_header (outbfd)->sharedCodeLength = + sharedhdr.codeImageSize; + nlm_extended_header (outbfd)->sharedDataOffset = + sharedhdr.dataImageOffset - shared_offset + shared_section->filepos; + nlm_extended_header (outbfd)->sharedDataLength = + sharedhdr.dataImageSize; + nlm_extended_header (outbfd)->sharedRelocationFixupOffset = + (sharedhdr.relocationFixupOffset + - shared_offset + + shared_section->filepos); + nlm_extended_header (outbfd)->sharedRelocationFixupCount = + sharedhdr.numberOfRelocationFixups; + nlm_extended_header (outbfd)->sharedExternalReferenceOffset = + (sharedhdr.externalReferencesOffset + - shared_offset + + shared_section->filepos); + nlm_extended_header (outbfd)->sharedExternalReferenceCount = + sharedhdr.numberOfExternalReferences; + nlm_extended_header (outbfd)->sharedPublicsOffset = + sharedhdr.publicsOffset - shared_offset + shared_section->filepos; + nlm_extended_header (outbfd)->sharedPublicsCount = + sharedhdr.numberOfPublics; + nlm_extended_header (outbfd)->sharedDebugRecordOffset = + sharedhdr.debugInfoOffset - shared_offset + shared_section->filepos; + nlm_extended_header (outbfd)->sharedDebugRecordCount = + sharedhdr.numberOfDebugRecords; + nlm_extended_header (outbfd)->SharedInitializationOffset = + sharedhdr.codeStartOffset; + nlm_extended_header (outbfd)->SharedExitProcedureOffset = + sharedhdr.exitProcedureOffset; + free (data); + } + + { + const int max_len = NLM_MODULE_NAME_SIZE - 2; + const char * filename = lbasename (output_file); + + len = strlen (filename); + if (len > max_len) + len = max_len; + nlm_fixed_header (outbfd)->moduleName[0] = len; + + strncpy (nlm_fixed_header (outbfd)->moduleName + 1, filename, max_len); + nlm_fixed_header (outbfd)->moduleName[max_len + 1] = '\0'; + + for (modname = nlm_fixed_header (outbfd)->moduleName; + *modname != '\0'; + modname++) + *modname = TOUPPER (*modname); + } + + strncpy (nlm_variable_header (outbfd)->oldThreadName, " LONG", + NLM_OLD_THREAD_NAME_LENGTH); + + nlm_cygnus_ext_header (outbfd)->offset = secsec->filepos; + nlm_cygnus_ext_header (outbfd)->length = bfd_section_size (outbfd, secsec); + + if (! bfd_close (outbfd)) + bfd_fatal (output_file); + if (! bfd_close (inbfd)) + bfd_fatal (input_file); + + if (unlink_on_exit != NULL) + unlink (unlink_on_exit); + + return 0; +} + + +/* Show a usage message and exit. */ + +static void +show_usage (FILE *file, int status) +{ + fprintf (file, _("Usage: %s [option(s)] [in-file [out-file]]\n"), program_name); + fprintf (file, _(" Convert an object file into a NetWare Loadable Module\n")); + fprintf (file, _(" The options are:\n\ + -I --input-target= Set the input binary file format\n\ + -O --output-target= Set the output binary file format\n\ + -T --header-file= Read for NLM header information\n\ + -l --linker= Use for any linking\n\ + -d --debug Display on stderr the linker command line\n\ + @ Read options from .\n\ + -h --help Display this information\n\ + -v --version Display the program's version\n\ +")); + if (REPORT_BUGS_TO[0] && status == 0) + fprintf (file, _("Report bugs to %s\n"), REPORT_BUGS_TO); + exit (status); +} + +/* Select the output format based on the input architecture, machine, + and endianness. This chooses the appropriate NLM target. */ + +static const char * +select_output_format (enum bfd_architecture arch, unsigned long mach, + bfd_boolean bigendian ATTRIBUTE_UNUSED) +{ + switch (arch) + { +#ifdef NLMCONV_I386 + case bfd_arch_i386: + return "nlm32-i386"; +#endif +#ifdef NLMCONV_SPARC + case bfd_arch_sparc: + return "nlm32-sparc"; +#endif +#ifdef NLMCONV_ALPHA + case bfd_arch_alpha: + return "nlm32-alpha"; +#endif +#ifdef NLMCONV_POWERPC + case bfd_arch_powerpc: + return "nlm32-powerpc"; +#endif + default: + fatal (_("support not compiled in for %s"), + bfd_printable_arch_mach (arch, mach)); + } + /*NOTREACHED*/ +} + +/* The BFD sections are copied in two passes. This function selects + the output section for each input section, and sets up the section + name, size, etc. */ + +static void +setup_sections (bfd *inbfd ATTRIBUTE_UNUSED, asection *insec, void *data_ptr) +{ + bfd *outbfd = (bfd *) data_ptr; + flagword f; + const char *outname; + asection *outsec; + bfd_vma offset; + bfd_size_type align; + bfd_size_type add; + bfd_size_type secsecsize; + + f = bfd_get_section_flags (inbfd, insec); + if (f & SEC_CODE) + outname = NLM_CODE_NAME; + else if ((f & SEC_LOAD) && (f & SEC_HAS_CONTENTS)) + outname = NLM_INITIALIZED_DATA_NAME; + else if (f & SEC_ALLOC) + outname = NLM_UNINITIALIZED_DATA_NAME; + else + outname = bfd_section_name (inbfd, insec); + + outsec = bfd_get_section_by_name (outbfd, outname); + if (outsec == NULL) + { + outsec = bfd_make_section (outbfd, outname); + if (outsec == NULL) + bfd_fatal (_("make section")); + } + + insec->output_section = outsec; + + offset = bfd_section_size (outbfd, outsec); + align = 1 << bfd_section_alignment (inbfd, insec); + add = ((offset + align - 1) &~ (align - 1)) - offset; + insec->output_offset = offset + add; + + if (! bfd_set_section_size (outbfd, outsec, + (bfd_section_size (outbfd, outsec) + + bfd_section_size (inbfd, insec) + + add))) + bfd_fatal (_("set section size")); + + if ((bfd_section_alignment (inbfd, insec) + > bfd_section_alignment (outbfd, outsec)) + && ! bfd_set_section_alignment (outbfd, outsec, + bfd_section_alignment (inbfd, insec))) + bfd_fatal (_("set section alignment")); + + if (! bfd_set_section_flags (outbfd, outsec, + f | bfd_get_section_flags (outbfd, outsec))) + bfd_fatal (_("set section flags")); + + bfd_set_reloc (outbfd, outsec, (arelent **) NULL, 0); + + /* For each input section we allocate space for an entry in + .nlmsections. */ + secsecsize = bfd_section_size (outbfd, secsec); + secsecsize += strlen (bfd_section_name (inbfd, insec)) + 1; + secsecsize = (secsecsize + 3) &~ 3; + secsecsize += 8; + if (! bfd_set_section_size (outbfd, secsec, secsecsize)) + bfd_fatal (_("set .nlmsections size")); +} + +/* Copy the section contents. */ + +static void +copy_sections (bfd *inbfd, asection *insec, void *data_ptr) +{ + static bfd_size_type secsecoff = 0; + bfd *outbfd = (bfd *) data_ptr; + const char *inname; + asection *outsec; + bfd_size_type size; + bfd_byte *contents; + long reloc_size; + bfd_byte buf[4]; + bfd_size_type add; + + inname = bfd_section_name (inbfd, insec); + + outsec = insec->output_section; + assert (outsec != NULL); + + size = bfd_get_section_size (insec); + + if ((bfd_get_section_flags (inbfd, insec) & SEC_HAS_CONTENTS) == 0) + contents = NULL; + else + { + if (!bfd_malloc_and_get_section (inbfd, insec, &contents)) + bfd_fatal (bfd_get_filename (inbfd)); + } + + reloc_size = bfd_get_reloc_upper_bound (inbfd, insec); + if (reloc_size < 0) + bfd_fatal (bfd_get_filename (inbfd)); + if (reloc_size != 0) + { + arelent **relocs; + long reloc_count; + + relocs = (arelent **) xmalloc (reloc_size); + reloc_count = bfd_canonicalize_reloc (inbfd, insec, relocs, symbols); + if (reloc_count < 0) + bfd_fatal (bfd_get_filename (inbfd)); + mangle_relocs (outbfd, insec, &relocs, &reloc_count, (char *) contents, + size); + + /* FIXME: refers to internal BFD fields. */ + if (outsec->orelocation != (arelent **) NULL) + { + bfd_size_type total_count; + arelent **combined; + + total_count = reloc_count + outsec->reloc_count; + combined = (arelent **) xmalloc (total_count * sizeof (arelent *)); + memcpy (combined, outsec->orelocation, + outsec->reloc_count * sizeof (arelent *)); + memcpy (combined + outsec->reloc_count, relocs, + (size_t) (reloc_count * sizeof (arelent *))); + free (outsec->orelocation); + reloc_count = total_count; + relocs = combined; + } + + bfd_set_reloc (outbfd, outsec, relocs, reloc_count); + } + + if (contents != NULL) + { + if (! bfd_set_section_contents (outbfd, outsec, contents, + insec->output_offset, size)) + bfd_fatal (bfd_get_filename (outbfd)); + free (contents); + } + + /* Add this section to .nlmsections. */ + if (! bfd_set_section_contents (outbfd, secsec, (void *) inname, secsecoff, + strlen (inname) + 1)) + bfd_fatal (_("set .nlmsection contents")); + secsecoff += strlen (inname) + 1; + + add = ((secsecoff + 3) &~ 3) - secsecoff; + if (add != 0) + { + bfd_h_put_32 (outbfd, (bfd_vma) 0, buf); + if (! bfd_set_section_contents (outbfd, secsec, buf, secsecoff, add)) + bfd_fatal (_("set .nlmsection contents")); + secsecoff += add; + } + + if (contents != NULL) + bfd_h_put_32 (outbfd, (bfd_vma) outsec->filepos, buf); + else + bfd_h_put_32 (outbfd, (bfd_vma) 0, buf); + if (! bfd_set_section_contents (outbfd, secsec, buf, secsecoff, 4)) + bfd_fatal (_("set .nlmsection contents")); + secsecoff += 4; + + bfd_h_put_32 (outbfd, (bfd_vma) size, buf); + if (! bfd_set_section_contents (outbfd, secsec, buf, secsecoff, 4)) + bfd_fatal (_("set .nlmsection contents")); + secsecoff += 4; +} + +/* Some, perhaps all, NetWare targets require changing the relocs used + by the input formats. */ + +static void +mangle_relocs (bfd *outbfd, asection *insec, arelent ***relocs_ptr, + long *reloc_count_ptr, char *contents, + bfd_size_type contents_size) +{ + switch (bfd_get_arch (outbfd)) + { +#ifdef NLMCONV_I386 + case bfd_arch_i386: + i386_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, + contents, contents_size); + break; +#endif +#ifdef NLMCONV_ALPHA + case bfd_arch_alpha: + alpha_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, + contents, contents_size); + break; +#endif +#ifdef NLMCONV_POWERPC + case bfd_arch_powerpc: + powerpc_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, + contents, contents_size); + break; +#endif + default: + default_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, + contents, contents_size); + break; + } +} + +/* By default all we need to do for relocs is change the address by + the output_offset. */ + +static void +default_mangle_relocs (bfd *outbfd ATTRIBUTE_UNUSED, asection *insec, + arelent ***relocs_ptr, long *reloc_count_ptr, + char *contents ATTRIBUTE_UNUSED, + bfd_size_type contents_size ATTRIBUTE_UNUSED) +{ + if (insec->output_offset != 0) + { + long reloc_count; + arelent **relocs; + long i; + + reloc_count = *reloc_count_ptr; + relocs = *relocs_ptr; + for (i = 0; i < reloc_count; i++, relocs++) + (*relocs)->address += insec->output_offset; + } +} + +#ifdef NLMCONV_I386 + +/* NetWare on the i386 supports a restricted set of relocs, which are + different from those used on other i386 targets. This routine + converts the relocs. It is, obviously, very target dependent. At + the moment, the nlm32-i386 backend performs similar translations; + however, it is more reliable and efficient to do them here. */ + +static reloc_howto_type nlm_i386_pcrel_howto = + HOWTO (1, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "DISP32", /* name */ + TRUE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + TRUE); /* pcrel_offset */ + +static void +i386_mangle_relocs (bfd *outbfd, asection *insec, arelent ***relocs_ptr, + long *reloc_count_ptr, char *contents, + bfd_size_type contents_size) +{ + long reloc_count, i; + arelent **relocs; + + reloc_count = *reloc_count_ptr; + relocs = *relocs_ptr; + for (i = 0; i < reloc_count; i++) + { + arelent *rel; + asymbol *sym; + bfd_size_type address; + bfd_vma addend; + + rel = *relocs++; + /* PR 17512: file: 057f89c1. */ + if (rel->sym_ptr_ptr == NULL) + continue; + sym = *rel->sym_ptr_ptr; + + /* We're moving the relocs from the input section to the output + section, so we must adjust the address accordingly. */ + address = rel->address; + rel->address += insec->output_offset; + + /* Note that no serious harm will ensue if we fail to change a + reloc. The backend will fail when writing out the reloc. */ + + /* Make sure this reloc is within the data we have. We use only + 4 byte relocs here, so we insist on having 4 bytes. */ + if (address + 4 > contents_size) + continue; + + /* A PC relative reloc entirely within a single section is + completely unnecessary. This can be generated by ld -r. */ + if (sym == insec->symbol + && rel->howto != NULL + && rel->howto->pc_relative + && ! rel->howto->pcrel_offset) + { + --*reloc_count_ptr; + --relocs; + memmove (relocs, relocs + 1, + (size_t) ((reloc_count - i) * sizeof (arelent *))); + continue; + } + + /* Get the amount the relocation will add in. */ + addend = rel->addend + sym->value; + + /* NetWare doesn't support PC relative relocs against defined + symbols, so we have to eliminate them by doing the relocation + now. We can only do this if the reloc is within a single + section. */ + if (rel->howto != NULL + && rel->howto->pc_relative + && bfd_get_section (sym) == insec->output_section) + { + bfd_vma val; + + if (rel->howto->pcrel_offset) + addend -= address; + + val = bfd_get_32 (outbfd, (bfd_byte *) contents + address); + val += addend; + bfd_put_32 (outbfd, val, (bfd_byte *) contents + address); + + --*reloc_count_ptr; + --relocs; + memmove (relocs, relocs + 1, + (size_t) ((reloc_count - i) * sizeof (arelent *))); + continue; + } + + /* NetWare doesn't support reloc addends, so we get rid of them + here by simply adding them into the object data. We handle + the symbol value, if any, the same way. */ + if (addend != 0 + && rel->howto != NULL + && rel->howto->rightshift == 0 + && rel->howto->size == 2 + && rel->howto->bitsize == 32 + && rel->howto->bitpos == 0 + && rel->howto->src_mask == 0xffffffff + && rel->howto->dst_mask == 0xffffffff) + { + bfd_vma val; + + val = bfd_get_32 (outbfd, (bfd_byte *) contents + address); + val += addend; + bfd_put_32 (outbfd, val, (bfd_byte *) contents + address); + + /* Adjust the reloc for the changes we just made. */ + rel->addend = 0; + if (! bfd_is_und_section (bfd_get_section (sym))) + rel->sym_ptr_ptr = bfd_get_section (sym)->symbol_ptr_ptr; + } + + /* NetWare uses a reloc with pcrel_offset set. We adjust + pc_relative relocs accordingly. We are going to change the + howto field, so we can only do this if the current one is + compatible. We should check that special_function is NULL + here, but at the moment coff-i386 uses a special_function + which does not affect what we are doing here. */ + if (rel->howto != NULL + && rel->howto->pc_relative + && ! rel->howto->pcrel_offset + && rel->howto->rightshift == 0 + && rel->howto->size == 2 + && rel->howto->bitsize == 32 + && rel->howto->bitpos == 0 + && rel->howto->src_mask == 0xffffffff + && rel->howto->dst_mask == 0xffffffff) + { + bfd_vma val; + + /* When pcrel_offset is not set, it means that the negative + of the address of the memory location is stored in the + memory location. We must add it back in. */ + val = bfd_get_32 (outbfd, (bfd_byte *) contents + address); + val += address; + bfd_put_32 (outbfd, val, (bfd_byte *) contents + address); + + /* We must change to a new howto. */ + rel->howto = &nlm_i386_pcrel_howto; + } + } +} + +#endif /* NLMCONV_I386 */ + +#ifdef NLMCONV_ALPHA + +/* On the Alpha the first reloc for every section must be a special + relocs which hold the GP address. Also, the first reloc in the + file must be a special reloc which holds the address of the .lita + section. */ + +static reloc_howto_type nlm32_alpha_nw_howto = + HOWTO (ALPHA_R_NW_RELOC, /* type */ + 0, /* rightshift */ + 0, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + 0, /* special_function */ + "NW_RELOC", /* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + FALSE); /* pcrel_offset */ + +static void +alpha_mangle_relocs (bfd *outbfd, asection *insec, + arelent ***relocs_ptr, long *reloc_count_ptr, + char *contents ATTRIBUTE_UNUSED, + bfd_size_type contents_size ATTRIBUTE_UNUSED) +{ + long old_reloc_count; + arelent **old_relocs; + arelent **relocs; + + old_reloc_count = *reloc_count_ptr; + old_relocs = *relocs_ptr; + relocs = (arelent **) xmalloc ((old_reloc_count + 3) * sizeof (arelent *)); + *relocs_ptr = relocs; + + if (nlm_alpha_backend_data (outbfd)->lita_address == 0) + { + bfd *inbfd; + asection *lita_section; + + inbfd = insec->owner; + lita_section = bfd_get_section_by_name (inbfd, _LITA); + if (lita_section != (asection *) NULL) + { + nlm_alpha_backend_data (outbfd)->lita_address = + bfd_get_section_vma (inbfd, lita_section); + nlm_alpha_backend_data (outbfd)->lita_size = + bfd_section_size (inbfd, lita_section); + } + else + { + /* Avoid outputting this reloc again. */ + nlm_alpha_backend_data (outbfd)->lita_address = 4; + } + + *relocs = (arelent *) xmalloc (sizeof (arelent)); + (*relocs)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; + (*relocs)->address = nlm_alpha_backend_data (outbfd)->lita_address; + (*relocs)->addend = nlm_alpha_backend_data (outbfd)->lita_size + 1; + (*relocs)->howto = &nlm32_alpha_nw_howto; + ++relocs; + ++(*reloc_count_ptr); + } + + /* Get the GP value from bfd. */ + if (nlm_alpha_backend_data (outbfd)->gp == 0) + nlm_alpha_backend_data (outbfd)->gp = + bfd_ecoff_get_gp_value (insec->owner); + + *relocs = (arelent *) xmalloc (sizeof (arelent)); + (*relocs)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; + (*relocs)->address = nlm_alpha_backend_data (outbfd)->gp; + (*relocs)->addend = 0; + (*relocs)->howto = &nlm32_alpha_nw_howto; + ++relocs; + ++(*reloc_count_ptr); + + memcpy (relocs, old_relocs, (size_t) old_reloc_count * sizeof (arelent *)); + relocs[old_reloc_count] = (arelent *) NULL; + + free (old_relocs); + + if (insec->output_offset != 0) + { + bfd_size_type i; + + for (i = 0; i < (bfd_size_type) old_reloc_count; i++, relocs++) + (*relocs)->address += insec->output_offset; + } +} + +#endif /* NLMCONV_ALPHA */ + +#ifdef NLMCONV_POWERPC + +/* We keep a linked list of stubs which we must build. Because BFD + requires us to know the sizes of all sections before we can set the + contents of any, we must figure out which stubs we want to build + before we can actually build any of them. */ + +struct powerpc_stub +{ + /* Next stub in linked list. */ + struct powerpc_stub *next; + + /* Symbol whose value is the start of the stub. This is a symbol + whose name begins with `.'. */ + asymbol *start; + + /* Symbol we are going to create a reloc against. This is a symbol + with the same name as START but without the leading `.'. */ + asymbol *reloc; + + /* The TOC index for this stub. This is the index into the TOC + section at which the reloc is created. */ + unsigned int toc_index; +}; + +/* The linked list of stubs. */ + +static struct powerpc_stub *powerpc_stubs; + +/* This is what a stub looks like. The first instruction will get + adjusted with the correct TOC index. */ + +static unsigned long powerpc_stub_insns[] = +{ + 0x81820000, /* lwz r12,0(r2) */ + 0x90410014, /* stw r2,20(r1) */ + 0x800c0000, /* lwz r0,0(r12) */ + 0x804c0004, /* lwz r2,r(r12) */ + 0x7c0903a6, /* mtctr r0 */ + 0x4e800420, /* bctr */ + 0, /* Traceback table. */ + 0xc8000, + 0 +}; + +#define POWERPC_STUB_INSN_COUNT \ + (sizeof powerpc_stub_insns / sizeof powerpc_stub_insns[0]) + +#define POWERPC_STUB_SIZE (4 * POWERPC_STUB_INSN_COUNT) + +/* Each stub uses a four byte TOC entry. */ +#define POWERPC_STUB_TOC_ENTRY_SIZE (4) + +/* The original size of the .got section. */ +static bfd_size_type powerpc_initial_got_size; + +/* Look for all undefined symbols beginning with `.', and prepare to + build a stub for each one. */ + +static void +powerpc_build_stubs (bfd *inbfd, bfd *outbfd ATTRIBUTE_UNUSED, + asymbol ***symbols_ptr, long *symcount_ptr) +{ + asection *stub_sec; + asection *got_sec; + unsigned int got_base; + long i; + long symcount; + long stubcount; + + /* Make a section to hold stubs. We don't set SEC_HAS_CONTENTS for + the section to prevent copy_sections from reading from it. */ + stub_sec = bfd_make_section_with_flags (inbfd, ".stubs", + (SEC_CODE + | SEC_RELOC + | SEC_ALLOC + | SEC_LOAD)); + if (stub_sec == (asection *) NULL + || ! bfd_set_section_alignment (inbfd, stub_sec, 2)) + bfd_fatal (".stubs"); + + /* Get the TOC section, which is named .got. */ + got_sec = bfd_get_section_by_name (inbfd, ".got"); + if (got_sec == (asection *) NULL) + { + got_sec = bfd_make_section_with_flags (inbfd, ".got", + (SEC_DATA + | SEC_RELOC + | SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS)); + if (got_sec == (asection *) NULL + || ! bfd_set_section_alignment (inbfd, got_sec, 2)) + bfd_fatal (".got"); + } + + powerpc_initial_got_size = bfd_section_size (inbfd, got_sec); + got_base = powerpc_initial_got_size; + got_base = (got_base + 3) &~ 3; + + stubcount = 0; + + symcount = *symcount_ptr; + for (i = 0; i < symcount; i++) + { + asymbol *sym; + asymbol *newsym; + char *newname; + struct powerpc_stub *item; + + sym = (*symbols_ptr)[i]; + + /* We must make a stub for every undefined symbol whose name + starts with '.'. */ + if (bfd_asymbol_name (sym)[0] != '.' + || ! bfd_is_und_section (bfd_get_section (sym))) + continue; + + /* Make a new undefined symbol with the same name but without + the leading `.'. */ + newsym = xmalloc (sizeof (asymbol)); + *newsym = *sym; + newname = xmalloc (strlen (bfd_asymbol_name (sym))); + strcpy (newname, bfd_asymbol_name (sym) + 1); + newsym->name = newname; + + /* Define the `.' symbol to be in the stub section. */ + sym->section = stub_sec; + sym->value = stubcount * POWERPC_STUB_SIZE; + /* We set the BSF_DYNAMIC flag here so that we can check it when + we are mangling relocs. FIXME: This is a hack. */ + sym->flags = BSF_LOCAL | BSF_DYNAMIC; + + /* Add this stub to the linked list. */ + item = (struct powerpc_stub *) xmalloc (sizeof (struct powerpc_stub)); + item->start = sym; + item->reloc = newsym; + item->toc_index = got_base + stubcount * POWERPC_STUB_TOC_ENTRY_SIZE; + + item->next = powerpc_stubs; + powerpc_stubs = item; + + ++stubcount; + } + + if (stubcount > 0) + { + asymbol **s; + struct powerpc_stub *l; + + /* Add the new symbols we just created to the symbol table. */ + *symbols_ptr = (asymbol **) xrealloc ((char *) *symbols_ptr, + ((symcount + stubcount) + * sizeof (asymbol))); + *symcount_ptr += stubcount; + s = &(*symbols_ptr)[symcount]; + for (l = powerpc_stubs; l != (struct powerpc_stub *) NULL; l = l->next) + *s++ = l->reloc; + + /* Set the size of the .stubs section and increase the size of + the .got section. */ + if (! bfd_set_section_size (inbfd, stub_sec, + stubcount * POWERPC_STUB_SIZE) + || ! bfd_set_section_size (inbfd, got_sec, + (got_base + + (stubcount + * POWERPC_STUB_TOC_ENTRY_SIZE)))) + bfd_fatal (_("stub section sizes")); + } +} + +/* Resolve all the stubs for PowerPC NetWare. We fill in the contents + of the output section, and create new relocs in the TOC. */ + +static void +powerpc_resolve_stubs (bfd *inbfd, bfd *outbfd) +{ + bfd_byte buf[POWERPC_STUB_SIZE]; + unsigned int i; + unsigned int stubcount; + arelent **relocs; + asection *got_sec; + arelent **r; + struct powerpc_stub *l; + + if (powerpc_stubs == (struct powerpc_stub *) NULL) + return; + + for (i = 0; i < POWERPC_STUB_INSN_COUNT; i++) + bfd_put_32 (outbfd, (bfd_vma) powerpc_stub_insns[i], buf + i * 4); + + got_sec = bfd_get_section_by_name (inbfd, ".got"); + assert (got_sec != (asection *) NULL); + assert (got_sec->output_section->orelocation == (arelent **) NULL); + + stubcount = 0; + for (l = powerpc_stubs; l != (struct powerpc_stub *) NULL; l = l->next) + ++stubcount; + relocs = (arelent **) xmalloc (stubcount * sizeof (arelent *)); + + r = relocs; + for (l = powerpc_stubs; l != (struct powerpc_stub *) NULL; l = l->next) + { + arelent *reloc; + + /* Adjust the first instruction to use the right TOC index. */ + bfd_put_32 (outbfd, (bfd_vma) powerpc_stub_insns[0] + l->toc_index, buf); + + /* Write this stub out. */ + if (! bfd_set_section_contents (outbfd, + bfd_get_section (l->start), + buf, + l->start->value, + POWERPC_STUB_SIZE)) + bfd_fatal (_("writing stub")); + + /* Create a new reloc for the TOC entry. */ + reloc = (arelent *) xmalloc (sizeof (arelent)); + reloc->sym_ptr_ptr = &l->reloc; + reloc->address = l->toc_index + got_sec->output_offset; + reloc->addend = 0; + reloc->howto = bfd_reloc_type_lookup (inbfd, BFD_RELOC_32); + + *r++ = reloc; + } + + bfd_set_reloc (outbfd, got_sec->output_section, relocs, stubcount); +} + +/* Adjust relocation entries for PowerPC NetWare. We do not output + TOC relocations. The object code already contains the offset from + the TOC pointer. When the function is called, the TOC register, + r2, will be set to the correct TOC value, so there is no need for + any further reloc. */ + +static void +powerpc_mangle_relocs (bfd *outbfd, asection *insec, + arelent ***relocs_ptr, + long *reloc_count_ptr, char *contents, + bfd_size_type contents_size ATTRIBUTE_UNUSED) +{ + reloc_howto_type *toc_howto; + long reloc_count; + arelent **relocs; + long i; + + toc_howto = bfd_reloc_type_lookup (insec->owner, BFD_RELOC_PPC_TOC16); + if (toc_howto == (reloc_howto_type *) NULL) + fatal (_("Unable to locate PPC_TOC16 reloc information")); + + /* If this is the .got section, clear out all the contents beyond + the initial size. We must do this here because copy_sections is + going to write out whatever we return in the contents field. */ + if (strcmp (bfd_get_section_name (insec->owner, insec), ".got") == 0) + memset (contents + powerpc_initial_got_size, 0, + (size_t) (bfd_get_section_size (insec) - powerpc_initial_got_size)); + + reloc_count = *reloc_count_ptr; + relocs = *relocs_ptr; + for (i = 0; i < reloc_count; i++) + { + arelent *rel; + asymbol *sym; + bfd_vma sym_value; + + rel = *relocs++; + sym = *rel->sym_ptr_ptr; + + /* Convert any relocs against the .bss section into relocs + against the .data section. */ + if (strcmp (bfd_get_section_name (outbfd, bfd_get_section (sym)), + NLM_UNINITIALIZED_DATA_NAME) == 0) + { + asection *datasec; + + datasec = bfd_get_section_by_name (outbfd, + NLM_INITIALIZED_DATA_NAME); + if (datasec != NULL) + { + rel->addend += (bfd_get_section_vma (outbfd, + bfd_get_section (sym)) + + sym->value); + rel->sym_ptr_ptr = datasec->symbol_ptr_ptr; + sym = *rel->sym_ptr_ptr; + } + } + + /* PR 17512: file: 70cfde95. */ + if (rel->howto == NULL) + continue; + + /* We must be able to resolve all PC relative relocs at this + point. If we get a branch to an undefined symbol we build a + stub, since NetWare will resolve undefined symbols into a + pointer to a function descriptor. */ + if (rel->howto->pc_relative) + { + /* This check for whether a symbol is in the same section as + the reloc will be wrong if there is a PC relative reloc + between two sections both of which were placed in the + same output section. This should not happen. */ + if (bfd_get_section (sym) != insec->output_section) + non_fatal (_("unresolved PC relative reloc against %s"), + bfd_asymbol_name (sym)); + else + { + bfd_vma val; + + if (rel->address > contents_size - 4) + { + non_fatal (_("Out of range relocation: %lx"), + (long) rel->address); + break; + } + + assert (rel->howto->size == 2 && rel->howto->pcrel_offset); + val = bfd_get_32 (outbfd, (bfd_byte *) contents + rel->address); + val = ((val &~ rel->howto->dst_mask) + | (((val & rel->howto->src_mask) + + (sym->value - rel->address) + + rel->addend) + & rel->howto->dst_mask)); + bfd_put_32 (outbfd, val, (bfd_byte *) contents + rel->address); + + /* If this reloc is against an stubbed symbol and the + next instruction is + cror 31,31,31 + then we replace the next instruction with + lwz r2,20(r1) + This reloads the TOC pointer after a stub call. */ + if (bfd_asymbol_name (sym)[0] == '.' + && (sym->flags & BSF_DYNAMIC) != 0 + && (bfd_get_32 (outbfd, + (bfd_byte *) contents + rel->address + 4) + == 0x4ffffb82)) /* cror 31,31,31 */ + bfd_put_32 (outbfd, (bfd_vma) 0x80410014, /* lwz r2,20(r1) */ + (bfd_byte *) contents + rel->address + 4); + + --*reloc_count_ptr; + --relocs; + memmove (relocs, relocs + 1, + (size_t) ((reloc_count - 1) * sizeof (arelent *))); + continue; + } + } + + /* When considering a TOC reloc, we do not want to include the + symbol value. The symbol will be start of the TOC section + (which is named .got). We do want to include the addend. */ + if (rel->howto == toc_howto) + sym_value = 0; + else + sym_value = sym->value; + + /* If this is a relocation against a symbol with a value, or + there is a reloc addend, we need to update the addend in the + object file. */ + if (sym_value + rel->addend != 0) + { + bfd_vma val; + + switch (rel->howto->size) + { + case 1: + if (rel->address > contents_size - 2) + { + non_fatal (_("Out of range relocation: %lx"), + (long) rel->address); + break; + } + + val = bfd_get_16 (outbfd, + (bfd_byte *) contents + rel->address); + val = ((val &~ rel->howto->dst_mask) + | (((val & rel->howto->src_mask) + + sym_value + + rel->addend) + & rel->howto->dst_mask)); + if ((bfd_signed_vma) val < - 0x8000 + || (bfd_signed_vma) val >= 0x8000) + non_fatal (_("overflow when adjusting relocation against %s"), + bfd_asymbol_name (sym)); + bfd_put_16 (outbfd, val, (bfd_byte *) contents + rel->address); + break; + + case 2: + /* PR 17512: file: 0455a112. */ + if (rel->address > contents_size - 4) + { + non_fatal (_("Out of range relocation: %lx"), + (long) rel->address); + break; + } + + val = bfd_get_32 (outbfd, + (bfd_byte *) contents + rel->address); + val = ((val &~ rel->howto->dst_mask) + | (((val & rel->howto->src_mask) + + sym_value + + rel->addend) + & rel->howto->dst_mask)); + bfd_put_32 (outbfd, val, (bfd_byte *) contents + rel->address); + break; + + default: + fatal (_("Unsupported relocation size: %d"), rel->howto->size); + } + + if (! bfd_is_und_section (bfd_get_section (sym))) + rel->sym_ptr_ptr = bfd_get_section (sym)->symbol_ptr_ptr; + rel->addend = 0; + } + + /* Now that we have incorporated the addend, remove any TOC + relocs. */ + if (rel->howto == toc_howto) + { + --*reloc_count_ptr; + --relocs; + memmove (relocs, relocs + 1, + (size_t) ((reloc_count - i) * sizeof (arelent *))); + continue; + } + + rel->address += insec->output_offset; + } +} + +#endif /* NLMCONV_POWERPC */ + +/* Name of linker. */ +#ifndef LD_NAME +#define LD_NAME "ld" +#endif + +/* The user has specified several input files. Invoke the linker to + link them all together, and convert and delete the resulting output + file. */ + +static char * +link_inputs (struct string_list *inputs, char *ld, char * mfile) +{ + size_t c; + struct string_list *q; + char **argv; + size_t i; + int pid; + int status; + char *errfmt; + char *errarg; + + c = 0; + for (q = inputs; q != NULL; q = q->next) + ++c; + + argv = (char **) xmalloc ((c + 7) * sizeof (char *)); + +#ifndef __MSDOS__ + if (ld == NULL) + { + char *p; + + /* Find the linker to invoke based on how nlmconv was run. */ + p = program_name + strlen (program_name); + while (p != program_name) + { + if (p[-1] == '/') + { + ld = (char *) xmalloc (p - program_name + strlen (LD_NAME) + 1); + memcpy (ld, program_name, p - program_name); + strcpy (ld + (p - program_name), LD_NAME); + break; + } + --p; + } + } +#endif + + if (ld == NULL) + ld = (char *) LD_NAME; + + unlink_on_exit = make_temp_file (".O"); + + argv[0] = ld; + argv[1] = (char *) "-Ur"; + argv[2] = (char *) "-o"; + argv[3] = unlink_on_exit; + /* If we have been given the name of a mapfile and that + name is not 'stderr' then pass it on to the linker. */ + if (mfile + && * mfile + && strcmp (mfile, "stderr") == 0) + { + argv[4] = (char *) "-Map"; + argv[5] = mfile; + i = 6; + } + else + i = 4; + + for (q = inputs; q != NULL; q = q->next, i++) + argv[i] = q->string; + argv[i] = NULL; + + if (debug) + { + for (i = 0; argv[i] != NULL; i++) + fprintf (stderr, " %s", argv[i]); + fprintf (stderr, "\n"); + } + + pid = pexecute (ld, argv, program_name, (char *) NULL, &errfmt, &errarg, + PEXECUTE_SEARCH | PEXECUTE_ONE); + free (argv); + + if (pid == -1) + { + fprintf (stderr, _("%s: execution of %s failed: "), program_name, ld); + fprintf (stderr, errfmt, errarg); + unlink (unlink_on_exit); + exit (1); + } + + if (pwait (pid, &status, 0) < 0) + { + perror ("pwait"); + unlink (unlink_on_exit); + exit (1); + } + + if (status != 0) + { + non_fatal (_("Execution of %s failed"), ld); + unlink (unlink_on_exit); + exit (1); + } + + return unlink_on_exit; +} diff --git a/support/sdbinutils/binutils/nlmconv.h b/support/sdbinutils/binutils/nlmconv.h new file mode 100644 index 0000000..b2267d9 --- /dev/null +++ b/support/sdbinutils/binutils/nlmconv.h @@ -0,0 +1,86 @@ +/* nlmconv.h -- header file for NLM conversion program + Copyright (C) 1993-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + + +/* Written by Ian Lance Taylor . + + bfd.h, nlm/common.h and nlm/internal.h must be included before this + file. */ + +/* A linked list of strings. */ + +struct string_list +{ + struct string_list *next; + char *string; +}; + +/* The NLM header parser in nlmheader.y stores information in the + following variables. */ + +extern Nlm_Internal_Fixed_Header *fixed_hdr; +extern Nlm_Internal_Variable_Header *var_hdr; +extern Nlm_Internal_Version_Header *version_hdr; +extern Nlm_Internal_Copyright_Header *copyright_hdr; +extern Nlm_Internal_Extended_Header *extended_hdr; + +/* Procedure named by CHECK. */ +extern char *check_procedure; +/* File named by CUSTOM. */ +extern char *custom_file; +/* Whether to generate debugging information (DEBUG). */ +extern bfd_boolean debug_info; +/* Procedure named by EXIT. */ +extern char *exit_procedure; +/* Exported symbols (EXPORT). */ +extern struct string_list *export_symbols; +/* List of files from INPUT. */ +extern struct string_list *input_files; +/* Map file name (MAP, FULLMAP). */ +extern char *map_file; +/* Whether a full map has been requested (FULLMAP). */ +extern bfd_boolean full_map; +/* File named by HELP. */ +extern char *help_file; +/* Imported symbols (IMPORT). */ +extern struct string_list *import_symbols; +/* File named by MESSAGES. */ +extern char *message_file; +/* Autoload module list (MODULE). */ +extern struct string_list *modules; +/* File named by OUTPUT. */ +extern char *output_file; +/* File named by SHARELIB. */ +extern char *sharelib_file; +/* Start procedure name (START). */ +extern char *start_procedure; +/* VERBOSE. */ +extern bfd_boolean verbose; +/* RPC description file (XDCDATA). */ +extern char *rpc_file; + +/* The number of serious parse errors. */ +extern int parse_errors; + +/* The parser. */ +extern int yyparse (void); + +/* Tell the lexer what file to read. */ +extern bfd_boolean nlmlex_file (const char *); diff --git a/support/sdbinutils/binutils/nlmheader.c b/support/sdbinutils/binutils/nlmheader.c new file mode 100644 index 0000000..120cb75 --- /dev/null +++ b/support/sdbinutils/binutils/nlmheader.c @@ -0,0 +1,2638 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "3.0.4" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* Copy the first part of user declarations. */ +#line 1 "nlmheader.y" /* yacc.c:339 */ +/* nlmheader.y - parse NLM header specification keywords. + Copyright (C) 1993-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +/* Written by Ian Lance Taylor . + + This bison file parses the commands recognized by the NetWare NLM + linker, except for lists of object files. It stores the + information in global variables. + + This implementation is based on the description in the NetWare Tool + Maker Specification manual, edition 1.0. */ + +#include "sysdep.h" +#include "safe-ctype.h" +#include "bfd.h" +#include "nlm/common.h" +#include "nlm/internal.h" +#include "bucomm.h" +#include "nlmconv.h" + +/* Information is stored in the structures pointed to by these + variables. */ + +Nlm_Internal_Fixed_Header *fixed_hdr; +Nlm_Internal_Variable_Header *var_hdr; +Nlm_Internal_Version_Header *version_hdr; +Nlm_Internal_Copyright_Header *copyright_hdr; +Nlm_Internal_Extended_Header *extended_hdr; + +/* Procedure named by CHECK. */ +char *check_procedure; +/* File named by CUSTOM. */ +char *custom_file; +/* Whether to generate debugging information (DEBUG). */ +bfd_boolean debug_info; +/* Procedure named by EXIT. */ +char *exit_procedure; +/* Exported symbols (EXPORT). */ +struct string_list *export_symbols; +/* List of files from INPUT. */ +struct string_list *input_files; +/* Map file name (MAP, FULLMAP). */ +char *map_file; +/* Whether a full map has been requested (FULLMAP). */ +bfd_boolean full_map; +/* File named by HELP. */ +char *help_file; +/* Imported symbols (IMPORT). */ +struct string_list *import_symbols; +/* File named by MESSAGES. */ +char *message_file; +/* Autoload module list (MODULE). */ +struct string_list *modules; +/* File named by OUTPUT. */ +char *output_file; +/* File named by SHARELIB. */ +char *sharelib_file; +/* Start procedure name (START). */ +char *start_procedure; +/* VERBOSE. */ +bfd_boolean verbose; +/* RPC description file (XDCDATA). */ +char *rpc_file; + +/* The number of serious errors that have occurred. */ +int parse_errors; + +/* The current symbol prefix when reading a list of import or export + symbols. */ +static char *symbol_prefix; + +/* Parser error message handler. */ +#define yyerror(msg) nlmheader_error (msg); + +/* Local functions. */ +static int yylex (void); +static void nlmlex_file_push (const char *); +static bfd_boolean nlmlex_file_open (const char *); +static int nlmlex_buf_init (void); +static char nlmlex_buf_add (int); +static long nlmlex_get_number (const char *); +static void nlmheader_identify (void); +static void nlmheader_warn (const char *, int); +static void nlmheader_error (const char *); +static struct string_list * string_list_cons (char *, struct string_list *); +static struct string_list * string_list_append (struct string_list *, + struct string_list *); +static struct string_list * string_list_append1 (struct string_list *, + char *); +static char *xstrdup (const char *); + + +#line 176 "nlmheader.c" /* yacc.c:339 */ + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* In a future release of Bison, this section will be replaced + by #include "y.tab.h". */ +#ifndef YY_YY_NLMHEADER_H_INCLUDED +# define YY_YY_NLMHEADER_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + CHECK = 258, + CODESTART = 259, + COPYRIGHT = 260, + CUSTOM = 261, + DATE = 262, + DEBUG_K = 263, + DESCRIPTION = 264, + EXIT = 265, + EXPORT = 266, + FLAG_ON = 267, + FLAG_OFF = 268, + FULLMAP = 269, + HELP = 270, + IMPORT = 271, + INPUT = 272, + MAP = 273, + MESSAGES = 274, + MODULE = 275, + MULTIPLE = 276, + OS_DOMAIN = 277, + OUTPUT = 278, + PSEUDOPREEMPTION = 279, + REENTRANT = 280, + SCREENNAME = 281, + SHARELIB = 282, + STACK = 283, + START = 284, + SYNCHRONIZE = 285, + THREADNAME = 286, + TYPE = 287, + VERBOSE = 288, + VERSIONK = 289, + XDCDATA = 290, + STRING = 291, + QUOTED_STRING = 292 + }; +#endif +/* Tokens. */ +#define CHECK 258 +#define CODESTART 259 +#define COPYRIGHT 260 +#define CUSTOM 261 +#define DATE 262 +#define DEBUG_K 263 +#define DESCRIPTION 264 +#define EXIT 265 +#define EXPORT 266 +#define FLAG_ON 267 +#define FLAG_OFF 268 +#define FULLMAP 269 +#define HELP 270 +#define IMPORT 271 +#define INPUT 272 +#define MAP 273 +#define MESSAGES 274 +#define MODULE 275 +#define MULTIPLE 276 +#define OS_DOMAIN 277 +#define OUTPUT 278 +#define PSEUDOPREEMPTION 279 +#define REENTRANT 280 +#define SCREENNAME 281 +#define SHARELIB 282 +#define STACK 283 +#define START 284 +#define SYNCHRONIZE 285 +#define THREADNAME 286 +#define TYPE 287 +#define VERBOSE 288 +#define VERSIONK 289 +#define XDCDATA 290 +#define STRING 291 +#define QUOTED_STRING 292 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 112 "nlmheader.y" /* yacc.c:355 */ + + char *string; + struct string_list *list; + +#line 295 "nlmheader.c" /* yacc.c:355 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_NLMHEADER_H_INCLUDED */ + +/* Copy the second part of user declarations. */ + +#line 312 "nlmheader.c" /* yacc.c:358 */ + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 64 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 73 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 40 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 11 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 52 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 82 + +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 292 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 38, 39, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37 +}; + +#if YYDEBUG + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 143, 143, 148, 150, 156, 160, 165, 182, 186, + 204, 208, 224, 229, 228, 236, 241, 246, 251, 256, + 261, 260, 268, 272, 276, 280, 284, 288, 292, 296, + 303, 307, 311, 327, 331, 336, 340, 344, 360, 365, + 369, 393, 409, 419, 422, 433, 437, 441, 445, 454, + 465, 482, 485 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || 0 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "CHECK", "CODESTART", "COPYRIGHT", + "CUSTOM", "DATE", "DEBUG_K", "DESCRIPTION", "EXIT", "EXPORT", "FLAG_ON", + "FLAG_OFF", "FULLMAP", "HELP", "IMPORT", "INPUT", "MAP", "MESSAGES", + "MODULE", "MULTIPLE", "OS_DOMAIN", "OUTPUT", "PSEUDOPREEMPTION", + "REENTRANT", "SCREENNAME", "SHARELIB", "STACK", "START", "SYNCHRONIZE", + "THREADNAME", "TYPE", "VERBOSE", "VERSIONK", "XDCDATA", "STRING", + "QUOTED_STRING", "'('", "')'", "$accept", "file", "commands", "command", + "$@1", "$@2", "symbol_list_opt", "symbol_list", "symbol_prefix", + "symbol", "string_list", YY_NULLPTR +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 40, 41 +}; +# endif + +#define YYPACT_NINF -20 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-20))) + +#define YYTABLE_NINF -1 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int8 yypact[] = +{ + -3, -1, 1, 2, 4, 5, -20, 6, 8, -20, + 9, 10, 11, 12, -20, 13, 14, 16, 13, -20, + -20, 17, -20, -20, 18, 20, 21, 22, -20, 23, + 25, -20, 26, 27, 38, -20, -3, -20, -20, -20, + -20, 28, -20, -20, -2, -20, -20, -20, -20, -2, + 13, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, 30, -20, -20, -20, 31, -20, 32, -20, + -2, -20, -20, -20, -20, 33, -20, 3, -20, -20, + -20, -20 +}; + + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 3, 0, 0, 0, 0, 0, 10, 0, 0, 13, + 0, 0, 17, 0, 20, 51, 23, 0, 51, 27, + 28, 0, 30, 31, 0, 0, 0, 0, 36, 0, + 0, 39, 0, 0, 0, 2, 3, 5, 6, 7, + 8, 0, 11, 12, 43, 15, 16, 18, 19, 43, + 51, 22, 24, 25, 26, 29, 32, 33, 34, 35, + 37, 38, 0, 42, 1, 4, 0, 50, 0, 14, + 44, 46, 45, 21, 52, 41, 9, 0, 48, 47, + 40, 49 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -20, -20, 34, -20, -20, -20, 24, -20, -19, -16, + 15 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 34, 35, 36, 44, 49, 69, 70, 71, 72, + 51 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_uint8 yytable[] = +{ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 54, 67, 37, 68, 38, 64, 39, + 40, 41, 81, 42, 43, 45, 46, 47, 48, 50, + 52, 78, 53, 55, 79, 56, 57, 58, 59, 0, + 60, 61, 62, 63, 66, 74, 75, 76, 77, 80, + 65, 0, 0, 73 +}; + +static const yytype_int8 yycheck[] = +{ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 18, 36, 36, 38, 36, 0, 37, + 36, 36, 39, 37, 36, 36, 36, 36, 36, 36, + 36, 70, 36, 36, 70, 37, 36, 36, 36, -1, + 37, 36, 36, 36, 36, 50, 36, 36, 36, 36, + 36, -1, -1, 49 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 41, 42, 43, 36, 36, 37, + 36, 36, 37, 36, 44, 36, 36, 36, 36, 45, + 36, 50, 36, 36, 50, 36, 37, 36, 36, 36, + 37, 36, 36, 36, 0, 42, 36, 36, 38, 46, + 47, 48, 49, 46, 50, 36, 36, 36, 48, 49, + 36, 39 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 40, 41, 42, 42, 43, 43, 43, 43, 43, + 43, 43, 43, 44, 43, 43, 43, 43, 43, 43, + 45, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 46, 46, 47, 47, 47, 47, 48, + 49, 50, 50 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 2, 2, 2, 2, 2, 4, + 1, 2, 2, 0, 3, 2, 2, 1, 2, 2, + 0, 3, 2, 1, 2, 2, 2, 1, 1, 2, + 1, 1, 2, 2, 2, 2, 1, 2, 2, 1, + 4, 3, 2, 0, 1, 1, 1, 2, 2, 3, + 1, 0, 2 +}; + + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +{ + unsigned long int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +yystrlen (const char *yystr) +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +yystpcpy (char *yydest, const char *yysrc) +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +{ + YYUSE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 5: +#line 157 "nlmheader.y" /* yacc.c:1646 */ + { + check_procedure = (yyvsp[0].string); + } +#line 1448 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 6: +#line 161 "nlmheader.y" /* yacc.c:1646 */ + { + nlmheader_warn (_("CODESTART is not implemented; sorry"), -1); + free ((yyvsp[0].string)); + } +#line 1457 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 7: +#line 166 "nlmheader.y" /* yacc.c:1646 */ + { + int len; + + strncpy (copyright_hdr->stamp, "CoPyRiGhT=", 10); + len = strlen ((yyvsp[0].string)); + if (len >= NLM_MAX_COPYRIGHT_MESSAGE_LENGTH) + { + nlmheader_warn (_("copyright string is too long"), + NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1); + len = NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1; + } + copyright_hdr->copyrightMessageLength = len; + strncpy (copyright_hdr->copyrightMessage, (yyvsp[0].string), len); + copyright_hdr->copyrightMessage[len] = '\0'; + free ((yyvsp[0].string)); + } +#line 1478 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 8: +#line 183 "nlmheader.y" /* yacc.c:1646 */ + { + custom_file = (yyvsp[0].string); + } +#line 1486 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 9: +#line 187 "nlmheader.y" /* yacc.c:1646 */ + { + /* We don't set the version stamp here, because we use the + version stamp to detect whether the required VERSION + keyword was given. */ + version_hdr->month = nlmlex_get_number ((yyvsp[-2].string)); + version_hdr->day = nlmlex_get_number ((yyvsp[-1].string)); + version_hdr->year = nlmlex_get_number ((yyvsp[0].string)); + free ((yyvsp[-2].string)); + free ((yyvsp[-1].string)); + free ((yyvsp[0].string)); + if (version_hdr->month < 1 || version_hdr->month > 12) + nlmheader_warn (_("illegal month"), -1); + if (version_hdr->day < 1 || version_hdr->day > 31) + nlmheader_warn (_("illegal day"), -1); + if (version_hdr->year < 1900 || version_hdr->year > 3000) + nlmheader_warn (_("illegal year"), -1); + } +#line 1508 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 10: +#line 205 "nlmheader.y" /* yacc.c:1646 */ + { + debug_info = TRUE; + } +#line 1516 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 11: +#line 209 "nlmheader.y" /* yacc.c:1646 */ + { + int len; + + len = strlen ((yyvsp[0].string)); + if (len > NLM_MAX_DESCRIPTION_LENGTH) + { + nlmheader_warn (_("description string is too long"), + NLM_MAX_DESCRIPTION_LENGTH); + len = NLM_MAX_DESCRIPTION_LENGTH; + } + var_hdr->descriptionLength = len; + strncpy (var_hdr->descriptionText, (yyvsp[0].string), len); + var_hdr->descriptionText[len] = '\0'; + free ((yyvsp[0].string)); + } +#line 1536 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 12: +#line 225 "nlmheader.y" /* yacc.c:1646 */ + { + exit_procedure = (yyvsp[0].string); + } +#line 1544 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 13: +#line 229 "nlmheader.y" /* yacc.c:1646 */ + { + symbol_prefix = NULL; + } +#line 1552 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 14: +#line 233 "nlmheader.y" /* yacc.c:1646 */ + { + export_symbols = string_list_append (export_symbols, (yyvsp[0].list)); + } +#line 1560 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 15: +#line 237 "nlmheader.y" /* yacc.c:1646 */ + { + fixed_hdr->flags |= nlmlex_get_number ((yyvsp[0].string)); + free ((yyvsp[0].string)); + } +#line 1569 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 16: +#line 242 "nlmheader.y" /* yacc.c:1646 */ + { + fixed_hdr->flags &=~ nlmlex_get_number ((yyvsp[0].string)); + free ((yyvsp[0].string)); + } +#line 1578 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 17: +#line 247 "nlmheader.y" /* yacc.c:1646 */ + { + map_file = ""; + full_map = TRUE; + } +#line 1587 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 18: +#line 252 "nlmheader.y" /* yacc.c:1646 */ + { + map_file = (yyvsp[0].string); + full_map = TRUE; + } +#line 1596 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 19: +#line 257 "nlmheader.y" /* yacc.c:1646 */ + { + help_file = (yyvsp[0].string); + } +#line 1604 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 20: +#line 261 "nlmheader.y" /* yacc.c:1646 */ + { + symbol_prefix = NULL; + } +#line 1612 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 21: +#line 265 "nlmheader.y" /* yacc.c:1646 */ + { + import_symbols = string_list_append (import_symbols, (yyvsp[0].list)); + } +#line 1620 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 22: +#line 269 "nlmheader.y" /* yacc.c:1646 */ + { + input_files = string_list_append (input_files, (yyvsp[0].list)); + } +#line 1628 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 23: +#line 273 "nlmheader.y" /* yacc.c:1646 */ + { + map_file = ""; + } +#line 1636 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 24: +#line 277 "nlmheader.y" /* yacc.c:1646 */ + { + map_file = (yyvsp[0].string); + } +#line 1644 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 25: +#line 281 "nlmheader.y" /* yacc.c:1646 */ + { + message_file = (yyvsp[0].string); + } +#line 1652 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 26: +#line 285 "nlmheader.y" /* yacc.c:1646 */ + { + modules = string_list_append (modules, (yyvsp[0].list)); + } +#line 1660 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 27: +#line 289 "nlmheader.y" /* yacc.c:1646 */ + { + fixed_hdr->flags |= 0x2; + } +#line 1668 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 28: +#line 293 "nlmheader.y" /* yacc.c:1646 */ + { + fixed_hdr->flags |= 0x10; + } +#line 1676 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 29: +#line 297 "nlmheader.y" /* yacc.c:1646 */ + { + if (output_file == NULL) + output_file = (yyvsp[0].string); + else + nlmheader_warn (_("ignoring duplicate OUTPUT statement"), -1); + } +#line 1687 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 30: +#line 304 "nlmheader.y" /* yacc.c:1646 */ + { + fixed_hdr->flags |= 0x8; + } +#line 1695 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 31: +#line 308 "nlmheader.y" /* yacc.c:1646 */ + { + fixed_hdr->flags |= 0x1; + } +#line 1703 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 32: +#line 312 "nlmheader.y" /* yacc.c:1646 */ + { + int len; + + len = strlen ((yyvsp[0].string)); + if (len >= NLM_MAX_SCREEN_NAME_LENGTH) + { + nlmheader_warn (_("screen name is too long"), + NLM_MAX_SCREEN_NAME_LENGTH); + len = NLM_MAX_SCREEN_NAME_LENGTH; + } + var_hdr->screenNameLength = len; + strncpy (var_hdr->screenName, (yyvsp[0].string), len); + var_hdr->screenName[NLM_MAX_SCREEN_NAME_LENGTH] = '\0'; + free ((yyvsp[0].string)); + } +#line 1723 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 33: +#line 328 "nlmheader.y" /* yacc.c:1646 */ + { + sharelib_file = (yyvsp[0].string); + } +#line 1731 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 34: +#line 332 "nlmheader.y" /* yacc.c:1646 */ + { + var_hdr->stackSize = nlmlex_get_number ((yyvsp[0].string)); + free ((yyvsp[0].string)); + } +#line 1740 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 35: +#line 337 "nlmheader.y" /* yacc.c:1646 */ + { + start_procedure = (yyvsp[0].string); + } +#line 1748 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 36: +#line 341 "nlmheader.y" /* yacc.c:1646 */ + { + fixed_hdr->flags |= 0x4; + } +#line 1756 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 37: +#line 345 "nlmheader.y" /* yacc.c:1646 */ + { + int len; + + len = strlen ((yyvsp[0].string)); + if (len >= NLM_MAX_THREAD_NAME_LENGTH) + { + nlmheader_warn (_("thread name is too long"), + NLM_MAX_THREAD_NAME_LENGTH); + len = NLM_MAX_THREAD_NAME_LENGTH; + } + var_hdr->threadNameLength = len; + strncpy (var_hdr->threadName, (yyvsp[0].string), len); + var_hdr->threadName[len] = '\0'; + free ((yyvsp[0].string)); + } +#line 1776 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 38: +#line 361 "nlmheader.y" /* yacc.c:1646 */ + { + fixed_hdr->moduleType = nlmlex_get_number ((yyvsp[0].string)); + free ((yyvsp[0].string)); + } +#line 1785 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 39: +#line 366 "nlmheader.y" /* yacc.c:1646 */ + { + verbose = TRUE; + } +#line 1793 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 40: +#line 370 "nlmheader.y" /* yacc.c:1646 */ + { + long val; + + strncpy (version_hdr->stamp, "VeRsIoN#", 8); + version_hdr->majorVersion = nlmlex_get_number ((yyvsp[-2].string)); + val = nlmlex_get_number ((yyvsp[-1].string)); + if (val < 0 || val > 99) + nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"), + -1); + else + version_hdr->minorVersion = val; + val = nlmlex_get_number ((yyvsp[0].string)); + if (val < 0) + nlmheader_warn (_("illegal revision number (must be between 0 and 26)"), + -1); + else if (val > 26) + version_hdr->revision = 0; + else + version_hdr->revision = val; + free ((yyvsp[-2].string)); + free ((yyvsp[-1].string)); + free ((yyvsp[0].string)); + } +#line 1821 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 41: +#line 394 "nlmheader.y" /* yacc.c:1646 */ + { + long val; + + strncpy (version_hdr->stamp, "VeRsIoN#", 8); + version_hdr->majorVersion = nlmlex_get_number ((yyvsp[-1].string)); + val = nlmlex_get_number ((yyvsp[0].string)); + if (val < 0 || val > 99) + nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"), + -1); + else + version_hdr->minorVersion = val; + version_hdr->revision = 0; + free ((yyvsp[-1].string)); + free ((yyvsp[0].string)); + } +#line 1841 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 42: +#line 410 "nlmheader.y" /* yacc.c:1646 */ + { + rpc_file = (yyvsp[0].string); + } +#line 1849 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 43: +#line 419 "nlmheader.y" /* yacc.c:1646 */ + { + (yyval.list) = NULL; + } +#line 1857 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 44: +#line 423 "nlmheader.y" /* yacc.c:1646 */ + { + (yyval.list) = (yyvsp[0].list); + } +#line 1865 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 45: +#line 434 "nlmheader.y" /* yacc.c:1646 */ + { + (yyval.list) = string_list_cons ((yyvsp[0].string), NULL); + } +#line 1873 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 46: +#line 438 "nlmheader.y" /* yacc.c:1646 */ + { + (yyval.list) = NULL; + } +#line 1881 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 47: +#line 442 "nlmheader.y" /* yacc.c:1646 */ + { + (yyval.list) = string_list_append1 ((yyvsp[-1].list), (yyvsp[0].string)); + } +#line 1889 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 48: +#line 446 "nlmheader.y" /* yacc.c:1646 */ + { + (yyval.list) = (yyvsp[-1].list); + } +#line 1897 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 49: +#line 455 "nlmheader.y" /* yacc.c:1646 */ + { + if (symbol_prefix != NULL) + free (symbol_prefix); + symbol_prefix = (yyvsp[-1].string); + } +#line 1907 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 50: +#line 466 "nlmheader.y" /* yacc.c:1646 */ + { + if (symbol_prefix == NULL) + (yyval.string) = (yyvsp[0].string); + else + { + (yyval.string) = xmalloc (strlen (symbol_prefix) + strlen ((yyvsp[0].string)) + 2); + sprintf ((yyval.string), "%s@%s", symbol_prefix, (yyvsp[0].string)); + free ((yyvsp[0].string)); + } + } +#line 1922 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 51: +#line 482 "nlmheader.y" /* yacc.c:1646 */ + { + (yyval.list) = NULL; + } +#line 1930 "nlmheader.c" /* yacc.c:1646 */ + break; + + case 52: +#line 486 "nlmheader.y" /* yacc.c:1646 */ + { + (yyval.list) = string_list_cons ((yyvsp[-1].string), (yyvsp[0].list)); + } +#line 1938 "nlmheader.c" /* yacc.c:1646 */ + break; + + +#line 1942 "nlmheader.c" /* yacc.c:1646 */ + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} +#line 491 "nlmheader.y" /* yacc.c:1906 */ + + +/* If strerror is just a macro, we want to use the one from libiberty + since it will handle undefined values. */ +#undef strerror +extern char *strerror (int); + +/* The lexer is simple, too simple for flex. Keywords are only + recognized at the start of lines. Everything else must be an + argument. A comma is treated as whitespace. */ + +/* The states the lexer can be in. */ + +enum lex_state +{ + /* At the beginning of a line. */ + BEGINNING_OF_LINE, + /* In the middle of a line. */ + IN_LINE +}; + +/* We need to keep a stack of files to handle file inclusion. */ + +struct input +{ + /* The file to read from. */ + FILE *file; + /* The name of the file. */ + char *name; + /* The current line number. */ + int lineno; + /* The current state. */ + enum lex_state state; + /* The next file on the stack. */ + struct input *next; +}; + +/* The current input file. */ + +static struct input current; + +/* The character which introduces comments. */ +#define COMMENT_CHAR '#' + +/* Start the lexer going on the main input file. */ + +bfd_boolean +nlmlex_file (const char *name) +{ + current.next = NULL; + return nlmlex_file_open (name); +} + +/* Start the lexer going on a subsidiary input file. */ + +static void +nlmlex_file_push (const char *name) +{ + struct input *push; + + push = (struct input *) xmalloc (sizeof (struct input)); + *push = current; + if (nlmlex_file_open (name)) + current.next = push; + else + { + current = *push; + free (push); + } +} + +/* Start lexing from a file. */ + +static bfd_boolean +nlmlex_file_open (const char *name) +{ + current.file = fopen (name, "r"); + if (current.file == NULL) + { + fprintf (stderr, "%s:%s: %s\n", program_name, name, strerror (errno)); + ++parse_errors; + return FALSE; + } + current.name = xstrdup (name); + current.lineno = 1; + current.state = BEGINNING_OF_LINE; + return TRUE; +} + +/* Table used to turn keywords into tokens. */ + +struct keyword_tokens_struct +{ + const char *keyword; + int token; +}; + +static struct keyword_tokens_struct keyword_tokens[] = +{ + { "CHECK", CHECK }, + { "CODESTART", CODESTART }, + { "COPYRIGHT", COPYRIGHT }, + { "CUSTOM", CUSTOM }, + { "DATE", DATE }, + { "DEBUG", DEBUG_K }, + { "DESCRIPTION", DESCRIPTION }, + { "EXIT", EXIT }, + { "EXPORT", EXPORT }, + { "FLAG_ON", FLAG_ON }, + { "FLAG_OFF", FLAG_OFF }, + { "FULLMAP", FULLMAP }, + { "HELP", HELP }, + { "IMPORT", IMPORT }, + { "INPUT", INPUT }, + { "MAP", MAP }, + { "MESSAGES", MESSAGES }, + { "MODULE", MODULE }, + { "MULTIPLE", MULTIPLE }, + { "OS_DOMAIN", OS_DOMAIN }, + { "OUTPUT", OUTPUT }, + { "PSEUDOPREEMPTION", PSEUDOPREEMPTION }, + { "REENTRANT", REENTRANT }, + { "SCREENNAME", SCREENNAME }, + { "SHARELIB", SHARELIB }, + { "STACK", STACK }, + { "STACKSIZE", STACK }, + { "START", START }, + { "SYNCHRONIZE", SYNCHRONIZE }, + { "THREADNAME", THREADNAME }, + { "TYPE", TYPE }, + { "VERBOSE", VERBOSE }, + { "VERSION", VERSIONK }, + { "XDCDATA", XDCDATA } +}; + +#define KEYWORD_COUNT (sizeof (keyword_tokens) / sizeof (keyword_tokens[0])) + +/* The lexer accumulates strings in these variables. */ +static char *lex_buf; +static int lex_size; +static int lex_pos; + +/* Start accumulating strings into the buffer. */ +#define BUF_INIT() \ + ((void) (lex_buf != NULL ? lex_pos = 0 : nlmlex_buf_init ())) + +static int +nlmlex_buf_init (void) +{ + lex_size = 10; + lex_buf = xmalloc (lex_size + 1); + lex_pos = 0; + return 0; +} + +/* Finish a string in the buffer. */ +#define BUF_FINISH() ((void) (lex_buf[lex_pos] = '\0')) + +/* Accumulate a character into the buffer. */ +#define BUF_ADD(c) \ + ((void) (lex_pos < lex_size \ + ? lex_buf[lex_pos++] = (c) \ + : nlmlex_buf_add (c))) + +static char +nlmlex_buf_add (int c) +{ + if (lex_pos >= lex_size) + { + lex_size *= 2; + lex_buf = xrealloc (lex_buf, lex_size + 1); + } + + return lex_buf[lex_pos++] = c; +} + +/* The lexer proper. This is called by the bison generated parsing + code. */ + +static int +yylex (void) +{ + int c; + +tail_recurse: + + c = getc (current.file); + + /* Commas are treated as whitespace characters. */ + while (ISSPACE (c) || c == ',') + { + current.state = IN_LINE; + if (c == '\n') + { + ++current.lineno; + current.state = BEGINNING_OF_LINE; + } + c = getc (current.file); + } + + /* At the end of the file we either pop to the previous file or + finish up. */ + if (c == EOF) + { + fclose (current.file); + free (current.name); + if (current.next == NULL) + return 0; + else + { + struct input *next; + + next = current.next; + current = *next; + free (next); + goto tail_recurse; + } + } + + /* A comment character always means to drop everything until the + next newline. */ + if (c == COMMENT_CHAR) + { + do + { + c = getc (current.file); + } + while (c != '\n'); + ++current.lineno; + current.state = BEGINNING_OF_LINE; + goto tail_recurse; + } + + /* An '@' introduces an include file. */ + if (c == '@') + { + do + { + c = getc (current.file); + if (c == '\n') + ++current.lineno; + } + while (ISSPACE (c)); + BUF_INIT (); + while (! ISSPACE (c) && c != EOF) + { + BUF_ADD (c); + c = getc (current.file); + } + BUF_FINISH (); + + ungetc (c, current.file); + + nlmlex_file_push (lex_buf); + goto tail_recurse; + } + + /* A non-space character at the start of a line must be the start of + a keyword. */ + if (current.state == BEGINNING_OF_LINE) + { + BUF_INIT (); + while (ISALNUM (c) || c == '_') + { + BUF_ADD (TOUPPER (c)); + c = getc (current.file); + } + BUF_FINISH (); + + if (c != EOF && ! ISSPACE (c) && c != ',') + { + nlmheader_identify (); + fprintf (stderr, _("%s:%d: illegal character in keyword: %c\n"), + current.name, current.lineno, c); + } + else + { + unsigned int i; + + for (i = 0; i < KEYWORD_COUNT; i++) + { + if (lex_buf[0] == keyword_tokens[i].keyword[0] + && strcmp (lex_buf, keyword_tokens[i].keyword) == 0) + { + /* Pushing back the final whitespace avoids worrying + about \n here. */ + ungetc (c, current.file); + current.state = IN_LINE; + return keyword_tokens[i].token; + } + } + + nlmheader_identify (); + fprintf (stderr, _("%s:%d: unrecognized keyword: %s\n"), + current.name, current.lineno, lex_buf); + } + + ++parse_errors; + /* Treat the rest of this line as a comment. */ + ungetc (COMMENT_CHAR, current.file); + goto tail_recurse; + } + + /* Parentheses just represent themselves. */ + if (c == '(' || c == ')') + return c; + + /* Handle quoted strings. */ + if (c == '"' || c == '\'') + { + int quote; + int start_lineno; + + quote = c; + start_lineno = current.lineno; + + c = getc (current.file); + BUF_INIT (); + while (c != quote && c != EOF) + { + BUF_ADD (c); + if (c == '\n') + ++current.lineno; + c = getc (current.file); + } + BUF_FINISH (); + + if (c == EOF) + { + nlmheader_identify (); + fprintf (stderr, _("%s:%d: end of file in quoted string\n"), + current.name, start_lineno); + ++parse_errors; + } + + /* FIXME: Possible memory leak. */ + yylval.string = xstrdup (lex_buf); + return QUOTED_STRING; + } + + /* Gather a generic argument. */ + BUF_INIT (); + while (! ISSPACE (c) + && c != ',' + && c != COMMENT_CHAR + && c != '(' + && c != ')') + { + BUF_ADD (c); + c = getc (current.file); + } + BUF_FINISH (); + + ungetc (c, current.file); + + /* FIXME: Possible memory leak. */ + yylval.string = xstrdup (lex_buf); + return STRING; +} + +/* Get a number from a string. */ + +static long +nlmlex_get_number (const char *s) +{ + long ret; + char *send; + + ret = strtol (s, &send, 10); + if (*send != '\0') + nlmheader_warn (_("bad number"), -1); + return ret; +} + +/* Prefix the nlmconv warnings with a note as to where they come from. + We don't use program_name on every warning, because then some + versions of the emacs next-error function can't recognize the line + number. */ + +static void +nlmheader_identify (void) +{ + static int done; + + if (! done) + { + fprintf (stderr, _("%s: problems in NLM command language input:\n"), + program_name); + done = 1; + } +} + +/* Issue a warning. */ + +static void +nlmheader_warn (const char *s, int imax) +{ + nlmheader_identify (); + fprintf (stderr, "%s:%d: %s", current.name, current.lineno, s); + if (imax != -1) + fprintf (stderr, " (max %d)", imax); + fprintf (stderr, "\n"); +} + +/* Report an error. */ + +static void +nlmheader_error (const char *s) +{ + nlmheader_warn (s, -1); + ++parse_errors; +} + +/* Add a string to a string list. */ + +static struct string_list * +string_list_cons (char *s, struct string_list *l) +{ + struct string_list *ret; + + ret = (struct string_list *) xmalloc (sizeof (struct string_list)); + ret->next = l; + ret->string = s; + return ret; +} + +/* Append a string list to another string list. */ + +static struct string_list * +string_list_append (struct string_list *l1, struct string_list *l2) +{ + register struct string_list **pp; + + for (pp = &l1; *pp != NULL; pp = &(*pp)->next) + ; + *pp = l2; + return l1; +} + +/* Append a string to a string list. */ + +static struct string_list * +string_list_append1 (struct string_list *l, char *s) +{ + struct string_list *n; + register struct string_list **pp; + + n = (struct string_list *) xmalloc (sizeof (struct string_list)); + n->next = NULL; + n->string = s; + for (pp = &l; *pp != NULL; pp = &(*pp)->next) + ; + *pp = n; + return l; +} + +/* Duplicate a string in memory. */ + +static char * +xstrdup (const char *s) +{ + unsigned long len; + char *ret; + + len = strlen (s); + ret = xmalloc (len + 1); + strcpy (ret, s); + return ret; +} diff --git a/support/sdbinutils/binutils/nlmheader.h b/support/sdbinutils/binutils/nlmheader.h new file mode 100644 index 0000000..6fe2403 --- /dev/null +++ b/support/sdbinutils/binutils/nlmheader.h @@ -0,0 +1,145 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef YY_YY_NLMHEADER_H_INCLUDED +# define YY_YY_NLMHEADER_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + CHECK = 258, + CODESTART = 259, + COPYRIGHT = 260, + CUSTOM = 261, + DATE = 262, + DEBUG_K = 263, + DESCRIPTION = 264, + EXIT = 265, + EXPORT = 266, + FLAG_ON = 267, + FLAG_OFF = 268, + FULLMAP = 269, + HELP = 270, + IMPORT = 271, + INPUT = 272, + MAP = 273, + MESSAGES = 274, + MODULE = 275, + MULTIPLE = 276, + OS_DOMAIN = 277, + OUTPUT = 278, + PSEUDOPREEMPTION = 279, + REENTRANT = 280, + SCREENNAME = 281, + SHARELIB = 282, + STACK = 283, + START = 284, + SYNCHRONIZE = 285, + THREADNAME = 286, + TYPE = 287, + VERBOSE = 288, + VERSIONK = 289, + XDCDATA = 290, + STRING = 291, + QUOTED_STRING = 292 + }; +#endif +/* Tokens. */ +#define CHECK 258 +#define CODESTART 259 +#define COPYRIGHT 260 +#define CUSTOM 261 +#define DATE 262 +#define DEBUG_K 263 +#define DESCRIPTION 264 +#define EXIT 265 +#define EXPORT 266 +#define FLAG_ON 267 +#define FLAG_OFF 268 +#define FULLMAP 269 +#define HELP 270 +#define IMPORT 271 +#define INPUT 272 +#define MAP 273 +#define MESSAGES 274 +#define MODULE 275 +#define MULTIPLE 276 +#define OS_DOMAIN 277 +#define OUTPUT 278 +#define PSEUDOPREEMPTION 279 +#define REENTRANT 280 +#define SCREENNAME 281 +#define SHARELIB 282 +#define STACK 283 +#define START 284 +#define SYNCHRONIZE 285 +#define THREADNAME 286 +#define TYPE 287 +#define VERBOSE 288 +#define VERSIONK 289 +#define XDCDATA 290 +#define STRING 291 +#define QUOTED_STRING 292 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 112 "nlmheader.y" /* yacc.c:1909 */ + + char *string; + struct string_list *list; + +#line 133 "nlmheader.h" /* yacc.c:1909 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_NLMHEADER_H_INCLUDED */ diff --git a/support/sdbinutils/binutils/nlmheader.y b/support/sdbinutils/binutils/nlmheader.y new file mode 100644 index 0000000..1bf01e0 --- /dev/null +++ b/support/sdbinutils/binutils/nlmheader.y @@ -0,0 +1,959 @@ +%{/* nlmheader.y - parse NLM header specification keywords. + Copyright (C) 1993-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +/* Written by Ian Lance Taylor . + + This bison file parses the commands recognized by the NetWare NLM + linker, except for lists of object files. It stores the + information in global variables. + + This implementation is based on the description in the NetWare Tool + Maker Specification manual, edition 1.0. */ + +#include "sysdep.h" +#include "safe-ctype.h" +#include "bfd.h" +#include "nlm/common.h" +#include "nlm/internal.h" +#include "bucomm.h" +#include "nlmconv.h" + +/* Information is stored in the structures pointed to by these + variables. */ + +Nlm_Internal_Fixed_Header *fixed_hdr; +Nlm_Internal_Variable_Header *var_hdr; +Nlm_Internal_Version_Header *version_hdr; +Nlm_Internal_Copyright_Header *copyright_hdr; +Nlm_Internal_Extended_Header *extended_hdr; + +/* Procedure named by CHECK. */ +char *check_procedure; +/* File named by CUSTOM. */ +char *custom_file; +/* Whether to generate debugging information (DEBUG). */ +bfd_boolean debug_info; +/* Procedure named by EXIT. */ +char *exit_procedure; +/* Exported symbols (EXPORT). */ +struct string_list *export_symbols; +/* List of files from INPUT. */ +struct string_list *input_files; +/* Map file name (MAP, FULLMAP). */ +char *map_file; +/* Whether a full map has been requested (FULLMAP). */ +bfd_boolean full_map; +/* File named by HELP. */ +char *help_file; +/* Imported symbols (IMPORT). */ +struct string_list *import_symbols; +/* File named by MESSAGES. */ +char *message_file; +/* Autoload module list (MODULE). */ +struct string_list *modules; +/* File named by OUTPUT. */ +char *output_file; +/* File named by SHARELIB. */ +char *sharelib_file; +/* Start procedure name (START). */ +char *start_procedure; +/* VERBOSE. */ +bfd_boolean verbose; +/* RPC description file (XDCDATA). */ +char *rpc_file; + +/* The number of serious errors that have occurred. */ +int parse_errors; + +/* The current symbol prefix when reading a list of import or export + symbols. */ +static char *symbol_prefix; + +/* Parser error message handler. */ +#define yyerror(msg) nlmheader_error (msg); + +/* Local functions. */ +static int yylex (void); +static void nlmlex_file_push (const char *); +static bfd_boolean nlmlex_file_open (const char *); +static int nlmlex_buf_init (void); +static char nlmlex_buf_add (int); +static long nlmlex_get_number (const char *); +static void nlmheader_identify (void); +static void nlmheader_warn (const char *, int); +static void nlmheader_error (const char *); +static struct string_list * string_list_cons (char *, struct string_list *); +static struct string_list * string_list_append (struct string_list *, + struct string_list *); +static struct string_list * string_list_append1 (struct string_list *, + char *); +static char *xstrdup (const char *); + +%} + +%union +{ + char *string; + struct string_list *list; +}; + +/* The reserved words. */ + +%token CHECK CODESTART COPYRIGHT CUSTOM DATE DEBUG_K DESCRIPTION EXIT +%token EXPORT FLAG_ON FLAG_OFF FULLMAP HELP IMPORT INPUT MAP MESSAGES +%token MODULE MULTIPLE OS_DOMAIN OUTPUT PSEUDOPREEMPTION REENTRANT +%token SCREENNAME SHARELIB STACK START SYNCHRONIZE +%token THREADNAME TYPE VERBOSE VERSIONK XDCDATA + +/* Arguments. */ + +%token STRING +%token QUOTED_STRING + +/* Typed non-terminals. */ +%type symbol_list_opt symbol_list string_list +%type symbol + +%% + +/* Keywords must start in the leftmost column of the file. Arguments + may appear anywhere else. The lexer uses this to determine what + token to return, so we don't have to worry about it here. */ + +/* The entire file is just a list of commands. */ + +file: + commands + ; + +/* A possibly empty list of commands. */ + +commands: + /* May be empty. */ + | command commands + ; + +/* A single command. There is where most of the work takes place. */ + +command: + CHECK STRING + { + check_procedure = $2; + } + | CODESTART STRING + { + nlmheader_warn (_("CODESTART is not implemented; sorry"), -1); + free ($2); + } + | COPYRIGHT QUOTED_STRING + { + int len; + + strncpy (copyright_hdr->stamp, "CoPyRiGhT=", 10); + len = strlen ($2); + if (len >= NLM_MAX_COPYRIGHT_MESSAGE_LENGTH) + { + nlmheader_warn (_("copyright string is too long"), + NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1); + len = NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1; + } + copyright_hdr->copyrightMessageLength = len; + strncpy (copyright_hdr->copyrightMessage, $2, len); + copyright_hdr->copyrightMessage[len] = '\0'; + free ($2); + } + | CUSTOM STRING + { + custom_file = $2; + } + | DATE STRING STRING STRING + { + /* We don't set the version stamp here, because we use the + version stamp to detect whether the required VERSION + keyword was given. */ + version_hdr->month = nlmlex_get_number ($2); + version_hdr->day = nlmlex_get_number ($3); + version_hdr->year = nlmlex_get_number ($4); + free ($2); + free ($3); + free ($4); + if (version_hdr->month < 1 || version_hdr->month > 12) + nlmheader_warn (_("illegal month"), -1); + if (version_hdr->day < 1 || version_hdr->day > 31) + nlmheader_warn (_("illegal day"), -1); + if (version_hdr->year < 1900 || version_hdr->year > 3000) + nlmheader_warn (_("illegal year"), -1); + } + | DEBUG_K + { + debug_info = TRUE; + } + | DESCRIPTION QUOTED_STRING + { + int len; + + len = strlen ($2); + if (len > NLM_MAX_DESCRIPTION_LENGTH) + { + nlmheader_warn (_("description string is too long"), + NLM_MAX_DESCRIPTION_LENGTH); + len = NLM_MAX_DESCRIPTION_LENGTH; + } + var_hdr->descriptionLength = len; + strncpy (var_hdr->descriptionText, $2, len); + var_hdr->descriptionText[len] = '\0'; + free ($2); + } + | EXIT STRING + { + exit_procedure = $2; + } + | EXPORT + { + symbol_prefix = NULL; + } + symbol_list_opt + { + export_symbols = string_list_append (export_symbols, $3); + } + | FLAG_ON STRING + { + fixed_hdr->flags |= nlmlex_get_number ($2); + free ($2); + } + | FLAG_OFF STRING + { + fixed_hdr->flags &=~ nlmlex_get_number ($2); + free ($2); + } + | FULLMAP + { + map_file = ""; + full_map = TRUE; + } + | FULLMAP STRING + { + map_file = $2; + full_map = TRUE; + } + | HELP STRING + { + help_file = $2; + } + | IMPORT + { + symbol_prefix = NULL; + } + symbol_list_opt + { + import_symbols = string_list_append (import_symbols, $3); + } + | INPUT string_list + { + input_files = string_list_append (input_files, $2); + } + | MAP + { + map_file = ""; + } + | MAP STRING + { + map_file = $2; + } + | MESSAGES STRING + { + message_file = $2; + } + | MODULE string_list + { + modules = string_list_append (modules, $2); + } + | MULTIPLE + { + fixed_hdr->flags |= 0x2; + } + | OS_DOMAIN + { + fixed_hdr->flags |= 0x10; + } + | OUTPUT STRING + { + if (output_file == NULL) + output_file = $2; + else + nlmheader_warn (_("ignoring duplicate OUTPUT statement"), -1); + } + | PSEUDOPREEMPTION + { + fixed_hdr->flags |= 0x8; + } + | REENTRANT + { + fixed_hdr->flags |= 0x1; + } + | SCREENNAME QUOTED_STRING + { + int len; + + len = strlen ($2); + if (len >= NLM_MAX_SCREEN_NAME_LENGTH) + { + nlmheader_warn (_("screen name is too long"), + NLM_MAX_SCREEN_NAME_LENGTH); + len = NLM_MAX_SCREEN_NAME_LENGTH; + } + var_hdr->screenNameLength = len; + strncpy (var_hdr->screenName, $2, len); + var_hdr->screenName[NLM_MAX_SCREEN_NAME_LENGTH] = '\0'; + free ($2); + } + | SHARELIB STRING + { + sharelib_file = $2; + } + | STACK STRING + { + var_hdr->stackSize = nlmlex_get_number ($2); + free ($2); + } + | START STRING + { + start_procedure = $2; + } + | SYNCHRONIZE + { + fixed_hdr->flags |= 0x4; + } + | THREADNAME QUOTED_STRING + { + int len; + + len = strlen ($2); + if (len >= NLM_MAX_THREAD_NAME_LENGTH) + { + nlmheader_warn (_("thread name is too long"), + NLM_MAX_THREAD_NAME_LENGTH); + len = NLM_MAX_THREAD_NAME_LENGTH; + } + var_hdr->threadNameLength = len; + strncpy (var_hdr->threadName, $2, len); + var_hdr->threadName[len] = '\0'; + free ($2); + } + | TYPE STRING + { + fixed_hdr->moduleType = nlmlex_get_number ($2); + free ($2); + } + | VERBOSE + { + verbose = TRUE; + } + | VERSIONK STRING STRING STRING + { + long val; + + strncpy (version_hdr->stamp, "VeRsIoN#", 8); + version_hdr->majorVersion = nlmlex_get_number ($2); + val = nlmlex_get_number ($3); + if (val < 0 || val > 99) + nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"), + -1); + else + version_hdr->minorVersion = val; + val = nlmlex_get_number ($4); + if (val < 0) + nlmheader_warn (_("illegal revision number (must be between 0 and 26)"), + -1); + else if (val > 26) + version_hdr->revision = 0; + else + version_hdr->revision = val; + free ($2); + free ($3); + free ($4); + } + | VERSIONK STRING STRING + { + long val; + + strncpy (version_hdr->stamp, "VeRsIoN#", 8); + version_hdr->majorVersion = nlmlex_get_number ($2); + val = nlmlex_get_number ($3); + if (val < 0 || val > 99) + nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"), + -1); + else + version_hdr->minorVersion = val; + version_hdr->revision = 0; + free ($2); + free ($3); + } + | XDCDATA STRING + { + rpc_file = $2; + } + ; + +/* A possibly empty list of symbols. */ + +symbol_list_opt: + /* Empty. */ + { + $$ = NULL; + } + | symbol_list + { + $$ = $1; + } + ; + +/* A list of symbols in an import or export list. Prefixes may appear + in parentheses. We need to use left recursion here to avoid + building up a large import list on the parser stack. */ + +symbol_list: + symbol + { + $$ = string_list_cons ($1, NULL); + } + | symbol_prefix + { + $$ = NULL; + } + | symbol_list symbol + { + $$ = string_list_append1 ($1, $2); + } + | symbol_list symbol_prefix + { + $$ = $1; + } + ; + +/* A prefix for subsequent symbols. */ + +symbol_prefix: + '(' STRING ')' + { + if (symbol_prefix != NULL) + free (symbol_prefix); + symbol_prefix = $2; + } + ; + +/* A single symbol. */ + +symbol: + STRING + { + if (symbol_prefix == NULL) + $$ = $1; + else + { + $$ = xmalloc (strlen (symbol_prefix) + strlen ($1) + 2); + sprintf ($$, "%s@%s", symbol_prefix, $1); + free ($1); + } + } + ; + +/* A list of strings. */ + +string_list: + /* May be empty. */ + { + $$ = NULL; + } + | STRING string_list + { + $$ = string_list_cons ($1, $2); + } + ; + +%% + +/* If strerror is just a macro, we want to use the one from libiberty + since it will handle undefined values. */ +#undef strerror +extern char *strerror (int); + +/* The lexer is simple, too simple for flex. Keywords are only + recognized at the start of lines. Everything else must be an + argument. A comma is treated as whitespace. */ + +/* The states the lexer can be in. */ + +enum lex_state +{ + /* At the beginning of a line. */ + BEGINNING_OF_LINE, + /* In the middle of a line. */ + IN_LINE +}; + +/* We need to keep a stack of files to handle file inclusion. */ + +struct input +{ + /* The file to read from. */ + FILE *file; + /* The name of the file. */ + char *name; + /* The current line number. */ + int lineno; + /* The current state. */ + enum lex_state state; + /* The next file on the stack. */ + struct input *next; +}; + +/* The current input file. */ + +static struct input current; + +/* The character which introduces comments. */ +#define COMMENT_CHAR '#' + +/* Start the lexer going on the main input file. */ + +bfd_boolean +nlmlex_file (const char *name) +{ + current.next = NULL; + return nlmlex_file_open (name); +} + +/* Start the lexer going on a subsidiary input file. */ + +static void +nlmlex_file_push (const char *name) +{ + struct input *push; + + push = (struct input *) xmalloc (sizeof (struct input)); + *push = current; + if (nlmlex_file_open (name)) + current.next = push; + else + { + current = *push; + free (push); + } +} + +/* Start lexing from a file. */ + +static bfd_boolean +nlmlex_file_open (const char *name) +{ + current.file = fopen (name, "r"); + if (current.file == NULL) + { + fprintf (stderr, "%s:%s: %s\n", program_name, name, strerror (errno)); + ++parse_errors; + return FALSE; + } + current.name = xstrdup (name); + current.lineno = 1; + current.state = BEGINNING_OF_LINE; + return TRUE; +} + +/* Table used to turn keywords into tokens. */ + +struct keyword_tokens_struct +{ + const char *keyword; + int token; +}; + +static struct keyword_tokens_struct keyword_tokens[] = +{ + { "CHECK", CHECK }, + { "CODESTART", CODESTART }, + { "COPYRIGHT", COPYRIGHT }, + { "CUSTOM", CUSTOM }, + { "DATE", DATE }, + { "DEBUG", DEBUG_K }, + { "DESCRIPTION", DESCRIPTION }, + { "EXIT", EXIT }, + { "EXPORT", EXPORT }, + { "FLAG_ON", FLAG_ON }, + { "FLAG_OFF", FLAG_OFF }, + { "FULLMAP", FULLMAP }, + { "HELP", HELP }, + { "IMPORT", IMPORT }, + { "INPUT", INPUT }, + { "MAP", MAP }, + { "MESSAGES", MESSAGES }, + { "MODULE", MODULE }, + { "MULTIPLE", MULTIPLE }, + { "OS_DOMAIN", OS_DOMAIN }, + { "OUTPUT", OUTPUT }, + { "PSEUDOPREEMPTION", PSEUDOPREEMPTION }, + { "REENTRANT", REENTRANT }, + { "SCREENNAME", SCREENNAME }, + { "SHARELIB", SHARELIB }, + { "STACK", STACK }, + { "STACKSIZE", STACK }, + { "START", START }, + { "SYNCHRONIZE", SYNCHRONIZE }, + { "THREADNAME", THREADNAME }, + { "TYPE", TYPE }, + { "VERBOSE", VERBOSE }, + { "VERSION", VERSIONK }, + { "XDCDATA", XDCDATA } +}; + +#define KEYWORD_COUNT (sizeof (keyword_tokens) / sizeof (keyword_tokens[0])) + +/* The lexer accumulates strings in these variables. */ +static char *lex_buf; +static int lex_size; +static int lex_pos; + +/* Start accumulating strings into the buffer. */ +#define BUF_INIT() \ + ((void) (lex_buf != NULL ? lex_pos = 0 : nlmlex_buf_init ())) + +static int +nlmlex_buf_init (void) +{ + lex_size = 10; + lex_buf = xmalloc (lex_size + 1); + lex_pos = 0; + return 0; +} + +/* Finish a string in the buffer. */ +#define BUF_FINISH() ((void) (lex_buf[lex_pos] = '\0')) + +/* Accumulate a character into the buffer. */ +#define BUF_ADD(c) \ + ((void) (lex_pos < lex_size \ + ? lex_buf[lex_pos++] = (c) \ + : nlmlex_buf_add (c))) + +static char +nlmlex_buf_add (int c) +{ + if (lex_pos >= lex_size) + { + lex_size *= 2; + lex_buf = xrealloc (lex_buf, lex_size + 1); + } + + return lex_buf[lex_pos++] = c; +} + +/* The lexer proper. This is called by the bison generated parsing + code. */ + +static int +yylex (void) +{ + int c; + +tail_recurse: + + c = getc (current.file); + + /* Commas are treated as whitespace characters. */ + while (ISSPACE (c) || c == ',') + { + current.state = IN_LINE; + if (c == '\n') + { + ++current.lineno; + current.state = BEGINNING_OF_LINE; + } + c = getc (current.file); + } + + /* At the end of the file we either pop to the previous file or + finish up. */ + if (c == EOF) + { + fclose (current.file); + free (current.name); + if (current.next == NULL) + return 0; + else + { + struct input *next; + + next = current.next; + current = *next; + free (next); + goto tail_recurse; + } + } + + /* A comment character always means to drop everything until the + next newline. */ + if (c == COMMENT_CHAR) + { + do + { + c = getc (current.file); + } + while (c != '\n'); + ++current.lineno; + current.state = BEGINNING_OF_LINE; + goto tail_recurse; + } + + /* An '@' introduces an include file. */ + if (c == '@') + { + do + { + c = getc (current.file); + if (c == '\n') + ++current.lineno; + } + while (ISSPACE (c)); + BUF_INIT (); + while (! ISSPACE (c) && c != EOF) + { + BUF_ADD (c); + c = getc (current.file); + } + BUF_FINISH (); + + ungetc (c, current.file); + + nlmlex_file_push (lex_buf); + goto tail_recurse; + } + + /* A non-space character at the start of a line must be the start of + a keyword. */ + if (current.state == BEGINNING_OF_LINE) + { + BUF_INIT (); + while (ISALNUM (c) || c == '_') + { + BUF_ADD (TOUPPER (c)); + c = getc (current.file); + } + BUF_FINISH (); + + if (c != EOF && ! ISSPACE (c) && c != ',') + { + nlmheader_identify (); + fprintf (stderr, _("%s:%d: illegal character in keyword: %c\n"), + current.name, current.lineno, c); + } + else + { + unsigned int i; + + for (i = 0; i < KEYWORD_COUNT; i++) + { + if (lex_buf[0] == keyword_tokens[i].keyword[0] + && strcmp (lex_buf, keyword_tokens[i].keyword) == 0) + { + /* Pushing back the final whitespace avoids worrying + about \n here. */ + ungetc (c, current.file); + current.state = IN_LINE; + return keyword_tokens[i].token; + } + } + + nlmheader_identify (); + fprintf (stderr, _("%s:%d: unrecognized keyword: %s\n"), + current.name, current.lineno, lex_buf); + } + + ++parse_errors; + /* Treat the rest of this line as a comment. */ + ungetc (COMMENT_CHAR, current.file); + goto tail_recurse; + } + + /* Parentheses just represent themselves. */ + if (c == '(' || c == ')') + return c; + + /* Handle quoted strings. */ + if (c == '"' || c == '\'') + { + int quote; + int start_lineno; + + quote = c; + start_lineno = current.lineno; + + c = getc (current.file); + BUF_INIT (); + while (c != quote && c != EOF) + { + BUF_ADD (c); + if (c == '\n') + ++current.lineno; + c = getc (current.file); + } + BUF_FINISH (); + + if (c == EOF) + { + nlmheader_identify (); + fprintf (stderr, _("%s:%d: end of file in quoted string\n"), + current.name, start_lineno); + ++parse_errors; + } + + /* FIXME: Possible memory leak. */ + yylval.string = xstrdup (lex_buf); + return QUOTED_STRING; + } + + /* Gather a generic argument. */ + BUF_INIT (); + while (! ISSPACE (c) + && c != ',' + && c != COMMENT_CHAR + && c != '(' + && c != ')') + { + BUF_ADD (c); + c = getc (current.file); + } + BUF_FINISH (); + + ungetc (c, current.file); + + /* FIXME: Possible memory leak. */ + yylval.string = xstrdup (lex_buf); + return STRING; +} + +/* Get a number from a string. */ + +static long +nlmlex_get_number (const char *s) +{ + long ret; + char *send; + + ret = strtol (s, &send, 10); + if (*send != '\0') + nlmheader_warn (_("bad number"), -1); + return ret; +} + +/* Prefix the nlmconv warnings with a note as to where they come from. + We don't use program_name on every warning, because then some + versions of the emacs next-error function can't recognize the line + number. */ + +static void +nlmheader_identify (void) +{ + static int done; + + if (! done) + { + fprintf (stderr, _("%s: problems in NLM command language input:\n"), + program_name); + done = 1; + } +} + +/* Issue a warning. */ + +static void +nlmheader_warn (const char *s, int imax) +{ + nlmheader_identify (); + fprintf (stderr, "%s:%d: %s", current.name, current.lineno, s); + if (imax != -1) + fprintf (stderr, " (max %d)", imax); + fprintf (stderr, "\n"); +} + +/* Report an error. */ + +static void +nlmheader_error (const char *s) +{ + nlmheader_warn (s, -1); + ++parse_errors; +} + +/* Add a string to a string list. */ + +static struct string_list * +string_list_cons (char *s, struct string_list *l) +{ + struct string_list *ret; + + ret = (struct string_list *) xmalloc (sizeof (struct string_list)); + ret->next = l; + ret->string = s; + return ret; +} + +/* Append a string list to another string list. */ + +static struct string_list * +string_list_append (struct string_list *l1, struct string_list *l2) +{ + register struct string_list **pp; + + for (pp = &l1; *pp != NULL; pp = &(*pp)->next) + ; + *pp = l2; + return l1; +} + +/* Append a string to a string list. */ + +static struct string_list * +string_list_append1 (struct string_list *l, char *s) +{ + struct string_list *n; + register struct string_list **pp; + + n = (struct string_list *) xmalloc (sizeof (struct string_list)); + n->next = NULL; + n->string = s; + for (pp = &l; *pp != NULL; pp = &(*pp)->next) + ; + *pp = n; + return l; +} + +/* Duplicate a string in memory. */ + +static char * +xstrdup (const char *s) +{ + unsigned long len; + char *ret; + + len = strlen (s); + ret = xmalloc (len + 1); + strcpy (ret, s); + return ret; +} diff --git a/support/sdbinutils/binutils/nm.c b/support/sdbinutils/binutils/nm.c new file mode 100644 index 0000000..e46fffc --- /dev/null +++ b/support/sdbinutils/binutils/nm.c @@ -0,0 +1,1807 @@ +/* nm.c -- Describe symbol table of a rel file. + Copyright (C) 1991-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "sysdep.h" +#include "bfd.h" +#include "progress.h" +#include "getopt.h" +#include "aout/stab_gnu.h" +#include "aout/ranlib.h" +#include "demangle.h" +#include "libiberty.h" +#include "elf-bfd.h" +#include "elf/common.h" +#define DO_NOT_DEFINE_AOUTHDR +#define DO_NOT_DEFINE_FILHDR +#define DO_NOT_DEFINE_LINENO +#define DO_NOT_DEFINE_SCNHDR +#include "coff/external.h" +#include "coff/internal.h" +#include "libcoff.h" +#include "bucomm.h" +#include "plugin-api.h" +#include "plugin.h" + +/* When sorting by size, we use this structure to hold the size and a + pointer to the minisymbol. */ + +struct size_sym +{ + const void *minisym; + bfd_vma size; +}; + +/* When fetching relocs, we use this structure to pass information to + get_relocs. */ + +struct get_relocs_info +{ + asection **secs; + arelent ***relocs; + long *relcount; + asymbol **syms; +}; + +struct extended_symbol_info +{ + symbol_info *sinfo; + bfd_vma ssize; + elf_symbol_type *elfinfo; + coff_symbol_type *coffinfo; + /* FIXME: We should add more fields for Type, Line, Section. */ +}; +#define SYM_NAME(sym) (sym->sinfo->name) +#define SYM_VALUE(sym) (sym->sinfo->value) +#define SYM_TYPE(sym) (sym->sinfo->type) +#define SYM_STAB_NAME(sym) (sym->sinfo->stab_name) +#define SYM_STAB_DESC(sym) (sym->sinfo->stab_desc) +#define SYM_STAB_OTHER(sym) (sym->sinfo->stab_other) +#define SYM_SIZE(sym) \ + (sym->elfinfo ? sym->elfinfo->internal_elf_sym.st_size: sym->ssize) + +/* The output formatting functions. */ +static void print_object_filename_bsd (char *); +static void print_object_filename_sysv (char *); +static void print_object_filename_posix (char *); +static void print_archive_filename_bsd (char *); +static void print_archive_filename_sysv (char *); +static void print_archive_filename_posix (char *); +static void print_archive_member_bsd (char *, const char *); +static void print_archive_member_sysv (char *, const char *); +static void print_archive_member_posix (char *, const char *); +static void print_symbol_filename_bsd (bfd *, bfd *); +static void print_symbol_filename_sysv (bfd *, bfd *); +static void print_symbol_filename_posix (bfd *, bfd *); +static void print_value (bfd *, bfd_vma); +static void print_symbol_info_bsd (struct extended_symbol_info *, bfd *); +static void print_symbol_info_sysv (struct extended_symbol_info *, bfd *); +static void print_symbol_info_posix (struct extended_symbol_info *, bfd *); + +/* Support for different output formats. */ +struct output_fns + { + /* Print the name of an object file given on the command line. */ + void (*print_object_filename) (char *); + + /* Print the name of an archive file given on the command line. */ + void (*print_archive_filename) (char *); + + /* Print the name of an archive member file. */ + void (*print_archive_member) (char *, const char *); + + /* Print the name of the file (and archive, if there is one) + containing a symbol. */ + void (*print_symbol_filename) (bfd *, bfd *); + + /* Print a line of information about a symbol. */ + void (*print_symbol_info) (struct extended_symbol_info *, bfd *); + }; + +static struct output_fns formats[] = +{ + {print_object_filename_bsd, + print_archive_filename_bsd, + print_archive_member_bsd, + print_symbol_filename_bsd, + print_symbol_info_bsd}, + {print_object_filename_sysv, + print_archive_filename_sysv, + print_archive_member_sysv, + print_symbol_filename_sysv, + print_symbol_info_sysv}, + {print_object_filename_posix, + print_archive_filename_posix, + print_archive_member_posix, + print_symbol_filename_posix, + print_symbol_info_posix} +}; + +/* Indices in `formats'. */ +#define FORMAT_BSD 0 +#define FORMAT_SYSV 1 +#define FORMAT_POSIX 2 +#define FORMAT_DEFAULT FORMAT_BSD + +/* The output format to use. */ +static struct output_fns *format = &formats[FORMAT_DEFAULT]; + +/* Command options. */ + +static int do_demangle = 0; /* Pretty print C++ symbol names. */ +static int external_only = 0; /* Print external symbols only. */ +static int defined_only = 0; /* Print defined symbols only. */ +static int no_sort = 0; /* Don't sort; print syms in order found. */ +static int print_debug_syms = 0;/* Print debugger-only symbols too. */ +static int print_armap = 0; /* Describe __.SYMDEF data in archive files. */ +static int print_size = 0; /* Print size of defined symbols. */ +static int reverse_sort = 0; /* Sort in downward(alpha or numeric) order. */ +static int sort_numerically = 0;/* Sort in numeric rather than alpha order. */ +static int sort_by_size = 0; /* Sort by size of symbol. */ +static int undefined_only = 0; /* Print undefined symbols only. */ +static int dynamic = 0; /* Print dynamic symbols. */ +static int show_version = 0; /* Show the version number. */ +static int show_synthetic = 0; /* Display synthesized symbols too. */ +static int line_numbers = 0; /* Print line numbers for symbols. */ +static int allow_special_symbols = 0; /* Allow special symbols. */ +static int with_symbol_versions = 0; /* Include symbol version information in the output. */ + +/* When to print the names of files. Not mutually exclusive in SYSV format. */ +static int filename_per_file = 0; /* Once per file, on its own line. */ +static int filename_per_symbol = 0; /* Once per symbol, at start of line. */ + +/* Print formats for printing a symbol value. */ +static char value_format_32bit[] = "%08lx"; +#if BFD_HOST_64BIT_LONG +static char value_format_64bit[] = "%016lx"; +#elif BFD_HOST_64BIT_LONG_LONG +#ifndef __MSVCRT__ +static char value_format_64bit[] = "%016llx"; +#else +static char value_format_64bit[] = "%016I64x"; +#endif +#endif +static int print_width = 0; +static int print_radix = 16; +/* Print formats for printing stab info. */ +static char other_format[] = "%02x"; +static char desc_format[] = "%04x"; + +static char *target = NULL; +#if BFD_SUPPORTS_PLUGINS +static const char *plugin_target = "plugin"; +#else +static const char *plugin_target = NULL; +#endif + +/* Used to cache the line numbers for a BFD. */ +static bfd *lineno_cache_bfd; +static bfd *lineno_cache_rel_bfd; + +#define OPTION_TARGET 200 +#define OPTION_PLUGIN (OPTION_TARGET + 1) +#define OPTION_SIZE_SORT (OPTION_PLUGIN + 1) + +static struct option long_options[] = +{ + {"debug-syms", no_argument, &print_debug_syms, 1}, + {"demangle", optional_argument, 0, 'C'}, + {"dynamic", no_argument, &dynamic, 1}, + {"extern-only", no_argument, &external_only, 1}, + {"format", required_argument, 0, 'f'}, + {"help", no_argument, 0, 'h'}, + {"line-numbers", no_argument, 0, 'l'}, + {"no-cplus", no_argument, &do_demangle, 0}, /* Linux compatibility. */ + {"no-demangle", no_argument, &do_demangle, 0}, + {"no-sort", no_argument, 0, 'p'}, + {"numeric-sort", no_argument, 0, 'n'}, + {"plugin", required_argument, 0, OPTION_PLUGIN}, + {"portability", no_argument, 0, 'P'}, + {"print-armap", no_argument, &print_armap, 1}, + {"print-file-name", no_argument, 0, 'o'}, + {"print-size", no_argument, 0, 'S'}, + {"radix", required_argument, 0, 't'}, + {"reverse-sort", no_argument, &reverse_sort, 1}, + {"size-sort", no_argument, 0, OPTION_SIZE_SORT}, + {"special-syms", no_argument, &allow_special_symbols, 1}, + {"synthetic", no_argument, &show_synthetic, 1}, + {"target", required_argument, 0, OPTION_TARGET}, + {"defined-only", no_argument, &defined_only, 1}, + {"undefined-only", no_argument, &undefined_only, 1}, + {"version", no_argument, &show_version, 1}, + {"with-symbol-versions", no_argument, &with_symbol_versions, 1}, + {0, no_argument, 0, 0} +}; + +/* Some error-reporting functions. */ + +ATTRIBUTE_NORETURN static void +usage (FILE *stream, int status) +{ + fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name); + fprintf (stream, _(" List symbols in [file(s)] (a.out by default).\n")); + fprintf (stream, _(" The options are:\n\ + -a, --debug-syms Display debugger-only symbols\n\ + -A, --print-file-name Print name of the input file before every symbol\n\ + -B Same as --format=bsd\n\ + -C, --demangle[=STYLE] Decode low-level symbol names into user-level names\n\ + The STYLE, if specified, can be `auto' (the default),\n\ + `gnu', `lucid', `arm', `hp', `edg', `gnu-v3', `java'\n\ + or `gnat'\n\ + --no-demangle Do not demangle low-level symbol names\n\ + -D, --dynamic Display dynamic symbols instead of normal symbols\n\ + --defined-only Display only defined symbols\n\ + -e (ignored)\n\ + -f, --format=FORMAT Use the output format FORMAT. FORMAT can be `bsd',\n\ + `sysv' or `posix'. The default is `bsd'\n\ + -g, --extern-only Display only external symbols\n\ + -l, --line-numbers Use debugging information to find a filename and\n\ + line number for each symbol\n\ + -n, --numeric-sort Sort symbols numerically by address\n\ + -o Same as -A\n\ + -p, --no-sort Do not sort the symbols\n\ + -P, --portability Same as --format=posix\n\ + -r, --reverse-sort Reverse the sense of the sort\n")); +#if BFD_SUPPORTS_PLUGINS + fprintf (stream, _("\ + --plugin NAME Load the specified plugin\n")); +#endif + fprintf (stream, _("\ + -S, --print-size Print size of defined symbols\n\ + -s, --print-armap Include index for symbols from archive members\n\ + --size-sort Sort symbols by size\n\ + --special-syms Include special symbols in the output\n\ + --synthetic Display synthetic symbols as well\n\ + -t, --radix=RADIX Use RADIX for printing symbol values\n\ + --target=BFDNAME Specify the target object format as BFDNAME\n\ + -u, --undefined-only Display only undefined symbols\n\ + --with-symbol-versions Display version strings after symbol names\n\ + -X 32_64 (ignored)\n\ + @FILE Read options from FILE\n\ + -h, --help Display this information\n\ + -V, --version Display this program's version number\n\ +\n")); + list_supported_targets (program_name, stream); + if (REPORT_BUGS_TO[0] && status == 0) + fprintf (stream, _("Report bugs to %s.\n"), REPORT_BUGS_TO); + exit (status); +} + +/* Set the radix for the symbol value and size according to RADIX. */ + +static void +set_print_radix (char *radix) +{ + switch (*radix) + { + case 'x': + break; + case 'd': + case 'o': + if (*radix == 'd') + print_radix = 10; + else + print_radix = 8; + value_format_32bit[4] = *radix; +#if BFD_HOST_64BIT_LONG + value_format_64bit[5] = *radix; +#elif BFD_HOST_64BIT_LONG_LONG +#ifndef __MSVCRT__ + value_format_64bit[6] = *radix; +#else + value_format_64bit[7] = *radix; +#endif +#endif + other_format[3] = desc_format[3] = *radix; + break; + default: + fatal (_("%s: invalid radix"), radix); + } +} + +static void +set_output_format (char *f) +{ + int i; + + switch (*f) + { + case 'b': + case 'B': + i = FORMAT_BSD; + break; + case 'p': + case 'P': + i = FORMAT_POSIX; + break; + case 's': + case 'S': + i = FORMAT_SYSV; + break; + default: + fatal (_("%s: invalid output format"), f); + } + format = &formats[i]; +} + +static const char * +get_elf_symbol_type (unsigned int type) +{ + static char *bufp; + int n; + + switch (type) + { + case STT_NOTYPE: return "NOTYPE"; + case STT_OBJECT: return "OBJECT"; + case STT_FUNC: return "FUNC"; + case STT_SECTION: return "SECTION"; + case STT_FILE: return "FILE"; + case STT_COMMON: return "COMMON"; + case STT_TLS: return "TLS"; + } + + free (bufp); + if (type >= STT_LOPROC && type <= STT_HIPROC) + n = asprintf (&bufp, _(": %d"), type); + else if (type >= STT_LOOS && type <= STT_HIOS) + n = asprintf (&bufp, _(": %d"), type); + else + n = asprintf (&bufp, _(": %d"), type); + if (n < 0) + fatal ("%s", xstrerror (errno)); + return bufp; +} + +static const char * +get_coff_symbol_type (const struct internal_syment *sym) +{ + static char *bufp; + int n; + + switch (sym->n_sclass) + { + case C_BLOCK: return "Block"; + case C_FILE: return "File"; + case C_LINE: return "Line"; + } + + if (!sym->n_type) + return "None"; + + switch (DTYPE(sym->n_type)) + { + case DT_FCN: return "Function"; + case DT_PTR: return "Pointer"; + case DT_ARY: return "Array"; + } + + free (bufp); + n = asprintf (&bufp, _(": %d/%d"), sym->n_sclass, sym->n_type); + if (n < 0) + fatal ("%s", xstrerror (errno)); + return bufp; +} + +/* Print symbol name NAME, read from ABFD, with printf format FORM, + demangling it if requested. */ + +static void +print_symname (const char *form, const char *name, bfd *abfd) +{ + if (do_demangle && *name) + { + char *res = bfd_demangle (abfd, name, DMGL_ANSI | DMGL_PARAMS); + + if (res != NULL) + { + printf (form, res); + free (res); + return; + } + } + + printf (form, name); +} + +static void +print_symdef_entry (bfd *abfd) +{ + symindex idx = BFD_NO_MORE_SYMBOLS; + carsym *thesym; + bfd_boolean everprinted = FALSE; + + for (idx = bfd_get_next_mapent (abfd, idx, &thesym); + idx != BFD_NO_MORE_SYMBOLS; + idx = bfd_get_next_mapent (abfd, idx, &thesym)) + { + bfd *elt; + if (!everprinted) + { + printf (_("\nArchive index:\n")); + everprinted = TRUE; + } + elt = bfd_get_elt_at_index (abfd, idx); + if (elt == NULL) + bfd_fatal ("bfd_get_elt_at_index"); + if (thesym->name != (char *) NULL) + { + print_symname ("%s", thesym->name, abfd); + printf (" in %s\n", bfd_get_filename (elt)); + } + } +} + +/* Choose which symbol entries to print; + compact them downward to get rid of the rest. + Return the number of symbols to be printed. */ + +static long +filter_symbols (bfd *abfd, bfd_boolean is_dynamic, void *minisyms, + long symcount, unsigned int size) +{ + bfd_byte *from, *fromend, *to; + asymbol *store; + + store = bfd_make_empty_symbol (abfd); + if (store == NULL) + bfd_fatal (bfd_get_filename (abfd)); + + from = (bfd_byte *) minisyms; + fromend = from + symcount * size; + to = (bfd_byte *) minisyms; + + for (; from < fromend; from += size) + { + int keep = 0; + asymbol *sym; + + PROGRESS (1); + + sym = bfd_minisymbol_to_symbol (abfd, is_dynamic, (const void *) from, store); + if (sym == NULL) + bfd_fatal (bfd_get_filename (abfd)); + + if (sym->name[0] == '_' + && sym->name[1] == '_' + && strcmp (sym->name + (sym->name[2] == '_'), "__gnu_lto_slim") == 0) + non_fatal (_("%s: plugin needed to handle lto object"), + bfd_get_filename (abfd)); + + if (undefined_only) + keep = bfd_is_und_section (sym->section); + else if (external_only) + /* PR binutls/12753: Unique symbols are global too. */ + keep = ((sym->flags & (BSF_GLOBAL + | BSF_WEAK + | BSF_GNU_UNIQUE)) != 0 + || bfd_is_und_section (sym->section) + || bfd_is_com_section (sym->section)); + else + keep = 1; + + if (keep + && ! print_debug_syms + && (sym->flags & BSF_DEBUGGING) != 0) + keep = 0; + + if (keep + && sort_by_size + && (bfd_is_abs_section (sym->section) + || bfd_is_und_section (sym->section))) + keep = 0; + + if (keep + && defined_only) + { + if (bfd_is_und_section (sym->section)) + keep = 0; + } + + if (keep + && bfd_is_target_special_symbol (abfd, sym) + && ! allow_special_symbols) + keep = 0; + + if (keep) + { + if (to != from) + memcpy (to, from, size); + to += size; + } + } + + return (to - (bfd_byte *) minisyms) / size; +} + +/* These globals are used to pass information into the sorting + routines. */ +static bfd *sort_bfd; +static bfd_boolean sort_dynamic; +static asymbol *sort_x; +static asymbol *sort_y; + +/* Symbol-sorting predicates */ +#define valueof(x) ((x)->section->vma + (x)->value) + +/* Numeric sorts. Undefined symbols are always considered "less than" + defined symbols with zero values. Common symbols are not treated + specially -- i.e., their sizes are used as their "values". */ + +static int +non_numeric_forward (const void *P_x, const void *P_y) +{ + asymbol *x, *y; + const char *xn, *yn; + + x = bfd_minisymbol_to_symbol (sort_bfd, sort_dynamic, P_x, sort_x); + y = bfd_minisymbol_to_symbol (sort_bfd, sort_dynamic, P_y, sort_y); + if (x == NULL || y == NULL) + bfd_fatal (bfd_get_filename (sort_bfd)); + + xn = bfd_asymbol_name (x); + yn = bfd_asymbol_name (y); + + if (yn == NULL) + return xn != NULL; + if (xn == NULL) + return -1; + +#ifdef HAVE_STRCOLL + /* Solaris 2.5 has a bug in strcoll. + strcoll returns invalid values when confronted with empty strings. */ + if (*yn == '\0') + return *xn != '\0'; + if (*xn == '\0') + return -1; + + return strcoll (xn, yn); +#else + return strcmp (xn, yn); +#endif +} + +static int +non_numeric_reverse (const void *x, const void *y) +{ + return - non_numeric_forward (x, y); +} + +static int +numeric_forward (const void *P_x, const void *P_y) +{ + asymbol *x, *y; + asection *xs, *ys; + + x = bfd_minisymbol_to_symbol (sort_bfd, sort_dynamic, P_x, sort_x); + y = bfd_minisymbol_to_symbol (sort_bfd, sort_dynamic, P_y, sort_y); + if (x == NULL || y == NULL) + bfd_fatal (bfd_get_filename (sort_bfd)); + + xs = bfd_get_section (x); + ys = bfd_get_section (y); + + if (bfd_is_und_section (xs)) + { + if (! bfd_is_und_section (ys)) + return -1; + } + else if (bfd_is_und_section (ys)) + return 1; + else if (valueof (x) != valueof (y)) + return valueof (x) < valueof (y) ? -1 : 1; + + return non_numeric_forward (P_x, P_y); +} + +static int +numeric_reverse (const void *x, const void *y) +{ + return - numeric_forward (x, y); +} + +static int (*(sorters[2][2])) (const void *, const void *) = +{ + { non_numeric_forward, non_numeric_reverse }, + { numeric_forward, numeric_reverse } +}; + +/* This sort routine is used by sort_symbols_by_size. It is similar + to numeric_forward, but when symbols have the same value it sorts + by section VMA. This simplifies the sort_symbols_by_size code + which handles symbols at the end of sections. Also, this routine + tries to sort file names before other symbols with the same value. + That will make the file name have a zero size, which will make + sort_symbols_by_size choose the non file name symbol, leading to + more meaningful output. For similar reasons, this code sorts + gnu_compiled_* and gcc2_compiled before other symbols with the same + value. */ + +static int +size_forward1 (const void *P_x, const void *P_y) +{ + asymbol *x, *y; + asection *xs, *ys; + const char *xn, *yn; + size_t xnl, ynl; + int xf, yf; + + x = bfd_minisymbol_to_symbol (sort_bfd, sort_dynamic, P_x, sort_x); + y = bfd_minisymbol_to_symbol (sort_bfd, sort_dynamic, P_y, sort_y); + if (x == NULL || y == NULL) + bfd_fatal (bfd_get_filename (sort_bfd)); + + xs = bfd_get_section (x); + ys = bfd_get_section (y); + + if (bfd_is_und_section (xs)) + abort (); + if (bfd_is_und_section (ys)) + abort (); + + if (valueof (x) != valueof (y)) + return valueof (x) < valueof (y) ? -1 : 1; + + if (xs->vma != ys->vma) + return xs->vma < ys->vma ? -1 : 1; + + xn = bfd_asymbol_name (x); + yn = bfd_asymbol_name (y); + xnl = strlen (xn); + ynl = strlen (yn); + + /* The symbols gnu_compiled and gcc2_compiled convey even less + information than the file name, so sort them out first. */ + + xf = (strstr (xn, "gnu_compiled") != NULL + || strstr (xn, "gcc2_compiled") != NULL); + yf = (strstr (yn, "gnu_compiled") != NULL + || strstr (yn, "gcc2_compiled") != NULL); + + if (xf && ! yf) + return -1; + if (! xf && yf) + return 1; + + /* We use a heuristic for the file name. It may not work on non + Unix systems, but it doesn't really matter; the only difference + is precisely which symbol names get printed. */ + +#define file_symbol(s, sn, snl) \ + (((s)->flags & BSF_FILE) != 0 \ + || ((snl) > 2 \ + && (sn)[(snl) - 2] == '.' \ + && ((sn)[(snl) - 1] == 'o' \ + || (sn)[(snl) - 1] == 'a'))) + + xf = file_symbol (x, xn, xnl); + yf = file_symbol (y, yn, ynl); + + if (xf && ! yf) + return -1; + if (! xf && yf) + return 1; + + return non_numeric_forward (P_x, P_y); +} + +/* This sort routine is used by sort_symbols_by_size. It is sorting + an array of size_sym structures into size order. */ + +static int +size_forward2 (const void *P_x, const void *P_y) +{ + const struct size_sym *x = (const struct size_sym *) P_x; + const struct size_sym *y = (const struct size_sym *) P_y; + + if (x->size < y->size) + return reverse_sort ? 1 : -1; + else if (x->size > y->size) + return reverse_sort ? -1 : 1; + else + return sorters[0][reverse_sort] (x->minisym, y->minisym); +} + +/* Sort the symbols by size. ELF provides a size but for other formats + we have to make a guess by assuming that the difference between the + address of a symbol and the address of the next higher symbol is the + size. */ + +static long +sort_symbols_by_size (bfd *abfd, bfd_boolean is_dynamic, void *minisyms, + long symcount, unsigned int size, + struct size_sym **symsizesp) +{ + struct size_sym *symsizes; + bfd_byte *from, *fromend; + asymbol *sym = NULL; + asymbol *store_sym, *store_next; + + qsort (minisyms, symcount, size, size_forward1); + + /* We are going to return a special set of symbols and sizes to + print. */ + symsizes = (struct size_sym *) xmalloc (symcount * sizeof (struct size_sym)); + *symsizesp = symsizes; + + /* Note that filter_symbols has already removed all absolute and + undefined symbols. Here we remove all symbols whose size winds + up as zero. */ + from = (bfd_byte *) minisyms; + fromend = from + symcount * size; + + store_sym = sort_x; + store_next = sort_y; + + if (from < fromend) + { + sym = bfd_minisymbol_to_symbol (abfd, is_dynamic, (const void *) from, + store_sym); + if (sym == NULL) + bfd_fatal (bfd_get_filename (abfd)); + } + + for (; from < fromend; from += size) + { + asymbol *next; + asection *sec; + bfd_vma sz; + asymbol *temp; + + if (from + size < fromend) + { + next = bfd_minisymbol_to_symbol (abfd, + is_dynamic, + (const void *) (from + size), + store_next); + if (next == NULL) + bfd_fatal (bfd_get_filename (abfd)); + } + else + next = NULL; + + sec = bfd_get_section (sym); + + /* Synthetic symbols don't have a full type set of data available, thus + we can't rely on that information for the symbol size. Ditto for + bfd/section.c:global_syms like *ABS*. */ + if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0 + && bfd_get_flavour (abfd) == bfd_target_elf_flavour) + sz = ((elf_symbol_type *) sym)->internal_elf_sym.st_size; + else if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0 + && bfd_is_com_section (sec)) + sz = sym->value; + else + { + if (from + size < fromend + && sec == bfd_get_section (next)) + sz = valueof (next) - valueof (sym); + else + sz = (bfd_get_section_vma (abfd, sec) + + bfd_section_size (abfd, sec) + - valueof (sym)); + } + + if (sz != 0) + { + symsizes->minisym = (const void *) from; + symsizes->size = sz; + ++symsizes; + } + + sym = next; + + temp = store_sym; + store_sym = store_next; + store_next = temp; + } + + symcount = symsizes - *symsizesp; + + /* We must now sort again by size. */ + qsort ((void *) *symsizesp, symcount, sizeof (struct size_sym), size_forward2); + + return symcount; +} + +/* This function is used to get the relocs for a particular section. + It is called via bfd_map_over_sections. */ + +static void +get_relocs (bfd *abfd, asection *sec, void *dataarg) +{ + struct get_relocs_info *data = (struct get_relocs_info *) dataarg; + + *data->secs = sec; + + if ((sec->flags & SEC_RELOC) == 0) + { + *data->relocs = NULL; + *data->relcount = 0; + } + else + { + long relsize; + + relsize = bfd_get_reloc_upper_bound (abfd, sec); + if (relsize < 0) + bfd_fatal (bfd_get_filename (abfd)); + + *data->relocs = (arelent **) xmalloc (relsize); + *data->relcount = bfd_canonicalize_reloc (abfd, sec, *data->relocs, + data->syms); + if (*data->relcount < 0) + bfd_fatal (bfd_get_filename (abfd)); + } + + ++data->secs; + ++data->relocs; + ++data->relcount; +} + +/* Print a single symbol. */ + +static void +print_symbol (bfd * abfd, + asymbol * sym, + bfd_vma ssize, + bfd * archive_bfd) +{ + symbol_info syminfo; + struct extended_symbol_info info; + + PROGRESS (1); + + format->print_symbol_filename (archive_bfd, abfd); + + bfd_get_symbol_info (abfd, sym, &syminfo); + + info.sinfo = &syminfo; + info.ssize = ssize; + /* Synthetic symbols do not have a full symbol type set of data available. + Nor do bfd/section.c:global_syms like *ABS*. */ + if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) != 0) + { + info.elfinfo = NULL; + info.coffinfo = NULL; + } + else + { + info.elfinfo = elf_symbol_from (abfd, sym); + info.coffinfo = coff_symbol_from (sym); + } + + format->print_symbol_info (&info, abfd); + + if (with_symbol_versions) + { + const char * version_string = NULL; + bfd_boolean hidden = FALSE; + + if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0) + version_string = bfd_get_symbol_version_string (abfd, sym, &hidden); + + if (bfd_is_und_section (bfd_get_section (sym))) + hidden = TRUE; + + if (version_string && *version_string != '\0') + printf (hidden ? "@%s" : "@@%s", version_string); + } + + if (line_numbers) + { + static asymbol **syms; + static long symcount; + const char *filename, *functionname; + unsigned int lineno; + + /* We need to get the canonical symbols in order to call + bfd_find_nearest_line. This is inefficient, but, then, you + don't have to use --line-numbers. */ + if (abfd != lineno_cache_bfd && syms != NULL) + { + free (syms); + syms = NULL; + } + if (syms == NULL) + { + long symsize; + + symsize = bfd_get_symtab_upper_bound (abfd); + if (symsize < 0) + bfd_fatal (bfd_get_filename (abfd)); + syms = (asymbol **) xmalloc (symsize); + symcount = bfd_canonicalize_symtab (abfd, syms); + if (symcount < 0) + bfd_fatal (bfd_get_filename (abfd)); + lineno_cache_bfd = abfd; + } + + if (bfd_is_und_section (bfd_get_section (sym))) + { + static asection **secs; + static arelent ***relocs; + static long *relcount; + static unsigned int seccount; + unsigned int i; + const char *symname; + + /* For an undefined symbol, we try to find a reloc for the + symbol, and print the line number of the reloc. */ + if (abfd != lineno_cache_rel_bfd && relocs != NULL) + { + for (i = 0; i < seccount; i++) + if (relocs[i] != NULL) + free (relocs[i]); + free (secs); + free (relocs); + free (relcount); + secs = NULL; + relocs = NULL; + relcount = NULL; + } + + if (relocs == NULL) + { + struct get_relocs_info rinfo; + + seccount = bfd_count_sections (abfd); + + secs = (asection **) xmalloc (seccount * sizeof *secs); + relocs = (arelent ***) xmalloc (seccount * sizeof *relocs); + relcount = (long *) xmalloc (seccount * sizeof *relcount); + + rinfo.secs = secs; + rinfo.relocs = relocs; + rinfo.relcount = relcount; + rinfo.syms = syms; + bfd_map_over_sections (abfd, get_relocs, (void *) &rinfo); + lineno_cache_rel_bfd = abfd; + } + + symname = bfd_asymbol_name (sym); + for (i = 0; i < seccount; i++) + { + long j; + + for (j = 0; j < relcount[i]; j++) + { + arelent *r; + + r = relocs[i][j]; + if (r->sym_ptr_ptr != NULL + && (*r->sym_ptr_ptr)->section == sym->section + && (*r->sym_ptr_ptr)->value == sym->value + && strcmp (symname, + bfd_asymbol_name (*r->sym_ptr_ptr)) == 0 + && bfd_find_nearest_line (abfd, secs[i], syms, + r->address, &filename, + &functionname, &lineno) + && filename != NULL) + { + /* We only print the first one we find. */ + printf ("\t%s:%u", filename, lineno); + i = seccount; + break; + } + } + } + } + else if (bfd_get_section (sym)->owner == abfd) + { + if ((bfd_find_line (abfd, syms, sym, &filename, &lineno) + || bfd_find_nearest_line (abfd, bfd_get_section (sym), + syms, sym->value, &filename, + &functionname, &lineno)) + && filename != NULL + && lineno != 0) + printf ("\t%s:%u", filename, lineno); + } + } + + putchar ('\n'); +} + +/* Print the symbols when sorting by size. */ + +static void +print_size_symbols (bfd * abfd, + bfd_boolean is_dynamic, + struct size_sym * symsizes, + long symcount, + bfd * archive_bfd) +{ + asymbol *store; + struct size_sym *from; + struct size_sym *fromend; + + store = bfd_make_empty_symbol (abfd); + if (store == NULL) + bfd_fatal (bfd_get_filename (abfd)); + + from = symsizes; + fromend = from + symcount; + + for (; from < fromend; from++) + { + asymbol *sym; + + sym = bfd_minisymbol_to_symbol (abfd, is_dynamic, from->minisym, store); + if (sym == NULL) + bfd_fatal (bfd_get_filename (abfd)); + + print_symbol (abfd, sym, from->size, archive_bfd); + } +} + + +/* Print the symbols of ABFD that are held in MINISYMS. + + If ARCHIVE_BFD is non-NULL, it is the archive containing ABFD. + + SYMCOUNT is the number of symbols in MINISYMS. + + SIZE is the size of a symbol in MINISYMS. */ + +static void +print_symbols (bfd * abfd, + bfd_boolean is_dynamic, + void * minisyms, + long symcount, + unsigned int size, + bfd * archive_bfd) +{ + asymbol *store; + bfd_byte *from; + bfd_byte *fromend; + + store = bfd_make_empty_symbol (abfd); + if (store == NULL) + bfd_fatal (bfd_get_filename (abfd)); + + from = (bfd_byte *) minisyms; + fromend = from + symcount * size; + + for (; from < fromend; from += size) + { + asymbol *sym; + + sym = bfd_minisymbol_to_symbol (abfd, is_dynamic, from, store); + if (sym == NULL) + bfd_fatal (bfd_get_filename (abfd)); + + print_symbol (abfd, sym, (bfd_vma) 0, archive_bfd); + } +} + +/* If ARCHIVE_BFD is non-NULL, it is the archive containing ABFD. */ + +static void +display_rel_file (bfd *abfd, bfd *archive_bfd) +{ + long symcount; + void *minisyms; + unsigned int size; + struct size_sym *symsizes; + asymbol *synthsyms = NULL; + + if (! dynamic) + { + if (!(bfd_get_file_flags (abfd) & HAS_SYMS)) + { + non_fatal (_("%s: no symbols"), bfd_get_filename (abfd)); + return; + } + } + + symcount = bfd_read_minisymbols (abfd, dynamic, &minisyms, &size); + if (symcount < 0) + { + if (dynamic && bfd_get_error () == bfd_error_no_symbols) + { + non_fatal (_("%s: no symbols"), bfd_get_filename (abfd)); + return; + } + + bfd_fatal (bfd_get_filename (abfd)); + } + + if (symcount == 0) + { + non_fatal (_("%s: no symbols"), bfd_get_filename (abfd)); + return; + } + + if (show_synthetic && size == sizeof (asymbol *)) + { + asymbol **static_syms = NULL; + asymbol **dyn_syms = NULL; + long static_count = 0; + long dyn_count = 0; + long synth_count; + + if (dynamic) + { + dyn_count = symcount; + dyn_syms = (asymbol **) minisyms; + } + else + { + long storage = bfd_get_dynamic_symtab_upper_bound (abfd); + + static_count = symcount; + static_syms = (asymbol **) minisyms; + + if (storage > 0) + { + dyn_syms = (asymbol **) xmalloc (storage); + dyn_count = bfd_canonicalize_dynamic_symtab (abfd, dyn_syms); + if (dyn_count < 0) + bfd_fatal (bfd_get_filename (abfd)); + } + } + + synth_count = bfd_get_synthetic_symtab (abfd, static_count, static_syms, + dyn_count, dyn_syms, &synthsyms); + if (synth_count > 0) + { + asymbol **symp; + void *new_mini; + long i; + + new_mini = xmalloc ((symcount + synth_count + 1) * sizeof (*symp)); + symp = (asymbol **) new_mini; + memcpy (symp, minisyms, symcount * sizeof (*symp)); + symp += symcount; + for (i = 0; i < synth_count; i++) + *symp++ = synthsyms + i; + *symp = 0; + minisyms = new_mini; + symcount += synth_count; + } + } + + /* Discard the symbols we don't want to print. + It's OK to do this in place; we'll free the storage anyway + (after printing). */ + + symcount = filter_symbols (abfd, dynamic, minisyms, symcount, size); + + symsizes = NULL; + if (! no_sort) + { + sort_bfd = abfd; + sort_dynamic = dynamic; + sort_x = bfd_make_empty_symbol (abfd); + sort_y = bfd_make_empty_symbol (abfd); + if (sort_x == NULL || sort_y == NULL) + bfd_fatal (bfd_get_filename (abfd)); + + if (! sort_by_size) + qsort (minisyms, symcount, size, + sorters[sort_numerically][reverse_sort]); + else + symcount = sort_symbols_by_size (abfd, dynamic, minisyms, symcount, + size, &symsizes); + } + + if (! sort_by_size) + print_symbols (abfd, dynamic, minisyms, symcount, size, archive_bfd); + else + print_size_symbols (abfd, dynamic, symsizes, symcount, archive_bfd); + + if (synthsyms) + free (synthsyms); + free (minisyms); + free (symsizes); +} + +static void +set_print_width (bfd *file) +{ + print_width = bfd_get_arch_size (file); + + if (print_width == -1) + { + /* PR binutils/4292 + Guess the target's bitsize based on its name. + We assume here than any 64-bit format will include + "64" somewhere in its name. The only known exception + is the MMO object file format. */ + if (strstr (bfd_get_target (file), "64") != NULL + || strcmp (bfd_get_target (file), "mmo") == 0) + print_width = 64; + else + print_width = 32; + } +} + +static void +display_archive (bfd *file) +{ + bfd *arfile = NULL; + bfd *last_arfile = NULL; + char **matching; + + format->print_archive_filename (bfd_get_filename (file)); + + if (print_armap) + print_symdef_entry (file); + + for (;;) + { + PROGRESS (1); + + arfile = bfd_openr_next_archived_file (file, arfile); + + if (arfile == NULL) + { + if (bfd_get_error () != bfd_error_no_more_archived_files) + bfd_fatal (bfd_get_filename (file)); + break; + } + + if (bfd_check_format_matches (arfile, bfd_object, &matching)) + { + set_print_width (arfile); + format->print_archive_member (bfd_get_filename (file), + bfd_get_filename (arfile)); + display_rel_file (arfile, file); + } + else + { + bfd_nonfatal (bfd_get_filename (arfile)); + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (matching); + free (matching); + } + } + + if (last_arfile != NULL) + { + bfd_close (last_arfile); + lineno_cache_bfd = NULL; + lineno_cache_rel_bfd = NULL; + if (arfile == last_arfile) + return; + } + last_arfile = arfile; + } + + if (last_arfile != NULL) + { + bfd_close (last_arfile); + lineno_cache_bfd = NULL; + lineno_cache_rel_bfd = NULL; + } +} + +static bfd_boolean +display_file (char *filename) +{ + bfd_boolean retval = TRUE; + bfd *file; + char **matching; + + if (get_file_size (filename) < 1) + return FALSE; + + file = bfd_openr (filename, target ? target : plugin_target); + if (file == NULL) + { + bfd_nonfatal (filename); + return FALSE; + } + + /* If printing line numbers, decompress the debug sections. */ + if (line_numbers) + file->flags |= BFD_DECOMPRESS; + + if (bfd_check_format (file, bfd_archive)) + { + display_archive (file); + } + else if (bfd_check_format_matches (file, bfd_object, &matching)) + { + set_print_width (file); + format->print_object_filename (filename); + display_rel_file (file, NULL); + } + else + { + bfd_nonfatal (filename); + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (matching); + free (matching); + } + retval = FALSE; + } + + if (!bfd_close (file)) + bfd_fatal (filename); + + lineno_cache_bfd = NULL; + lineno_cache_rel_bfd = NULL; + + return retval; +} + +/* The following 3 groups of functions are called unconditionally, + once at the start of processing each file of the appropriate type. + They should check `filename_per_file' and `filename_per_symbol', + as appropriate for their output format, to determine whether to + print anything. */ + +/* Print the name of an object file given on the command line. */ + +static void +print_object_filename_bsd (char *filename) +{ + if (filename_per_file && !filename_per_symbol) + printf ("\n%s:\n", filename); +} + +static void +print_object_filename_sysv (char *filename) +{ + if (undefined_only) + printf (_("\n\nUndefined symbols from %s:\n\n"), filename); + else + printf (_("\n\nSymbols from %s:\n\n"), filename); + if (print_width == 32) + printf (_("\ +Name Value Class Type Size Line Section\n\n")); + else + printf (_("\ +Name Value Class Type Size Line Section\n\n")); +} + +static void +print_object_filename_posix (char *filename) +{ + if (filename_per_file && !filename_per_symbol) + printf ("%s:\n", filename); +} + +/* Print the name of an archive file given on the command line. */ + +static void +print_archive_filename_bsd (char *filename) +{ + if (filename_per_file) + printf ("\n%s:\n", filename); +} + +static void +print_archive_filename_sysv (char *filename ATTRIBUTE_UNUSED) +{ +} + +static void +print_archive_filename_posix (char *filename ATTRIBUTE_UNUSED) +{ +} + +/* Print the name of an archive member file. */ + +static void +print_archive_member_bsd (char *archive ATTRIBUTE_UNUSED, + const char *filename) +{ + if (!filename_per_symbol) + printf ("\n%s:\n", filename); +} + +static void +print_archive_member_sysv (char *archive, const char *filename) +{ + if (undefined_only) + printf (_("\n\nUndefined symbols from %s[%s]:\n\n"), archive, filename); + else + printf (_("\n\nSymbols from %s[%s]:\n\n"), archive, filename); + if (print_width == 32) + printf (_("\ +Name Value Class Type Size Line Section\n\n")); + else + printf (_("\ +Name Value Class Type Size Line Section\n\n")); +} + +static void +print_archive_member_posix (char *archive, const char *filename) +{ + if (!filename_per_symbol) + printf ("%s[%s]:\n", archive, filename); +} + +/* Print the name of the file (and archive, if there is one) + containing a symbol. */ + +static void +print_symbol_filename_bsd (bfd *archive_bfd, bfd *abfd) +{ + if (filename_per_symbol) + { + if (archive_bfd) + printf ("%s:", bfd_get_filename (archive_bfd)); + printf ("%s:", bfd_get_filename (abfd)); + } +} + +static void +print_symbol_filename_sysv (bfd *archive_bfd, bfd *abfd) +{ + if (filename_per_symbol) + { + if (archive_bfd) + printf ("%s:", bfd_get_filename (archive_bfd)); + printf ("%s:", bfd_get_filename (abfd)); + } +} + +static void +print_symbol_filename_posix (bfd *archive_bfd, bfd *abfd) +{ + if (filename_per_symbol) + { + if (archive_bfd) + printf ("%s[%s]: ", bfd_get_filename (archive_bfd), + bfd_get_filename (abfd)); + else + printf ("%s: ", bfd_get_filename (abfd)); + } +} + +/* Print a symbol value. */ + +static void +print_value (bfd *abfd ATTRIBUTE_UNUSED, bfd_vma val) +{ + switch (print_width) + { + case 32: + printf (value_format_32bit, (unsigned long) val); + break; + + case 64: +#if BFD_HOST_64BIT_LONG || BFD_HOST_64BIT_LONG_LONG + printf (value_format_64bit, val); +#else + /* We have a 64 bit value to print, but the host is only 32 bit. */ + if (print_radix == 16) + bfd_fprintf_vma (abfd, stdout, val); + else + { + char buf[30]; + char *s; + + s = buf + sizeof buf; + *--s = '\0'; + while (val > 0) + { + *--s = (val % print_radix) + '0'; + val /= print_radix; + } + while ((buf + sizeof buf - 1) - s < 16) + *--s = '0'; + printf ("%s", s); + } +#endif + break; + + default: + fatal (_("Print width has not been initialized (%d)"), print_width); + break; + } +} + +/* Print a line of information about a symbol. */ + +static void +print_symbol_info_bsd (struct extended_symbol_info *info, bfd *abfd) +{ + if (bfd_is_undefined_symclass (SYM_TYPE (info))) + { + if (print_width == 64) + printf (" "); + printf (" "); + } + else + { + /* Normally we print the value of the symbol. If we are printing the + size or sorting by size then we print its size, except for the + (weird) special case where both flags are defined, in which case we + print both values. This conforms to documented behaviour. */ + if (sort_by_size && !print_size) + print_value (abfd, SYM_SIZE (info)); + else + print_value (abfd, SYM_VALUE (info)); + if (print_size && SYM_SIZE (info)) + { + printf (" "); + print_value (abfd, SYM_SIZE (info)); + } + } + + printf (" %c", SYM_TYPE (info)); + + if (SYM_TYPE (info) == '-') + { + /* A stab. */ + printf (" "); + printf (other_format, SYM_STAB_OTHER (info)); + printf (" "); + printf (desc_format, SYM_STAB_DESC (info)); + printf (" %5s", SYM_STAB_NAME (info)); + } + print_symname (" %s", SYM_NAME (info), abfd); +} + +static void +print_symbol_info_sysv (struct extended_symbol_info *info, bfd *abfd) +{ + print_symname ("%-20s|", SYM_NAME (info), abfd); + + if (bfd_is_undefined_symclass (SYM_TYPE (info))) + { + if (print_width == 32) + printf (" "); + else + printf (" "); + } + else + print_value (abfd, SYM_VALUE (info)); + + printf ("| %c |", SYM_TYPE (info)); + + if (SYM_TYPE (info) == '-') + { + /* A stab. */ + printf ("%18s| ", SYM_STAB_NAME (info)); /* (C) Type. */ + printf (desc_format, SYM_STAB_DESC (info)); /* Size. */ + printf ("| |"); /* Line, Section. */ + } + else + { + /* Type, Size, Line, Section */ + if (info->elfinfo) + printf ("%18s|", + get_elf_symbol_type (ELF_ST_TYPE (info->elfinfo->internal_elf_sym.st_info))); + else if (info->coffinfo) + printf ("%18s|", + get_coff_symbol_type (&info->coffinfo->native->u.syment)); + else + printf (" |"); + + if (SYM_SIZE (info)) + print_value (abfd, SYM_SIZE (info)); + else + { + if (print_width == 32) + printf (" "); + else + printf (" "); + } + + if (info->elfinfo) + printf("| |%s", info->elfinfo->symbol.section->name); + else if (info->coffinfo) + printf("| |%s", info->coffinfo->symbol.section->name); + else + printf("| |"); + } +} + +static void +print_symbol_info_posix (struct extended_symbol_info *info, bfd *abfd) +{ + print_symname ("%s ", SYM_NAME (info), abfd); + printf ("%c ", SYM_TYPE (info)); + + if (bfd_is_undefined_symclass (SYM_TYPE (info))) + printf (" "); + else + { + print_value (abfd, SYM_VALUE (info)); + printf (" "); + if (SYM_SIZE (info)) + print_value (abfd, SYM_SIZE (info)); + } +} + +int +main (int argc, char **argv) +{ + int c; + int retval; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); + setlocale (LC_COLLATE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + program_name = *argv; + xmalloc_set_program_name (program_name); + bfd_set_error_program_name (program_name); +#if BFD_SUPPORTS_PLUGINS + bfd_plugin_set_program_name (program_name); +#endif + + START_PROGRESS (program_name, 0); + + expandargv (&argc, &argv); + + bfd_init (); + set_default_bfd_target (); + + while ((c = getopt_long (argc, argv, "aABCDef:gHhlnopPrSst:uvVvX:", + long_options, (int *) 0)) != EOF) + { + switch (c) + { + case 'a': + print_debug_syms = 1; + break; + case 'A': + case 'o': + filename_per_symbol = 1; + break; + case 'B': /* For MIPS compatibility. */ + set_output_format ("bsd"); + break; + case 'C': + do_demangle = 1; + if (optarg != NULL) + { + enum demangling_styles style; + + style = cplus_demangle_name_to_style (optarg); + if (style == unknown_demangling) + fatal (_("unknown demangling style `%s'"), + optarg); + + cplus_demangle_set_style (style); + } + break; + case 'D': + dynamic = 1; + break; + case 'e': + /* Ignored for HP/UX compatibility. */ + break; + case 'f': + set_output_format (optarg); + break; + case 'g': + external_only = 1; + break; + case 'H': + case 'h': + usage (stdout, 0); + case 'l': + line_numbers = 1; + break; + case 'n': + case 'v': + no_sort = 0; + sort_numerically = 1; + sort_by_size = 0; + break; + case 'p': + no_sort = 1; + sort_numerically = 0; + sort_by_size = 0; + break; + case OPTION_SIZE_SORT: + no_sort = 0; + sort_numerically = 0; + sort_by_size = 1; + break; + case 'P': + set_output_format ("posix"); + break; + case 'r': + reverse_sort = 1; + break; + case 's': + print_armap = 1; + break; + case 'S': + print_size = 1; + break; + case 't': + set_print_radix (optarg); + break; + case 'u': + undefined_only = 1; + break; + case 'V': + show_version = 1; + break; + case 'X': + /* Ignored for (partial) AIX compatibility. On AIX, the + argument has values 32, 64, or 32_64, and specifies that + only 32-bit, only 64-bit, or both kinds of objects should + be examined. The default is 32. So plain AIX nm on a + library archive with both kinds of objects will ignore + the 64-bit ones. For GNU nm, the default is and always + has been -X 32_64, and other options are not supported. */ + if (strcmp (optarg, "32_64") != 0) + fatal (_("Only -X 32_64 is supported")); + break; + + case OPTION_TARGET: /* --target */ + target = optarg; + break; + + case OPTION_PLUGIN: /* --plugin */ +#if BFD_SUPPORTS_PLUGINS + bfd_plugin_set_plugin (optarg); +#else + fatal (_("sorry - this program has been built without plugin support\n")); +#endif + break; + + case 0: /* A long option that just sets a flag. */ + break; + + default: + usage (stderr, 1); + } + } + + if (show_version) + print_version ("nm"); + + if (sort_by_size && undefined_only) + { + non_fatal (_("Using the --size-sort and --undefined-only options together")); + non_fatal (_("will produce no output, since undefined symbols have no size.")); + return 0; + } + + /* OK, all options now parsed. If no filename specified, do a.out. */ + if (optind == argc) + return !display_file ("a.out"); + + retval = 0; + + if (argc - optind > 1) + filename_per_file = 1; + + /* We were given several filenames to do. */ + while (optind < argc) + { + PROGRESS (1); + if (!display_file (argv[optind++])) + retval++; + } + + END_PROGRESS (program_name); + + exit (retval); + return retval; +} diff --git a/support/sdbinutils/binutils/not-ranlib.c b/support/sdbinutils/binutils/not-ranlib.c new file mode 100644 index 0000000..ccd3cfd --- /dev/null +++ b/support/sdbinutils/binutils/not-ranlib.c @@ -0,0 +1,22 @@ +/* Copyright (C) 2007-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Linked with ar.o to flag that this program is 'ar' (not 'ranlib'). */ + +int is_ranlib = 0; diff --git a/support/sdbinutils/binutils/not-strip.c b/support/sdbinutils/binutils/not-strip.c new file mode 100644 index 0000000..0627818 --- /dev/null +++ b/support/sdbinutils/binutils/not-strip.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2007-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Linked with objcopy.o to flag that this program is 'objcopy' (not + 'strip'). */ + +int is_strip = 0; diff --git a/support/sdbinutils/binutils/objcopy.c b/support/sdbinutils/binutils/objcopy.c new file mode 100644 index 0000000..1e39f6d --- /dev/null +++ b/support/sdbinutils/binutils/objcopy.c @@ -0,0 +1,5587 @@ +/* objcopy.c -- copy object file from input to output, optionally massaging it. + Copyright (C) 1991-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "sysdep.h" +#include "bfd.h" +#include "progress.h" +#include "getopt.h" +#include "libiberty.h" +#include "bucomm.h" +#include "budbg.h" +#include "filenames.h" +#include "fnmatch.h" +#include "elf-bfd.h" +#include "coff/internal.h" +#include "libcoff.h" +#include "safe-ctype.h" + +/* FIXME: See bfd/peXXigen.c for why we include an architecture specific + header in generic PE code. */ +#include "coff/i386.h" +#include "coff/pe.h" + +static bfd_vma pe_file_alignment = (bfd_vma) -1; +static bfd_vma pe_heap_commit = (bfd_vma) -1; +static bfd_vma pe_heap_reserve = (bfd_vma) -1; +static bfd_vma pe_image_base = (bfd_vma) -1; +static bfd_vma pe_section_alignment = (bfd_vma) -1; +static bfd_vma pe_stack_commit = (bfd_vma) -1; +static bfd_vma pe_stack_reserve = (bfd_vma) -1; +static short pe_subsystem = -1; +static short pe_major_subsystem_version = -1; +static short pe_minor_subsystem_version = -1; + +struct is_specified_symbol_predicate_data +{ + const char * name; + bfd_boolean found; +}; + +/* A node includes symbol name mapping to support redefine_sym. */ +struct redefine_node +{ + char *source; + char *target; +}; + +struct addsym_node +{ + struct addsym_node *next; + char * symdef; + long symval; + flagword flags; + char * section; + char * othersym; +}; + +typedef struct section_rename +{ + const char * old_name; + const char * new_name; + flagword flags; + struct section_rename * next; +} +section_rename; + +/* List of sections to be renamed. */ +static section_rename *section_rename_list; + +static asymbol **isympp = NULL; /* Input symbols. */ +static asymbol **osympp = NULL; /* Output symbols that survive stripping. */ + +/* If `copy_byte' >= 0, copy 'copy_width' byte(s) of every `interleave' bytes. */ +static int copy_byte = -1; +static int interleave = 0; /* Initialised to 4 in copy_main(). */ +static int copy_width = 1; + +static bfd_boolean verbose; /* Print file and target names. */ +static bfd_boolean preserve_dates; /* Preserve input file timestamp. */ +static int deterministic = -1; /* Enable deterministic archives. */ +static int status = 0; /* Exit status. */ + +static bfd_boolean merge_notes = FALSE; /* Merge note sections. */ +static bfd_byte * merged_notes = NULL; /* Contents on note section undergoing a merge. */ +static bfd_size_type merged_size = 0; /* New, smaller size of the merged note section. */ + +enum strip_action +{ + STRIP_UNDEF, + STRIP_NONE, /* Don't strip. */ + STRIP_DEBUG, /* Strip all debugger symbols. */ + STRIP_UNNEEDED, /* Strip unnecessary symbols. */ + STRIP_NONDEBUG, /* Strip everything but debug info. */ + STRIP_DWO, /* Strip all DWO info. */ + STRIP_NONDWO, /* Strip everything but DWO info. */ + STRIP_ALL /* Strip all symbols. */ +}; + +/* Which symbols to remove. */ +static enum strip_action strip_symbols = STRIP_UNDEF; + +enum locals_action +{ + LOCALS_UNDEF, + LOCALS_START_L, /* Discard locals starting with L. */ + LOCALS_ALL /* Discard all locals. */ +}; + +/* Which local symbols to remove. Overrides STRIP_ALL. */ +static enum locals_action discard_locals; + +/* Structure used to hold lists of sections and actions to take. */ +struct section_list +{ + struct section_list * next; /* Next section to change. */ + const char * pattern; /* Section name pattern. */ + bfd_boolean used; /* Whether this entry was used. */ + + unsigned int context; /* What to do with matching sections. */ + /* Flag bits used in the context field. + COPY and REMOVE are mutually exlusive. SET and ALTER are mutually exclusive. */ +#define SECTION_CONTEXT_REMOVE (1 << 0) /* Remove this section. */ +#define SECTION_CONTEXT_COPY (1 << 1) /* Copy this section, delete all non-copied section. */ +#define SECTION_CONTEXT_SET_VMA (1 << 2) /* Set the sections' VMA address. */ +#define SECTION_CONTEXT_ALTER_VMA (1 << 3) /* Increment or decrement the section's VMA address. */ +#define SECTION_CONTEXT_SET_LMA (1 << 4) /* Set the sections' LMA address. */ +#define SECTION_CONTEXT_ALTER_LMA (1 << 5) /* Increment or decrement the section's LMA address. */ +#define SECTION_CONTEXT_SET_FLAGS (1 << 6) /* Set the section's flags. */ +#define SECTION_CONTEXT_REMOVE_RELOCS (1 << 7) /* Remove relocations for this section. */ + + bfd_vma vma_val; /* Amount to change by or set to. */ + bfd_vma lma_val; /* Amount to change by or set to. */ + flagword flags; /* What to set the section flags to. */ +}; + +static struct section_list *change_sections; + +/* TRUE if some sections are to be removed. */ +static bfd_boolean sections_removed; + +/* TRUE if only some sections are to be copied. */ +static bfd_boolean sections_copied; + +/* Changes to the start address. */ +static bfd_vma change_start = 0; +static bfd_boolean set_start_set = FALSE; +static bfd_vma set_start; + +/* Changes to section addresses. */ +static bfd_vma change_section_address = 0; + +/* Filling gaps between sections. */ +static bfd_boolean gap_fill_set = FALSE; +static bfd_byte gap_fill = 0; + +/* Pad to a given address. */ +static bfd_boolean pad_to_set = FALSE; +static bfd_vma pad_to; + +/* Use alternative machine code? */ +static unsigned long use_alt_mach_code = 0; + +/* Output BFD flags user wants to set or clear */ +static flagword bfd_flags_to_set; +static flagword bfd_flags_to_clear; + +/* List of sections to add. */ +struct section_add +{ + /* Next section to add. */ + struct section_add *next; + /* Name of section to add. */ + const char *name; + /* Name of file holding section contents. */ + const char *filename; + /* Size of file. */ + size_t size; + /* Contents of file. */ + bfd_byte *contents; + /* BFD section, after it has been added. */ + asection *section; +}; + +/* List of sections to add to the output BFD. */ +static struct section_add *add_sections; + +/* List of sections to update in the output BFD. */ +static struct section_add *update_sections; + +/* List of sections to dump from the output BFD. */ +static struct section_add *dump_sections; + +/* If non-NULL the argument to --add-gnu-debuglink. + This should be the filename to store in the .gnu_debuglink section. */ +static const char * gnu_debuglink_filename = NULL; + +/* Whether to convert debugging information. */ +static bfd_boolean convert_debugging = FALSE; + +/* Whether to compress/decompress DWARF debug sections. */ +static enum +{ + nothing = 0, + compress = 1 << 0, + compress_zlib = compress | 1 << 1, + compress_gnu_zlib = compress | 1 << 2, + compress_gabi_zlib = compress | 1 << 3, + decompress = 1 << 4 +} do_debug_sections = nothing; + +/* Whether to generate ELF common symbols with the STT_COMMON type. */ +static enum bfd_link_elf_stt_common do_elf_stt_common = unchanged; + +/* Whether to change the leading character in symbol names. */ +static bfd_boolean change_leading_char = FALSE; + +/* Whether to remove the leading character from global symbol names. */ +static bfd_boolean remove_leading_char = FALSE; + +/* Whether to permit wildcard in symbol comparison. */ +static bfd_boolean wildcard = FALSE; + +/* True if --localize-hidden is in effect. */ +static bfd_boolean localize_hidden = FALSE; + +/* List of symbols to strip, keep, localize, keep-global, weaken, + or redefine. */ +static htab_t strip_specific_htab = NULL; +static htab_t strip_unneeded_htab = NULL; +static htab_t keep_specific_htab = NULL; +static htab_t localize_specific_htab = NULL; +static htab_t globalize_specific_htab = NULL; +static htab_t keepglobal_specific_htab = NULL; +static htab_t weaken_specific_htab = NULL; +static htab_t redefine_specific_htab = NULL; +static htab_t redefine_specific_reverse_htab = NULL; +static struct addsym_node *add_sym_list = NULL, **add_sym_tail = &add_sym_list; +static int add_symbols = 0; + +/* If this is TRUE, we weaken global symbols (set BSF_WEAK). */ +static bfd_boolean weaken = FALSE; + +/* If this is TRUE, we retain BSF_FILE symbols. */ +static bfd_boolean keep_file_symbols = FALSE; + +/* Prefix symbols/sections. */ +static char *prefix_symbols_string = 0; +static char *prefix_sections_string = 0; +static char *prefix_alloc_sections_string = 0; + +/* True if --extract-symbol was passed on the command line. */ +static bfd_boolean extract_symbol = FALSE; + +/* If `reverse_bytes' is nonzero, then reverse the order of every chunk + of bytes within each output section. */ +static int reverse_bytes = 0; + +/* For Coff objects, we may want to allow or disallow long section names, + or preserve them where found in the inputs. Debug info relies on them. */ +enum long_section_name_handling +{ + DISABLE, + ENABLE, + KEEP +}; + +/* The default long section handling mode is to preserve them. + This is also the only behaviour for 'strip'. */ +static enum long_section_name_handling long_section_names = KEEP; + +/* 150 isn't special; it's just an arbitrary non-ASCII char value. */ +enum command_line_switch +{ + OPTION_ADD_SECTION=150, + OPTION_ADD_GNU_DEBUGLINK, + OPTION_ADD_SYMBOL, + OPTION_ALT_MACH_CODE, + OPTION_CHANGE_ADDRESSES, + OPTION_CHANGE_LEADING_CHAR, + OPTION_CHANGE_SECTION_ADDRESS, + OPTION_CHANGE_SECTION_LMA, + OPTION_CHANGE_SECTION_VMA, + OPTION_CHANGE_START, + OPTION_CHANGE_WARNINGS, + OPTION_COMPRESS_DEBUG_SECTIONS, + OPTION_DEBUGGING, + OPTION_DECOMPRESS_DEBUG_SECTIONS, + OPTION_DUMP_SECTION, + OPTION_ELF_STT_COMMON, + OPTION_EXTRACT_DWO, + OPTION_EXTRACT_SYMBOL, + OPTION_FILE_ALIGNMENT, + OPTION_FORMATS_INFO, + OPTION_GAP_FILL, + OPTION_GLOBALIZE_SYMBOL, + OPTION_GLOBALIZE_SYMBOLS, + OPTION_HEAP, + OPTION_IMAGE_BASE, + OPTION_IMPURE, + OPTION_INTERLEAVE_WIDTH, + OPTION_KEEPGLOBAL_SYMBOLS, + OPTION_KEEP_FILE_SYMBOLS, + OPTION_KEEP_SYMBOLS, + OPTION_LOCALIZE_HIDDEN, + OPTION_LOCALIZE_SYMBOLS, + OPTION_LONG_SECTION_NAMES, + OPTION_MERGE_NOTES, + OPTION_NO_MERGE_NOTES, + OPTION_NO_CHANGE_WARNINGS, + OPTION_ONLY_KEEP_DEBUG, + OPTION_PAD_TO, + OPTION_PREFIX_ALLOC_SECTIONS, + OPTION_PREFIX_SECTIONS, + OPTION_PREFIX_SYMBOLS, + OPTION_PURE, + OPTION_READONLY_TEXT, + OPTION_REDEFINE_SYM, + OPTION_REDEFINE_SYMS, + OPTION_REMOVE_LEADING_CHAR, + OPTION_REMOVE_RELOCS, + OPTION_RENAME_SECTION, + OPTION_REVERSE_BYTES, + OPTION_SECTION_ALIGNMENT, + OPTION_SET_SECTION_FLAGS, + OPTION_SET_START, + OPTION_SREC_FORCES3, + OPTION_SREC_LEN, + OPTION_STACK, + OPTION_STRIP_DWO, + OPTION_STRIP_SYMBOLS, + OPTION_STRIP_UNNEEDED, + OPTION_STRIP_UNNEEDED_SYMBOL, + OPTION_STRIP_UNNEEDED_SYMBOLS, + OPTION_SUBSYSTEM, + OPTION_UPDATE_SECTION, + OPTION_WEAKEN, + OPTION_WEAKEN_SYMBOLS, + OPTION_WRITABLE_TEXT +}; + +/* Options to handle if running as "strip". */ + +static struct option strip_options[] = +{ + {"disable-deterministic-archives", no_argument, 0, 'U'}, + {"discard-all", no_argument, 0, 'x'}, + {"discard-locals", no_argument, 0, 'X'}, + {"enable-deterministic-archives", no_argument, 0, 'D'}, + {"format", required_argument, 0, 'F'}, /* Obsolete */ + {"help", no_argument, 0, 'h'}, + {"info", no_argument, 0, OPTION_FORMATS_INFO}, + {"input-format", required_argument, 0, 'I'}, /* Obsolete */ + {"input-target", required_argument, 0, 'I'}, + {"keep-file-symbols", no_argument, 0, OPTION_KEEP_FILE_SYMBOLS}, + {"keep-symbol", required_argument, 0, 'K'}, + {"merge-notes", no_argument, 0, 'M'}, + {"no-merge-notes", no_argument, 0, OPTION_NO_MERGE_NOTES}, + {"only-keep-debug", no_argument, 0, OPTION_ONLY_KEEP_DEBUG}, + {"output-file", required_argument, 0, 'o'}, + {"output-format", required_argument, 0, 'O'}, /* Obsolete */ + {"output-target", required_argument, 0, 'O'}, + {"preserve-dates", no_argument, 0, 'p'}, + {"remove-section", required_argument, 0, 'R'}, + {"remove-relocations", required_argument, 0, OPTION_REMOVE_RELOCS}, + {"strip-all", no_argument, 0, 's'}, + {"strip-debug", no_argument, 0, 'S'}, + {"strip-dwo", no_argument, 0, OPTION_STRIP_DWO}, + {"strip-symbol", required_argument, 0, 'N'}, + {"strip-unneeded", no_argument, 0, OPTION_STRIP_UNNEEDED}, + {"target", required_argument, 0, 'F'}, + {"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, + {"wildcard", no_argument, 0, 'w'}, + {0, no_argument, 0, 0} +}; + +/* Options to handle if running as "objcopy". */ + +static struct option copy_options[] = +{ + {"add-gnu-debuglink", required_argument, 0, OPTION_ADD_GNU_DEBUGLINK}, + {"add-section", required_argument, 0, OPTION_ADD_SECTION}, + {"add-symbol", required_argument, 0, OPTION_ADD_SYMBOL}, + {"adjust-section-vma", required_argument, 0, OPTION_CHANGE_SECTION_ADDRESS}, + {"adjust-start", required_argument, 0, OPTION_CHANGE_START}, + {"adjust-vma", required_argument, 0, OPTION_CHANGE_ADDRESSES}, + {"adjust-warnings", no_argument, 0, OPTION_CHANGE_WARNINGS}, + {"alt-machine-code", required_argument, 0, OPTION_ALT_MACH_CODE}, + {"binary-architecture", required_argument, 0, 'B'}, + {"byte", required_argument, 0, 'b'}, + {"change-addresses", required_argument, 0, OPTION_CHANGE_ADDRESSES}, + {"change-leading-char", no_argument, 0, OPTION_CHANGE_LEADING_CHAR}, + {"change-section-address", required_argument, 0, OPTION_CHANGE_SECTION_ADDRESS}, + {"change-section-lma", required_argument, 0, OPTION_CHANGE_SECTION_LMA}, + {"change-section-vma", required_argument, 0, OPTION_CHANGE_SECTION_VMA}, + {"change-start", required_argument, 0, OPTION_CHANGE_START}, + {"change-warnings", no_argument, 0, OPTION_CHANGE_WARNINGS}, + {"compress-debug-sections", optional_argument, 0, OPTION_COMPRESS_DEBUG_SECTIONS}, + {"debugging", no_argument, 0, OPTION_DEBUGGING}, + {"decompress-debug-sections", no_argument, 0, OPTION_DECOMPRESS_DEBUG_SECTIONS}, + {"disable-deterministic-archives", no_argument, 0, 'U'}, + {"discard-all", no_argument, 0, 'x'}, + {"discard-locals", no_argument, 0, 'X'}, + {"dump-section", required_argument, 0, OPTION_DUMP_SECTION}, + {"elf-stt-common", required_argument, 0, OPTION_ELF_STT_COMMON}, + {"enable-deterministic-archives", no_argument, 0, 'D'}, + {"extract-dwo", no_argument, 0, OPTION_EXTRACT_DWO}, + {"extract-symbol", no_argument, 0, OPTION_EXTRACT_SYMBOL}, + {"file-alignment", required_argument, 0, OPTION_FILE_ALIGNMENT}, + {"format", required_argument, 0, 'F'}, /* Obsolete */ + {"gap-fill", required_argument, 0, OPTION_GAP_FILL}, + {"globalize-symbol", required_argument, 0, OPTION_GLOBALIZE_SYMBOL}, + {"globalize-symbols", required_argument, 0, OPTION_GLOBALIZE_SYMBOLS}, + {"heap", required_argument, 0, OPTION_HEAP}, + {"help", no_argument, 0, 'h'}, + {"image-base", required_argument, 0 , OPTION_IMAGE_BASE}, + {"impure", no_argument, 0, OPTION_IMPURE}, + {"info", no_argument, 0, OPTION_FORMATS_INFO}, + {"input-format", required_argument, 0, 'I'}, /* Obsolete */ + {"input-target", required_argument, 0, 'I'}, + {"interleave", optional_argument, 0, 'i'}, + {"interleave-width", required_argument, 0, OPTION_INTERLEAVE_WIDTH}, + {"keep-file-symbols", no_argument, 0, OPTION_KEEP_FILE_SYMBOLS}, + {"keep-global-symbol", required_argument, 0, 'G'}, + {"keep-global-symbols", required_argument, 0, OPTION_KEEPGLOBAL_SYMBOLS}, + {"keep-symbol", required_argument, 0, 'K'}, + {"keep-symbols", required_argument, 0, OPTION_KEEP_SYMBOLS}, + {"localize-hidden", no_argument, 0, OPTION_LOCALIZE_HIDDEN}, + {"localize-symbol", required_argument, 0, 'L'}, + {"localize-symbols", required_argument, 0, OPTION_LOCALIZE_SYMBOLS}, + {"long-section-names", required_argument, 0, OPTION_LONG_SECTION_NAMES}, + {"merge-notes", no_argument, 0, 'M'}, + {"no-merge-notes", no_argument, 0, OPTION_NO_MERGE_NOTES}, + {"no-adjust-warnings", no_argument, 0, OPTION_NO_CHANGE_WARNINGS}, + {"no-change-warnings", no_argument, 0, OPTION_NO_CHANGE_WARNINGS}, + {"only-keep-debug", no_argument, 0, OPTION_ONLY_KEEP_DEBUG}, + {"only-section", required_argument, 0, 'j'}, + {"output-format", required_argument, 0, 'O'}, /* Obsolete */ + {"output-target", required_argument, 0, 'O'}, + {"pad-to", required_argument, 0, OPTION_PAD_TO}, + {"prefix-alloc-sections", required_argument, 0, OPTION_PREFIX_ALLOC_SECTIONS}, + {"prefix-sections", required_argument, 0, OPTION_PREFIX_SECTIONS}, + {"prefix-symbols", required_argument, 0, OPTION_PREFIX_SYMBOLS}, + {"preserve-dates", no_argument, 0, 'p'}, + {"pure", no_argument, 0, OPTION_PURE}, + {"readonly-text", no_argument, 0, OPTION_READONLY_TEXT}, + {"redefine-sym", required_argument, 0, OPTION_REDEFINE_SYM}, + {"redefine-syms", required_argument, 0, OPTION_REDEFINE_SYMS}, + {"remove-leading-char", no_argument, 0, OPTION_REMOVE_LEADING_CHAR}, + {"remove-section", required_argument, 0, 'R'}, + {"remove-relocations", required_argument, 0, OPTION_REMOVE_RELOCS}, + {"rename-section", required_argument, 0, OPTION_RENAME_SECTION}, + {"reverse-bytes", required_argument, 0, OPTION_REVERSE_BYTES}, + {"section-alignment", required_argument, 0, OPTION_SECTION_ALIGNMENT}, + {"set-section-flags", required_argument, 0, OPTION_SET_SECTION_FLAGS}, + {"set-start", required_argument, 0, OPTION_SET_START}, + {"srec-forceS3", no_argument, 0, OPTION_SREC_FORCES3}, + {"srec-len", required_argument, 0, OPTION_SREC_LEN}, + {"stack", required_argument, 0, OPTION_STACK}, + {"strip-all", no_argument, 0, 'S'}, + {"strip-debug", no_argument, 0, 'g'}, + {"strip-dwo", no_argument, 0, OPTION_STRIP_DWO}, + {"strip-symbol", required_argument, 0, 'N'}, + {"strip-symbols", required_argument, 0, OPTION_STRIP_SYMBOLS}, + {"strip-unneeded", no_argument, 0, OPTION_STRIP_UNNEEDED}, + {"strip-unneeded-symbol", required_argument, 0, OPTION_STRIP_UNNEEDED_SYMBOL}, + {"strip-unneeded-symbols", required_argument, 0, OPTION_STRIP_UNNEEDED_SYMBOLS}, + {"subsystem", required_argument, 0, OPTION_SUBSYSTEM}, + {"target", required_argument, 0, 'F'}, + {"update-section", required_argument, 0, OPTION_UPDATE_SECTION}, + {"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, + {"weaken", no_argument, 0, OPTION_WEAKEN}, + {"weaken-symbol", required_argument, 0, 'W'}, + {"weaken-symbols", required_argument, 0, OPTION_WEAKEN_SYMBOLS}, + {"wildcard", no_argument, 0, 'w'}, + {"writable-text", no_argument, 0, OPTION_WRITABLE_TEXT}, + {0, no_argument, 0, 0} +}; + +/* IMPORTS */ +extern char *program_name; + +/* This flag distinguishes between strip and objcopy: + 1 means this is 'strip'; 0 means this is 'objcopy'. + -1 means if we should use argv[0] to decide. */ +extern int is_strip; + +/* The maximum length of an S record. This variable is defined in srec.c + and can be modified by the --srec-len parameter. */ +extern unsigned int _bfd_srec_len; + +/* Restrict the generation of Srecords to type S3 only. + This variable is defined in bfd/srec.c and can be toggled + on by the --srec-forceS3 command line switch. */ +extern bfd_boolean _bfd_srec_forceS3; + +/* Forward declarations. */ +static void setup_section (bfd *, asection *, void *); +static void setup_bfd_headers (bfd *, bfd *); +static void copy_relocations_in_section (bfd *, asection *, void *); +static void copy_section (bfd *, asection *, void *); +static void get_sections (bfd *, asection *, void *); +static int compare_section_lma (const void *, const void *); +static void mark_symbols_used_in_relocations (bfd *, asection *, void *); +static bfd_boolean write_debugging_info (bfd *, void *, long *, asymbol ***); +static const char *lookup_sym_redefinition (const char *); +static const char *find_section_rename (const char *, flagword *); + +ATTRIBUTE_NORETURN static void +copy_usage (FILE *stream, int exit_status) +{ + fprintf (stream, _("Usage: %s [option(s)] in-file [out-file]\n"), program_name); + fprintf (stream, _(" Copies a binary file, possibly transforming it in the process\n")); + fprintf (stream, _(" The options are:\n")); + fprintf (stream, _("\ + -I --input-target Assume input file is in format \n\ + -O --output-target Create an output file in format \n\ + -B --binary-architecture Set output arch, when input is arch-less\n\ + -F --target Set both input and output format to \n\ + --debugging Convert debugging information, if possible\n\ + -p --preserve-dates Copy modified/access timestamps to the output\n")); + if (DEFAULT_AR_DETERMINISTIC) + fprintf (stream, _("\ + -D --enable-deterministic-archives\n\ + Produce deterministic output when stripping archives (default)\n\ + -U --disable-deterministic-archives\n\ + Disable -D behavior\n")); + else + fprintf (stream, _("\ + -D --enable-deterministic-archives\n\ + Produce deterministic output when stripping archives\n\ + -U --disable-deterministic-archives\n\ + Disable -D behavior (default)\n")); + fprintf (stream, _("\ + -j --only-section Only copy section into the output\n\ + --add-gnu-debuglink= Add section .gnu_debuglink linking to \n\ + -R --remove-section Remove section from the output\n\ + --remove-relocations Remove relocations from section \n\ + -S --strip-all Remove all symbol and relocation information\n\ + -g --strip-debug Remove all debugging symbols & sections\n\ + --strip-dwo Remove all DWO sections\n\ + --strip-unneeded Remove all symbols not needed by relocations\n\ + -N --strip-symbol Do not copy symbol \n\ + --strip-unneeded-symbol \n\ + Do not copy symbol unless needed by\n\ + relocations\n\ + --only-keep-debug Strip everything but the debug information\n\ + --extract-dwo Copy only DWO sections\n\ + --extract-symbol Remove section contents but keep symbols\n\ + -K --keep-symbol Do not strip symbol \n\ + --keep-file-symbols Do not strip file symbol(s)\n\ + --localize-hidden Turn all ELF hidden symbols into locals\n\ + -L --localize-symbol Force symbol to be marked as a local\n\ + --globalize-symbol Force symbol to be marked as a global\n\ + -G --keep-global-symbol Localize all symbols except \n\ + -W --weaken-symbol Force symbol to be marked as a weak\n\ + --weaken Force all global symbols to be marked as weak\n\ + -w --wildcard Permit wildcard in symbol comparison\n\ + -x --discard-all Remove all non-global symbols\n\ + -X --discard-locals Remove any compiler-generated symbols\n\ + -i --interleave[=] Only copy N out of every bytes\n\ + --interleave-width Set N for --interleave\n\ + -b --byte Select byte in every interleaved block\n\ + --gap-fill Fill gaps between sections with \n\ + --pad-to Pad the last section up to address \n\ + --set-start Set the start address to \n\ + {--change-start|--adjust-start} \n\ + Add to the start address\n\ + {--change-addresses|--adjust-vma} \n\ + Add to LMA, VMA and start addresses\n\ + {--change-section-address|--adjust-section-vma} {=|+|-}\n\ + Change LMA and VMA of section by \n\ + --change-section-lma {=|+|-}\n\ + Change the LMA of section by \n\ + --change-section-vma {=|+|-}\n\ + Change the VMA of section by \n\ + {--[no-]change-warnings|--[no-]adjust-warnings}\n\ + Warn if a named section does not exist\n\ + --set-section-flags =\n\ + Set section 's properties to \n\ + --add-section = Add section found in to output\n\ + --update-section =\n\ + Update contents of section with\n\ + contents found in \n\ + --dump-section = Dump the contents of section into \n\ + --rename-section =[,] Rename section to \n\ + --long-section-names {enable|disable|keep}\n\ + Handle long section names in Coff objects.\n\ + --change-leading-char Force output format's leading character style\n\ + --remove-leading-char Remove leading character from global symbols\n\ + --reverse-bytes= Reverse bytes at a time, in output sections with content\n\ + --redefine-sym = Redefine symbol name to \n\ + --redefine-syms --redefine-sym for all symbol pairs \n\ + listed in \n\ + --srec-len Restrict the length of generated Srecords\n\ + --srec-forceS3 Restrict the type of generated Srecords to S3\n\ + --strip-symbols -N for all symbols listed in \n\ + --strip-unneeded-symbols \n\ + --strip-unneeded-symbol for all symbols listed\n\ + in \n\ + --keep-symbols -K for all symbols listed in \n\ + --localize-symbols -L for all symbols listed in \n\ + --globalize-symbols --globalize-symbol for all in \n\ + --keep-global-symbols -G for all symbols listed in \n\ + --weaken-symbols -W for all symbols listed in \n\ + --add-symbol =[
:][,] Add a symbol\n\ + --alt-machine-code Use the target's 'th alternative machine\n\ + --writable-text Mark the output text as writable\n\ + --readonly-text Make the output text write protected\n\ + --pure Mark the output file as demand paged\n\ + --impure Mark the output file as impure\n\ + --prefix-symbols Add to start of every symbol name\n\ + --prefix-sections Add to start of every section name\n\ + --prefix-alloc-sections \n\ + Add to start of every allocatable\n\ + section name\n\ + --file-alignment Set PE file alignment to \n\ + --heap [,] Set PE reserve/commit heap to /\n\ + \n\ + --image-base
Set PE image base to
\n\ + --section-alignment Set PE section alignment to \n\ + --stack [,] Set PE reserve/commit stack to /\n\ + \n\ + --subsystem [:]\n\ + Set PE subsystem to [& ]\n\ + --compress-debug-sections[={none|zlib|zlib-gnu|zlib-gabi}]\n\ + Compress DWARF debug sections using zlib\n\ + --decompress-debug-sections Decompress DWARF debug sections using zlib\n\ + --elf-stt-common=[yes|no] Generate ELF common symbols with STT_COMMON\n\ + type\n\ + -M --merge-notes Remove redundant entries in note sections\n\ + --no-merge-notes Do not attempt to remove redundant notes (default)\n\ + -v --verbose List all object files modified\n\ + @ Read options from \n\ + -V --version Display this program's version number\n\ + -h --help Display this output\n\ + --info List object formats & architectures supported\n\ +")); + list_supported_targets (program_name, stream); + if (REPORT_BUGS_TO[0] && exit_status == 0) + fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); + exit (exit_status); +} + +ATTRIBUTE_NORETURN static void +strip_usage (FILE *stream, int exit_status) +{ + fprintf (stream, _("Usage: %s in-file(s)\n"), program_name); + fprintf (stream, _(" Removes symbols and sections from files\n")); + fprintf (stream, _(" The options are:\n")); + fprintf (stream, _("\ + -I --input-target= Assume input file is in format \n\ + -O --output-target= Create an output file in format \n\ + -F --target= Set both input and output format to \n\ + -p --preserve-dates Copy modified/access timestamps to the output\n\ +")); + if (DEFAULT_AR_DETERMINISTIC) + fprintf (stream, _("\ + -D --enable-deterministic-archives\n\ + Produce deterministic output when stripping archives (default)\n\ + -U --disable-deterministic-archives\n\ + Disable -D behavior\n")); + else + fprintf (stream, _("\ + -D --enable-deterministic-archives\n\ + Produce deterministic output when stripping archives\n\ + -U --disable-deterministic-archives\n\ + Disable -D behavior (default)\n")); + fprintf (stream, _("\ + -R --remove-section= Also remove section from the output\n\ + --remove-relocations Remove relocations from section \n\ + -s --strip-all Remove all symbol and relocation information\n\ + -g -S -d --strip-debug Remove all debugging symbols & sections\n\ + --strip-dwo Remove all DWO sections\n\ + --strip-unneeded Remove all symbols not needed by relocations\n\ + --only-keep-debug Strip everything but the debug information\n\ + -M --merge-notes Remove redundant entries in note sections (default)\n\ + --no-merge-notes Do not attempt to remove redundant notes\n\ + -N --strip-symbol= Do not copy symbol \n\ + -K --keep-symbol= Do not strip symbol \n\ + --keep-file-symbols Do not strip file symbol(s)\n\ + -w --wildcard Permit wildcard in symbol comparison\n\ + -x --discard-all Remove all non-global symbols\n\ + -X --discard-locals Remove any compiler-generated symbols\n\ + -v --verbose List all object files modified\n\ + -V --version Display this program's version number\n\ + -h --help Display this output\n\ + --info List object formats & architectures supported\n\ + -o Place stripped output into \n\ +")); + + list_supported_targets (program_name, stream); + if (REPORT_BUGS_TO[0] && exit_status == 0) + fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); + exit (exit_status); +} + +/* Parse section flags into a flagword, with a fatal error if the + string can't be parsed. */ + +static flagword +parse_flags (const char *s) +{ + flagword ret; + const char *snext; + int len; + + ret = SEC_NO_FLAGS; + + do + { + snext = strchr (s, ','); + if (snext == NULL) + len = strlen (s); + else + { + len = snext - s; + ++snext; + } + + if (0) ; +#define PARSE_FLAG(fname,fval) \ + else if (strncasecmp (fname, s, len) == 0) ret |= fval + PARSE_FLAG ("alloc", SEC_ALLOC); + PARSE_FLAG ("load", SEC_LOAD); + PARSE_FLAG ("noload", SEC_NEVER_LOAD); + PARSE_FLAG ("readonly", SEC_READONLY); + PARSE_FLAG ("debug", SEC_DEBUGGING); + PARSE_FLAG ("code", SEC_CODE); + PARSE_FLAG ("data", SEC_DATA); + PARSE_FLAG ("rom", SEC_ROM); + PARSE_FLAG ("share", SEC_COFF_SHARED); + PARSE_FLAG ("contents", SEC_HAS_CONTENTS); + PARSE_FLAG ("merge", SEC_MERGE); + PARSE_FLAG ("strings", SEC_STRINGS); +#undef PARSE_FLAG + else + { + char *copy; + + copy = (char *) xmalloc (len + 1); + strncpy (copy, s, len); + copy[len] = '\0'; + non_fatal (_("unrecognized section flag `%s'"), copy); + fatal (_("supported flags: %s"), + "alloc, load, noload, readonly, debug, code, data, rom, share, contents, merge, strings"); + } + + s = snext; + } + while (s != NULL); + + return ret; +} + +/* Parse symbol flags into a flagword, with a fatal error if the + string can't be parsed. */ + +static flagword +parse_symflags (const char *s, char **other) +{ + flagword ret; + const char *snext; + size_t len; + + ret = BSF_NO_FLAGS; + + do + { + snext = strchr (s, ','); + if (snext == NULL) + len = strlen (s); + else + { + len = snext - s; + ++snext; + } + +#define PARSE_FLAG(fname, fval) \ + else if (len == sizeof fname - 1 \ + && strncasecmp (fname, s, len) == 0) \ + ret |= fval + +#define PARSE_OTHER(fname, fval) \ + else if (len >= sizeof fname \ + && strncasecmp (fname, s, sizeof fname - 1) == 0) \ + fval = xstrndup (s + sizeof fname - 1, len - sizeof fname + 1) + + if (0) ; + PARSE_FLAG ("local", BSF_LOCAL); + PARSE_FLAG ("global", BSF_GLOBAL); + PARSE_FLAG ("export", BSF_EXPORT); + PARSE_FLAG ("debug", BSF_DEBUGGING); + PARSE_FLAG ("function", BSF_FUNCTION); + PARSE_FLAG ("weak", BSF_WEAK); + PARSE_FLAG ("section", BSF_SECTION_SYM); + PARSE_FLAG ("constructor", BSF_CONSTRUCTOR); + PARSE_FLAG ("warning", BSF_WARNING); + PARSE_FLAG ("indirect", BSF_INDIRECT); + PARSE_FLAG ("file", BSF_FILE); + PARSE_FLAG ("object", BSF_OBJECT); + PARSE_FLAG ("synthetic", BSF_SYNTHETIC); + PARSE_FLAG ("indirect-function", BSF_GNU_INDIRECT_FUNCTION | BSF_FUNCTION); + PARSE_FLAG ("unique-object", BSF_GNU_UNIQUE | BSF_OBJECT); + PARSE_OTHER ("before=", *other); + +#undef PARSE_FLAG +#undef PARSE_OTHER + else + { + char *copy; + + copy = (char *) xmalloc (len + 1); + strncpy (copy, s, len); + copy[len] = '\0'; + non_fatal (_("unrecognized symbol flag `%s'"), copy); + fatal (_("supported flags: %s"), + "local, global, export, debug, function, weak, section, " + "constructor, warning, indirect, file, object, synthetic, " + "indirect-function, unique-object, before="); + } + + s = snext; + } + while (s != NULL); + + return ret; +} + +/* Find and optionally add an entry in the change_sections list. + + We need to be careful in how we match section names because of the support + for wildcard characters. For example suppose that the user has invoked + objcopy like this: + + --set-section-flags .debug_*=debug + --set-section-flags .debug_str=readonly,debug + --change-section-address .debug_*ranges=0x1000 + + With the idea that all debug sections will receive the DEBUG flag, the + .debug_str section will also receive the READONLY flag and the + .debug_ranges and .debug_aranges sections will have their address set to + 0x1000. (This may not make much sense, but it is just an example). + + When adding the section name patterns to the section list we need to make + sure that previous entries do not match with the new entry, unless the + match is exact. (In which case we assume that the user is overriding + the previous entry with the new context). + + When matching real section names to the section list we make use of the + wildcard characters, but we must do so in context. Eg if we are setting + section addresses then we match for .debug_ranges but not for .debug_info. + + Finally, if ADD is false and we do find a match, we mark the section list + entry as used. */ + +static struct section_list * +find_section_list (const char *name, bfd_boolean add, unsigned int context) +{ + struct section_list *p, *match = NULL; + + /* assert ((context & ((1 << 7) - 1)) != 0); */ + + for (p = change_sections; p != NULL; p = p->next) + { + if (add) + { + if (strcmp (p->pattern, name) == 0) + { + /* Check for context conflicts. */ + if (((p->context & SECTION_CONTEXT_REMOVE) + && (context & SECTION_CONTEXT_COPY)) + || ((context & SECTION_CONTEXT_REMOVE) + && (p->context & SECTION_CONTEXT_COPY))) + fatal (_("error: %s both copied and removed"), name); + + if (((p->context & SECTION_CONTEXT_SET_VMA) + && (context & SECTION_CONTEXT_ALTER_VMA)) + || ((context & SECTION_CONTEXT_SET_VMA) + && (context & SECTION_CONTEXT_ALTER_VMA))) + fatal (_("error: %s both sets and alters VMA"), name); + + if (((p->context & SECTION_CONTEXT_SET_LMA) + && (context & SECTION_CONTEXT_ALTER_LMA)) + || ((context & SECTION_CONTEXT_SET_LMA) + && (context & SECTION_CONTEXT_ALTER_LMA))) + fatal (_("error: %s both sets and alters LMA"), name); + + /* Extend the context. */ + p->context |= context; + return p; + } + } + /* If we are not adding a new name/pattern then + only check for a match if the context applies. */ + else if (p->context & context) + { + /* We could check for the presence of wildchar characters + first and choose between calling strcmp and fnmatch, + but is that really worth it ? */ + if (p->pattern [0] == '!') + { + if (fnmatch (p->pattern + 1, name, 0) == 0) + { + p->used = TRUE; + return NULL; + } + } + else + { + if (fnmatch (p->pattern, name, 0) == 0) + { + if (match == NULL) + match = p; + } + } + } + } + + if (! add) + { + if (match != NULL) + match->used = TRUE; + return match; + } + + p = (struct section_list *) xmalloc (sizeof (struct section_list)); + p->pattern = name; + p->used = FALSE; + p->context = context; + p->vma_val = 0; + p->lma_val = 0; + p->flags = 0; + p->next = change_sections; + change_sections = p; + + return p; +} + +/* S1 is the entry node already in the table, S2 is the key node. */ + +static int +eq_string_redefnode (const void *s1, const void *s2) +{ + struct redefine_node *node1 = (struct redefine_node *) s1; + struct redefine_node *node2 = (struct redefine_node *) s2; + return !strcmp ((const char *) node1->source, (const char *) node2->source); +} + +/* P is redefine node. Hash value is generated from its "source" filed. */ + +static hashval_t +htab_hash_redefnode (const void *p) +{ + struct redefine_node *redefnode = (struct redefine_node *) p; + return htab_hash_string (redefnode->source); +} + +/* Create hashtab used for redefine node. */ + +static htab_t +create_symbol2redef_htab (void) +{ + return htab_create_alloc (16, htab_hash_redefnode, eq_string_redefnode, NULL, + xcalloc, free); +} + +/* There is htab_hash_string but no htab_eq_string. Makes sense. */ + +static int +eq_string (const void *s1, const void *s2) +{ + return strcmp ((const char *) s1, (const char *) s2) == 0; +} + +static htab_t +create_symbol_htab (void) +{ + return htab_create_alloc (16, htab_hash_string, eq_string, NULL, xcalloc, free); +} + +static void +create_symbol_htabs (void) +{ + strip_specific_htab = create_symbol_htab (); + strip_unneeded_htab = create_symbol_htab (); + keep_specific_htab = create_symbol_htab (); + localize_specific_htab = create_symbol_htab (); + globalize_specific_htab = create_symbol_htab (); + keepglobal_specific_htab = create_symbol_htab (); + weaken_specific_htab = create_symbol_htab (); + redefine_specific_htab = create_symbol2redef_htab (); + /* As there is no bidirectional hash table in libiberty, need a reverse table + to check duplicated target string. */ + redefine_specific_reverse_htab = create_symbol_htab (); +} + +/* Add a symbol to strip_specific_list. */ + +static void +add_specific_symbol (const char *name, htab_t htab) +{ + *htab_find_slot (htab, name, INSERT) = (char *) name; +} + +/* Like add_specific_symbol, but the element type is void *. */ + +static void +add_specific_symbol_node (const void *node, htab_t htab) +{ + *htab_find_slot (htab, node, INSERT) = (void *) node; +} + +/* Add symbols listed in `filename' to strip_specific_list. */ + +#define IS_WHITESPACE(c) ((c) == ' ' || (c) == '\t') +#define IS_LINE_TERMINATOR(c) ((c) == '\n' || (c) == '\r' || (c) == '\0') + +static void +add_specific_symbols (const char *filename, htab_t htab) +{ + off_t size; + FILE * f; + char * line; + char * buffer; + unsigned int line_count; + + size = get_file_size (filename); + if (size == 0) + { + status = 1; + return; + } + + buffer = (char *) xmalloc (size + 2); + f = fopen (filename, FOPEN_RT); + if (f == NULL) + fatal (_("cannot open '%s': %s"), filename, strerror (errno)); + + if (fread (buffer, 1, size, f) == 0 || ferror (f)) + fatal (_("%s: fread failed"), filename); + + fclose (f); + buffer [size] = '\n'; + buffer [size + 1] = '\0'; + + line_count = 1; + + for (line = buffer; * line != '\0'; line ++) + { + char * eol; + char * name; + char * name_end; + int finished = FALSE; + + for (eol = line;; eol ++) + { + switch (* eol) + { + case '\n': + * eol = '\0'; + /* Cope with \n\r. */ + if (eol[1] == '\r') + ++ eol; + finished = TRUE; + break; + + case '\r': + * eol = '\0'; + /* Cope with \r\n. */ + if (eol[1] == '\n') + ++ eol; + finished = TRUE; + break; + + case 0: + finished = TRUE; + break; + + case '#': + /* Line comment, Terminate the line here, in case a + name is present and then allow the rest of the + loop to find the real end of the line. */ + * eol = '\0'; + break; + + default: + break; + } + + if (finished) + break; + } + + /* A name may now exist somewhere between 'line' and 'eol'. + Strip off leading whitespace and trailing whitespace, + then add it to the list. */ + for (name = line; IS_WHITESPACE (* name); name ++) + ; + for (name_end = name; + (! IS_WHITESPACE (* name_end)) + && (! IS_LINE_TERMINATOR (* name_end)); + name_end ++) + ; + + if (! IS_LINE_TERMINATOR (* name_end)) + { + char * extra; + + for (extra = name_end + 1; IS_WHITESPACE (* extra); extra ++) + ; + + if (! IS_LINE_TERMINATOR (* extra)) + non_fatal (_("%s:%d: Ignoring rubbish found on this line"), + filename, line_count); + } + + * name_end = '\0'; + + if (name_end > name) + add_specific_symbol (name, htab); + + /* Advance line pointer to end of line. The 'eol ++' in the for + loop above will then advance us to the start of the next line. */ + line = eol; + line_count ++; + } +} + +/* See whether a symbol should be stripped or kept + based on strip_specific_list and keep_symbols. */ + +static int +is_specified_symbol_predicate (void **slot, void *data) +{ + struct is_specified_symbol_predicate_data *d = + (struct is_specified_symbol_predicate_data *) data; + const char *slot_name = (char *) *slot; + + if (*slot_name != '!') + { + if (! fnmatch (slot_name, d->name, 0)) + { + d->found = TRUE; + /* Continue traversal, there might be a non-match rule. */ + return 1; + } + } + else + { + if (! fnmatch (slot_name + 1, d->name, 0)) + { + d->found = FALSE; + /* Stop traversal. */ + return 0; + } + } + + /* Continue traversal. */ + return 1; +} + +static bfd_boolean +is_specified_symbol (const char *name, htab_t htab) +{ + if (wildcard) + { + struct is_specified_symbol_predicate_data data; + + data.name = name; + data.found = FALSE; + + htab_traverse (htab, is_specified_symbol_predicate, &data); + + return data.found; + } + + return htab_find (htab, name) != NULL; +} + +/* Return a pointer to the symbol used as a signature for GROUP. */ + +static asymbol * +group_signature (asection *group) +{ + bfd *abfd = group->owner; + Elf_Internal_Shdr *ghdr; + + /* PR 20089: An earlier error may have prevented us from loading the symbol table. */ + if (isympp == NULL) + return NULL; + + if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) + return NULL; + + ghdr = &elf_section_data (group)->this_hdr; + if (ghdr->sh_link < elf_numsections (abfd)) + { + const struct elf_backend_data *bed = get_elf_backend_data (abfd); + Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link]; + + if (symhdr->sh_type == SHT_SYMTAB + && ghdr->sh_info > 0 + && ghdr->sh_info < (symhdr->sh_size / bed->s->sizeof_sym)) + return isympp[ghdr->sh_info - 1]; + } + return NULL; +} + +/* Return TRUE if the section is a DWO section. */ + +static bfd_boolean +is_dwo_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) +{ + const char *name = bfd_get_section_name (abfd, sec); + int len = strlen (name); + + return strncmp (name + len - 4, ".dwo", 4) == 0; +} + +/* Return TRUE if section SEC is in the update list. */ + +static bfd_boolean +is_update_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) +{ + if (update_sections != NULL) + { + struct section_add *pupdate; + + for (pupdate = update_sections; + pupdate != NULL; + pupdate = pupdate->next) + { + if (strcmp (sec->name, pupdate->name) == 0) + return TRUE; + } + } + + return FALSE; +} + +static bfd_boolean +is_merged_note_section (bfd * abfd, asection * sec) +{ + if (merge_notes + && bfd_get_flavour (abfd) == bfd_target_elf_flavour + && elf_section_data (sec)->this_hdr.sh_type == SHT_NOTE + /* FIXME: We currently only support merging GNU_BUILD_NOTEs. + We should add support for more note types. */ + && ((elf_section_data (sec)->this_hdr.sh_flags & SHF_GNU_BUILD_NOTE) != 0 + /* Old versions of GAS (prior to 2.27) could not set the section + flags to OS-specific values, so we also accept sections with the + expected name. */ + || (strcmp (sec->name, GNU_BUILD_ATTRS_SECTION_NAME) == 0))) + return TRUE; + + return FALSE; +} + +/* See if a non-group section is being removed. */ + +static bfd_boolean +is_strip_section_1 (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) +{ + if (sections_removed || sections_copied) + { + struct section_list *p; + struct section_list *q; + + p = find_section_list (bfd_get_section_name (abfd, sec), FALSE, + SECTION_CONTEXT_REMOVE); + q = find_section_list (bfd_get_section_name (abfd, sec), FALSE, + SECTION_CONTEXT_COPY); + + if (p && q) + fatal (_("error: section %s matches both remove and copy options"), + bfd_get_section_name (abfd, sec)); + if (p && is_update_section (abfd, sec)) + fatal (_("error: section %s matches both update and remove options"), + bfd_get_section_name (abfd, sec)); + + if (p != NULL) + return TRUE; + if (sections_copied && q == NULL) + return TRUE; + } + + if ((bfd_get_section_flags (abfd, sec) & SEC_DEBUGGING) != 0) + { + if (strip_symbols == STRIP_DEBUG + || strip_symbols == STRIP_UNNEEDED + || strip_symbols == STRIP_ALL + || discard_locals == LOCALS_ALL + || convert_debugging) + { + /* By default we don't want to strip .reloc section. + This section has for pe-coff special meaning. See + pe-dll.c file in ld, and peXXigen.c in bfd for details. */ + if (strcmp (bfd_get_section_name (abfd, sec), ".reloc") != 0) + return TRUE; + } + + if (strip_symbols == STRIP_DWO) + return is_dwo_section (abfd, sec); + + if (strip_symbols == STRIP_NONDEBUG) + return FALSE; + } + + if (strip_symbols == STRIP_NONDWO) + return !is_dwo_section (abfd, sec); + + return FALSE; +} + +/* See if a section is being removed. */ + +static bfd_boolean +is_strip_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) +{ + if (is_strip_section_1 (abfd, sec)) + return TRUE; + + if ((bfd_get_section_flags (abfd, sec) & SEC_GROUP) != 0) + { + asymbol *gsym; + const char *gname; + asection *elt, *first; + + /* PR binutils/3181 + If we are going to strip the group signature symbol, then + strip the group section too. */ + gsym = group_signature (sec); + if (gsym != NULL) + gname = gsym->name; + else + gname = sec->name; + if ((strip_symbols == STRIP_ALL + && !is_specified_symbol (gname, keep_specific_htab)) + || is_specified_symbol (gname, strip_specific_htab)) + return TRUE; + + /* Remove the group section if all members are removed. */ + first = elt = elf_next_in_group (sec); + while (elt != NULL) + { + if (!is_strip_section_1 (abfd, elt)) + return FALSE; + elt = elf_next_in_group (elt); + if (elt == first) + break; + } + + return TRUE; + } + + return FALSE; +} + +static bfd_boolean +is_nondebug_keep_contents_section (bfd *ibfd, asection *isection) +{ + /* Always keep ELF note sections. */ + if (ibfd->xvec->flavour == bfd_target_elf_flavour) + return (elf_section_type (isection) == SHT_NOTE); + + /* Always keep the .buildid section for PE/COFF. + + Strictly, this should be written "always keep the section storing the debug + directory", but that may be the .text section for objects produced by some + tools, which it is not sensible to keep. */ + if (ibfd->xvec->flavour == bfd_target_coff_flavour) + return (strcmp (bfd_get_section_name (ibfd, isection), ".buildid") == 0); + + return FALSE; +} + +/* Return true if SYM is a hidden symbol. */ + +static bfd_boolean +is_hidden_symbol (asymbol *sym) +{ + elf_symbol_type *elf_sym; + + elf_sym = elf_symbol_from (sym->the_bfd, sym); + if (elf_sym != NULL) + switch (ELF_ST_VISIBILITY (elf_sym->internal_elf_sym.st_other)) + { + case STV_HIDDEN: + case STV_INTERNAL: + return TRUE; + } + return FALSE; +} + +static bfd_boolean +need_sym_before (struct addsym_node **node, const char *sym) +{ + int count; + struct addsym_node *ptr = add_sym_list; + + /* 'othersym' symbols are at the front of the list. */ + for (count = 0; count < add_symbols; count++) + { + if (!ptr->othersym) + break; + else if (strcmp (ptr->othersym, sym) == 0) + { + free (ptr->othersym); + ptr->othersym = ""; /* Empty name is hopefully never a valid symbol name. */ + *node = ptr; + return TRUE; + } + ptr = ptr->next; + } + return FALSE; +} + +static asymbol * +create_new_symbol (struct addsym_node *ptr, bfd *obfd) +{ + asymbol *sym = bfd_make_empty_symbol (obfd); + + bfd_asymbol_name (sym) = ptr->symdef; + sym->value = ptr->symval; + sym->flags = ptr->flags; + if (ptr->section) + { + asection *sec = bfd_get_section_by_name (obfd, ptr->section); + if (!sec) + fatal (_("Section %s not found"), ptr->section); + sym->section = sec; + } + else + sym->section = bfd_abs_section_ptr; + return sym; +} + +/* Choose which symbol entries to copy; put the result in OSYMS. + We don't copy in place, because that confuses the relocs. + Return the number of symbols to print. */ + +static unsigned int +filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, + asymbol **isyms, long symcount) +{ + asymbol **from = isyms, **to = osyms; + long src_count = 0, dst_count = 0; + int relocatable = (abfd->flags & (EXEC_P | DYNAMIC)) == 0; + + for (; src_count < symcount; src_count++) + { + asymbol *sym = from[src_count]; + flagword flags = sym->flags; + char *name = (char *) bfd_asymbol_name (sym); + bfd_boolean keep; + bfd_boolean used_in_reloc = FALSE; + bfd_boolean undefined; + bfd_boolean rem_leading_char; + bfd_boolean add_leading_char; + + undefined = bfd_is_und_section (bfd_get_section (sym)); + + if (add_sym_list) + { + struct addsym_node *ptr; + + if (need_sym_before (&ptr, name)) + to[dst_count++] = create_new_symbol (ptr, obfd); + } + + if (htab_elements (redefine_specific_htab) || section_rename_list) + { + char *new_name; + + new_name = (char *) lookup_sym_redefinition (name); + if (new_name == name + && (flags & BSF_SECTION_SYM) != 0) + new_name = (char *) find_section_rename (name, NULL); + bfd_asymbol_name (sym) = new_name; + name = new_name; + } + + /* Check if we will remove the current leading character. */ + rem_leading_char = + (name[0] == bfd_get_symbol_leading_char (abfd)) + && (change_leading_char + || (remove_leading_char + && ((flags & (BSF_GLOBAL | BSF_WEAK)) != 0 + || undefined + || bfd_is_com_section (bfd_get_section (sym))))); + + /* Check if we will add a new leading character. */ + add_leading_char = + change_leading_char + && (bfd_get_symbol_leading_char (obfd) != '\0') + && (bfd_get_symbol_leading_char (abfd) == '\0' + || (name[0] == bfd_get_symbol_leading_char (abfd))); + + /* Short circuit for change_leading_char if we can do it in-place. */ + if (rem_leading_char && add_leading_char && !prefix_symbols_string) + { + name[0] = bfd_get_symbol_leading_char (obfd); + bfd_asymbol_name (sym) = name; + rem_leading_char = FALSE; + add_leading_char = FALSE; + } + + /* Remove leading char. */ + if (rem_leading_char) + bfd_asymbol_name (sym) = ++name; + + /* Add new leading char and/or prefix. */ + if (add_leading_char || prefix_symbols_string) + { + char *n, *ptr; + + ptr = n = (char *) xmalloc (1 + strlen (prefix_symbols_string) + + strlen (name) + 1); + if (add_leading_char) + *ptr++ = bfd_get_symbol_leading_char (obfd); + + if (prefix_symbols_string) + { + strcpy (ptr, prefix_symbols_string); + ptr += strlen (prefix_symbols_string); + } + + strcpy (ptr, name); + bfd_asymbol_name (sym) = n; + name = n; + } + + if (strip_symbols == STRIP_ALL) + keep = FALSE; + else if ((flags & BSF_KEEP) != 0 /* Used in relocation. */ + || ((flags & BSF_SECTION_SYM) != 0 + && ((*bfd_get_section (sym)->symbol_ptr_ptr)->flags + & BSF_KEEP) != 0)) + { + keep = TRUE; + used_in_reloc = TRUE; + } + else if (relocatable /* Relocatable file. */ + && ((flags & (BSF_GLOBAL | BSF_WEAK)) != 0 + || bfd_is_com_section (bfd_get_section (sym)))) + keep = TRUE; + else if (bfd_decode_symclass (sym) == 'I') + /* Global symbols in $idata sections need to be retained + even if relocatable is FALSE. External users of the + library containing the $idata section may reference these + symbols. */ + keep = TRUE; + else if ((flags & BSF_GLOBAL) != 0 /* Global symbol. */ + || (flags & BSF_WEAK) != 0 + || undefined + || bfd_is_com_section (bfd_get_section (sym))) + keep = strip_symbols != STRIP_UNNEEDED; + else if ((flags & BSF_DEBUGGING) != 0) /* Debugging symbol. */ + keep = (strip_symbols != STRIP_DEBUG + && strip_symbols != STRIP_UNNEEDED + && ! convert_debugging); + else if (bfd_coff_get_comdat_section (abfd, bfd_get_section (sym))) + /* COMDAT sections store special information in local + symbols, so we cannot risk stripping any of them. */ + keep = TRUE; + else /* Local symbol. */ + keep = (strip_symbols != STRIP_UNNEEDED + && (discard_locals != LOCALS_ALL + && (discard_locals != LOCALS_START_L + || ! bfd_is_local_label (abfd, sym)))); + + if (keep && is_specified_symbol (name, strip_specific_htab)) + { + /* There are multiple ways to set 'keep' above, but if it + was the relocatable symbol case, then that's an error. */ + if (used_in_reloc) + { + non_fatal (_("not stripping symbol `%s' because it is named in a relocation"), name); + status = 1; + } + else + keep = FALSE; + } + + if (keep + && !(flags & BSF_KEEP) + && is_specified_symbol (name, strip_unneeded_htab)) + keep = FALSE; + + if (!keep + && ((keep_file_symbols && (flags & BSF_FILE)) + || is_specified_symbol (name, keep_specific_htab))) + keep = TRUE; + + if (keep && is_strip_section (abfd, bfd_get_section (sym))) + keep = FALSE; + + if (keep) + { + if ((flags & BSF_GLOBAL) != 0 + && (weaken || is_specified_symbol (name, weaken_specific_htab))) + { + sym->flags &= ~ BSF_GLOBAL; + sym->flags |= BSF_WEAK; + } + + if (!undefined + && (flags & (BSF_GLOBAL | BSF_WEAK)) + && (is_specified_symbol (name, localize_specific_htab) + || (htab_elements (keepglobal_specific_htab) != 0 + && ! is_specified_symbol (name, keepglobal_specific_htab)) + || (localize_hidden && is_hidden_symbol (sym)))) + { + sym->flags &= ~ (BSF_GLOBAL | BSF_WEAK); + sym->flags |= BSF_LOCAL; + } + + if (!undefined + && (flags & BSF_LOCAL) + && is_specified_symbol (name, globalize_specific_htab)) + { + sym->flags &= ~ BSF_LOCAL; + sym->flags |= BSF_GLOBAL; + } + + to[dst_count++] = sym; + } + } + if (add_sym_list) + { + struct addsym_node *ptr = add_sym_list; + + for (src_count = 0; src_count < add_symbols; src_count++) + { + if (ptr->othersym) + { + if (strcmp (ptr->othersym, "")) + fatal (_("'before=%s' not found"), ptr->othersym); + } + else + to[dst_count++] = create_new_symbol (ptr, obfd); + + ptr = ptr->next; + } + } + + to[dst_count] = NULL; + + return dst_count; +} + +/* Find the redefined name of symbol SOURCE. */ + +static const char * +lookup_sym_redefinition (const char *source) +{ + struct redefine_node key_node = {(char *) source, NULL}; + struct redefine_node *redef_node + = (struct redefine_node *) htab_find (redefine_specific_htab, &key_node); + + return redef_node == NULL ? source : redef_node->target; +} + +/* Insert a node into symbol redefine hash tabel. */ + +static void +add_redefine_and_check (const char *cause, const char *source, + const char *target) +{ + struct redefine_node *new_node + = (struct redefine_node *) xmalloc (sizeof (struct redefine_node)); + + new_node->source = strdup (source); + new_node->target = strdup (target); + + if (htab_find (redefine_specific_htab, new_node) != HTAB_EMPTY_ENTRY) + fatal (_("%s: Multiple redefinition of symbol \"%s\""), + cause, source); + + if (htab_find (redefine_specific_reverse_htab, target) != HTAB_EMPTY_ENTRY) + fatal (_("%s: Symbol \"%s\" is target of more than one redefinition"), + cause, target); + + /* Insert the NEW_NODE into hash table for quick search. */ + add_specific_symbol_node (new_node, redefine_specific_htab); + + /* Insert the target string into the reverse hash table, this is needed for + duplicated target string check. */ + add_specific_symbol (new_node->target, redefine_specific_reverse_htab); + +} + +/* Handle the --redefine-syms option. Read lines containing "old new" + from the file, and add them to the symbol redefine list. */ + +static void +add_redefine_syms_file (const char *filename) +{ + FILE *file; + char *buf; + size_t bufsize; + size_t len; + size_t outsym_off; + int c, lineno; + + file = fopen (filename, "r"); + if (file == NULL) + fatal (_("couldn't open symbol redefinition file %s (error: %s)"), + filename, strerror (errno)); + + bufsize = 100; + buf = (char *) xmalloc (bufsize + 1 /* For the terminating NUL. */); + + lineno = 1; + c = getc (file); + len = 0; + outsym_off = 0; + while (c != EOF) + { + /* Collect the input symbol name. */ + while (! IS_WHITESPACE (c) && ! IS_LINE_TERMINATOR (c) && c != EOF) + { + if (c == '#') + goto comment; + buf[len++] = c; + if (len >= bufsize) + { + bufsize *= 2; + buf = (char *) xrealloc (buf, bufsize + 1); + } + c = getc (file); + } + buf[len++] = '\0'; + if (c == EOF) + break; + + /* Eat white space between the symbol names. */ + while (IS_WHITESPACE (c)) + c = getc (file); + if (c == '#' || IS_LINE_TERMINATOR (c)) + goto comment; + if (c == EOF) + break; + + /* Collect the output symbol name. */ + outsym_off = len; + while (! IS_WHITESPACE (c) && ! IS_LINE_TERMINATOR (c) && c != EOF) + { + if (c == '#') + goto comment; + buf[len++] = c; + if (len >= bufsize) + { + bufsize *= 2; + buf = (char *) xrealloc (buf, bufsize + 1); + } + c = getc (file); + } + buf[len++] = '\0'; + if (c == EOF) + break; + + /* Eat white space at end of line. */ + while (! IS_LINE_TERMINATOR(c) && c != EOF && IS_WHITESPACE (c)) + c = getc (file); + if (c == '#') + goto comment; + /* Handle \r\n. */ + if ((c == '\r' && (c = getc (file)) == '\n') + || c == '\n' || c == EOF) + { + end_of_line: + /* Append the redefinition to the list. */ + if (buf[0] != '\0') + add_redefine_and_check (filename, &buf[0], &buf[outsym_off]); + + lineno++; + len = 0; + outsym_off = 0; + if (c == EOF) + break; + c = getc (file); + continue; + } + else + fatal (_("%s:%d: garbage found at end of line"), filename, lineno); + comment: + if (len != 0 && (outsym_off == 0 || outsym_off == len)) + fatal (_("%s:%d: missing new symbol name"), filename, lineno); + buf[len++] = '\0'; + + /* Eat the rest of the line and finish it. */ + while (c != '\n' && c != EOF) + c = getc (file); + goto end_of_line; + } + + if (len != 0) + fatal (_("%s:%d: premature end of file"), filename, lineno); + + free (buf); +} + +/* Copy unknown object file IBFD onto OBFD. + Returns TRUE upon success, FALSE otherwise. */ + +static bfd_boolean +copy_unknown_object (bfd *ibfd, bfd *obfd) +{ + char *cbuf; + int tocopy; + long ncopied; + long size; + struct stat buf; + + if (bfd_stat_arch_elt (ibfd, &buf) != 0) + { + bfd_nonfatal_message (NULL, ibfd, NULL, NULL); + return FALSE; + } + + size = buf.st_size; + if (size < 0) + { + non_fatal (_("stat returns negative size for `%s'"), + bfd_get_archive_filename (ibfd)); + return FALSE; + } + + if (bfd_seek (ibfd, (file_ptr) 0, SEEK_SET) != 0) + { + bfd_nonfatal (bfd_get_archive_filename (ibfd)); + return FALSE; + } + + if (verbose) + printf (_("copy from `%s' [unknown] to `%s' [unknown]\n"), + bfd_get_archive_filename (ibfd), bfd_get_filename (obfd)); + + cbuf = (char *) xmalloc (BUFSIZE); + ncopied = 0; + while (ncopied < size) + { + tocopy = size - ncopied; + if (tocopy > BUFSIZE) + tocopy = BUFSIZE; + + if (bfd_bread (cbuf, (bfd_size_type) tocopy, ibfd) + != (bfd_size_type) tocopy) + { + bfd_nonfatal_message (NULL, ibfd, NULL, NULL); + free (cbuf); + return FALSE; + } + + if (bfd_bwrite (cbuf, (bfd_size_type) tocopy, obfd) + != (bfd_size_type) tocopy) + { + bfd_nonfatal_message (NULL, obfd, NULL, NULL); + free (cbuf); + return FALSE; + } + + ncopied += tocopy; + } + + /* We should at least to be able to read it back when copying an + unknown object in an archive. */ + chmod (bfd_get_filename (obfd), buf.st_mode | S_IRUSR); + free (cbuf); + return TRUE; +} + +/* Returns the number of bytes needed to store VAL. */ + +static inline unsigned int +num_bytes (unsigned long val) +{ + unsigned int count = 0; + + /* FIXME: There must be a faster way to do this. */ + while (val) + { + count ++; + val >>= 8; + } + return count; +} + +typedef struct objcopy_internal_note +{ + Elf_Internal_Note note; + bfd_vma start; + bfd_vma end; + bfd_boolean modified; +} objcopy_internal_note; + +/* Returns TRUE if a gap does, or could, exist between the address range + covered by PNOTE1 and PNOTE2. */ + +static bfd_boolean +gap_exists (objcopy_internal_note * pnote1, + objcopy_internal_note * pnote2) +{ + /* Without range end notes, we assume that a gap might exist. */ + if (pnote1->end == 0 || pnote2->end == 0) + return TRUE; + + /* FIXME: Alignment of 16 bytes taken from x86_64 binaries. + Really we should extract the alignment of the section covered by the notes. */ + return BFD_ALIGN (pnote1->end, 16) < pnote2->start; +} + +static bfd_boolean +is_open_note (objcopy_internal_note * pnote) +{ + return (pnote->note.type == NT_GNU_BUILD_ATTRIBUTE_OPEN); +} + +static bfd_boolean +is_func_note (objcopy_internal_note * pnote) +{ + return (pnote->note.type == NT_GNU_BUILD_ATTRIBUTE_FUNC); +} + +static bfd_boolean +is_64bit (bfd * abfd) +{ + /* Should never happen, but let's be paranoid. */ + if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) + return FALSE; + + return elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64; +} + +/* Merge the notes on SEC, removing redundant entries. + Returns the new, smaller size of the section upon success. */ + +static bfd_size_type +merge_gnu_build_notes (bfd * abfd, asection * sec, bfd_size_type size, bfd_byte * contents) +{ + objcopy_internal_note * pnotes_end; + objcopy_internal_note * pnotes = NULL; + objcopy_internal_note * pnote; + bfd_size_type remain = size; + unsigned version_1_seen = 0; + unsigned version_2_seen = 0; + unsigned version_3_seen = 0; + bfd_boolean duplicate_found = FALSE; + const char * err = NULL; + bfd_byte * in = contents; + int attribute_type_byte; + int val_start; + unsigned long previous_func_start = 0; + unsigned long previous_open_start = 0; + unsigned long previous_func_end = 0; + unsigned long previous_open_end = 0; + long relsize; + + + relsize = bfd_get_reloc_upper_bound (abfd, sec); + if (relsize > 0) + { + arelent ** relpp; + long relcount; + + /* If there are relocs associated with this section then we + cannot safely merge it. */ + relpp = (arelent **) xmalloc (relsize); + relcount = bfd_canonicalize_reloc (abfd, sec, relpp, isympp); + free (relpp); + if (relcount != 0) + goto done; + } + + /* Make a copy of the notes and convert to our internal format. + Minimum size of a note is 12 bytes. */ + pnote = pnotes = (objcopy_internal_note *) xcalloc ((size / 12), sizeof (* pnote)); + while (remain >= 12) + { + bfd_vma start, end; + + pnote->note.namesz = (bfd_get_32 (abfd, in ) + 3) & ~3; + pnote->note.descsz = (bfd_get_32 (abfd, in + 4) + 3) & ~3; + pnote->note.type = bfd_get_32 (abfd, in + 8); + + if (pnote->note.type != NT_GNU_BUILD_ATTRIBUTE_OPEN + && pnote->note.type != NT_GNU_BUILD_ATTRIBUTE_FUNC) + { + err = _("corrupt GNU build attribute note: wrong note type"); + goto done; + } + + if (pnote->note.namesz + pnote->note.descsz + 12 > remain) + { + err = _("corrupt GNU build attribute note: note too big"); + goto done; + } + + if (pnote->note.namesz < 2) + { + err = _("corrupt GNU build attribute note: name too small"); + goto done; + } + + pnote->note.namedata = (char *)(in + 12); + pnote->note.descdata = (char *)(in + 12 + pnote->note.namesz); + + remain -= 12 + pnote->note.namesz + pnote->note.descsz; + in += 12 + pnote->note.namesz + pnote->note.descsz; + + if (pnote->note.namesz > 2 + && pnote->note.namedata[0] == '$' + && pnote->note.namedata[1] == GNU_BUILD_ATTRIBUTE_VERSION + && pnote->note.namedata[2] == '1') + ++ version_1_seen; + else if (pnote->note.namesz > 4 + && pnote->note.namedata[0] == 'G' + && pnote->note.namedata[1] == 'A' + && pnote->note.namedata[2] == '$' + && pnote->note.namedata[3] == GNU_BUILD_ATTRIBUTE_VERSION) + { + if (pnote->note.namedata[4] == '2') + ++ version_2_seen; + else if (pnote->note.namedata[4] == '3') + ++ version_3_seen; + else + { + err = _("corrupt GNU build attribute note: unsupported version"); + goto done; + } + } + + switch (pnote->note.descsz) + { + case 0: + start = end = 0; + break; + + case 4: + start = bfd_get_32 (abfd, pnote->note.descdata); + /* FIXME: For version 1 and 2 notes we should try to + calculate the end address by finding a symbol whose + value is START, and then adding in its size. + + For now though, since v1 and v2 was not intended to + handle gaps, we chose an artificially large end + address. */ + end = (bfd_vma) 0x7ffffffffffffffUL; + break; + + case 8: + if (! is_64bit (abfd)) + { + start = bfd_get_32 (abfd, pnote->note.descdata); + end = bfd_get_32 (abfd, pnote->note.descdata + 4); + } + else + { + start = bfd_get_64 (abfd, pnote->note.descdata); + /* FIXME: For version 1 and 2 notes we should try to + calculate the end address by finding a symbol whose + value is START, and then adding in its size. + + For now though, since v1 and v2 was not intended to + handle gaps, we chose an artificially large end + address. */ + end = (bfd_vma) 0x7ffffffffffffffUL; + } + break; + + case 16: + start = bfd_get_64 (abfd, pnote->note.descdata); + end = bfd_get_64 (abfd, pnote->note.descdata + 8); + break; + + default: + err = _("corrupt GNU build attribute note: bad description size"); + goto done; + } + + if (is_open_note (pnote)) + { + if (start) + previous_open_start = start; + + pnote->start = previous_open_start; + + if (end) + previous_open_end = end; + + pnote->end = previous_open_end; + } + else + { + if (start) + previous_func_start = start; + + pnote->start = previous_func_start; + + if (end) + previous_func_end = end; + + pnote->end = previous_func_end; + } + + if (pnote->note.namedata[pnote->note.namesz - 1] != 0) + { + err = _("corrupt GNU build attribute note: name not NUL terminated"); + goto done; + } + + pnote ++; + } + + pnotes_end = pnote; + + /* Check that the notes are valid. */ + if (remain != 0) + { + err = _("corrupt GNU build attribute notes: excess data at end"); + goto done; + } + + if (version_1_seen == 0 && version_2_seen == 0 && version_3_seen == 0) + { + err = _("bad GNU build attribute notes: no known versions detected"); + goto done; + } + + if ((version_1_seen > 0 && version_2_seen > 0) + || (version_1_seen > 0 && version_3_seen > 0) + || (version_2_seen > 0 && version_3_seen > 0)) + { + err = _("bad GNU build attribute notes: multiple different versions"); + goto done; + } + + /* Merging is only needed if there is more than one version note... */ + if (version_1_seen == 1 || version_2_seen == 1 || version_3_seen == 1) + goto done; + + attribute_type_byte = version_1_seen ? 1 : 3; + val_start = attribute_type_byte + 1; + + /* The first note should be the first version note. */ + if (pnotes[0].note.namedata[attribute_type_byte] != GNU_BUILD_ATTRIBUTE_VERSION) + { + err = _("bad GNU build attribute notes: first note not version note"); + goto done; + } + + /* Now merge the notes. The rules are: + 1. Preserve the ordering of the notes. + 2. Preserve any NT_GNU_BUILD_ATTRIBUTE_FUNC notes. + 3. Eliminate any NT_GNU_BUILD_ATTRIBUTE_OPEN notes that have the same + full name field as the immediately preceeding note with the same type + of name and whose address ranges coincide. + IE - it there are gaps in the coverage of the notes, then these gaps + must be preserved. + 4. Combine the numeric value of any NT_GNU_BUILD_ATTRIBUTE_OPEN notes + of type GNU_BUILD_ATTRIBUTE_STACK_SIZE. + 5. If an NT_GNU_BUILD_ATTRIBUTE_OPEN note is going to be preserved and + its description field is empty then the nearest preceeding OPEN note + with a non-empty description field must also be preserved *OR* the + description field of the note must be changed to contain the starting + address to which it refers. */ + for (pnote = pnotes + 1; pnote < pnotes_end; pnote ++) + { + int note_type; + objcopy_internal_note * back; + objcopy_internal_note * prev_open_with_range = NULL; + + /* Rule 2 - preserve function notes. */ + if (! is_open_note (pnote)) + continue; + + note_type = pnote->note.namedata[attribute_type_byte]; + + /* Scan backwards from pnote, looking for duplicates. + Clear the type field of any found - but do not delete them just yet. */ + for (back = pnote - 1; back >= pnotes; back --) + { + int back_type = back->note.namedata[attribute_type_byte]; + + /* If this is the first open note with an address + range that we have encountered then record it. */ + if (prev_open_with_range == NULL + && back->note.descsz > 0 + && ! is_func_note (back)) + prev_open_with_range = back; + + if (! is_open_note (back)) + continue; + + /* If the two notes are different then keep on searching. */ + if (back_type != note_type) + continue; + + /* Rule 4 - combine stack size notes. */ + if (back_type == GNU_BUILD_ATTRIBUTE_STACK_SIZE) + { + unsigned char * name; + unsigned long note_val; + unsigned long back_val; + unsigned int shift; + unsigned int bytes; + unsigned long byte; + + for (shift = 0, note_val = 0, + bytes = pnote->note.namesz - val_start, + name = (unsigned char *) pnote->note.namedata + val_start; + bytes--;) + { + byte = (* name ++) & 0xff; + note_val |= byte << shift; + shift += 8; + } + + for (shift = 0, back_val = 0, + bytes = back->note.namesz - val_start, + name = (unsigned char *) back->note.namedata + val_start; + bytes--;) + { + byte = (* name ++) & 0xff; + back_val |= byte << shift; + shift += 8; + } + + back_val += note_val; + if (num_bytes (back_val) >= back->note.namesz - val_start) + { + /* We have a problem - the new value requires more bytes of + storage in the name field than are available. Currently + we have no way of fixing this, so we just preserve both + notes. */ + continue; + } + + /* Write the new val into back. */ + name = (unsigned char *) back->note.namedata + val_start; + while (name < (unsigned char *) back->note.namedata + + back->note.namesz) + { + byte = back_val & 0xff; + * name ++ = byte; + if (back_val == 0) + break; + back_val >>= 8; + } + + duplicate_found = TRUE; + pnote->note.type = 0; + break; + } + + /* Rule 3 - combine identical open notes. */ + if (back->note.namesz == pnote->note.namesz + && memcmp (back->note.namedata, + pnote->note.namedata, back->note.namesz) == 0 + && ! gap_exists (back, pnote)) + { + duplicate_found = TRUE; + pnote->note.type = 0; + + if (pnote->end > back->end) + back->end = pnote->end; + + if (version_3_seen) + back->modified = TRUE; + break; + } + + /* Rule 5 - Since we are keeping this note we must check to see + if its description refers back to an earlier OPEN version + note that has been scheduled for deletion. If so then we + must make sure that version note is also preserved. */ + if (version_3_seen) + { + /* As of version 3 we can just + move the range into the note. */ + pnote->modified = TRUE; + pnote->note.type = NT_GNU_BUILD_ATTRIBUTE_FUNC; + back->modified = TRUE; + back->note.type = NT_GNU_BUILD_ATTRIBUTE_FUNC; + } + else + { + if (pnote->note.descsz == 0 + && prev_open_with_range != NULL + && prev_open_with_range->note.type == 0) + prev_open_with_range->note.type = NT_GNU_BUILD_ATTRIBUTE_OPEN; + } + + /* We have found a similar attribute but the details do not match. + Stop searching backwards. */ + break; + } + } + + if (duplicate_found) + { + bfd_byte * new_contents; + bfd_byte * old; + bfd_byte * new; + bfd_size_type new_size; + bfd_vma prev_start = 0; + bfd_vma prev_end = 0; + + /* Eliminate the duplicates. */ + new = new_contents = xmalloc (size); + for (pnote = pnotes, old = contents; + pnote < pnotes_end; + pnote ++) + { + bfd_size_type note_size = 12 + pnote->note.namesz + pnote->note.descsz; + + if (pnote->note.type != 0) + { + if (pnote->modified) + { + /* If the note has been modified then we must copy it by + hand, potentially adding in a new description field. */ + if (pnote->start == prev_start && pnote->end == prev_end) + { + bfd_put_32 (abfd, pnote->note.namesz, new); + bfd_put_32 (abfd, 0, new + 4); + bfd_put_32 (abfd, pnote->note.type, new + 8); + new += 12; + memcpy (new, pnote->note.namedata, pnote->note.namesz); + new += pnote->note.namesz; + } + else + { + bfd_put_32 (abfd, pnote->note.namesz, new); + bfd_put_32 (abfd, is_64bit (abfd) ? 16 : 8, new + 4); + bfd_put_32 (abfd, pnote->note.type, new + 8); + new += 12; + memcpy (new, pnote->note.namedata, pnote->note.namesz); + new += pnote->note.namesz; + if (is_64bit (abfd)) + { + bfd_put_64 (abfd, pnote->start, new); + bfd_put_64 (abfd, pnote->end, new + 8); + new += 16; + } + else + { + bfd_put_32 (abfd, pnote->start, new); + bfd_put_32 (abfd, pnote->end, new + 4); + new += 8; + } + } + } + else + { + memcpy (new, old, note_size); + new += note_size; + } + prev_start = pnote->start; + prev_end = pnote->end; + } + + old += note_size; + } + + new_size = new - new_contents; + memcpy (contents, new_contents, new_size); + size = new_size; + free (new_contents); + } + + done: + if (err) + { + bfd_set_error (bfd_error_bad_value); + bfd_nonfatal_message (NULL, abfd, sec, err); + status = 1; + } + + free (pnotes); + return size; +} + +/* Copy object file IBFD onto OBFD. + Returns TRUE upon success, FALSE otherwise. */ + +static bfd_boolean +copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) +{ + bfd_vma start; + long symcount; + asection **osections = NULL; + asection *osec; + asection *gnu_debuglink_section = NULL; + bfd_size_type *gaps = NULL; + bfd_size_type max_gap = 0; + long symsize; + void *dhandle; + enum bfd_architecture iarch; + unsigned int imach; + unsigned int c, i; + + if (ibfd->xvec->byteorder != obfd->xvec->byteorder + && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN + && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN) + { + /* PR 17636: Call non-fatal so that we return to our parent who + may need to tidy temporary files. */ + non_fatal (_("Unable to change endianness of input file(s)")); + return FALSE; + } + + if (!bfd_set_format (obfd, bfd_get_format (ibfd))) + { + bfd_nonfatal_message (NULL, obfd, NULL, NULL); + return FALSE; + } + + if (ibfd->sections == NULL) + { + non_fatal (_("error: the input file '%s' has no sections"), + bfd_get_archive_filename (ibfd)); + return FALSE; + } + + if (ibfd->xvec->flavour != bfd_target_elf_flavour) + { + if ((do_debug_sections & compress) != 0 + && do_debug_sections != compress) + { + non_fatal (_("--compress-debug-sections=[zlib|zlib-gnu|zlib-gabi] is unsupported on `%s'"), + bfd_get_archive_filename (ibfd)); + return FALSE; + } + + if (do_elf_stt_common) + { + non_fatal (_("--elf-stt-common=[yes|no] is unsupported on `%s'"), + bfd_get_archive_filename (ibfd)); + return FALSE; + } + } + + if (verbose) + printf (_("copy from `%s' [%s] to `%s' [%s]\n"), + bfd_get_archive_filename (ibfd), bfd_get_target (ibfd), + bfd_get_filename (obfd), bfd_get_target (obfd)); + + if (extract_symbol) + start = 0; + else + { + if (set_start_set) + start = set_start; + else + start = bfd_get_start_address (ibfd); + start += change_start; + } + + /* Neither the start address nor the flags + need to be set for a core file. */ + if (bfd_get_format (obfd) != bfd_core) + { + flagword flags; + + flags = bfd_get_file_flags (ibfd); + flags |= bfd_flags_to_set; + flags &= ~bfd_flags_to_clear; + flags &= bfd_applicable_file_flags (obfd); + + if (strip_symbols == STRIP_ALL) + flags &= ~HAS_RELOC; + + if (!bfd_set_start_address (obfd, start) + || !bfd_set_file_flags (obfd, flags)) + { + bfd_nonfatal_message (NULL, ibfd, NULL, NULL); + return FALSE; + } + } + + /* Copy architecture of input file to output file. */ + iarch = bfd_get_arch (ibfd); + imach = bfd_get_mach (ibfd); + if (input_arch) + { + if (bfd_get_arch_info (ibfd) == NULL + || bfd_get_arch_info (ibfd)->arch == bfd_arch_unknown) + { + iarch = input_arch->arch; + imach = input_arch->mach; + } + else + non_fatal (_("Input file `%s' ignores binary architecture parameter."), + bfd_get_archive_filename (ibfd)); + } + if (!bfd_set_arch_mach (obfd, iarch, imach) + && (ibfd->target_defaulted + || bfd_get_arch (ibfd) != bfd_get_arch (obfd))) + { + if (bfd_get_arch (ibfd) == bfd_arch_unknown) + non_fatal (_("Unable to recognise the format of the input file `%s'"), + bfd_get_archive_filename (ibfd)); + else + non_fatal (_("Output file cannot represent architecture `%s'"), + bfd_printable_arch_mach (bfd_get_arch (ibfd), + bfd_get_mach (ibfd))); + return FALSE; + } + + if (!bfd_set_format (obfd, bfd_get_format (ibfd))) + { + bfd_nonfatal_message (NULL, ibfd, NULL, NULL); + return FALSE; + } + + if (bfd_get_flavour (obfd) == bfd_target_coff_flavour + && bfd_pei_p (obfd)) + { + /* Set up PE parameters. */ + pe_data_type *pe = pe_data (obfd); + + /* Copy PE parameters before changing them. */ + if (ibfd->xvec->flavour == bfd_target_coff_flavour + && bfd_pei_p (ibfd)) + pe->pe_opthdr = pe_data (ibfd)->pe_opthdr; + + if (pe_file_alignment != (bfd_vma) -1) + pe->pe_opthdr.FileAlignment = pe_file_alignment; + else + pe_file_alignment = PE_DEF_FILE_ALIGNMENT; + + if (pe_heap_commit != (bfd_vma) -1) + pe->pe_opthdr.SizeOfHeapCommit = pe_heap_commit; + + if (pe_heap_reserve != (bfd_vma) -1) + pe->pe_opthdr.SizeOfHeapCommit = pe_heap_reserve; + + if (pe_image_base != (bfd_vma) -1) + pe->pe_opthdr.ImageBase = pe_image_base; + + if (pe_section_alignment != (bfd_vma) -1) + pe->pe_opthdr.SectionAlignment = pe_section_alignment; + else + pe_section_alignment = PE_DEF_SECTION_ALIGNMENT; + + if (pe_stack_commit != (bfd_vma) -1) + pe->pe_opthdr.SizeOfStackCommit = pe_stack_commit; + + if (pe_stack_reserve != (bfd_vma) -1) + pe->pe_opthdr.SizeOfStackCommit = pe_stack_reserve; + + if (pe_subsystem != -1) + pe->pe_opthdr.Subsystem = pe_subsystem; + + if (pe_major_subsystem_version != -1) + pe->pe_opthdr.MajorSubsystemVersion = pe_major_subsystem_version; + + if (pe_minor_subsystem_version != -1) + pe->pe_opthdr.MinorSubsystemVersion = pe_minor_subsystem_version; + + if (pe_file_alignment > pe_section_alignment) + { + char file_alignment[20], section_alignment[20]; + + sprintf_vma (file_alignment, pe_file_alignment); + sprintf_vma (section_alignment, pe_section_alignment); + non_fatal (_("warning: file alignment (0x%s) > section alignment (0x%s)"), + + file_alignment, section_alignment); + } + } + + if (isympp) + free (isympp); + + if (osympp != isympp) + free (osympp); + + isympp = NULL; + osympp = NULL; + + symsize = bfd_get_symtab_upper_bound (ibfd); + if (symsize < 0) + { + bfd_nonfatal_message (NULL, ibfd, NULL, NULL); + return FALSE; + } + + osympp = isympp = (asymbol **) xmalloc (symsize); + symcount = bfd_canonicalize_symtab (ibfd, isympp); + if (symcount < 0) + { + bfd_nonfatal_message (NULL, ibfd, NULL, NULL); + return FALSE; + } + /* PR 17512: file: d6323821 + If the symbol table could not be loaded do not pretend that we have + any symbols. This trips us up later on when we load the relocs. */ + if (symcount == 0) + { + free (isympp); + osympp = isympp = NULL; + } + + /* BFD mandates that all output sections be created and sizes set before + any output is done. Thus, we traverse all sections multiple times. */ + bfd_map_over_sections (ibfd, setup_section, obfd); + + if (!extract_symbol) + setup_bfd_headers (ibfd, obfd); + + if (add_sections != NULL) + { + struct section_add *padd; + struct section_list *pset; + + for (padd = add_sections; padd != NULL; padd = padd->next) + { + flagword flags; + + pset = find_section_list (padd->name, FALSE, + SECTION_CONTEXT_SET_FLAGS); + if (pset != NULL) + flags = pset->flags | SEC_HAS_CONTENTS; + else + flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DATA; + + /* bfd_make_section_with_flags() does not return very helpful + error codes, so check for the most likely user error first. */ + if (bfd_get_section_by_name (obfd, padd->name)) + { + bfd_nonfatal_message (NULL, obfd, NULL, + _("can't add section '%s'"), padd->name); + return FALSE; + } + else + { + /* We use LINKER_CREATED here so that the backend hooks + will create any special section type information, + instead of presuming we know what we're doing merely + because we set the flags. */ + padd->section = bfd_make_section_with_flags + (obfd, padd->name, flags | SEC_LINKER_CREATED); + if (padd->section == NULL) + { + bfd_nonfatal_message (NULL, obfd, NULL, + _("can't create section `%s'"), + padd->name); + return FALSE; + } + } + + if (! bfd_set_section_size (obfd, padd->section, padd->size)) + { + bfd_nonfatal_message (NULL, obfd, padd->section, NULL); + return FALSE; + } + + pset = find_section_list (padd->name, FALSE, + SECTION_CONTEXT_SET_VMA | SECTION_CONTEXT_ALTER_VMA); + if (pset != NULL + && ! bfd_set_section_vma (obfd, padd->section, pset->vma_val)) + { + bfd_nonfatal_message (NULL, obfd, padd->section, NULL); + return FALSE; + } + + pset = find_section_list (padd->name, FALSE, + SECTION_CONTEXT_SET_LMA | SECTION_CONTEXT_ALTER_LMA); + if (pset != NULL) + { + padd->section->lma = pset->lma_val; + + if (! bfd_set_section_alignment + (obfd, padd->section, + bfd_section_alignment (obfd, padd->section))) + { + bfd_nonfatal_message (NULL, obfd, padd->section, NULL); + return FALSE; + } + } + } + } + + if (update_sections != NULL) + { + struct section_add *pupdate; + + for (pupdate = update_sections; + pupdate != NULL; + pupdate = pupdate->next) + { + pupdate->section = bfd_get_section_by_name (ibfd, pupdate->name); + if (pupdate->section == NULL) + { + non_fatal (_("error: %s not found, can't be updated"), pupdate->name); + return FALSE; + } + + osec = pupdate->section->output_section; + if (! bfd_set_section_size (obfd, osec, pupdate->size)) + { + bfd_nonfatal_message (NULL, obfd, osec, NULL); + return FALSE; + } + } + } + + if (merge_notes) + { + /* This palaver is necessary because we must set the output + section size first, before its contents are ready. */ + osec = bfd_get_section_by_name (ibfd, GNU_BUILD_ATTRS_SECTION_NAME); + if (osec && is_merged_note_section (ibfd, osec)) + { + bfd_size_type size; + + size = bfd_get_section_size (osec); + if (size == 0) + { + bfd_nonfatal_message (NULL, ibfd, osec, _("warning: note section is empty")); + merge_notes = FALSE; + } + else if (! bfd_get_full_section_contents (ibfd, osec, & merged_notes)) + { + bfd_nonfatal_message (NULL, ibfd, osec, _("warning: could not load note section")); + free (merged_notes); + merged_notes = NULL; + merge_notes = FALSE; + } + else + { + merged_size = merge_gnu_build_notes (ibfd, osec, size, merged_notes); + if (merged_size == size) + { + /* Merging achieves nothing. */ + free (merged_notes); + merged_notes = NULL; + merge_notes = FALSE; + merged_size = 0; + } + else + { + if (osec->output_section == NULL + || ! bfd_set_section_size (obfd, osec->output_section, merged_size)) + { + bfd_nonfatal_message (NULL, obfd, osec, _("warning: failed to set merged notes size")); + free (merged_notes); + merged_notes = NULL; + merge_notes = FALSE; + merged_size = 0; + } + } + } + } + } + + if (dump_sections != NULL) + { + struct section_add * pdump; + + for (pdump = dump_sections; pdump != NULL; pdump = pdump->next) + { + osec = bfd_get_section_by_name (ibfd, pdump->name); + if (osec == NULL) + { + bfd_nonfatal_message (NULL, ibfd, NULL, + _("can't dump section '%s' - it does not exist"), + pdump->name); + continue; + } + + if ((bfd_get_section_flags (ibfd, osec) & SEC_HAS_CONTENTS) == 0) + { + bfd_nonfatal_message (NULL, ibfd, osec, + _("can't dump section - it has no contents")); + continue; + } + + bfd_size_type size = bfd_get_section_size (osec); + if (size == 0) + { + bfd_nonfatal_message (NULL, ibfd, osec, + _("can't dump section - it is empty")); + continue; + } + + FILE * f; + f = fopen (pdump->filename, FOPEN_WB); + if (f == NULL) + { + bfd_nonfatal_message (pdump->filename, NULL, NULL, + _("could not open section dump file")); + continue; + } + + bfd_byte *contents; + if (bfd_malloc_and_get_section (ibfd, osec, &contents)) + { + if (fwrite (contents, 1, size, f) != size) + { + non_fatal (_("error writing section contents to %s (error: %s)"), + pdump->filename, + strerror (errno)); + free (contents); + return FALSE; + } + } + else + bfd_nonfatal_message (NULL, ibfd, osec, + _("could not retrieve section contents")); + + fclose (f); + free (contents); + } + } + + if (gnu_debuglink_filename != NULL) + { + /* PR 15125: Give a helpful warning message if + the debuglink section already exists, and + allow the rest of the copy to complete. */ + if (bfd_get_section_by_name (obfd, ".gnu_debuglink")) + { + non_fatal (_("%s: debuglink section already exists"), + bfd_get_filename (obfd)); + gnu_debuglink_filename = NULL; + } + else + { + gnu_debuglink_section = bfd_create_gnu_debuglink_section + (obfd, gnu_debuglink_filename); + + if (gnu_debuglink_section == NULL) + { + bfd_nonfatal_message (NULL, obfd, NULL, + _("cannot create debug link section `%s'"), + gnu_debuglink_filename); + return FALSE; + } + + /* Special processing for PE format files. We + have no way to distinguish PE from COFF here. */ + if (bfd_get_flavour (obfd) == bfd_target_coff_flavour) + { + bfd_vma debuglink_vma; + asection * highest_section; + + /* The PE spec requires that all sections be adjacent and sorted + in ascending order of VMA. It also specifies that debug + sections should be last. This is despite the fact that debug + sections are not loaded into memory and so in theory have no + use for a VMA. + + This means that the debuglink section must be given a non-zero + VMA which makes it contiguous with other debug sections. So + walk the current section list, find the section with the + highest VMA and start the debuglink section after that one. */ + for (osec = obfd->sections, highest_section = NULL; + osec != NULL; + osec = osec->next) + if (osec->vma > 0 + && (highest_section == NULL + || osec->vma > highest_section->vma)) + highest_section = osec; + + if (highest_section) + debuglink_vma = BFD_ALIGN (highest_section->vma + + highest_section->size, + /* FIXME: We ought to be using + COFF_PAGE_SIZE here or maybe + bfd_get_section_alignment() (if it + was set) but since this is for PE + and we know the required alignment + it is easier just to hard code it. */ + 0x1000); + else + /* Umm, not sure what to do in this case. */ + debuglink_vma = 0x1000; + + bfd_set_section_vma (obfd, gnu_debuglink_section, debuglink_vma); + } + } + } + + c = bfd_count_sections (obfd); + if (c != 0 + && (gap_fill_set || pad_to_set)) + { + asection **set; + + /* We must fill in gaps between the sections and/or we must pad + the last section to a specified address. We do this by + grabbing a list of the sections, sorting them by VMA, and + increasing the section sizes as required to fill the gaps. + We write out the gap contents below. */ + + osections = (asection **) xmalloc (c * sizeof (asection *)); + set = osections; + bfd_map_over_sections (obfd, get_sections, &set); + + qsort (osections, c, sizeof (asection *), compare_section_lma); + + gaps = (bfd_size_type *) xmalloc (c * sizeof (bfd_size_type)); + memset (gaps, 0, c * sizeof (bfd_size_type)); + + if (gap_fill_set) + { + for (i = 0; i < c - 1; i++) + { + flagword flags; + bfd_size_type size; + bfd_vma gap_start, gap_stop; + + flags = bfd_get_section_flags (obfd, osections[i]); + if ((flags & SEC_HAS_CONTENTS) == 0 + || (flags & SEC_LOAD) == 0) + continue; + + size = bfd_section_size (obfd, osections[i]); + gap_start = bfd_section_lma (obfd, osections[i]) + size; + gap_stop = bfd_section_lma (obfd, osections[i + 1]); + if (gap_start < gap_stop) + { + if (! bfd_set_section_size (obfd, osections[i], + size + (gap_stop - gap_start))) + { + bfd_nonfatal_message (NULL, obfd, osections[i], + _("Can't fill gap after section")); + status = 1; + break; + } + gaps[i] = gap_stop - gap_start; + if (max_gap < gap_stop - gap_start) + max_gap = gap_stop - gap_start; + } + } + } + + if (pad_to_set) + { + bfd_vma lma; + bfd_size_type size; + + lma = bfd_section_lma (obfd, osections[c - 1]); + size = bfd_section_size (obfd, osections[c - 1]); + if (lma + size < pad_to) + { + if (! bfd_set_section_size (obfd, osections[c - 1], + pad_to - lma)) + { + bfd_nonfatal_message (NULL, obfd, osections[c - 1], + _("can't add padding")); + status = 1; + } + else + { + gaps[c - 1] = pad_to - (lma + size); + if (max_gap < pad_to - (lma + size)) + max_gap = pad_to - (lma + size); + } + } + } + } + + /* Symbol filtering must happen after the output sections + have been created, but before their contents are set. */ + dhandle = NULL; + if (convert_debugging) + dhandle = read_debugging_info (ibfd, isympp, symcount, FALSE); + + if (strip_symbols == STRIP_DEBUG + || strip_symbols == STRIP_ALL + || strip_symbols == STRIP_UNNEEDED + || strip_symbols == STRIP_NONDEBUG + || strip_symbols == STRIP_DWO + || strip_symbols == STRIP_NONDWO + || discard_locals != LOCALS_UNDEF + || localize_hidden + || htab_elements (strip_specific_htab) != 0 + || htab_elements (keep_specific_htab) != 0 + || htab_elements (localize_specific_htab) != 0 + || htab_elements (globalize_specific_htab) != 0 + || htab_elements (keepglobal_specific_htab) != 0 + || htab_elements (weaken_specific_htab) != 0 + || htab_elements (redefine_specific_htab) != 0 + || prefix_symbols_string + || sections_removed + || sections_copied + || convert_debugging + || change_leading_char + || remove_leading_char + || section_rename_list + || weaken + || add_symbols) + { + /* Mark symbols used in output relocations so that they + are kept, even if they are local labels or static symbols. + + Note we iterate over the input sections examining their + relocations since the relocations for the output sections + haven't been set yet. mark_symbols_used_in_relocations will + ignore input sections which have no corresponding output + section. */ + if (strip_symbols != STRIP_ALL) + bfd_map_over_sections (ibfd, + mark_symbols_used_in_relocations, + isympp); + osympp = (asymbol **) xmalloc ((symcount + add_symbols + 1) * sizeof (asymbol *)); + symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount); + } + + if (convert_debugging && dhandle != NULL) + { + if (! write_debugging_info (obfd, dhandle, &symcount, &osympp)) + { + status = 1; + return FALSE; + } + } + + bfd_set_symtab (obfd, osympp, symcount); + + /* This has to happen before section positions are set. */ + bfd_map_over_sections (ibfd, copy_relocations_in_section, obfd); + + /* This has to happen after the symbol table has been set. */ + bfd_map_over_sections (ibfd, copy_section, obfd); + + if (add_sections != NULL) + { + struct section_add *padd; + + for (padd = add_sections; padd != NULL; padd = padd->next) + { + if (! bfd_set_section_contents (obfd, padd->section, padd->contents, + 0, padd->size)) + { + bfd_nonfatal_message (NULL, obfd, padd->section, NULL); + return FALSE; + } + } + } + + if (update_sections != NULL) + { + struct section_add *pupdate; + + for (pupdate = update_sections; + pupdate != NULL; + pupdate = pupdate->next) + { + osec = pupdate->section->output_section; + if (! bfd_set_section_contents (obfd, osec, pupdate->contents, + 0, pupdate->size)) + { + bfd_nonfatal_message (NULL, obfd, osec, NULL); + return FALSE; + } + } + } + + if (merge_notes) + { + osec = bfd_get_section_by_name (obfd, GNU_BUILD_ATTRS_SECTION_NAME); + if (osec && is_merged_note_section (obfd, osec)) + { + if (! bfd_set_section_contents (obfd, osec, merged_notes, 0, merged_size)) + { + bfd_nonfatal_message (NULL, obfd, osec, _("error: failed to copy merged notes into output")); + return FALSE; + } + } + else if (! is_strip) + bfd_nonfatal_message (NULL, obfd, osec, _("could not find any mergeable note sections")); + free (merged_notes); + merged_notes = NULL; + merge_notes = FALSE; + } + + if (gnu_debuglink_filename != NULL) + { + if (! bfd_fill_in_gnu_debuglink_section + (obfd, gnu_debuglink_section, gnu_debuglink_filename)) + { + bfd_nonfatal_message (NULL, obfd, NULL, + _("cannot fill debug link section `%s'"), + gnu_debuglink_filename); + return FALSE; + } + } + + if (gap_fill_set || pad_to_set) + { + bfd_byte *buf; + + /* Fill in the gaps. */ + if (max_gap > 8192) + max_gap = 8192; + buf = (bfd_byte *) xmalloc (max_gap); + memset (buf, gap_fill, max_gap); + + c = bfd_count_sections (obfd); + for (i = 0; i < c; i++) + { + if (gaps[i] != 0) + { + bfd_size_type left; + file_ptr off; + + left = gaps[i]; + off = bfd_section_size (obfd, osections[i]) - left; + + while (left > 0) + { + bfd_size_type now; + + if (left > 8192) + now = 8192; + else + now = left; + + if (! bfd_set_section_contents (obfd, osections[i], buf, + off, now)) + { + bfd_nonfatal_message (NULL, obfd, osections[i], NULL); + return FALSE; + } + + left -= now; + off += now; + } + } + } + } + + /* Allow the BFD backend to copy any private data it understands + from the input BFD to the output BFD. This is done last to + permit the routine to look at the filtered symbol table, which is + important for the ECOFF code at least. */ + if (! bfd_copy_private_bfd_data (ibfd, obfd)) + { + bfd_nonfatal_message (NULL, obfd, NULL, + _("error copying private BFD data")); + return FALSE; + } + + /* Switch to the alternate machine code. We have to do this at the + very end, because we only initialize the header when we create + the first section. */ + if (use_alt_mach_code != 0) + { + if (! bfd_alt_mach_code (obfd, use_alt_mach_code)) + { + non_fatal (_("this target does not support %lu alternative machine codes"), + use_alt_mach_code); + if (bfd_get_flavour (obfd) == bfd_target_elf_flavour) + { + non_fatal (_("treating that number as an absolute e_machine value instead")); + elf_elfheader (obfd)->e_machine = use_alt_mach_code; + } + else + non_fatal (_("ignoring the alternative value")); + } + } + + return TRUE; +} + +/* Read each archive element in turn from IBFD, copy the + contents to temp file, and keep the temp file handle. + If 'force_output_target' is TRUE then make sure that + all elements in the new archive are of the type + 'output_target'. */ + +static void +copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, + bfd_boolean force_output_target, + const bfd_arch_info_type *input_arch) +{ + struct name_list + { + struct name_list *next; + const char *name; + bfd *obfd; + } *list, *l; + bfd **ptr = &obfd->archive_head; + bfd *this_element; + char *dir; + const char *filename; + + /* Make a temp directory to hold the contents. */ + dir = make_tempdir (bfd_get_filename (obfd)); + if (dir == NULL) + fatal (_("cannot create tempdir for archive copying (error: %s)"), + strerror (errno)); + + if (strip_symbols == STRIP_ALL) + obfd->has_armap = FALSE; + else + obfd->has_armap = ibfd->has_armap; + obfd->is_thin_archive = ibfd->is_thin_archive; + + if (deterministic) + obfd->flags |= BFD_DETERMINISTIC_OUTPUT; + + list = NULL; + + this_element = bfd_openr_next_archived_file (ibfd, NULL); + + if (!bfd_set_format (obfd, bfd_get_format (ibfd))) + { + status = 1; + bfd_nonfatal_message (NULL, obfd, NULL, NULL); + goto cleanup_and_exit; + } + + while (!status && this_element != NULL) + { + char *output_name; + bfd *output_bfd; + bfd *last_element; + struct stat buf; + int stat_status = 0; + bfd_boolean del = TRUE; + bfd_boolean ok_object; + + /* PR binutils/17533: Do not allow directory traversal + outside of the current directory tree by archive members. */ + if (! is_valid_archive_path (bfd_get_filename (this_element))) + { + non_fatal (_("illegal pathname found in archive member: %s"), + bfd_get_filename (this_element)); + status = 1; + goto cleanup_and_exit; + } + + /* Create an output file for this member. */ + output_name = concat (dir, "/", + bfd_get_filename (this_element), (char *) 0); + + /* If the file already exists, make another temp dir. */ + if (stat (output_name, &buf) >= 0) + { + output_name = make_tempdir (output_name); + if (output_name == NULL) + { + non_fatal (_("cannot create tempdir for archive copying (error: %s)"), + strerror (errno)); + status = 1; + goto cleanup_and_exit; + } + + l = (struct name_list *) xmalloc (sizeof (struct name_list)); + l->name = output_name; + l->next = list; + l->obfd = NULL; + list = l; + output_name = concat (output_name, "/", + bfd_get_filename (this_element), (char *) 0); + } + + if (preserve_dates) + { + stat_status = bfd_stat_arch_elt (this_element, &buf); + + if (stat_status != 0) + non_fatal (_("internal stat error on %s"), + bfd_get_filename (this_element)); + } + + l = (struct name_list *) xmalloc (sizeof (struct name_list)); + l->name = output_name; + l->next = list; + l->obfd = NULL; + list = l; + + ok_object = bfd_check_format (this_element, bfd_object); + if (!ok_object) + bfd_nonfatal_message (NULL, this_element, NULL, + _("Unable to recognise the format of file")); + + /* PR binutils/3110: Cope with archives + containing multiple target types. */ + if (force_output_target || !ok_object) + output_bfd = bfd_openw (output_name, output_target); + else + output_bfd = bfd_openw (output_name, bfd_get_target (this_element)); + + if (output_bfd == NULL) + { + bfd_nonfatal_message (output_name, NULL, NULL, NULL); + status = 1; + goto cleanup_and_exit; + } + + if (ok_object) + { + del = !copy_object (this_element, output_bfd, input_arch); + + if (del && bfd_get_arch (this_element) == bfd_arch_unknown) + /* Try again as an unknown object file. */ + ok_object = FALSE; + else if (!bfd_close (output_bfd)) + { + bfd_nonfatal_message (output_name, NULL, NULL, NULL); + /* Error in new object file. Don't change archive. */ + status = 1; + } + } + + if (!ok_object) + { + del = !copy_unknown_object (this_element, output_bfd); + if (!bfd_close_all_done (output_bfd)) + { + bfd_nonfatal_message (output_name, NULL, NULL, NULL); + /* Error in new object file. Don't change archive. */ + status = 1; + } + } + + if (del) + { + unlink (output_name); + status = 1; + } + else + { + if (preserve_dates && stat_status == 0) + set_times (output_name, &buf); + + /* Open the newly output file and attach to our list. */ + output_bfd = bfd_openr (output_name, output_target); + + l->obfd = output_bfd; + + *ptr = output_bfd; + ptr = &output_bfd->archive_next; + + last_element = this_element; + + this_element = bfd_openr_next_archived_file (ibfd, last_element); + + bfd_close (last_element); + } + } + *ptr = NULL; + + filename = bfd_get_filename (obfd); + if (!bfd_close (obfd)) + { + status = 1; + bfd_nonfatal_message (filename, NULL, NULL, NULL); + } + + filename = bfd_get_filename (ibfd); + if (!bfd_close (ibfd)) + { + status = 1; + bfd_nonfatal_message (filename, NULL, NULL, NULL); + } + + cleanup_and_exit: + /* Delete all the files that we opened. */ + for (l = list; l != NULL; l = l->next) + { + if (l->obfd == NULL) + rmdir (l->name); + else + { + bfd_close (l->obfd); + unlink (l->name); + } + } + + rmdir (dir); +} + +static void +set_long_section_mode (bfd *output_bfd, bfd *input_bfd, enum long_section_name_handling style) +{ + /* This is only relevant to Coff targets. */ + if (bfd_get_flavour (output_bfd) == bfd_target_coff_flavour) + { + if (style == KEEP + && bfd_get_flavour (input_bfd) == bfd_target_coff_flavour) + style = bfd_coff_long_section_names (input_bfd) ? ENABLE : DISABLE; + bfd_coff_set_long_section_names (output_bfd, style != DISABLE); + } +} + +/* The top-level control. */ + +static void +copy_file (const char *input_filename, const char *output_filename, + const char *input_target, const char *output_target, + const bfd_arch_info_type *input_arch) +{ + bfd *ibfd; + char **obj_matching; + char **core_matching; + off_t size = get_file_size (input_filename); + + if (size < 1) + { + if (size == 0) + non_fatal (_("error: the input file '%s' is empty"), + input_filename); + status = 1; + return; + } + + /* To allow us to do "strip *" without dying on the first + non-object file, failures are nonfatal. */ + ibfd = bfd_openr (input_filename, input_target); + if (ibfd == NULL) + { + bfd_nonfatal_message (input_filename, NULL, NULL, NULL); + status = 1; + return; + } + + switch (do_debug_sections) + { + case compress: + case compress_zlib: + case compress_gnu_zlib: + case compress_gabi_zlib: + ibfd->flags |= BFD_COMPRESS; + /* Don't check if input is ELF here since this information is + only available after bfd_check_format_matches is called. */ + if (do_debug_sections != compress_gnu_zlib) + ibfd->flags |= BFD_COMPRESS_GABI; + break; + case decompress: + ibfd->flags |= BFD_DECOMPRESS; + break; + default: + break; + } + + switch (do_elf_stt_common) + { + case elf_stt_common: + ibfd->flags |= BFD_CONVERT_ELF_COMMON | BFD_USE_ELF_STT_COMMON; + break; + break; + case no_elf_stt_common: + ibfd->flags |= BFD_CONVERT_ELF_COMMON; + break; + default: + break; + } + + if (bfd_check_format (ibfd, bfd_archive)) + { + bfd_boolean force_output_target; + bfd *obfd; + + /* bfd_get_target does not return the correct value until + bfd_check_format succeeds. */ + if (output_target == NULL) + { + output_target = bfd_get_target (ibfd); + force_output_target = FALSE; + } + else + force_output_target = TRUE; + + obfd = bfd_openw (output_filename, output_target); + if (obfd == NULL) + { + bfd_nonfatal_message (output_filename, NULL, NULL, NULL); + status = 1; + return; + } + /* This is a no-op on non-Coff targets. */ + set_long_section_mode (obfd, ibfd, long_section_names); + + copy_archive (ibfd, obfd, output_target, force_output_target, input_arch); + } + else if (bfd_check_format_matches (ibfd, bfd_object, &obj_matching)) + { + bfd *obfd; + do_copy: + + /* bfd_get_target does not return the correct value until + bfd_check_format succeeds. */ + if (output_target == NULL) + output_target = bfd_get_target (ibfd); + + obfd = bfd_openw (output_filename, output_target); + if (obfd == NULL) + { + bfd_nonfatal_message (output_filename, NULL, NULL, NULL); + status = 1; + return; + } + /* This is a no-op on non-Coff targets. */ + set_long_section_mode (obfd, ibfd, long_section_names); + + if (! copy_object (ibfd, obfd, input_arch)) + status = 1; + + /* PR 17512: file: 0f15796a. + If the file could not be copied it may not be in a writeable + state. So use bfd_close_all_done to avoid the possibility of + writing uninitialised data into the file. */ + if (! (status ? bfd_close_all_done (obfd) : bfd_close (obfd))) + { + status = 1; + bfd_nonfatal_message (output_filename, NULL, NULL, NULL); + return; + } + + if (!bfd_close (ibfd)) + { + status = 1; + bfd_nonfatal_message (input_filename, NULL, NULL, NULL); + return; + } + } + else + { + bfd_error_type obj_error = bfd_get_error (); + bfd_error_type core_error; + + if (bfd_check_format_matches (ibfd, bfd_core, &core_matching)) + { + /* This probably can't happen.. */ + if (obj_error == bfd_error_file_ambiguously_recognized) + free (obj_matching); + goto do_copy; + } + + core_error = bfd_get_error (); + /* Report the object error in preference to the core error. */ + if (obj_error != core_error) + bfd_set_error (obj_error); + + bfd_nonfatal_message (input_filename, NULL, NULL, NULL); + + if (obj_error == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (obj_matching); + free (obj_matching); + } + if (core_error == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (core_matching); + free (core_matching); + } + + status = 1; + } +} + +/* Add a name to the section renaming list. */ + +static void +add_section_rename (const char * old_name, const char * new_name, + flagword flags) +{ + section_rename * srename; + + /* Check for conflicts first. */ + for (srename = section_rename_list; srename != NULL; srename = srename->next) + if (strcmp (srename->old_name, old_name) == 0) + { + /* Silently ignore duplicate definitions. */ + if (strcmp (srename->new_name, new_name) == 0 + && srename->flags == flags) + return; + + fatal (_("Multiple renames of section %s"), old_name); + } + + srename = (section_rename *) xmalloc (sizeof (* srename)); + + srename->old_name = old_name; + srename->new_name = new_name; + srename->flags = flags; + srename->next = section_rename_list; + + section_rename_list = srename; +} + +/* Check the section rename list for a new name of the input section + called OLD_NAME. Returns the new name if one is found and sets + RETURNED_FLAGS if non-NULL to the flags to be used for this section. */ + +static const char * +find_section_rename (const char *old_name, flagword *returned_flags) +{ + const section_rename *srename; + + for (srename = section_rename_list; srename != NULL; srename = srename->next) + if (strcmp (srename->old_name, old_name) == 0) + { + if (returned_flags != NULL && srename->flags != (flagword) -1) + *returned_flags = srename->flags; + + return srename->new_name; + } + + return old_name; +} + +/* Once each of the sections is copied, we may still need to do some + finalization work for private section headers. Do that here. */ + +static void +setup_bfd_headers (bfd *ibfd, bfd *obfd) +{ + /* Allow the BFD backend to copy any private data it understands + from the input section to the output section. */ + if (! bfd_copy_private_header_data (ibfd, obfd)) + { + status = 1; + bfd_nonfatal_message (NULL, ibfd, NULL, + _("error in private header data")); + return; + } + + /* All went well. */ + return; +} + +/* Create a section in OBFD with the same + name and attributes as ISECTION in IBFD. */ + +static void +setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) +{ + bfd *obfd = (bfd *) obfdarg; + struct section_list *p; + sec_ptr osection; + bfd_size_type size; + bfd_vma vma; + bfd_vma lma; + flagword flags; + const char *err; + const char * name; + char *prefix = NULL; + bfd_boolean make_nobits; + + if (is_strip_section (ibfd, isection)) + return; + + /* Get the, possibly new, name of the output section. */ + name = bfd_section_name (ibfd, isection); + flags = bfd_get_section_flags (ibfd, isection); + name = find_section_rename (name, &flags); + + /* Prefix sections. */ + if ((prefix_alloc_sections_string) + && (bfd_get_section_flags (ibfd, isection) & SEC_ALLOC)) + prefix = prefix_alloc_sections_string; + else if (prefix_sections_string) + prefix = prefix_sections_string; + + if (prefix) + { + char *n; + + n = (char *) xmalloc (strlen (prefix) + strlen (name) + 1); + strcpy (n, prefix); + strcat (n, name); + name = n; + } + + make_nobits = FALSE; + + p = find_section_list (bfd_section_name (ibfd, isection), FALSE, + SECTION_CONTEXT_SET_FLAGS); + if (p != NULL) + flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC)); + else if (strip_symbols == STRIP_NONDEBUG + && (flags & (SEC_ALLOC | SEC_GROUP)) != 0 + && !is_nondebug_keep_contents_section (ibfd, isection)) + { + flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD | SEC_GROUP); + if (obfd->xvec->flavour == bfd_target_elf_flavour) + { + make_nobits = TRUE; + + /* Twiddle the input section flags so that it seems to + elf.c:copy_private_bfd_data that section flags have not + changed between input and output sections. This hack + prevents wholesale rewriting of the program headers. */ + isection->flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD | SEC_GROUP); + } + } + + osection = bfd_make_section_anyway_with_flags (obfd, name, flags); + + if (osection == NULL) + { + err = _("failed to create output section"); + goto loser; + } + + if (make_nobits) + elf_section_type (osection) = SHT_NOBITS; + + size = bfd_section_size (ibfd, isection); + size = bfd_convert_section_size (ibfd, isection, obfd, size); + if (copy_byte >= 0) + size = (size + interleave - 1) / interleave * copy_width; + else if (extract_symbol) + size = 0; + if (! bfd_set_section_size (obfd, osection, size)) + { + err = _("failed to set size"); + goto loser; + } + + vma = bfd_section_vma (ibfd, isection); + p = find_section_list (bfd_section_name (ibfd, isection), FALSE, + SECTION_CONTEXT_ALTER_VMA | SECTION_CONTEXT_SET_VMA); + if (p != NULL) + { + if (p->context & SECTION_CONTEXT_SET_VMA) + vma = p->vma_val; + else + vma += p->vma_val; + } + else + vma += change_section_address; + + if (! bfd_set_section_vma (obfd, osection, vma)) + { + err = _("failed to set vma"); + goto loser; + } + + lma = isection->lma; + p = find_section_list (bfd_section_name (ibfd, isection), FALSE, + SECTION_CONTEXT_ALTER_LMA | SECTION_CONTEXT_SET_LMA); + if (p != NULL) + { + if (p->context & SECTION_CONTEXT_ALTER_LMA) + lma += p->lma_val; + else + lma = p->lma_val; + } + else + lma += change_section_address; + + osection->lma = lma; + + /* FIXME: This is probably not enough. If we change the LMA we + may have to recompute the header for the file as well. */ + if (!bfd_set_section_alignment (obfd, + osection, + bfd_section_alignment (ibfd, isection))) + { + err = _("failed to set alignment"); + goto loser; + } + + /* Copy merge entity size. */ + osection->entsize = isection->entsize; + + /* Copy compress status. */ + osection->compress_status = isection->compress_status; + + /* This used to be mangle_section; we do here to avoid using + bfd_get_section_by_name since some formats allow multiple + sections with the same name. */ + isection->output_section = osection; + isection->output_offset = 0; + + if ((isection->flags & SEC_GROUP) != 0) + { + asymbol *gsym = group_signature (isection); + + if (gsym != NULL) + { + gsym->flags |= BSF_KEEP; + if (ibfd->xvec->flavour == bfd_target_elf_flavour) + elf_group_id (isection) = gsym; + } + } + + /* Allow the BFD backend to copy any private data it understands + from the input section to the output section. */ + if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection)) + { + err = _("failed to copy private data"); + goto loser; + } + + /* All went well. */ + return; + + loser: + status = 1; + bfd_nonfatal_message (NULL, obfd, osection, err); +} + +/* Return TRUE if input section ISECTION should be skipped. */ + +static bfd_boolean +skip_section (bfd *ibfd, sec_ptr isection, bfd_boolean skip_copy) +{ + sec_ptr osection; + bfd_size_type size; + flagword flags; + + /* If we have already failed earlier on, + do not keep on generating complaints now. */ + if (status != 0) + return TRUE; + + if (extract_symbol) + return TRUE; + + if (is_strip_section (ibfd, isection)) + return TRUE; + + if (is_update_section (ibfd, isection)) + return TRUE; + + /* When merging a note section we skip the copying of the contents, + but not the copying of the relocs associated with the contents. */ + if (skip_copy && is_merged_note_section (ibfd, isection)) + return TRUE; + + flags = bfd_get_section_flags (ibfd, isection); + if ((flags & SEC_GROUP) != 0) + return TRUE; + + osection = isection->output_section; + size = bfd_get_section_size (isection); + + if (size == 0 || osection == 0) + return TRUE; + + return FALSE; +} + +/* Add section SECTION_PATTERN to the list of sections that will have their + relocations removed. */ + +static void +handle_remove_relocations_option (const char *section_pattern) +{ + find_section_list (section_pattern, TRUE, SECTION_CONTEXT_REMOVE_RELOCS); +} + +/* Return TRUE if ISECTION from IBFD should have its relocations removed, + otherwise return FALSE. If the user has requested that relocations be + removed from a section that does not have relocations then this + function will still return TRUE. */ + +static bfd_boolean +discard_relocations (bfd *ibfd ATTRIBUTE_UNUSED, asection *isection) +{ + return (find_section_list (bfd_section_name (ibfd, isection), FALSE, + SECTION_CONTEXT_REMOVE_RELOCS) != NULL); +} + +/* Wrapper for dealing with --remove-section (-R) command line arguments. + A special case is detected here, if the user asks to remove a relocation + section (one starting with ".rela." or ".rel.") then this removal must + be done using a different technique. */ + +static void +handle_remove_section_option (const char *section_pattern) +{ + if (strncmp (section_pattern, ".rela.", 6) == 0) + handle_remove_relocations_option (section_pattern + 5); + else if (strncmp (section_pattern, ".rel.", 5) == 0) + handle_remove_relocations_option (section_pattern + 4); + else + { + find_section_list (section_pattern, TRUE, SECTION_CONTEXT_REMOVE); + sections_removed = TRUE; + } +} + +/* Copy relocations in input section ISECTION of IBFD to an output + section with the same name in OBFDARG. If stripping then don't + copy any relocation info. */ + +static void +copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg) +{ + bfd *obfd = (bfd *) obfdarg; + long relsize; + arelent **relpp; + long relcount; + sec_ptr osection; + + if (skip_section (ibfd, isection, FALSE)) + return; + + osection = isection->output_section; + + /* Core files and DWO files do not need to be relocated. */ + if (bfd_get_format (obfd) == bfd_core + || strip_symbols == STRIP_NONDWO + || discard_relocations (ibfd, isection)) + relsize = 0; + else + { + relsize = bfd_get_reloc_upper_bound (ibfd, isection); + + if (relsize < 0) + { + /* Do not complain if the target does not support relocations. */ + if (relsize == -1 && bfd_get_error () == bfd_error_invalid_operation) + relsize = 0; + else + { + status = 1; + bfd_nonfatal_message (NULL, ibfd, isection, NULL); + return; + } + } + } + + if (relsize == 0) + { + bfd_set_reloc (obfd, osection, NULL, 0); + osection->flags &= ~SEC_RELOC; + } + else + { + if (isection->orelocation != NULL) + { + /* Some other function has already set up the output relocs + for us, so scan those instead of the default relocs. */ + relcount = isection->reloc_count; + relpp = isection->orelocation; + } + else + { + relpp = (arelent **) xmalloc (relsize); + relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp); + if (relcount < 0) + { + status = 1; + bfd_nonfatal_message (NULL, ibfd, isection, + _("relocation count is negative")); + return; + } + } + + if (strip_symbols == STRIP_ALL) + { + /* Remove relocations which are not in + keep_strip_specific_list. */ + arelent **temp_relpp; + long temp_relcount = 0; + long i; + + temp_relpp = (arelent **) xmalloc (relsize); + for (i = 0; i < relcount; i++) + { + /* PR 17512: file: 9e907e0c. */ + if (relpp[i]->sym_ptr_ptr + /* PR 20096 */ + && * relpp[i]->sym_ptr_ptr) + if (is_specified_symbol (bfd_asymbol_name (*relpp[i]->sym_ptr_ptr), + keep_specific_htab)) + temp_relpp [temp_relcount++] = relpp [i]; + } + relcount = temp_relcount; + if (isection->orelocation == NULL) + free (relpp); + relpp = temp_relpp; + } + + bfd_set_reloc (obfd, osection, relcount == 0 ? NULL : relpp, relcount); + if (relcount == 0) + { + osection->flags &= ~SEC_RELOC; + free (relpp); + } + } +} + +/* Copy the data of input section ISECTION of IBFD + to an output section with the same name in OBFD. */ + +static void +copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg) +{ + bfd *obfd = (bfd *) obfdarg; + struct section_list *p; + sec_ptr osection; + bfd_size_type size; + + if (skip_section (ibfd, isection, TRUE)) + return; + + osection = isection->output_section; + /* The output SHF_COMPRESSED section size is different from input if + ELF classes of input and output aren't the same. We can't use + the output section size since --interleave will shrink the output + section. Size will be updated if the section is converted. */ + size = bfd_get_section_size (isection); + + if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS + && bfd_get_section_flags (obfd, osection) & SEC_HAS_CONTENTS) + { + bfd_byte *memhunk = NULL; + + if (!bfd_get_full_section_contents (ibfd, isection, &memhunk) + || !bfd_convert_section_contents (ibfd, isection, obfd, + &memhunk, &size)) + { + status = 1; + bfd_nonfatal_message (NULL, ibfd, isection, NULL); + free (memhunk); + return; + } + + if (reverse_bytes) + { + /* We don't handle leftover bytes (too many possible behaviors, + and we don't know what the user wants). The section length + must be a multiple of the number of bytes to swap. */ + if ((size % reverse_bytes) == 0) + { + unsigned long i, j; + bfd_byte b; + + for (i = 0; i < size; i += reverse_bytes) + for (j = 0; j < (unsigned long)(reverse_bytes / 2); j++) + { + bfd_byte *m = (bfd_byte *) memhunk; + + b = m[i + j]; + m[i + j] = m[(i + reverse_bytes) - (j + 1)]; + m[(i + reverse_bytes) - (j + 1)] = b; + } + } + else + /* User must pad the section up in order to do this. */ + fatal (_("cannot reverse bytes: length of section %s must be evenly divisible by %d"), + bfd_section_name (ibfd, isection), reverse_bytes); + } + + if (copy_byte >= 0) + { + /* Keep only every `copy_byte'th byte in MEMHUNK. */ + char *from = (char *) memhunk + copy_byte; + char *to = (char *) memhunk; + char *end = (char *) memhunk + size; + int i; + + /* If the section address is not exactly divisible by the interleave, + then we must bias the from address. If the copy_byte is less than + the bias, then we must skip forward one interleave, and increment + the final lma. */ + int extra = isection->lma % interleave; + from -= extra; + if (copy_byte < extra) + from += interleave; + + for (; from < end; from += interleave) + for (i = 0; i < copy_width; i++) + { + if (&from[i] >= end) + break; + *to++ = from[i]; + } + + size = (size + interleave - 1 - copy_byte) / interleave * copy_width; + osection->lma /= interleave; + if (copy_byte < extra) + osection->lma++; + } + + if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size)) + { + status = 1; + bfd_nonfatal_message (NULL, obfd, osection, NULL); + free (memhunk); + return; + } + free (memhunk); + } + else if ((p = find_section_list (bfd_get_section_name (ibfd, isection), + FALSE, SECTION_CONTEXT_SET_FLAGS)) != NULL + && (p->flags & SEC_HAS_CONTENTS) != 0) + { + void *memhunk = xmalloc (size); + + /* We don't permit the user to turn off the SEC_HAS_CONTENTS + flag--they can just remove the section entirely and add it + back again. However, we do permit them to turn on the + SEC_HAS_CONTENTS flag, and take it to mean that the section + contents should be zeroed out. */ + + memset (memhunk, 0, size); + if (! bfd_set_section_contents (obfd, osection, memhunk, 0, size)) + { + status = 1; + bfd_nonfatal_message (NULL, obfd, osection, NULL); + free (memhunk); + return; + } + free (memhunk); + } +} + +/* Get all the sections. This is used when --gap-fill or --pad-to is + used. */ + +static void +get_sections (bfd *obfd ATTRIBUTE_UNUSED, asection *osection, void *secppparg) +{ + asection ***secppp = (asection ***) secppparg; + + **secppp = osection; + ++(*secppp); +} + +/* Sort sections by VMA. This is called via qsort, and is used when + --gap-fill or --pad-to is used. We force non loadable or empty + sections to the front, where they are easier to ignore. */ + +static int +compare_section_lma (const void *arg1, const void *arg2) +{ + const asection *const *sec1 = (const asection * const *) arg1; + const asection *const *sec2 = (const asection * const *) arg2; + flagword flags1, flags2; + + /* Sort non loadable sections to the front. */ + flags1 = (*sec1)->flags; + flags2 = (*sec2)->flags; + if ((flags1 & SEC_HAS_CONTENTS) == 0 + || (flags1 & SEC_LOAD) == 0) + { + if ((flags2 & SEC_HAS_CONTENTS) != 0 + && (flags2 & SEC_LOAD) != 0) + return -1; + } + else + { + if ((flags2 & SEC_HAS_CONTENTS) == 0 + || (flags2 & SEC_LOAD) == 0) + return 1; + } + + /* Sort sections by LMA. */ + if ((*sec1)->lma > (*sec2)->lma) + return 1; + else if ((*sec1)->lma < (*sec2)->lma) + return -1; + + /* Sort sections with the same LMA by size. */ + if (bfd_get_section_size (*sec1) > bfd_get_section_size (*sec2)) + return 1; + else if (bfd_get_section_size (*sec1) < bfd_get_section_size (*sec2)) + return -1; + + return 0; +} + +/* Mark all the symbols which will be used in output relocations with + the BSF_KEEP flag so that those symbols will not be stripped. + + Ignore relocations which will not appear in the output file. */ + +static void +mark_symbols_used_in_relocations (bfd *ibfd, sec_ptr isection, void *symbolsarg) +{ + asymbol **symbols = (asymbol **) symbolsarg; + long relsize; + arelent **relpp; + long relcount, i; + + /* Ignore an input section with no corresponding output section. */ + if (isection->output_section == NULL) + return; + + relsize = bfd_get_reloc_upper_bound (ibfd, isection); + if (relsize < 0) + { + /* Do not complain if the target does not support relocations. */ + if (relsize == -1 && bfd_get_error () == bfd_error_invalid_operation) + return; + bfd_fatal (bfd_get_filename (ibfd)); + } + + if (relsize == 0) + return; + + relpp = (arelent **) xmalloc (relsize); + relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, symbols); + if (relcount < 0) + bfd_fatal (bfd_get_filename (ibfd)); + + /* Examine each symbol used in a relocation. If it's not one of the + special bfd section symbols, then mark it with BSF_KEEP. */ + for (i = 0; i < relcount; i++) + { + /* See PRs 20923 and 20930 for reproducers for the NULL tests. */ + if (relpp[i]->sym_ptr_ptr != NULL + && * relpp[i]->sym_ptr_ptr != NULL + && *relpp[i]->sym_ptr_ptr != bfd_com_section_ptr->symbol + && *relpp[i]->sym_ptr_ptr != bfd_abs_section_ptr->symbol + && *relpp[i]->sym_ptr_ptr != bfd_und_section_ptr->symbol) + (*relpp[i]->sym_ptr_ptr)->flags |= BSF_KEEP; + } + + if (relpp != NULL) + free (relpp); +} + +/* Write out debugging information. */ + +static bfd_boolean +write_debugging_info (bfd *obfd, void *dhandle, + long *symcountp ATTRIBUTE_UNUSED, + asymbol ***symppp ATTRIBUTE_UNUSED) +{ + if (bfd_get_flavour (obfd) == bfd_target_ieee_flavour) + return write_ieee_debugging_info (obfd, dhandle); + + if (bfd_get_flavour (obfd) == bfd_target_coff_flavour + || bfd_get_flavour (obfd) == bfd_target_elf_flavour) + { + bfd_byte *syms, *strings; + bfd_size_type symsize, stringsize; + asection *stabsec, *stabstrsec; + flagword flags; + + if (! write_stabs_in_sections_debugging_info (obfd, dhandle, &syms, + &symsize, &strings, + &stringsize)) + return FALSE; + + flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING; + stabsec = bfd_make_section_with_flags (obfd, ".stab", flags); + stabstrsec = bfd_make_section_with_flags (obfd, ".stabstr", flags); + if (stabsec == NULL + || stabstrsec == NULL + || ! bfd_set_section_size (obfd, stabsec, symsize) + || ! bfd_set_section_size (obfd, stabstrsec, stringsize) + || ! bfd_set_section_alignment (obfd, stabsec, 2) + || ! bfd_set_section_alignment (obfd, stabstrsec, 0)) + { + bfd_nonfatal_message (NULL, obfd, NULL, + _("can't create debugging section")); + return FALSE; + } + + /* We can get away with setting the section contents now because + the next thing the caller is going to do is copy over the + real sections. We may someday have to split the contents + setting out of this function. */ + if (! bfd_set_section_contents (obfd, stabsec, syms, 0, symsize) + || ! bfd_set_section_contents (obfd, stabstrsec, strings, 0, + stringsize)) + { + bfd_nonfatal_message (NULL, obfd, NULL, + _("can't set debugging section contents")); + return FALSE; + } + + return TRUE; + } + + bfd_nonfatal_message (NULL, obfd, NULL, + _("don't know how to write debugging information for %s"), + bfd_get_target (obfd)); + return FALSE; +} + +/* If neither -D nor -U was specified explicitly, + then use the configured default. */ +static void +default_deterministic (void) +{ + if (deterministic < 0) + deterministic = DEFAULT_AR_DETERMINISTIC; +} + +static int +strip_main (int argc, char *argv[]) +{ + char *input_target = NULL; + char *output_target = NULL; + bfd_boolean show_version = FALSE; + bfd_boolean formats_info = FALSE; + int c; + int i; + char *output_file = NULL; + + merge_notes = TRUE; + + while ((c = getopt_long (argc, argv, "I:O:F:K:MN:R:o:sSpdgxXHhVvwDU", + strip_options, (int *) 0)) != EOF) + { + switch (c) + { + case 'I': + input_target = optarg; + break; + case 'O': + output_target = optarg; + break; + case 'F': + input_target = output_target = optarg; + break; + case 'R': + handle_remove_section_option (optarg); + break; + case OPTION_REMOVE_RELOCS: + handle_remove_relocations_option (optarg); + break; + case 's': + strip_symbols = STRIP_ALL; + break; + case 'S': + case 'g': + case 'd': /* Historic BSD alias for -g. Used by early NetBSD. */ + strip_symbols = STRIP_DEBUG; + break; + case OPTION_STRIP_DWO: + strip_symbols = STRIP_DWO; + break; + case OPTION_STRIP_UNNEEDED: + strip_symbols = STRIP_UNNEEDED; + break; + case 'K': + add_specific_symbol (optarg, keep_specific_htab); + break; + case 'M': + merge_notes = TRUE; + break; + case OPTION_NO_MERGE_NOTES: + merge_notes = FALSE; + break; + case 'N': + add_specific_symbol (optarg, strip_specific_htab); + break; + case 'o': + output_file = optarg; + break; + case 'p': + preserve_dates = TRUE; + break; + case 'D': + deterministic = TRUE; + break; + case 'U': + deterministic = FALSE; + break; + case 'x': + discard_locals = LOCALS_ALL; + break; + case 'X': + discard_locals = LOCALS_START_L; + break; + case 'v': + verbose = TRUE; + break; + case 'V': + show_version = TRUE; + break; + case OPTION_FORMATS_INFO: + formats_info = TRUE; + break; + case OPTION_ONLY_KEEP_DEBUG: + strip_symbols = STRIP_NONDEBUG; + break; + case OPTION_KEEP_FILE_SYMBOLS: + keep_file_symbols = 1; + break; + case 0: + /* We've been given a long option. */ + break; + case 'w': + wildcard = TRUE; + break; + case 'H': + case 'h': + strip_usage (stdout, 0); + default: + strip_usage (stderr, 1); + } + } + + if (formats_info) + { + display_info (); + return 0; + } + + if (show_version) + print_version ("strip"); + + default_deterministic (); + + /* Default is to strip all symbols. */ + if (strip_symbols == STRIP_UNDEF + && discard_locals == LOCALS_UNDEF + && htab_elements (strip_specific_htab) == 0) + strip_symbols = STRIP_ALL; + + if (output_target == NULL) + output_target = input_target; + + i = optind; + if (i == argc + || (output_file != NULL && (i + 1) < argc)) + strip_usage (stderr, 1); + + for (; i < argc; i++) + { + int hold_status = status; + struct stat statbuf; + char *tmpname; + + if (get_file_size (argv[i]) < 1) + { + status = 1; + continue; + } + + if (preserve_dates) + /* No need to check the return value of stat(). + It has already been checked in get_file_size(). */ + stat (argv[i], &statbuf); + + if (output_file == NULL + || filename_cmp (argv[i], output_file) == 0) + tmpname = make_tempname (argv[i]); + else + tmpname = output_file; + + if (tmpname == NULL) + { + bfd_nonfatal_message (argv[i], NULL, NULL, + _("could not create temporary file to hold stripped copy")); + status = 1; + continue; + } + + status = 0; + copy_file (argv[i], tmpname, input_target, output_target, NULL); + if (status == 0) + { + if (preserve_dates) + set_times (tmpname, &statbuf); + if (output_file != tmpname) + status = (smart_rename (tmpname, + output_file ? output_file : argv[i], + preserve_dates) != 0); + if (status == 0) + status = hold_status; + } + else + unlink_if_ordinary (tmpname); + if (output_file != tmpname) + free (tmpname); + } + + return status; +} + +/* Set up PE subsystem. */ + +static void +set_pe_subsystem (const char *s) +{ + const char *version, *subsystem; + size_t i; + static const struct + { + const char *name; + const char set_def; + const short value; + } + v[] = + { + { "native", 0, IMAGE_SUBSYSTEM_NATIVE }, + { "windows", 0, IMAGE_SUBSYSTEM_WINDOWS_GUI }, + { "console", 0, IMAGE_SUBSYSTEM_WINDOWS_CUI }, + { "posix", 0, IMAGE_SUBSYSTEM_POSIX_CUI }, + { "wince", 0, IMAGE_SUBSYSTEM_WINDOWS_CE_GUI }, + { "efi-app", 1, IMAGE_SUBSYSTEM_EFI_APPLICATION }, + { "efi-bsd", 1, IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER }, + { "efi-rtd", 1, IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER }, + { "sal-rtd", 1, IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER }, + { "xbox", 0, IMAGE_SUBSYSTEM_XBOX } + }; + short value; + char *copy; + int set_def = -1; + + /* Check for the presence of a version number. */ + version = strchr (s, ':'); + if (version == NULL) + subsystem = s; + else + { + int len = version - s; + copy = xstrdup (s); + subsystem = copy; + copy[len] = '\0'; + version = copy + 1 + len; + pe_major_subsystem_version = strtoul (version, ©, 0); + if (*copy == '.') + pe_minor_subsystem_version = strtoul (copy + 1, ©, 0); + if (*copy != '\0') + non_fatal (_("%s: bad version in PE subsystem"), s); + } + + /* Check for numeric subsystem. */ + value = (short) strtol (subsystem, ©, 0); + if (*copy == '\0') + { + for (i = 0; i < ARRAY_SIZE (v); i++) + if (v[i].value == value) + { + pe_subsystem = value; + set_def = v[i].set_def; + break; + } + } + else + { + /* Search for subsystem by name. */ + for (i = 0; i < ARRAY_SIZE (v); i++) + if (strcmp (subsystem, v[i].name) == 0) + { + pe_subsystem = v[i].value; + set_def = v[i].set_def; + break; + } + } + + switch (set_def) + { + case -1: + fatal (_("unknown PE subsystem: %s"), s); + break; + case 0: + break; + default: + if (pe_file_alignment == (bfd_vma) -1) + pe_file_alignment = PE_DEF_FILE_ALIGNMENT; + if (pe_section_alignment == (bfd_vma) -1) + pe_section_alignment = PE_DEF_SECTION_ALIGNMENT; + break; + } + if (s != subsystem) + free ((char *) subsystem); +} + +/* Convert EFI target to PEI target. */ + +static void +convert_efi_target (char *efi) +{ + efi[0] = 'p'; + efi[1] = 'e'; + efi[2] = 'i'; + + if (strcmp (efi + 4, "ia32") == 0) + { + /* Change ia32 to i386. */ + efi[5]= '3'; + efi[6]= '8'; + efi[7]= '6'; + } + else if (strcmp (efi + 4, "x86_64") == 0) + { + /* Change x86_64 to x86-64. */ + efi[7] = '-'; + } +} + +/* Allocate and return a pointer to a struct section_add, initializing the + structure using ARG, a string in the format "sectionname=filename". + The returned structure will have its next pointer set to NEXT. The + OPTION field is the name of the command line option currently being + parsed, and is only used if an error needs to be reported. */ + +static struct section_add * +init_section_add (const char *arg, + struct section_add *next, + const char *option) +{ + struct section_add *pa; + const char *s; + + s = strchr (arg, '='); + if (s == NULL) + fatal (_("bad format for %s"), option); + + pa = (struct section_add *) xmalloc (sizeof (struct section_add)); + pa->name = xstrndup (arg, s - arg); + pa->filename = s + 1; + pa->next = next; + pa->contents = NULL; + pa->size = 0; + + return pa; +} + +/* Load the file specified in PA, allocating memory to hold the file + contents, and store a pointer to the allocated memory in the contents + field of PA. The size field of PA is also updated. All errors call + FATAL. */ + +static void +section_add_load_file (struct section_add *pa) +{ + size_t off, alloc; + FILE *f; + + /* We don't use get_file_size so that we can do + --add-section .note.GNU_stack=/dev/null + get_file_size doesn't work on /dev/null. */ + + f = fopen (pa->filename, FOPEN_RB); + if (f == NULL) + fatal (_("cannot open: %s: %s"), + pa->filename, strerror (errno)); + + off = 0; + alloc = 4096; + pa->contents = (bfd_byte *) xmalloc (alloc); + while (!feof (f)) + { + off_t got; + + if (off == alloc) + { + alloc <<= 1; + pa->contents = (bfd_byte *) xrealloc (pa->contents, alloc); + } + + got = fread (pa->contents + off, 1, alloc - off, f); + if (ferror (f)) + fatal (_("%s: fread failed"), pa->filename); + + off += got; + } + + pa->size = off; + + fclose (f); +} + +static int +copy_main (int argc, char *argv[]) +{ + char *input_filename = NULL; + char *output_filename = NULL; + char *tmpname; + char *input_target = NULL; + char *output_target = NULL; + bfd_boolean show_version = FALSE; + bfd_boolean change_warn = TRUE; + bfd_boolean formats_info = FALSE; + int c; + struct stat statbuf; + const bfd_arch_info_type *input_arch = NULL; + + while ((c = getopt_long (argc, argv, "b:B:i:I:j:K:MN:s:O:d:F:L:G:R:SpgxXHhVvW:wDU", + copy_options, (int *) 0)) != EOF) + { + switch (c) + { + case 'b': + copy_byte = atoi (optarg); + if (copy_byte < 0) + fatal (_("byte number must be non-negative")); + break; + + case 'B': + input_arch = bfd_scan_arch (optarg); + if (input_arch == NULL) + fatal (_("architecture %s unknown"), optarg); + break; + + case 'i': + if (optarg) + { + interleave = atoi (optarg); + if (interleave < 1) + fatal (_("interleave must be positive")); + } + else + interleave = 4; + break; + + case OPTION_INTERLEAVE_WIDTH: + copy_width = atoi (optarg); + if (copy_width < 1) + fatal(_("interleave width must be positive")); + break; + + case 'I': + case 's': /* "source" - 'I' is preferred */ + input_target = optarg; + break; + + case 'O': + case 'd': /* "destination" - 'O' is preferred */ + output_target = optarg; + break; + + case 'F': + input_target = output_target = optarg; + break; + + case 'j': + find_section_list (optarg, TRUE, SECTION_CONTEXT_COPY); + sections_copied = TRUE; + break; + + case 'R': + handle_remove_section_option (optarg); + break; + + case OPTION_REMOVE_RELOCS: + handle_remove_relocations_option (optarg); + break; + + case 'S': + strip_symbols = STRIP_ALL; + break; + + case 'g': + strip_symbols = STRIP_DEBUG; + break; + + case OPTION_STRIP_DWO: + strip_symbols = STRIP_DWO; + break; + + case OPTION_STRIP_UNNEEDED: + strip_symbols = STRIP_UNNEEDED; + break; + + case OPTION_ONLY_KEEP_DEBUG: + strip_symbols = STRIP_NONDEBUG; + break; + + case OPTION_KEEP_FILE_SYMBOLS: + keep_file_symbols = 1; + break; + + case OPTION_ADD_GNU_DEBUGLINK: + long_section_names = ENABLE ; + gnu_debuglink_filename = optarg; + break; + + case 'K': + add_specific_symbol (optarg, keep_specific_htab); + break; + + case 'M': + merge_notes = TRUE; + break; + case OPTION_NO_MERGE_NOTES: + merge_notes = FALSE; + break; + + case 'N': + add_specific_symbol (optarg, strip_specific_htab); + break; + + case OPTION_STRIP_UNNEEDED_SYMBOL: + add_specific_symbol (optarg, strip_unneeded_htab); + break; + + case 'L': + add_specific_symbol (optarg, localize_specific_htab); + break; + + case OPTION_GLOBALIZE_SYMBOL: + add_specific_symbol (optarg, globalize_specific_htab); + break; + + case 'G': + add_specific_symbol (optarg, keepglobal_specific_htab); + break; + + case 'W': + add_specific_symbol (optarg, weaken_specific_htab); + break; + + case 'p': + preserve_dates = TRUE; + break; + + case 'D': + deterministic = TRUE; + break; + + case 'U': + deterministic = FALSE; + break; + + case 'w': + wildcard = TRUE; + break; + + case 'x': + discard_locals = LOCALS_ALL; + break; + + case 'X': + discard_locals = LOCALS_START_L; + break; + + case 'v': + verbose = TRUE; + break; + + case 'V': + show_version = TRUE; + break; + + case OPTION_FORMATS_INFO: + formats_info = TRUE; + break; + + case OPTION_WEAKEN: + weaken = TRUE; + break; + + case OPTION_ADD_SECTION: + add_sections = init_section_add (optarg, add_sections, + "--add-section"); + section_add_load_file (add_sections); + break; + + case OPTION_UPDATE_SECTION: + update_sections = init_section_add (optarg, update_sections, + "--update-section"); + section_add_load_file (update_sections); + break; + + case OPTION_DUMP_SECTION: + dump_sections = init_section_add (optarg, dump_sections, + "--dump-section"); + break; + + case OPTION_ADD_SYMBOL: + { + char *s, *t; + struct addsym_node *newsym = xmalloc (sizeof *newsym); + + newsym->next = NULL; + s = strchr (optarg, '='); + if (s == NULL) + fatal (_("bad format for %s"), "--add-symbol"); + t = strchr (s + 1, ':'); + + newsym->symdef = xstrndup (optarg, s - optarg); + if (t) + { + newsym->section = xstrndup (s + 1, t - (s + 1)); + newsym->symval = strtol (t + 1, NULL, 0); + } + else + { + newsym->section = NULL; + newsym->symval = strtol (s + 1, NULL, 0); + t = s; + } + + t = strchr (t + 1, ','); + newsym->othersym = NULL; + if (t) + newsym->flags = parse_symflags (t+1, &newsym->othersym); + else + newsym->flags = BSF_GLOBAL; + + /* Keep 'othersym' symbols at the front of the list. */ + if (newsym->othersym) + { + newsym->next = add_sym_list; + if (!add_sym_list) + add_sym_tail = &newsym->next; + add_sym_list = newsym; + } + else + { + *add_sym_tail = newsym; + add_sym_tail = &newsym->next; + } + add_symbols++; + } + break; + + case OPTION_CHANGE_START: + change_start = parse_vma (optarg, "--change-start"); + break; + + case OPTION_CHANGE_SECTION_ADDRESS: + case OPTION_CHANGE_SECTION_LMA: + case OPTION_CHANGE_SECTION_VMA: + { + struct section_list * p; + unsigned int context = 0; + const char *s; + int len; + char *name; + char *option = NULL; + bfd_vma val; + + switch (c) + { + case OPTION_CHANGE_SECTION_ADDRESS: + option = "--change-section-address"; + context = SECTION_CONTEXT_ALTER_LMA | SECTION_CONTEXT_ALTER_VMA; + break; + case OPTION_CHANGE_SECTION_LMA: + option = "--change-section-lma"; + context = SECTION_CONTEXT_ALTER_LMA; + break; + case OPTION_CHANGE_SECTION_VMA: + option = "--change-section-vma"; + context = SECTION_CONTEXT_ALTER_VMA; + break; + } + + s = strchr (optarg, '='); + if (s == NULL) + { + s = strchr (optarg, '+'); + if (s == NULL) + { + s = strchr (optarg, '-'); + if (s == NULL) + fatal (_("bad format for %s"), option); + } + } + else + { + /* Correct the context. */ + switch (c) + { + case OPTION_CHANGE_SECTION_ADDRESS: + context = SECTION_CONTEXT_SET_LMA | SECTION_CONTEXT_SET_VMA; + break; + case OPTION_CHANGE_SECTION_LMA: + context = SECTION_CONTEXT_SET_LMA; + break; + case OPTION_CHANGE_SECTION_VMA: + context = SECTION_CONTEXT_SET_VMA; + break; + } + } + + len = s - optarg; + name = (char *) xmalloc (len + 1); + strncpy (name, optarg, len); + name[len] = '\0'; + + p = find_section_list (name, TRUE, context); + + val = parse_vma (s + 1, option); + if (*s == '-') + val = - val; + + switch (c) + { + case OPTION_CHANGE_SECTION_ADDRESS: + p->vma_val = val; + /* Fall through. */ + + case OPTION_CHANGE_SECTION_LMA: + p->lma_val = val; + break; + + case OPTION_CHANGE_SECTION_VMA: + p->vma_val = val; + break; + } + } + break; + + case OPTION_CHANGE_ADDRESSES: + change_section_address = parse_vma (optarg, "--change-addresses"); + change_start = change_section_address; + break; + + case OPTION_CHANGE_WARNINGS: + change_warn = TRUE; + break; + + case OPTION_CHANGE_LEADING_CHAR: + change_leading_char = TRUE; + break; + + case OPTION_COMPRESS_DEBUG_SECTIONS: + if (optarg) + { + if (strcasecmp (optarg, "none") == 0) + do_debug_sections = decompress; + else if (strcasecmp (optarg, "zlib") == 0) + do_debug_sections = compress_zlib; + else if (strcasecmp (optarg, "zlib-gnu") == 0) + do_debug_sections = compress_gnu_zlib; + else if (strcasecmp (optarg, "zlib-gabi") == 0) + do_debug_sections = compress_gabi_zlib; + else + fatal (_("unrecognized --compress-debug-sections type `%s'"), + optarg); + } + else + do_debug_sections = compress; + break; + + case OPTION_DEBUGGING: + convert_debugging = TRUE; + break; + + case OPTION_DECOMPRESS_DEBUG_SECTIONS: + do_debug_sections = decompress; + break; + + case OPTION_ELF_STT_COMMON: + if (strcasecmp (optarg, "yes") == 0) + do_elf_stt_common = elf_stt_common; + else if (strcasecmp (optarg, "no") == 0) + do_elf_stt_common = no_elf_stt_common; + else + fatal (_("unrecognized --elf-stt-common= option `%s'"), + optarg); + break; + + case OPTION_GAP_FILL: + { + bfd_vma gap_fill_vma; + + gap_fill_vma = parse_vma (optarg, "--gap-fill"); + gap_fill = (bfd_byte) gap_fill_vma; + if ((bfd_vma) gap_fill != gap_fill_vma) + { + char buff[20]; + + sprintf_vma (buff, gap_fill_vma); + + non_fatal (_("Warning: truncating gap-fill from 0x%s to 0x%x"), + buff, gap_fill); + } + gap_fill_set = TRUE; + } + break; + + case OPTION_NO_CHANGE_WARNINGS: + change_warn = FALSE; + break; + + case OPTION_PAD_TO: + pad_to = parse_vma (optarg, "--pad-to"); + pad_to_set = TRUE; + break; + + case OPTION_REMOVE_LEADING_CHAR: + remove_leading_char = TRUE; + break; + + case OPTION_REDEFINE_SYM: + { + /* Insert this redefinition onto redefine_specific_htab. */ + + int len; + const char *s; + const char *nextarg; + char *source, *target; + + s = strchr (optarg, '='); + if (s == NULL) + fatal (_("bad format for %s"), "--redefine-sym"); + + len = s - optarg; + source = (char *) xmalloc (len + 1); + strncpy (source, optarg, len); + source[len] = '\0'; + + nextarg = s + 1; + len = strlen (nextarg); + target = (char *) xmalloc (len + 1); + strcpy (target, nextarg); + + add_redefine_and_check ("--redefine-sym", source, target); + + free (source); + free (target); + } + break; + + case OPTION_REDEFINE_SYMS: + add_redefine_syms_file (optarg); + break; + + case OPTION_SET_SECTION_FLAGS: + { + struct section_list *p; + const char *s; + int len; + char *name; + + s = strchr (optarg, '='); + if (s == NULL) + fatal (_("bad format for %s"), "--set-section-flags"); + + len = s - optarg; + name = (char *) xmalloc (len + 1); + strncpy (name, optarg, len); + name[len] = '\0'; + + p = find_section_list (name, TRUE, SECTION_CONTEXT_SET_FLAGS); + + p->flags = parse_flags (s + 1); + } + break; + + case OPTION_RENAME_SECTION: + { + flagword flags; + const char *eq, *fl; + char *old_name; + char *new_name; + unsigned int len; + + eq = strchr (optarg, '='); + if (eq == NULL) + fatal (_("bad format for %s"), "--rename-section"); + + len = eq - optarg; + if (len == 0) + fatal (_("bad format for %s"), "--rename-section"); + + old_name = (char *) xmalloc (len + 1); + strncpy (old_name, optarg, len); + old_name[len] = 0; + + eq++; + fl = strchr (eq, ','); + if (fl) + { + flags = parse_flags (fl + 1); + len = fl - eq; + } + else + { + flags = -1; + len = strlen (eq); + } + + if (len == 0) + fatal (_("bad format for %s"), "--rename-section"); + + new_name = (char *) xmalloc (len + 1); + strncpy (new_name, eq, len); + new_name[len] = 0; + + add_section_rename (old_name, new_name, flags); + } + break; + + case OPTION_SET_START: + set_start = parse_vma (optarg, "--set-start"); + set_start_set = TRUE; + break; + + case OPTION_SREC_LEN: + _bfd_srec_len = parse_vma (optarg, "--srec-len"); + break; + + case OPTION_SREC_FORCES3: + _bfd_srec_forceS3 = TRUE; + break; + + case OPTION_STRIP_SYMBOLS: + add_specific_symbols (optarg, strip_specific_htab); + break; + + case OPTION_STRIP_UNNEEDED_SYMBOLS: + add_specific_symbols (optarg, strip_unneeded_htab); + break; + + case OPTION_KEEP_SYMBOLS: + add_specific_symbols (optarg, keep_specific_htab); + break; + + case OPTION_LOCALIZE_HIDDEN: + localize_hidden = TRUE; + break; + + case OPTION_LOCALIZE_SYMBOLS: + add_specific_symbols (optarg, localize_specific_htab); + break; + + case OPTION_LONG_SECTION_NAMES: + if (!strcmp ("enable", optarg)) + long_section_names = ENABLE; + else if (!strcmp ("disable", optarg)) + long_section_names = DISABLE; + else if (!strcmp ("keep", optarg)) + long_section_names = KEEP; + else + fatal (_("unknown long section names option '%s'"), optarg); + break; + + case OPTION_GLOBALIZE_SYMBOLS: + add_specific_symbols (optarg, globalize_specific_htab); + break; + + case OPTION_KEEPGLOBAL_SYMBOLS: + add_specific_symbols (optarg, keepglobal_specific_htab); + break; + + case OPTION_WEAKEN_SYMBOLS: + add_specific_symbols (optarg, weaken_specific_htab); + break; + + case OPTION_ALT_MACH_CODE: + use_alt_mach_code = strtoul (optarg, NULL, 0); + if (use_alt_mach_code == 0) + fatal (_("unable to parse alternative machine code")); + break; + + case OPTION_PREFIX_SYMBOLS: + prefix_symbols_string = optarg; + break; + + case OPTION_PREFIX_SECTIONS: + prefix_sections_string = optarg; + break; + + case OPTION_PREFIX_ALLOC_SECTIONS: + prefix_alloc_sections_string = optarg; + break; + + case OPTION_READONLY_TEXT: + bfd_flags_to_set |= WP_TEXT; + bfd_flags_to_clear &= ~WP_TEXT; + break; + + case OPTION_WRITABLE_TEXT: + bfd_flags_to_clear |= WP_TEXT; + bfd_flags_to_set &= ~WP_TEXT; + break; + + case OPTION_PURE: + bfd_flags_to_set |= D_PAGED; + bfd_flags_to_clear &= ~D_PAGED; + break; + + case OPTION_IMPURE: + bfd_flags_to_clear |= D_PAGED; + bfd_flags_to_set &= ~D_PAGED; + break; + + case OPTION_EXTRACT_DWO: + strip_symbols = STRIP_NONDWO; + break; + + case OPTION_EXTRACT_SYMBOL: + extract_symbol = TRUE; + break; + + case OPTION_REVERSE_BYTES: + { + int prev = reverse_bytes; + + reverse_bytes = atoi (optarg); + if ((reverse_bytes <= 0) || ((reverse_bytes % 2) != 0)) + fatal (_("number of bytes to reverse must be positive and even")); + + if (prev && prev != reverse_bytes) + non_fatal (_("Warning: ignoring previous --reverse-bytes value of %d"), + prev); + break; + } + + case OPTION_FILE_ALIGNMENT: + pe_file_alignment = parse_vma (optarg, "--file-alignment"); + break; + + case OPTION_HEAP: + { + char *end; + pe_heap_reserve = strtoul (optarg, &end, 0); + if (end == optarg + || (*end != '.' && *end != '\0')) + non_fatal (_("%s: invalid reserve value for --heap"), + optarg); + else if (*end != '\0') + { + pe_heap_commit = strtoul (end + 1, &end, 0); + if (*end != '\0') + non_fatal (_("%s: invalid commit value for --heap"), + optarg); + } + } + break; + + case OPTION_IMAGE_BASE: + pe_image_base = parse_vma (optarg, "--image-base"); + break; + + case OPTION_SECTION_ALIGNMENT: + pe_section_alignment = parse_vma (optarg, + "--section-alignment"); + break; + + case OPTION_SUBSYSTEM: + set_pe_subsystem (optarg); + break; + + case OPTION_STACK: + { + char *end; + pe_stack_reserve = strtoul (optarg, &end, 0); + if (end == optarg + || (*end != '.' && *end != '\0')) + non_fatal (_("%s: invalid reserve value for --stack"), + optarg); + else if (*end != '\0') + { + pe_stack_commit = strtoul (end + 1, &end, 0); + if (*end != '\0') + non_fatal (_("%s: invalid commit value for --stack"), + optarg); + } + } + break; + + case 0: + /* We've been given a long option. */ + break; + + case 'H': + case 'h': + copy_usage (stdout, 0); + + default: + copy_usage (stderr, 1); + } + } + + if (formats_info) + { + display_info (); + return 0; + } + + if (show_version) + print_version ("objcopy"); + + if (interleave && copy_byte == -1) + fatal (_("interleave start byte must be set with --byte")); + + if (copy_byte >= interleave) + fatal (_("byte number must be less than interleave")); + + if (copy_width > interleave - copy_byte) + fatal (_("interleave width must be less than or equal to interleave - byte`")); + + if (optind == argc || optind + 2 < argc) + copy_usage (stderr, 1); + + input_filename = argv[optind]; + if (optind + 1 < argc) + output_filename = argv[optind + 1]; + + default_deterministic (); + + /* Default is to strip no symbols. */ + if (strip_symbols == STRIP_UNDEF && discard_locals == LOCALS_UNDEF) + strip_symbols = STRIP_NONE; + + if (output_target == NULL) + output_target = input_target; + + /* Convert input EFI target to PEI target. */ + if (input_target != NULL + && strncmp (input_target, "efi-", 4) == 0) + { + char *efi; + + efi = xstrdup (output_target + 4); + if (strncmp (efi, "bsdrv-", 6) == 0 + || strncmp (efi, "rtdrv-", 6) == 0) + efi += 2; + else if (strncmp (efi, "app-", 4) != 0) + fatal (_("unknown input EFI target: %s"), input_target); + + input_target = efi; + convert_efi_target (efi); + } + + /* Convert output EFI target to PEI target. */ + if (output_target != NULL + && strncmp (output_target, "efi-", 4) == 0) + { + char *efi; + + efi = xstrdup (output_target + 4); + if (strncmp (efi, "app-", 4) == 0) + { + if (pe_subsystem == -1) + pe_subsystem = IMAGE_SUBSYSTEM_EFI_APPLICATION; + } + else if (strncmp (efi, "bsdrv-", 6) == 0) + { + if (pe_subsystem == -1) + pe_subsystem = IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER; + efi += 2; + } + else if (strncmp (efi, "rtdrv-", 6) == 0) + { + if (pe_subsystem == -1) + pe_subsystem = IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER; + efi += 2; + } + else + fatal (_("unknown output EFI target: %s"), output_target); + + if (pe_file_alignment == (bfd_vma) -1) + pe_file_alignment = PE_DEF_FILE_ALIGNMENT; + if (pe_section_alignment == (bfd_vma) -1) + pe_section_alignment = PE_DEF_SECTION_ALIGNMENT; + + output_target = efi; + convert_efi_target (efi); + } + + if (preserve_dates) + if (stat (input_filename, & statbuf) < 0) + fatal (_("warning: could not locate '%s'. System error message: %s"), + input_filename, strerror (errno)); + + /* If there is no destination file, or the source and destination files + are the same, then create a temp and rename the result into the input. */ + if (output_filename == NULL + || filename_cmp (input_filename, output_filename) == 0) + tmpname = make_tempname (input_filename); + else + tmpname = output_filename; + + if (tmpname == NULL) + fatal (_("warning: could not create temporary file whilst copying '%s', (error: %s)"), + input_filename, strerror (errno)); + + copy_file (input_filename, tmpname, input_target, output_target, input_arch); + if (status == 0) + { + if (preserve_dates) + set_times (tmpname, &statbuf); + if (tmpname != output_filename) + status = (smart_rename (tmpname, input_filename, + preserve_dates) != 0); + } + else + unlink_if_ordinary (tmpname); + + if (tmpname != output_filename) + free (tmpname); + + if (change_warn) + { + struct section_list *p; + + for (p = change_sections; p != NULL; p = p->next) + { + if (! p->used) + { + if (p->context & (SECTION_CONTEXT_SET_VMA | SECTION_CONTEXT_ALTER_VMA)) + { + char buff [20]; + + sprintf_vma (buff, p->vma_val); + + /* xgettext:c-format */ + non_fatal (_("%s %s%c0x%s never used"), + "--change-section-vma", + p->pattern, + p->context & SECTION_CONTEXT_SET_VMA ? '=' : '+', + buff); + } + + if (p->context & (SECTION_CONTEXT_SET_LMA | SECTION_CONTEXT_ALTER_LMA)) + { + char buff [20]; + + sprintf_vma (buff, p->lma_val); + + /* xgettext:c-format */ + non_fatal (_("%s %s%c0x%s never used"), + "--change-section-lma", + p->pattern, + p->context & SECTION_CONTEXT_SET_LMA ? '=' : '+', + buff); + } + } + } + } + + return 0; +} + +int +main (int argc, char *argv[]) +{ +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + program_name = argv[0]; + xmalloc_set_program_name (program_name); + + START_PROGRESS (program_name, 0); + + expandargv (&argc, &argv); + + strip_symbols = STRIP_UNDEF; + discard_locals = LOCALS_UNDEF; + + bfd_init (); + set_default_bfd_target (); + + if (is_strip < 0) + { + int i = strlen (program_name); +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + /* Drop the .exe suffix, if any. */ + if (i > 4 && FILENAME_CMP (program_name + i - 4, ".exe") == 0) + { + i -= 4; + program_name[i] = '\0'; + } +#endif + is_strip = (i >= 5 && FILENAME_CMP (program_name + i - 5, "strip") == 0); + } + + create_symbol_htabs (); + + if (argv != NULL) + bfd_set_error_program_name (argv[0]); + + if (is_strip) + strip_main (argc, argv); + else + copy_main (argc, argv); + + END_PROGRESS (program_name); + + return status; +} diff --git a/support/sdbinutils/binutils/objdump.c b/support/sdbinutils/binutils/objdump.c new file mode 100644 index 0000000..6c4d936 --- /dev/null +++ b/support/sdbinutils/binutils/objdump.c @@ -0,0 +1,4080 @@ +/* objdump.c -- dump information about an object file. + Copyright (C) 1990-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + + +/* Objdump overview. + + Objdump displays information about one or more object files, either on + their own, or inside libraries. It is commonly used as a disassembler, + but it can also display information about file headers, symbol tables, + relocations, debugging directives and more. + + The flow of execution is as follows: + + 1. Command line arguments are checked for control switches and the + information to be displayed is selected. + + 2. Any remaining arguments are assumed to be object files, and they are + processed in order by display_bfd(). If the file is an archive each + of its elements is processed in turn. + + 3. The file's target architecture and binary file format are determined + by bfd_check_format(). If they are recognised, then dump_bfd() is + called. + + 4. dump_bfd() in turn calls separate functions to display the requested + item(s) of information(s). For example disassemble_data() is called if + a disassembly has been requested. + + When disassembling the code loops through blocks of instructions bounded + by symbols, calling disassemble_bytes() on each block. The actual + disassembling is done by the libopcodes library, via a function pointer + supplied by the disassembler() function. */ + +#include "sysdep.h" +#include "bfd.h" +#include "elf-bfd.h" +#include "coff-bfd.h" +#include "progress.h" +#include "bucomm.h" +#include "elfcomm.h" +#include "dwarf.h" +#include "getopt.h" +#include "safe-ctype.h" +#include "dis-asm.h" +#include "libiberty.h" +#include "demangle.h" +#include "filenames.h" +#include "debug.h" +#include "budbg.h" +#include "objdump.h" + +#ifdef HAVE_MMAP +#include +#endif + +/* Internal headers for the ELF .stab-dump code - sorry. */ +#define BYTES_IN_WORD 32 +#include "aout/aout64.h" + +/* Exit status. */ +static int exit_status = 0; + +static char *default_target = NULL; /* Default at runtime. */ + +/* The following variables are set based on arguments passed on the + command line. */ +static int show_version = 0; /* Show the version number. */ +static int dump_section_contents; /* -s */ +static int dump_section_headers; /* -h */ +static bfd_boolean dump_file_header; /* -f */ +static int dump_symtab; /* -t */ +static int dump_dynamic_symtab; /* -T */ +static int dump_reloc_info; /* -r */ +static int dump_dynamic_reloc_info; /* -R */ +static int dump_ar_hdrs; /* -a */ +static int dump_private_headers; /* -p */ +static char *dump_private_options; /* -P */ +static int prefix_addresses; /* --prefix-addresses */ +static int with_line_numbers; /* -l */ +static bfd_boolean with_source_code; /* -S */ +static int show_raw_insn; /* --show-raw-insn */ +static int dump_dwarf_section_info; /* --dwarf */ +static int dump_stab_section_info; /* --stabs */ +static int do_demangle; /* -C, --demangle */ +static bfd_boolean disassemble; /* -d */ +static bfd_boolean disassemble_all; /* -D */ +static int disassemble_zeroes; /* --disassemble-zeroes */ +static bfd_boolean formats_info; /* -i */ +static int wide_output; /* -w */ +static int insn_width; /* --insn-width */ +static bfd_vma start_address = (bfd_vma) -1; /* --start-address */ +static bfd_vma stop_address = (bfd_vma) -1; /* --stop-address */ +static int dump_debugging; /* --debugging */ +static int dump_debugging_tags; /* --debugging-tags */ +static int suppress_bfd_header; +static int dump_special_syms = 0; /* --special-syms */ +static bfd_vma adjust_section_vma = 0; /* --adjust-vma */ +static int file_start_context = 0; /* --file-start-context */ +static bfd_boolean display_file_offsets;/* -F */ +static const char *prefix; /* --prefix */ +static int prefix_strip; /* --prefix-strip */ +static size_t prefix_length; +static bfd_boolean unwind_inlines; /* --inlines. */ + +/* A structure to record the sections mentioned in -j switches. */ +struct only +{ + const char * name; /* The name of the section. */ + bfd_boolean seen; /* A flag to indicate that the section has been found in one or more input files. */ + struct only * next; /* Pointer to the next structure in the list. */ +}; +/* Pointer to an array of 'only' structures. + This pointer is NULL if the -j switch has not been used. */ +static struct only * only_list = NULL; + +/* Variables for handling include file path table. */ +static const char **include_paths; +static int include_path_count; + +/* Extra info to pass to the section disassembler and address printing + function. */ +struct objdump_disasm_info +{ + bfd * abfd; + asection * sec; + bfd_boolean require_sec; + arelent ** dynrelbuf; + long dynrelcount; + disassembler_ftype disassemble_fn; + arelent * reloc; +}; + +/* Architecture to disassemble for, or default if NULL. */ +static char *machine = NULL; + +/* Target specific options to the disassembler. */ +static char *disassembler_options = NULL; + +/* Endianness to disassemble for, or default if BFD_ENDIAN_UNKNOWN. */ +static enum bfd_endian endian = BFD_ENDIAN_UNKNOWN; + +/* The symbol table. */ +static asymbol **syms; + +/* Number of symbols in `syms'. */ +static long symcount = 0; + +/* The sorted symbol table. */ +static asymbol **sorted_syms; + +/* Number of symbols in `sorted_syms'. */ +static long sorted_symcount = 0; + +/* The dynamic symbol table. */ +static asymbol **dynsyms; + +/* The synthetic symbol table. */ +static asymbol *synthsyms; +static long synthcount = 0; + +/* Number of symbols in `dynsyms'. */ +static long dynsymcount = 0; + +static bfd_byte *stabs; +static bfd_size_type stab_size; + +static bfd_byte *strtab; +static bfd_size_type stabstr_size; + +static bfd_boolean is_relocatable = FALSE; + +/* Handlers for -P/--private. */ +static const struct objdump_private_desc * const objdump_private_vectors[] = + { + OBJDUMP_PRIVATE_VECTORS + NULL + }; + +static void usage (FILE *, int) ATTRIBUTE_NORETURN; +static void +usage (FILE *stream, int status) +{ + fprintf (stream, _("Usage: %s \n"), program_name); + fprintf (stream, _(" Display information from object .\n")); + fprintf (stream, _(" At least one of the following switches must be given:\n")); + fprintf (stream, _("\ + -a, --archive-headers Display archive header information\n\ + -f, --file-headers Display the contents of the overall file header\n\ + -p, --private-headers Display object format specific file header contents\n\ + -P, --private=OPT,OPT... Display object format specific contents\n\ + -h, --[section-]headers Display the contents of the section headers\n\ + -x, --all-headers Display the contents of all headers\n\ + -d, --disassemble Display assembler contents of executable sections\n\ + -D, --disassemble-all Display assembler contents of all sections\n\ + -S, --source Intermix source code with disassembly\n\ + -s, --full-contents Display the full contents of all sections requested\n\ + -g, --debugging Display debug information in object file\n\ + -e, --debugging-tags Display debug information using ctags style\n\ + -G, --stabs Display (in raw form) any STABS info in the file\n\ + -W[lLiaprmfFsoRtUuTgAckK] or\n\ + --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,\n\ + =frames-interp,=str,=loc,=Ranges,=pubtypes,\n\ + =gdb_index,=trace_info,=trace_abbrev,=trace_aranges,\n\ + =addr,=cu_index,=links,=follow-links]\n\ + Display DWARF info in the file\n\ + -t, --syms Display the contents of the symbol table(s)\n\ + -T, --dynamic-syms Display the contents of the dynamic symbol table\n\ + -r, --reloc Display the relocation entries in the file\n\ + -R, --dynamic-reloc Display the dynamic relocation entries in the file\n\ + @ Read options from \n\ + -v, --version Display this program's version number\n\ + -i, --info List object formats and architectures supported\n\ + -H, --help Display this information\n\ +")); + if (status != 2) + { + const struct objdump_private_desc * const *desc; + + fprintf (stream, _("\n The following switches are optional:\n")); + fprintf (stream, _("\ + -b, --target=BFDNAME Specify the target object format as BFDNAME\n\ + -m, --architecture=MACHINE Specify the target architecture as MACHINE\n\ + -j, --section=NAME Only display information for section NAME\n\ + -M, --disassembler-options=OPT Pass text OPT on to the disassembler\n\ + -EB --endian=big Assume big endian format when disassembling\n\ + -EL --endian=little Assume little endian format when disassembling\n\ + --file-start-context Include context from start of file (with -S)\n\ + -I, --include=DIR Add DIR to search list for source files\n\ + -l, --line-numbers Include line numbers and filenames in output\n\ + -F, --file-offsets Include file offsets when displaying information\n\ + -C, --demangle[=STYLE] Decode mangled/processed symbol names\n\ + The STYLE, if specified, can be `auto', `gnu',\n\ + `lucid', `arm', `hp', `edg', `gnu-v3', `java'\n\ + or `gnat'\n\ + -w, --wide Format output for more than 80 columns\n\ + -z, --disassemble-zeroes Do not skip blocks of zeroes when disassembling\n\ + --start-address=ADDR Only process data whose address is >= ADDR\n\ + --stop-address=ADDR Only process data whose address is <= ADDR\n\ + --prefix-addresses Print complete address alongside disassembly\n\ + --[no-]show-raw-insn Display hex alongside symbolic disassembly\n\ + --insn-width=WIDTH Display WIDTH bytes on a single line for -d\n\ + --adjust-vma=OFFSET Add OFFSET to all displayed section addresses\n\ + --special-syms Include special symbols in symbol dumps\n\ + --inlines Print all inlines for source line (with -l)\n\ + --prefix=PREFIX Add PREFIX to absolute paths for -S\n\ + --prefix-strip=LEVEL Strip initial directory names for -S\n")); + fprintf (stream, _("\ + --dwarf-depth=N Do not display DIEs at depth N or greater\n\ + --dwarf-start=N Display DIEs starting with N, at the same depth\n\ + or deeper\n\ + --dwarf-check Make additional dwarf internal consistency checks.\ + \n\n")); + list_supported_targets (program_name, stream); + list_supported_architectures (program_name, stream); + + disassembler_usage (stream); + + if (objdump_private_vectors[0] != NULL) + { + fprintf (stream, + _("\nOptions supported for -P/--private switch:\n")); + for (desc = objdump_private_vectors; *desc != NULL; desc++) + (*desc)->help (stream); + } + } + if (REPORT_BUGS_TO[0] && status == 0) + fprintf (stream, _("Report bugs to %s.\n"), REPORT_BUGS_TO); + exit (status); +} + +/* 150 isn't special; it's just an arbitrary non-ASCII char value. */ +enum option_values + { + OPTION_ENDIAN=150, + OPTION_START_ADDRESS, + OPTION_STOP_ADDRESS, + OPTION_DWARF, + OPTION_PREFIX, + OPTION_PREFIX_STRIP, + OPTION_INSN_WIDTH, + OPTION_ADJUST_VMA, + OPTION_DWARF_DEPTH, + OPTION_DWARF_CHECK, + OPTION_DWARF_START, + OPTION_INLINES + }; + +static struct option long_options[]= +{ + {"adjust-vma", required_argument, NULL, OPTION_ADJUST_VMA}, + {"all-headers", no_argument, NULL, 'x'}, + {"private-headers", no_argument, NULL, 'p'}, + {"private", required_argument, NULL, 'P'}, + {"architecture", required_argument, NULL, 'm'}, + {"archive-headers", no_argument, NULL, 'a'}, + {"debugging", no_argument, NULL, 'g'}, + {"debugging-tags", no_argument, NULL, 'e'}, + {"demangle", optional_argument, NULL, 'C'}, + {"disassemble", no_argument, NULL, 'd'}, + {"disassemble-all", no_argument, NULL, 'D'}, + {"disassembler-options", required_argument, NULL, 'M'}, + {"disassemble-zeroes", no_argument, NULL, 'z'}, + {"dynamic-reloc", no_argument, NULL, 'R'}, + {"dynamic-syms", no_argument, NULL, 'T'}, + {"endian", required_argument, NULL, OPTION_ENDIAN}, + {"file-headers", no_argument, NULL, 'f'}, + {"file-offsets", no_argument, NULL, 'F'}, + {"file-start-context", no_argument, &file_start_context, 1}, + {"full-contents", no_argument, NULL, 's'}, + {"headers", no_argument, NULL, 'h'}, + {"help", no_argument, NULL, 'H'}, + {"info", no_argument, NULL, 'i'}, + {"line-numbers", no_argument, NULL, 'l'}, + {"no-show-raw-insn", no_argument, &show_raw_insn, -1}, + {"prefix-addresses", no_argument, &prefix_addresses, 1}, + {"reloc", no_argument, NULL, 'r'}, + {"section", required_argument, NULL, 'j'}, + {"section-headers", no_argument, NULL, 'h'}, + {"show-raw-insn", no_argument, &show_raw_insn, 1}, + {"source", no_argument, NULL, 'S'}, + {"special-syms", no_argument, &dump_special_syms, 1}, + {"include", required_argument, NULL, 'I'}, + {"dwarf", optional_argument, NULL, OPTION_DWARF}, + {"stabs", no_argument, NULL, 'G'}, + {"start-address", required_argument, NULL, OPTION_START_ADDRESS}, + {"stop-address", required_argument, NULL, OPTION_STOP_ADDRESS}, + {"syms", no_argument, NULL, 't'}, + {"target", required_argument, NULL, 'b'}, + {"version", no_argument, NULL, 'V'}, + {"wide", no_argument, NULL, 'w'}, + {"prefix", required_argument, NULL, OPTION_PREFIX}, + {"prefix-strip", required_argument, NULL, OPTION_PREFIX_STRIP}, + {"insn-width", required_argument, NULL, OPTION_INSN_WIDTH}, + {"dwarf-depth", required_argument, 0, OPTION_DWARF_DEPTH}, + {"dwarf-start", required_argument, 0, OPTION_DWARF_START}, + {"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK}, + {"inlines", no_argument, 0, OPTION_INLINES}, + {0, no_argument, 0, 0} +}; + +static void +nonfatal (const char *msg) +{ + bfd_nonfatal (msg); + exit_status = 1; +} + +/* Returns TRUE if the specified section should be dumped. */ + +static bfd_boolean +process_section_p (asection * section) +{ + struct only * only; + + if (only_list == NULL) + return TRUE; + + for (only = only_list; only; only = only->next) + if (strcmp (only->name, section->name) == 0) + { + only->seen = TRUE; + return TRUE; + } + + return FALSE; +} + +/* Add an entry to the 'only' list. */ + +static void +add_only (char * name) +{ + struct only * only; + + /* First check to make sure that we do not + already have an entry for this name. */ + for (only = only_list; only; only = only->next) + if (strcmp (only->name, name) == 0) + return; + + only = xmalloc (sizeof * only); + only->name = name; + only->seen = FALSE; + only->next = only_list; + only_list = only; +} + +/* Release the memory used by the 'only' list. + PR 11225: Issue a warning message for unseen sections. + Only do this if none of the sections were seen. This is mainly to support + tools like the GAS testsuite where an object file is dumped with a list of + generic section names known to be present in a range of different file + formats. */ + +static void +free_only_list (void) +{ + bfd_boolean at_least_one_seen = FALSE; + struct only * only; + struct only * next; + + if (only_list == NULL) + return; + + for (only = only_list; only; only = only->next) + if (only->seen) + { + at_least_one_seen = TRUE; + break; + } + + for (only = only_list; only; only = next) + { + if (! at_least_one_seen) + { + non_fatal (_("section '%s' mentioned in a -j option, " + "but not found in any input file"), + only->name); + exit_status = 1; + } + next = only->next; + free (only); + } +} + + +static void +dump_section_header (bfd *abfd, asection *section, void *data) +{ + char *comma = ""; + unsigned int opb = bfd_octets_per_byte (abfd); + int longest_section_name = *((int *) data); + + /* Ignore linker created section. See elfNN_ia64_object_p in + bfd/elfxx-ia64.c. */ + if (section->flags & SEC_LINKER_CREATED) + return; + + /* PR 10413: Skip sections that we are ignoring. */ + if (! process_section_p (section)) + return; + + printf ("%3d %-*s %08lx ", section->index, longest_section_name, + bfd_get_section_name (abfd, section), + (unsigned long) bfd_section_size (abfd, section) / opb); + bfd_printf_vma (abfd, bfd_get_section_vma (abfd, section)); + printf (" "); + bfd_printf_vma (abfd, section->lma); + printf (" %08lx 2**%u", (unsigned long) section->filepos, + bfd_get_section_alignment (abfd, section)); + if (! wide_output) + printf ("\n "); + printf (" "); + +#define PF(x, y) \ + if (section->flags & x) { printf ("%s%s", comma, y); comma = ", "; } + + PF (SEC_HAS_CONTENTS, "CONTENTS"); + PF (SEC_ALLOC, "ALLOC"); + PF (SEC_CONSTRUCTOR, "CONSTRUCTOR"); + PF (SEC_LOAD, "LOAD"); + PF (SEC_RELOC, "RELOC"); + PF (SEC_READONLY, "READONLY"); + PF (SEC_CODE, "CODE"); + PF (SEC_DATA, "DATA"); + PF (SEC_ROM, "ROM"); + PF (SEC_DEBUGGING, "DEBUGGING"); + PF (SEC_NEVER_LOAD, "NEVER_LOAD"); + PF (SEC_EXCLUDE, "EXCLUDE"); + PF (SEC_SORT_ENTRIES, "SORT_ENTRIES"); + if (bfd_get_arch (abfd) == bfd_arch_tic54x) + { + PF (SEC_TIC54X_BLOCK, "BLOCK"); + PF (SEC_TIC54X_CLINK, "CLINK"); + } + PF (SEC_SMALL_DATA, "SMALL_DATA"); + if (bfd_get_flavour (abfd) == bfd_target_coff_flavour) + { + PF (SEC_COFF_SHARED, "SHARED"); + PF (SEC_COFF_NOREAD, "NOREAD"); + } + else if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) + PF (SEC_ELF_PURECODE, "PURECODE"); + PF (SEC_THREAD_LOCAL, "THREAD_LOCAL"); + PF (SEC_GROUP, "GROUP"); + if (bfd_get_arch (abfd) == bfd_arch_mep) + { + PF (SEC_MEP_VLIW, "VLIW"); + } + + if ((section->flags & SEC_LINK_ONCE) != 0) + { + const char *ls; + struct coff_comdat_info *comdat; + + switch (section->flags & SEC_LINK_DUPLICATES) + { + default: + abort (); + case SEC_LINK_DUPLICATES_DISCARD: + ls = "LINK_ONCE_DISCARD"; + break; + case SEC_LINK_DUPLICATES_ONE_ONLY: + ls = "LINK_ONCE_ONE_ONLY"; + break; + case SEC_LINK_DUPLICATES_SAME_SIZE: + ls = "LINK_ONCE_SAME_SIZE"; + break; + case SEC_LINK_DUPLICATES_SAME_CONTENTS: + ls = "LINK_ONCE_SAME_CONTENTS"; + break; + } + printf ("%s%s", comma, ls); + + comdat = bfd_coff_get_comdat_section (abfd, section); + if (comdat != NULL) + printf (" (COMDAT %s %ld)", comdat->name, comdat->symbol); + + comma = ", "; + } + + printf ("\n"); +#undef PF +} + +/* Called on each SECTION in ABFD, update the int variable pointed to by + DATA which contains the string length of the longest section name. */ + +static void +find_longest_section_name (bfd *abfd, asection *section, void *data) +{ + int *longest_so_far = (int *) data; + const char *name; + int len; + + /* Ignore linker created section. */ + if (section->flags & SEC_LINKER_CREATED) + return; + + /* Skip sections that we are ignoring. */ + if (! process_section_p (section)) + return; + + name = bfd_get_section_name (abfd, section); + len = (int) strlen (name); + if (len > *longest_so_far) + *longest_so_far = len; +} + +static void +dump_headers (bfd *abfd) +{ + /* The default width of 13 is just an arbitrary choice. */ + int max_section_name_length = 13; + int bfd_vma_width; + +#ifndef BFD64 + bfd_vma_width = 10; +#else + /* With BFD64, non-ELF returns -1 and wants always 64 bit addresses. */ + if (bfd_get_arch_size (abfd) == 32) + bfd_vma_width = 10; + else + bfd_vma_width = 18; +#endif + + printf (_("Sections:\n")); + + if (wide_output) + bfd_map_over_sections (abfd, find_longest_section_name, + &max_section_name_length); + + printf (_("Idx %-*s Size %-*s%-*sFile off Algn"), + max_section_name_length, "Name", + bfd_vma_width, "VMA", + bfd_vma_width, "LMA"); + + if (wide_output) + printf (_(" Flags")); + printf ("\n"); + + bfd_map_over_sections (abfd, dump_section_header, + &max_section_name_length); +} + +static asymbol ** +slurp_symtab (bfd *abfd) +{ + asymbol **sy = NULL; + long storage; + + if (!(bfd_get_file_flags (abfd) & HAS_SYMS)) + { + symcount = 0; + return NULL; + } + + storage = bfd_get_symtab_upper_bound (abfd); + if (storage < 0) + { + non_fatal (_("failed to read symbol table from: %s"), bfd_get_filename (abfd)); + bfd_fatal (_("error message was")); + } + if (storage) + sy = (asymbol **) xmalloc (storage); + + symcount = bfd_canonicalize_symtab (abfd, sy); + if (symcount < 0) + bfd_fatal (bfd_get_filename (abfd)); + return sy; +} + +/* Read in the dynamic symbols. */ + +static asymbol ** +slurp_dynamic_symtab (bfd *abfd) +{ + asymbol **sy = NULL; + long storage; + + storage = bfd_get_dynamic_symtab_upper_bound (abfd); + if (storage < 0) + { + if (!(bfd_get_file_flags (abfd) & DYNAMIC)) + { + non_fatal (_("%s: not a dynamic object"), bfd_get_filename (abfd)); + exit_status = 1; + dynsymcount = 0; + return NULL; + } + + bfd_fatal (bfd_get_filename (abfd)); + } + if (storage) + sy = (asymbol **) xmalloc (storage); + + dynsymcount = bfd_canonicalize_dynamic_symtab (abfd, sy); + if (dynsymcount < 0) + bfd_fatal (bfd_get_filename (abfd)); + return sy; +} + +/* Some symbol names are significant and should be kept in the + table of sorted symbol names, even if they are marked as + debugging/section symbols. */ + +static bfd_boolean +is_significant_symbol_name (const char * name) +{ + return strcmp (name, ".plt") == 0 + || strcmp (name, ".got") == 0 + || strcmp (name, ".plt.got") == 0; +} + +/* Filter out (in place) symbols that are useless for disassembly. + COUNT is the number of elements in SYMBOLS. + Return the number of useful symbols. */ + +static long +remove_useless_symbols (asymbol **symbols, long count) +{ + asymbol **in_ptr = symbols, **out_ptr = symbols; + + while (--count >= 0) + { + asymbol *sym = *in_ptr++; + + if (sym->name == NULL || sym->name[0] == '\0') + continue; + if ((sym->flags & (BSF_DEBUGGING | BSF_SECTION_SYM)) + && ! is_significant_symbol_name (sym->name)) + continue; + if (bfd_is_und_section (sym->section) + || bfd_is_com_section (sym->section)) + continue; + + *out_ptr++ = sym; + } + return out_ptr - symbols; +} + +/* Sort symbols into value order. */ + +static int +compare_symbols (const void *ap, const void *bp) +{ + const asymbol *a = * (const asymbol **) ap; + const asymbol *b = * (const asymbol **) bp; + const char *an; + const char *bn; + size_t anl; + size_t bnl; + bfd_boolean af; + bfd_boolean bf; + flagword aflags; + flagword bflags; + + if (bfd_asymbol_value (a) > bfd_asymbol_value (b)) + return 1; + else if (bfd_asymbol_value (a) < bfd_asymbol_value (b)) + return -1; + + if (a->section > b->section) + return 1; + else if (a->section < b->section) + return -1; + + an = bfd_asymbol_name (a); + bn = bfd_asymbol_name (b); + anl = strlen (an); + bnl = strlen (bn); + + /* The symbols gnu_compiled and gcc2_compiled convey no real + information, so put them after other symbols with the same value. */ + af = (strstr (an, "gnu_compiled") != NULL + || strstr (an, "gcc2_compiled") != NULL); + bf = (strstr (bn, "gnu_compiled") != NULL + || strstr (bn, "gcc2_compiled") != NULL); + + if (af && ! bf) + return 1; + if (! af && bf) + return -1; + + /* We use a heuristic for the file name, to try to sort it after + more useful symbols. It may not work on non Unix systems, but it + doesn't really matter; the only difference is precisely which + symbol names get printed. */ + +#define file_symbol(s, sn, snl) \ + (((s)->flags & BSF_FILE) != 0 \ + || ((sn)[(snl) - 2] == '.' \ + && ((sn)[(snl) - 1] == 'o' \ + || (sn)[(snl) - 1] == 'a'))) + + af = file_symbol (a, an, anl); + bf = file_symbol (b, bn, bnl); + + if (af && ! bf) + return 1; + if (! af && bf) + return -1; + + /* Try to sort global symbols before local symbols before function + symbols before debugging symbols. */ + + aflags = a->flags; + bflags = b->flags; + + if ((aflags & BSF_DEBUGGING) != (bflags & BSF_DEBUGGING)) + { + if ((aflags & BSF_DEBUGGING) != 0) + return 1; + else + return -1; + } + if ((aflags & BSF_FUNCTION) != (bflags & BSF_FUNCTION)) + { + if ((aflags & BSF_FUNCTION) != 0) + return -1; + else + return 1; + } + if ((aflags & BSF_LOCAL) != (bflags & BSF_LOCAL)) + { + if ((aflags & BSF_LOCAL) != 0) + return 1; + else + return -1; + } + if ((aflags & BSF_GLOBAL) != (bflags & BSF_GLOBAL)) + { + if ((aflags & BSF_GLOBAL) != 0) + return -1; + else + return 1; + } + + if (bfd_get_flavour (bfd_asymbol_bfd (a)) == bfd_target_elf_flavour + && bfd_get_flavour (bfd_asymbol_bfd (b)) == bfd_target_elf_flavour) + { + bfd_vma asz, bsz; + + asz = 0; + if ((a->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0) + asz = ((elf_symbol_type *) a)->internal_elf_sym.st_size; + bsz = 0; + if ((b->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0) + bsz = ((elf_symbol_type *) b)->internal_elf_sym.st_size; + if (asz != bsz) + return asz > bsz ? -1 : 1; + } + + /* Symbols that start with '.' might be section names, so sort them + after symbols that don't start with '.'. */ + if (an[0] == '.' && bn[0] != '.') + return 1; + if (an[0] != '.' && bn[0] == '.') + return -1; + + /* Finally, if we can't distinguish them in any other way, try to + get consistent results by sorting the symbols by name. */ + return strcmp (an, bn); +} + +/* Sort relocs into address order. */ + +static int +compare_relocs (const void *ap, const void *bp) +{ + const arelent *a = * (const arelent **) ap; + const arelent *b = * (const arelent **) bp; + + if (a->address > b->address) + return 1; + else if (a->address < b->address) + return -1; + + /* So that associated relocations tied to the same address show up + in the correct order, we don't do any further sorting. */ + if (a > b) + return 1; + else if (a < b) + return -1; + else + return 0; +} + +/* Print an address (VMA) to the output stream in INFO. + If SKIP_ZEROES is TRUE, omit leading zeroes. */ + +static void +objdump_print_value (bfd_vma vma, struct disassemble_info *inf, + bfd_boolean skip_zeroes) +{ + char buf[30]; + char *p; + struct objdump_disasm_info *aux; + + aux = (struct objdump_disasm_info *) inf->application_data; + bfd_sprintf_vma (aux->abfd, buf, vma); + if (! skip_zeroes) + p = buf; + else + { + for (p = buf; *p == '0'; ++p) + ; + if (*p == '\0') + --p; + } + (*inf->fprintf_func) (inf->stream, "%s", p); +} + +/* Print the name of a symbol. */ + +static void +objdump_print_symname (bfd *abfd, struct disassemble_info *inf, + asymbol *sym) +{ + char *alloc; + const char *name, *version_string = NULL; + bfd_boolean hidden = FALSE; + + alloc = NULL; + name = bfd_asymbol_name (sym); + if (do_demangle && name[0] != '\0') + { + /* Demangle the name. */ + alloc = bfd_demangle (abfd, name, DMGL_ANSI | DMGL_PARAMS); + if (alloc != NULL) + name = alloc; + } + + if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0) + version_string = bfd_get_symbol_version_string (abfd, sym, &hidden); + + if (bfd_is_und_section (bfd_get_section (sym))) + hidden = TRUE; + + if (inf != NULL) + { + (*inf->fprintf_func) (inf->stream, "%s", name); + if (version_string && *version_string != '\0') + (*inf->fprintf_func) (inf->stream, hidden ? "@%s" : "@@%s", + version_string); + } + else + { + printf ("%s", name); + if (version_string && *version_string != '\0') + printf (hidden ? "@%s" : "@@%s", version_string); + } + + if (alloc != NULL) + free (alloc); +} + +/* Locate a symbol given a bfd and a section (from INFO->application_data), + and a VMA. If INFO->application_data->require_sec is TRUE, then always + require the symbol to be in the section. Returns NULL if there is no + suitable symbol. If PLACE is not NULL, then *PLACE is set to the index + of the symbol in sorted_syms. */ + +static asymbol * +find_symbol_for_address (bfd_vma vma, + struct disassemble_info *inf, + long *place) +{ + /* @@ Would it speed things up to cache the last two symbols returned, + and maybe their address ranges? For many processors, only one memory + operand can be present at a time, so the 2-entry cache wouldn't be + constantly churned by code doing heavy memory accesses. */ + + /* Indices in `sorted_syms'. */ + long min = 0; + long max_count = sorted_symcount; + long thisplace; + struct objdump_disasm_info *aux; + bfd *abfd; + asection *sec; + unsigned int opb; + bfd_boolean want_section; + + if (sorted_symcount < 1) + return NULL; + + aux = (struct objdump_disasm_info *) inf->application_data; + abfd = aux->abfd; + sec = aux->sec; + opb = inf->octets_per_byte; + + /* Perform a binary search looking for the closest symbol to the + required value. We are searching the range (min, max_count]. */ + while (min + 1 < max_count) + { + asymbol *sym; + + thisplace = (max_count + min) / 2; + sym = sorted_syms[thisplace]; + + if (bfd_asymbol_value (sym) > vma) + max_count = thisplace; + else if (bfd_asymbol_value (sym) < vma) + min = thisplace; + else + { + min = thisplace; + break; + } + } + + /* The symbol we want is now in min, the low end of the range we + were searching. If there are several symbols with the same + value, we want the first (non-section/non-debugging) one. */ + thisplace = min; + while (thisplace > 0 + && (bfd_asymbol_value (sorted_syms[thisplace]) + == bfd_asymbol_value (sorted_syms[thisplace - 1])) + && ((sorted_syms[thisplace - 1]->flags + & (BSF_SECTION_SYM | BSF_DEBUGGING)) == 0) + ) + --thisplace; + + /* Prefer a symbol in the current section if we have multple symbols + with the same value, as can occur with overlays or zero size + sections. */ + min = thisplace; + while (min < max_count + && (bfd_asymbol_value (sorted_syms[min]) + == bfd_asymbol_value (sorted_syms[thisplace]))) + { + if (sorted_syms[min]->section == sec + && inf->symbol_is_valid (sorted_syms[min], inf)) + { + thisplace = min; + + if (place != NULL) + *place = thisplace; + + return sorted_syms[thisplace]; + } + ++min; + } + + /* If the file is relocatable, and the symbol could be from this + section, prefer a symbol from this section over symbols from + others, even if the other symbol's value might be closer. + + Note that this may be wrong for some symbol references if the + sections have overlapping memory ranges, but in that case there's + no way to tell what's desired without looking at the relocation + table. + + Also give the target a chance to reject symbols. */ + want_section = (aux->require_sec + || ((abfd->flags & HAS_RELOC) != 0 + && vma >= bfd_get_section_vma (abfd, sec) + && vma < (bfd_get_section_vma (abfd, sec) + + bfd_section_size (abfd, sec) / opb))); + if ((sorted_syms[thisplace]->section != sec && want_section) + || ! inf->symbol_is_valid (sorted_syms[thisplace], inf)) + { + long i; + long newplace = sorted_symcount; + + for (i = min - 1; i >= 0; i--) + { + if ((sorted_syms[i]->section == sec || !want_section) + && inf->symbol_is_valid (sorted_syms[i], inf)) + { + if (newplace == sorted_symcount) + newplace = i; + + if (bfd_asymbol_value (sorted_syms[i]) + != bfd_asymbol_value (sorted_syms[newplace])) + break; + + /* Remember this symbol and keep searching until we reach + an earlier address. */ + newplace = i; + } + } + + if (newplace != sorted_symcount) + thisplace = newplace; + else + { + /* We didn't find a good symbol with a smaller value. + Look for one with a larger value. */ + for (i = thisplace + 1; i < sorted_symcount; i++) + { + if ((sorted_syms[i]->section == sec || !want_section) + && inf->symbol_is_valid (sorted_syms[i], inf)) + { + thisplace = i; + break; + } + } + } + + if ((sorted_syms[thisplace]->section != sec && want_section) + || ! inf->symbol_is_valid (sorted_syms[thisplace], inf)) + /* There is no suitable symbol. */ + return NULL; + } + + /* If we have not found an exact match for the specified address + and we have dynamic relocations available, then we can produce + a better result by matching a relocation to the address and + using the symbol associated with that relocation. */ + if (!want_section + && aux->dynrelbuf != NULL + && sorted_syms[thisplace]->value != vma + /* If we have matched a synthetic symbol, then stick with that. */ + && (sorted_syms[thisplace]->flags & BSF_SYNTHETIC) == 0) + { + long rel_count; + arelent ** rel_pp; + + for (rel_count = aux->dynrelcount, rel_pp = aux->dynrelbuf; + rel_count--;) + { + arelent * rel = rel_pp[rel_count]; + + if (rel->address == vma + && rel->sym_ptr_ptr != NULL + /* Absolute relocations do not provide a more helpful symbolic address. */ + && ! bfd_is_abs_section ((* rel->sym_ptr_ptr)->section)) + { + if (place != NULL) + * place = thisplace; + return * rel->sym_ptr_ptr; + } + + /* We are scanning backwards, so if we go below the target address + we have failed. */ + if (rel_pp[rel_count]->address < vma) + break; + } + } + + if (place != NULL) + *place = thisplace; + + return sorted_syms[thisplace]; +} + +/* Print an address and the offset to the nearest symbol. */ + +static void +objdump_print_addr_with_sym (bfd *abfd, asection *sec, asymbol *sym, + bfd_vma vma, struct disassemble_info *inf, + bfd_boolean skip_zeroes) +{ + objdump_print_value (vma, inf, skip_zeroes); + + if (sym == NULL) + { + bfd_vma secaddr; + + (*inf->fprintf_func) (inf->stream, " <%s", + bfd_get_section_name (abfd, sec)); + secaddr = bfd_get_section_vma (abfd, sec); + if (vma < secaddr) + { + (*inf->fprintf_func) (inf->stream, "-0x"); + objdump_print_value (secaddr - vma, inf, TRUE); + } + else if (vma > secaddr) + { + (*inf->fprintf_func) (inf->stream, "+0x"); + objdump_print_value (vma - secaddr, inf, TRUE); + } + (*inf->fprintf_func) (inf->stream, ">"); + } + else + { + (*inf->fprintf_func) (inf->stream, " <"); + + objdump_print_symname (abfd, inf, sym); + + if (bfd_asymbol_value (sym) == vma) + ; + /* Undefined symbols in an executables and dynamic objects do not have + a value associated with them, so it does not make sense to display + an offset relative to them. Normally we would not be provided with + this kind of symbol, but the target backend might choose to do so, + and the code in find_symbol_for_address might return an as yet + unresolved symbol associated with a dynamic reloc. */ + else if ((bfd_get_file_flags (abfd) & (EXEC_P | DYNAMIC)) + && bfd_is_und_section (sym->section)) + ; + else if (bfd_asymbol_value (sym) > vma) + { + (*inf->fprintf_func) (inf->stream, "-0x"); + objdump_print_value (bfd_asymbol_value (sym) - vma, inf, TRUE); + } + else if (vma > bfd_asymbol_value (sym)) + { + (*inf->fprintf_func) (inf->stream, "+0x"); + objdump_print_value (vma - bfd_asymbol_value (sym), inf, TRUE); + } + + (*inf->fprintf_func) (inf->stream, ">"); + } + + if (display_file_offsets) + inf->fprintf_func (inf->stream, _(" (File Offset: 0x%lx)"), + (long int)(sec->filepos + (vma - sec->vma))); +} + +/* Print an address (VMA), symbolically if possible. + If SKIP_ZEROES is TRUE, don't output leading zeroes. */ + +static void +objdump_print_addr (bfd_vma vma, + struct disassemble_info *inf, + bfd_boolean skip_zeroes) +{ + struct objdump_disasm_info *aux; + asymbol *sym = NULL; + bfd_boolean skip_find = FALSE; + + aux = (struct objdump_disasm_info *) inf->application_data; + + if (sorted_symcount < 1) + { + (*inf->fprintf_func) (inf->stream, "0x"); + objdump_print_value (vma, inf, skip_zeroes); + + if (display_file_offsets) + inf->fprintf_func (inf->stream, _(" (File Offset: 0x%lx)"), + (long int)(aux->sec->filepos + (vma - aux->sec->vma))); + return; + } + + if (aux->reloc != NULL + && aux->reloc->sym_ptr_ptr != NULL + && * aux->reloc->sym_ptr_ptr != NULL) + { + sym = * aux->reloc->sym_ptr_ptr; + + /* Adjust the vma to the reloc. */ + vma += bfd_asymbol_value (sym); + + if (bfd_is_und_section (bfd_get_section (sym))) + skip_find = TRUE; + } + + if (!skip_find) + sym = find_symbol_for_address (vma, inf, NULL); + + objdump_print_addr_with_sym (aux->abfd, aux->sec, sym, vma, inf, + skip_zeroes); +} + +/* Print VMA to INFO. This function is passed to the disassembler + routine. */ + +static void +objdump_print_address (bfd_vma vma, struct disassemble_info *inf) +{ + objdump_print_addr (vma, inf, ! prefix_addresses); +} + +/* Determine if the given address has a symbol associated with it. */ + +static int +objdump_symbol_at_address (bfd_vma vma, struct disassemble_info * inf) +{ + asymbol * sym; + + sym = find_symbol_for_address (vma, inf, NULL); + + return (sym != NULL && (bfd_asymbol_value (sym) == vma)); +} + +/* Hold the last function name and the last line number we displayed + in a disassembly. */ + +static char *prev_functionname; +static unsigned int prev_line; +static unsigned int prev_discriminator; + +/* We keep a list of all files that we have seen when doing a + disassembly with source, so that we know how much of the file to + display. This can be important for inlined functions. */ + +struct print_file_list +{ + struct print_file_list *next; + const char *filename; + const char *modname; + const char *map; + size_t mapsize; + const char **linemap; + unsigned maxline; + unsigned last_line; + unsigned max_printed; + int first; +}; + +static struct print_file_list *print_files; + +/* The number of preceding context lines to show when we start + displaying a file for the first time. */ + +#define SHOW_PRECEDING_CONTEXT_LINES (5) + +/* Read a complete file into memory. */ + +static const char * +slurp_file (const char *fn, size_t *size, struct stat *fst) +{ +#ifdef HAVE_MMAP + int ps = getpagesize (); + size_t msize; +#endif + const char *map; + int fd = open (fn, O_RDONLY | O_BINARY); + + if (fd < 0) + return NULL; + if (fstat (fd, fst) < 0) + { + close (fd); + return NULL; + } + *size = fst->st_size; +#ifdef HAVE_MMAP + msize = (*size + ps - 1) & ~(ps - 1); + map = mmap (NULL, msize, PROT_READ, MAP_SHARED, fd, 0); + if (map != (char *) -1L) + { + close (fd); + return map; + } +#endif + map = (const char *) malloc (*size); + if (!map || (size_t) read (fd, (char *) map, *size) != *size) + { + free ((void *) map); + map = NULL; + } + close (fd); + return map; +} + +#define line_map_decrease 5 + +/* Precompute array of lines for a mapped file. */ + +static const char ** +index_file (const char *map, size_t size, unsigned int *maxline) +{ + const char *p, *lstart, *end; + int chars_per_line = 45; /* First iteration will use 40. */ + unsigned int lineno; + const char **linemap = NULL; + unsigned long line_map_size = 0; + + lineno = 0; + lstart = map; + end = map + size; + + for (p = map; p < end; p++) + { + if (*p == '\n') + { + if (p + 1 < end && p[1] == '\r') + p++; + } + else if (*p == '\r') + { + if (p + 1 < end && p[1] == '\n') + p++; + } + else + continue; + + /* End of line found. */ + + if (linemap == NULL || line_map_size < lineno + 1) + { + unsigned long newsize; + + chars_per_line -= line_map_decrease; + if (chars_per_line <= 1) + chars_per_line = 1; + line_map_size = size / chars_per_line + 1; + if (line_map_size < lineno + 1) + line_map_size = lineno + 1; + newsize = line_map_size * sizeof (char *); + linemap = (const char **) xrealloc (linemap, newsize); + } + + linemap[lineno++] = lstart; + lstart = p + 1; + } + + *maxline = lineno; + return linemap; +} + +/* Tries to open MODNAME, and if successful adds a node to print_files + linked list and returns that node. Returns NULL on failure. */ + +static struct print_file_list * +try_print_file_open (const char *origname, const char *modname, struct stat *fst) +{ + struct print_file_list *p; + + p = (struct print_file_list *) xmalloc (sizeof (struct print_file_list)); + + p->map = slurp_file (modname, &p->mapsize, fst); + if (p->map == NULL) + { + free (p); + return NULL; + } + + p->linemap = index_file (p->map, p->mapsize, &p->maxline); + p->last_line = 0; + p->max_printed = 0; + p->filename = origname; + p->modname = modname; + p->next = print_files; + p->first = 1; + print_files = p; + return p; +} + +/* If the source file, as described in the symtab, is not found + try to locate it in one of the paths specified with -I + If found, add location to print_files linked list. */ + +static struct print_file_list * +update_source_path (const char *filename, bfd *abfd) +{ + struct print_file_list *p; + const char *fname; + struct stat fst; + int i; + + p = try_print_file_open (filename, filename, &fst); + if (p == NULL) + { + if (include_path_count == 0) + return NULL; + + /* Get the name of the file. */ + fname = lbasename (filename); + + /* If file exists under a new path, we need to add it to the list + so that show_line knows about it. */ + for (i = 0; i < include_path_count; i++) + { + char *modname = concat (include_paths[i], "/", fname, + (const char *) 0); + + p = try_print_file_open (filename, modname, &fst); + if (p) + break; + + free (modname); + } + } + + if (p != NULL) + { + long mtime = bfd_get_mtime (abfd); + + if (fst.st_mtime > mtime) + warn (_("source file %s is more recent than object file\n"), + filename); + } + + return p; +} + +/* Print a source file line. */ + +static void +print_line (struct print_file_list *p, unsigned int linenum) +{ + const char *l; + size_t len; + + --linenum; + if (linenum >= p->maxline) + return; + l = p->linemap [linenum]; + /* Test fwrite return value to quiet glibc warning. */ + len = strcspn (l, "\n\r"); + if (len == 0 || fwrite (l, len, 1, stdout) == 1) + putchar ('\n'); +} + +/* Print a range of source code lines. */ + +static void +dump_lines (struct print_file_list *p, unsigned int start, unsigned int end) +{ + if (p->map == NULL) + return; + while (start <= end) + { + print_line (p, start); + start++; + } +} + +/* Show the line number, or the source line, in a disassembly + listing. */ + +static void +show_line (bfd *abfd, asection *section, bfd_vma addr_offset) +{ + const char *filename; + const char *functionname; + unsigned int linenumber; + unsigned int discriminator; + bfd_boolean reloc; + char *path = NULL; + + if (! with_line_numbers && ! with_source_code) + return; + + if (! bfd_find_nearest_line_discriminator (abfd, section, syms, addr_offset, + &filename, &functionname, + &linenumber, &discriminator)) + return; + + if (filename != NULL && *filename == '\0') + filename = NULL; + if (functionname != NULL && *functionname == '\0') + functionname = NULL; + + if (filename + && IS_ABSOLUTE_PATH (filename) + && prefix) + { + char *path_up; + const char *fname = filename; + + path = xmalloc (prefix_length + PATH_MAX + 1); + + if (prefix_length) + memcpy (path, prefix, prefix_length); + path_up = path + prefix_length; + + /* Build relocated filename, stripping off leading directories + from the initial filename if requested. */ + if (prefix_strip > 0) + { + int level = 0; + const char *s; + + /* Skip selected directory levels. */ + for (s = fname + 1; *s != '\0' && level < prefix_strip; s++) + if (IS_DIR_SEPARATOR(*s)) + { + fname = s; + level++; + } + } + + /* Update complete filename. */ + strncpy (path_up, fname, PATH_MAX); + path_up[PATH_MAX] = '\0'; + + filename = path; + reloc = TRUE; + } + else + reloc = FALSE; + + if (with_line_numbers) + { + if (functionname != NULL + && (prev_functionname == NULL + || strcmp (functionname, prev_functionname) != 0)) + { + printf ("%s():\n", functionname); + prev_line = -1; + } + if (linenumber > 0 + && (linenumber != prev_line + || discriminator != prev_discriminator)) + { + if (discriminator > 0) + printf ("%s:%u (discriminator %u)\n", + filename == NULL ? "???" : filename, + linenumber, discriminator); + else + printf ("%s:%u\n", filename == NULL ? "???" : filename, + linenumber); + } + if (unwind_inlines) + { + const char *filename2; + const char *functionname2; + unsigned line2; + + while (bfd_find_inliner_info (abfd, &filename2, &functionname2, + &line2)) + printf ("inlined by %s:%u (%s)\n", filename2, line2, + functionname2); + } + } + + if (with_source_code + && filename != NULL + && linenumber > 0) + { + struct print_file_list **pp, *p; + unsigned l; + + for (pp = &print_files; *pp != NULL; pp = &(*pp)->next) + if (filename_cmp ((*pp)->filename, filename) == 0) + break; + p = *pp; + + if (p == NULL) + { + if (reloc) + filename = xstrdup (filename); + p = update_source_path (filename, abfd); + } + + if (p != NULL && linenumber != p->last_line) + { + if (file_start_context && p->first) + l = 1; + else + { + l = linenumber - SHOW_PRECEDING_CONTEXT_LINES; + if (l >= linenumber) + l = 1; + if (p->max_printed >= l) + { + if (p->max_printed < linenumber) + l = p->max_printed + 1; + else + l = linenumber; + } + } + dump_lines (p, l, linenumber); + if (p->max_printed < linenumber) + p->max_printed = linenumber; + p->last_line = linenumber; + p->first = 0; + } + } + + if (functionname != NULL + && (prev_functionname == NULL + || strcmp (functionname, prev_functionname) != 0)) + { + if (prev_functionname != NULL) + free (prev_functionname); + prev_functionname = (char *) xmalloc (strlen (functionname) + 1); + strcpy (prev_functionname, functionname); + } + + if (linenumber > 0 && linenumber != prev_line) + prev_line = linenumber; + + if (discriminator != prev_discriminator) + prev_discriminator = discriminator; + + if (path) + free (path); +} + +/* Pseudo FILE object for strings. */ +typedef struct +{ + char *buffer; + size_t pos; + size_t alloc; +} SFILE; + +/* sprintf to a "stream". */ + +static int ATTRIBUTE_PRINTF_2 +objdump_sprintf (SFILE *f, const char *format, ...) +{ + size_t n; + va_list args; + + while (1) + { + size_t space = f->alloc - f->pos; + + va_start (args, format); + n = vsnprintf (f->buffer + f->pos, space, format, args); + va_end (args); + + if (space > n) + break; + + f->alloc = (f->alloc + n) * 2; + f->buffer = (char *) xrealloc (f->buffer, f->alloc); + } + f->pos += n; + + return n; +} + +/* The number of zeroes we want to see before we start skipping them. + The number is arbitrarily chosen. */ + +#define DEFAULT_SKIP_ZEROES 8 + +/* The number of zeroes to skip at the end of a section. If the + number of zeroes at the end is between SKIP_ZEROES_AT_END and + SKIP_ZEROES, they will be disassembled. If there are fewer than + SKIP_ZEROES_AT_END, they will be skipped. This is a heuristic + attempt to avoid disassembling zeroes inserted by section + alignment. */ + +#define DEFAULT_SKIP_ZEROES_AT_END 3 + +/* Disassemble some data in memory between given values. */ + +static void +disassemble_bytes (struct disassemble_info * inf, + disassembler_ftype disassemble_fn, + bfd_boolean insns, + bfd_byte * data, + bfd_vma start_offset, + bfd_vma stop_offset, + bfd_vma rel_offset, + arelent *** relppp, + arelent ** relppend) +{ + struct objdump_disasm_info *aux; + asection *section; + int octets_per_line; + int skip_addr_chars; + bfd_vma addr_offset; + unsigned int opb = inf->octets_per_byte; + unsigned int skip_zeroes = inf->skip_zeroes; + unsigned int skip_zeroes_at_end = inf->skip_zeroes_at_end; + int octets = opb; + SFILE sfile; + + aux = (struct objdump_disasm_info *) inf->application_data; + section = aux->sec; + + sfile.alloc = 120; + sfile.buffer = (char *) xmalloc (sfile.alloc); + sfile.pos = 0; + + if (insn_width) + octets_per_line = insn_width; + else if (insns) + octets_per_line = 4; + else + octets_per_line = 16; + + /* Figure out how many characters to skip at the start of an + address, to make the disassembly look nicer. We discard leading + zeroes in chunks of 4, ensuring that there is always a leading + zero remaining. */ + skip_addr_chars = 0; + if (! prefix_addresses) + { + char buf[30]; + + bfd_sprintf_vma (aux->abfd, buf, section->vma + section->size / opb); + + while (buf[skip_addr_chars] == '0') + ++skip_addr_chars; + + /* Don't discard zeros on overflow. */ + if (buf[skip_addr_chars] == '\0' && section->vma != 0) + skip_addr_chars = 0; + + if (skip_addr_chars != 0) + skip_addr_chars = (skip_addr_chars - 1) & -4; + } + + inf->insn_info_valid = 0; + + addr_offset = start_offset; + while (addr_offset < stop_offset) + { + bfd_vma z; + bfd_boolean need_nl = FALSE; + int previous_octets; + + /* Remember the length of the previous instruction. */ + previous_octets = octets; + octets = 0; + + /* Make sure we don't use relocs from previous instructions. */ + aux->reloc = NULL; + + /* If we see more than SKIP_ZEROES octets of zeroes, we just + print `...'. */ + for (z = addr_offset * opb; z < stop_offset * opb; z++) + if (data[z] != 0) + break; + if (! disassemble_zeroes + && (inf->insn_info_valid == 0 + || inf->branch_delay_insns == 0) + && (z - addr_offset * opb >= skip_zeroes + || (z == stop_offset * opb && + z - addr_offset * opb < skip_zeroes_at_end))) + { + /* If there are more nonzero octets to follow, we only skip + zeroes in multiples of 4, to try to avoid running over + the start of an instruction which happens to start with + zero. */ + if (z != stop_offset * opb) + z = addr_offset * opb + ((z - addr_offset * opb) &~ 3); + + octets = z - addr_offset * opb; + + /* If we are going to display more data, and we are displaying + file offsets, then tell the user how many zeroes we skip + and the file offset from where we resume dumping. */ + if (display_file_offsets && ((addr_offset + (octets / opb)) < stop_offset)) + printf ("\t... (skipping %d zeroes, resuming at file offset: 0x%lx)\n", + octets / opb, + (unsigned long) (section->filepos + + (addr_offset + (octets / opb)))); + else + printf ("\t...\n"); + } + else + { + char buf[50]; + int bpc = 0; + int pb = 0; + + if (with_line_numbers || with_source_code) + show_line (aux->abfd, section, addr_offset); + + if (! prefix_addresses) + { + char *s; + + bfd_sprintf_vma (aux->abfd, buf, section->vma + addr_offset); + for (s = buf + skip_addr_chars; *s == '0'; s++) + *s = ' '; + if (*s == '\0') + *--s = '0'; + printf ("%s:\t", buf + skip_addr_chars); + } + else + { + aux->require_sec = TRUE; + objdump_print_address (section->vma + addr_offset, inf); + aux->require_sec = FALSE; + putchar (' '); + } + + if (insns) + { + sfile.pos = 0; + inf->fprintf_func = (fprintf_ftype) objdump_sprintf; + inf->stream = &sfile; + inf->bytes_per_line = 0; + inf->bytes_per_chunk = 0; + inf->flags = disassemble_all ? DISASSEMBLE_DATA : 0; + if (machine) + inf->flags |= USER_SPECIFIED_MACHINE_TYPE; + + if (inf->disassembler_needs_relocs + && (bfd_get_file_flags (aux->abfd) & EXEC_P) == 0 + && (bfd_get_file_flags (aux->abfd) & DYNAMIC) == 0 + && *relppp < relppend) + { + bfd_signed_vma distance_to_rel; + + distance_to_rel = (**relppp)->address + - (rel_offset + addr_offset); + + /* Check to see if the current reloc is associated with + the instruction that we are about to disassemble. */ + if (distance_to_rel == 0 + /* FIXME: This is wrong. We are trying to catch + relocs that are addressed part way through the + current instruction, as might happen with a packed + VLIW instruction. Unfortunately we do not know the + length of the current instruction since we have not + disassembled it yet. Instead we take a guess based + upon the length of the previous instruction. The + proper solution is to have a new target-specific + disassembler function which just returns the length + of an instruction at a given address without trying + to display its disassembly. */ + || (distance_to_rel > 0 + && distance_to_rel < (bfd_signed_vma) (previous_octets/ opb))) + { + inf->flags |= INSN_HAS_RELOC; + aux->reloc = **relppp; + } + } + + if (! disassemble_all + && (section->flags & (SEC_CODE | SEC_HAS_CONTENTS)) + == (SEC_CODE | SEC_HAS_CONTENTS)) + /* Set a stop_vma so that the disassembler will not read + beyond the next symbol. We assume that symbols appear on + the boundaries between instructions. We only do this when + disassembling code of course, and when -D is in effect. */ + inf->stop_vma = section->vma + stop_offset; + + octets = (*disassemble_fn) (section->vma + addr_offset, inf); + + inf->stop_vma = 0; + inf->fprintf_func = (fprintf_ftype) fprintf; + inf->stream = stdout; + if (insn_width == 0 && inf->bytes_per_line != 0) + octets_per_line = inf->bytes_per_line; + if (octets < (int) opb) + { + if (sfile.pos) + printf ("%s\n", sfile.buffer); + if (octets >= 0) + { + non_fatal (_("disassemble_fn returned length %d"), + octets); + exit_status = 1; + } + break; + } + } + else + { + bfd_vma j; + + octets = octets_per_line; + if (addr_offset + octets / opb > stop_offset) + octets = (stop_offset - addr_offset) * opb; + + for (j = addr_offset * opb; j < addr_offset * opb + octets; ++j) + { + if (ISPRINT (data[j])) + buf[j - addr_offset * opb] = data[j]; + else + buf[j - addr_offset * opb] = '.'; + } + buf[j - addr_offset * opb] = '\0'; + } + + if (prefix_addresses + ? show_raw_insn > 0 + : show_raw_insn >= 0) + { + bfd_vma j; + + /* If ! prefix_addresses and ! wide_output, we print + octets_per_line octets per line. */ + pb = octets; + if (pb > octets_per_line && ! prefix_addresses && ! wide_output) + pb = octets_per_line; + + if (inf->bytes_per_chunk) + bpc = inf->bytes_per_chunk; + else + bpc = 1; + + for (j = addr_offset * opb; j < addr_offset * opb + pb; j += bpc) + { + /* PR 21580: Check for a buffer ending early. */ + if (j + bpc <= stop_offset * opb) + { + int k; + + if (inf->display_endian == BFD_ENDIAN_LITTLE) + { + for (k = bpc - 1; k >= 0; k--) + printf ("%02x", (unsigned) data[j + k]); + } + else + { + for (k = 0; k < bpc; k++) + printf ("%02x", (unsigned) data[j + k]); + } + } + putchar (' '); + } + + for (; pb < octets_per_line; pb += bpc) + { + int k; + + for (k = 0; k < bpc; k++) + printf (" "); + putchar (' '); + } + + /* Separate raw data from instruction by extra space. */ + if (insns) + putchar ('\t'); + else + printf (" "); + } + + if (! insns) + printf ("%s", buf); + else if (sfile.pos) + printf ("%s", sfile.buffer); + + if (prefix_addresses + ? show_raw_insn > 0 + : show_raw_insn >= 0) + { + while (pb < octets) + { + bfd_vma j; + char *s; + + putchar ('\n'); + j = addr_offset * opb + pb; + + bfd_sprintf_vma (aux->abfd, buf, section->vma + j / opb); + for (s = buf + skip_addr_chars; *s == '0'; s++) + *s = ' '; + if (*s == '\0') + *--s = '0'; + printf ("%s:\t", buf + skip_addr_chars); + + pb += octets_per_line; + if (pb > octets) + pb = octets; + for (; j < addr_offset * opb + pb; j += bpc) + { + /* PR 21619: Check for a buffer ending early. */ + if (j + bpc <= stop_offset * opb) + { + int k; + + if (inf->display_endian == BFD_ENDIAN_LITTLE) + { + for (k = bpc - 1; k >= 0; k--) + printf ("%02x", (unsigned) data[j + k]); + } + else + { + for (k = 0; k < bpc; k++) + printf ("%02x", (unsigned) data[j + k]); + } + } + putchar (' '); + } + } + } + + if (!wide_output) + putchar ('\n'); + else + need_nl = TRUE; + } + + while ((*relppp) < relppend + && (**relppp)->address < rel_offset + addr_offset + octets / opb) + { + if (dump_reloc_info || dump_dynamic_reloc_info) + { + arelent *q; + + q = **relppp; + + if (wide_output) + putchar ('\t'); + else + printf ("\t\t\t"); + + objdump_print_value (section->vma - rel_offset + q->address, + inf, TRUE); + + if (q->howto == NULL) + printf (": *unknown*\t"); + else if (q->howto->name) + printf (": %s\t", q->howto->name); + else + printf (": %d\t", q->howto->type); + + if (q->sym_ptr_ptr == NULL || *q->sym_ptr_ptr == NULL) + printf ("*unknown*"); + else + { + const char *sym_name; + + sym_name = bfd_asymbol_name (*q->sym_ptr_ptr); + if (sym_name != NULL && *sym_name != '\0') + objdump_print_symname (aux->abfd, inf, *q->sym_ptr_ptr); + else + { + asection *sym_sec; + + sym_sec = bfd_get_section (*q->sym_ptr_ptr); + sym_name = bfd_get_section_name (aux->abfd, sym_sec); + if (sym_name == NULL || *sym_name == '\0') + sym_name = "*unknown*"; + printf ("%s", sym_name); + } + } + + if (q->addend) + { + bfd_signed_vma addend = q->addend; + if (addend < 0) + { + printf ("-0x"); + addend = -addend; + } + else + printf ("+0x"); + objdump_print_value (addend, inf, TRUE); + } + + printf ("\n"); + need_nl = FALSE; + } + ++(*relppp); + } + + if (need_nl) + printf ("\n"); + + addr_offset += octets / opb; + } + + free (sfile.buffer); +} + +static void +disassemble_section (bfd *abfd, asection *section, void *inf) +{ + const struct elf_backend_data * bed; + bfd_vma sign_adjust = 0; + struct disassemble_info * pinfo = (struct disassemble_info *) inf; + struct objdump_disasm_info * paux; + unsigned int opb = pinfo->octets_per_byte; + bfd_byte * data = NULL; + bfd_size_type datasize = 0; + arelent ** rel_pp = NULL; + arelent ** rel_ppstart = NULL; + arelent ** rel_ppend; + bfd_vma stop_offset; + asymbol * sym = NULL; + long place = 0; + long rel_count; + bfd_vma rel_offset; + unsigned long addr_offset; + + /* Sections that do not contain machine + code are not normally disassembled. */ + if (! disassemble_all + && only_list == NULL + && ((section->flags & (SEC_CODE | SEC_HAS_CONTENTS)) + != (SEC_CODE | SEC_HAS_CONTENTS))) + return; + + if (! process_section_p (section)) + return; + + datasize = bfd_get_section_size (section); + if (datasize == 0) + return; + + if (start_address == (bfd_vma) -1 + || start_address < section->vma) + addr_offset = 0; + else + addr_offset = start_address - section->vma; + + if (stop_address == (bfd_vma) -1) + stop_offset = datasize / opb; + else + { + if (stop_address < section->vma) + stop_offset = 0; + else + stop_offset = stop_address - section->vma; + if (stop_offset > datasize / opb) + stop_offset = datasize / opb; + } + + if (addr_offset >= stop_offset) + return; + + /* Decide which set of relocs to use. Load them if necessary. */ + paux = (struct objdump_disasm_info *) pinfo->application_data; + if (paux->dynrelbuf && dump_dynamic_reloc_info) + { + rel_pp = paux->dynrelbuf; + rel_count = paux->dynrelcount; + /* Dynamic reloc addresses are absolute, non-dynamic are section + relative. REL_OFFSET specifies the reloc address corresponding + to the start of this section. */ + rel_offset = section->vma; + } + else + { + rel_count = 0; + rel_pp = NULL; + rel_offset = 0; + + if ((section->flags & SEC_RELOC) != 0 + && (dump_reloc_info || pinfo->disassembler_needs_relocs)) + { + long relsize; + + relsize = bfd_get_reloc_upper_bound (abfd, section); + if (relsize < 0) + bfd_fatal (bfd_get_filename (abfd)); + + if (relsize > 0) + { + rel_ppstart = rel_pp = (arelent **) xmalloc (relsize); + rel_count = bfd_canonicalize_reloc (abfd, section, rel_pp, syms); + if (rel_count < 0) + bfd_fatal (bfd_get_filename (abfd)); + + /* Sort the relocs by address. */ + qsort (rel_pp, rel_count, sizeof (arelent *), compare_relocs); + } + } + } + rel_ppend = rel_pp + rel_count; + + if (!bfd_malloc_and_get_section (abfd, section, &data)) + { + non_fatal (_("Reading section %s failed because: %s"), + section->name, bfd_errmsg (bfd_get_error ())); + return; + } + + paux->sec = section; + pinfo->buffer = data; + pinfo->buffer_vma = section->vma; + pinfo->buffer_length = datasize; + pinfo->section = section; + + /* Skip over the relocs belonging to addresses below the + start address. */ + while (rel_pp < rel_ppend + && (*rel_pp)->address < rel_offset + addr_offset) + ++rel_pp; + + printf (_("\nDisassembly of section %s:\n"), section->name); + + /* Find the nearest symbol forwards from our current position. */ + paux->require_sec = TRUE; + sym = (asymbol *) find_symbol_for_address (section->vma + addr_offset, + (struct disassemble_info *) inf, + &place); + paux->require_sec = FALSE; + + /* PR 9774: If the target used signed addresses then we must make + sure that we sign extend the value that we calculate for 'addr' + in the loop below. */ + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour + && (bed = get_elf_backend_data (abfd)) != NULL + && bed->sign_extend_vma) + sign_adjust = (bfd_vma) 1 << (bed->s->arch_size - 1); + + /* Disassemble a block of instructions up to the address associated with + the symbol we have just found. Then print the symbol and find the + next symbol on. Repeat until we have disassembled the entire section + or we have reached the end of the address range we are interested in. */ + while (addr_offset < stop_offset) + { + bfd_vma addr; + asymbol *nextsym; + bfd_vma nextstop_offset; + bfd_boolean insns; + + addr = section->vma + addr_offset; + addr = ((addr & ((sign_adjust << 1) - 1)) ^ sign_adjust) - sign_adjust; + + if (sym != NULL && bfd_asymbol_value (sym) <= addr) + { + int x; + + for (x = place; + (x < sorted_symcount + && (bfd_asymbol_value (sorted_syms[x]) <= addr)); + ++x) + continue; + + pinfo->symbols = sorted_syms + place; + pinfo->num_symbols = x - place; + pinfo->symtab_pos = place; + } + else + { + pinfo->symbols = NULL; + pinfo->num_symbols = 0; + pinfo->symtab_pos = -1; + } + + if (! prefix_addresses) + { + pinfo->fprintf_func (pinfo->stream, "\n"); + objdump_print_addr_with_sym (abfd, section, sym, addr, + pinfo, FALSE); + pinfo->fprintf_func (pinfo->stream, ":\n"); + } + + if (sym != NULL && bfd_asymbol_value (sym) > addr) + nextsym = sym; + else if (sym == NULL) + nextsym = NULL; + else + { +#define is_valid_next_sym(SYM) \ + ((SYM)->section == section \ + && (bfd_asymbol_value (SYM) > bfd_asymbol_value (sym)) \ + && pinfo->symbol_is_valid (SYM, pinfo)) + + /* Search forward for the next appropriate symbol in + SECTION. Note that all the symbols are sorted + together into one big array, and that some sections + may have overlapping addresses. */ + while (place < sorted_symcount + && ! is_valid_next_sym (sorted_syms [place])) + ++place; + + if (place >= sorted_symcount) + nextsym = NULL; + else + nextsym = sorted_syms[place]; + } + + if (sym != NULL && bfd_asymbol_value (sym) > addr) + nextstop_offset = bfd_asymbol_value (sym) - section->vma; + else if (nextsym == NULL) + nextstop_offset = stop_offset; + else + nextstop_offset = bfd_asymbol_value (nextsym) - section->vma; + + if (nextstop_offset > stop_offset + || nextstop_offset <= addr_offset) + nextstop_offset = stop_offset; + + /* If a symbol is explicitly marked as being an object + rather than a function, just dump the bytes without + disassembling them. */ + if (disassemble_all + || sym == NULL + || sym->section != section + || bfd_asymbol_value (sym) > addr + || ((sym->flags & BSF_OBJECT) == 0 + && (strstr (bfd_asymbol_name (sym), "gnu_compiled") + == NULL) + && (strstr (bfd_asymbol_name (sym), "gcc2_compiled") + == NULL)) + || (sym->flags & BSF_FUNCTION) != 0) + insns = TRUE; + else + insns = FALSE; + + disassemble_bytes (pinfo, paux->disassemble_fn, insns, data, + addr_offset, nextstop_offset, + rel_offset, &rel_pp, rel_ppend); + + addr_offset = nextstop_offset; + sym = nextsym; + } + + free (data); + + if (rel_ppstart != NULL) + free (rel_ppstart); +} + +/* Disassemble the contents of an object file. */ + +static void +disassemble_data (bfd *abfd) +{ + struct disassemble_info disasm_info; + struct objdump_disasm_info aux; + long i; + + print_files = NULL; + prev_functionname = NULL; + prev_line = -1; + prev_discriminator = 0; + + /* We make a copy of syms to sort. We don't want to sort syms + because that will screw up the relocs. */ + sorted_symcount = symcount ? symcount : dynsymcount; + sorted_syms = (asymbol **) xmalloc ((sorted_symcount + synthcount) + * sizeof (asymbol *)); + memcpy (sorted_syms, symcount ? syms : dynsyms, + sorted_symcount * sizeof (asymbol *)); + + sorted_symcount = remove_useless_symbols (sorted_syms, sorted_symcount); + + for (i = 0; i < synthcount; ++i) + { + sorted_syms[sorted_symcount] = synthsyms + i; + ++sorted_symcount; + } + + /* Sort the symbols into section and symbol order. */ + qsort (sorted_syms, sorted_symcount, sizeof (asymbol *), compare_symbols); + + init_disassemble_info (&disasm_info, stdout, (fprintf_ftype) fprintf); + + disasm_info.application_data = (void *) &aux; + aux.abfd = abfd; + aux.require_sec = FALSE; + aux.dynrelbuf = NULL; + aux.dynrelcount = 0; + aux.reloc = NULL; + + disasm_info.print_address_func = objdump_print_address; + disasm_info.symbol_at_address_func = objdump_symbol_at_address; + + if (machine != NULL) + { + const bfd_arch_info_type *inf = bfd_scan_arch (machine); + + if (inf == NULL) + fatal (_("can't use supplied machine %s"), machine); + + abfd->arch_info = inf; + } + + if (endian != BFD_ENDIAN_UNKNOWN) + { + struct bfd_target *xvec; + + xvec = (struct bfd_target *) xmalloc (sizeof (struct bfd_target)); + memcpy (xvec, abfd->xvec, sizeof (struct bfd_target)); + xvec->byteorder = endian; + abfd->xvec = xvec; + } + + /* Use libopcodes to locate a suitable disassembler. */ + aux.disassemble_fn = disassembler (bfd_get_arch (abfd), + bfd_big_endian (abfd), + bfd_get_mach (abfd), abfd); + if (!aux.disassemble_fn) + { + non_fatal (_("can't disassemble for architecture %s\n"), + bfd_printable_arch_mach (bfd_get_arch (abfd), 0)); + exit_status = 1; + return; + } + + disasm_info.flavour = bfd_get_flavour (abfd); + disasm_info.arch = bfd_get_arch (abfd); + disasm_info.mach = bfd_get_mach (abfd); + disasm_info.disassembler_options = disassembler_options; + disasm_info.octets_per_byte = bfd_octets_per_byte (abfd); + disasm_info.skip_zeroes = DEFAULT_SKIP_ZEROES; + disasm_info.skip_zeroes_at_end = DEFAULT_SKIP_ZEROES_AT_END; + disasm_info.disassembler_needs_relocs = FALSE; + + if (bfd_big_endian (abfd)) + disasm_info.display_endian = disasm_info.endian = BFD_ENDIAN_BIG; + else if (bfd_little_endian (abfd)) + disasm_info.display_endian = disasm_info.endian = BFD_ENDIAN_LITTLE; + else + /* ??? Aborting here seems too drastic. We could default to big or little + instead. */ + disasm_info.endian = BFD_ENDIAN_UNKNOWN; + + /* Allow the target to customize the info structure. */ + disassemble_init_for_target (& disasm_info); + + /* Pre-load the dynamic relocs as we may need them during the disassembly. */ + { + long relsize = bfd_get_dynamic_reloc_upper_bound (abfd); + + if (relsize < 0 && dump_dynamic_reloc_info) + bfd_fatal (bfd_get_filename (abfd)); + + if (relsize > 0) + { + aux.dynrelbuf = (arelent **) xmalloc (relsize); + aux.dynrelcount = bfd_canonicalize_dynamic_reloc (abfd, + aux.dynrelbuf, + dynsyms); + if (aux.dynrelcount < 0) + bfd_fatal (bfd_get_filename (abfd)); + + /* Sort the relocs by address. */ + qsort (aux.dynrelbuf, aux.dynrelcount, sizeof (arelent *), + compare_relocs); + } + } + disasm_info.symtab = sorted_syms; + disasm_info.symtab_size = sorted_symcount; + + bfd_map_over_sections (abfd, disassemble_section, & disasm_info); + + if (aux.dynrelbuf != NULL) + free (aux.dynrelbuf); + free (sorted_syms); +} + +static bfd_boolean +load_specific_debug_section (enum dwarf_section_display_enum debug, + asection *sec, void *file) +{ + struct dwarf_section *section = &debug_displays [debug].section; + bfd *abfd = (bfd *) file; + bfd_byte *contents; + + if (section->start != NULL) + { + /* If it is already loaded, do nothing. */ + if (streq (section->filename, bfd_get_filename (abfd))) + return TRUE; + free (section->start); + } + + section->filename = bfd_get_filename (abfd); + section->reloc_info = NULL; + section->num_relocs = 0; + section->address = bfd_get_section_vma (abfd, sec); + section->size = bfd_get_section_size (sec); + section->start = contents = malloc (section->size + 1); + section->user_data = sec; + if (section->start == NULL + || !bfd_get_full_section_contents (abfd, sec, &contents)) + { + free_debug_section (debug); + printf (_("\nCan't get contents for section '%s'.\n"), + section->name); + return FALSE; + } + /* Ensure any string section has a terminating NUL. */ + section->start[section->size] = 0; + + if (is_relocatable && debug_displays [debug].relocate) + { + long reloc_size; + bfd_boolean ret; + + bfd_cache_section_contents (sec, section->start); + + ret = bfd_simple_get_relocated_section_contents (abfd, + sec, + section->start, + syms) != NULL; + + if (! ret) + { + free_debug_section (debug); + printf (_("\nCan't get contents for section '%s'.\n"), + section->name); + return FALSE; + } + + reloc_size = bfd_get_reloc_upper_bound (abfd, sec); + if (reloc_size > 0) + { + unsigned long reloc_count; + arelent **relocs; + + relocs = (arelent **) xmalloc (reloc_size); + + reloc_count = bfd_canonicalize_reloc (abfd, sec, relocs, NULL); + if (reloc_count == 0) + free (relocs); + else + { + section->reloc_info = relocs; + section->num_relocs = reloc_count; + } + } + } + + return TRUE; +} + +bfd_boolean +reloc_at (struct dwarf_section * dsec, dwarf_vma offset) +{ + arelent ** relocs; + arelent * rp; + + if (dsec == NULL || dsec->reloc_info == NULL) + return FALSE; + + relocs = (arelent **) dsec->reloc_info; + + for (; (rp = * relocs) != NULL; ++ relocs) + if (rp->address == offset) + return TRUE; + + return FALSE; +} + +bfd_boolean +load_debug_section (enum dwarf_section_display_enum debug, void *file) +{ + struct dwarf_section *section = &debug_displays [debug].section; + bfd *abfd = (bfd *) file; + asection *sec; + + /* If it is already loaded, do nothing. */ + if (section->start != NULL) + { + if (streq (section->filename, bfd_get_filename (abfd))) + return TRUE; + } + + /* Locate the debug section. */ + sec = bfd_get_section_by_name (abfd, section->uncompressed_name); + if (sec != NULL) + section->name = section->uncompressed_name; + else + { + sec = bfd_get_section_by_name (abfd, section->compressed_name); + if (sec != NULL) + section->name = section->compressed_name; + } + if (sec == NULL) + return FALSE; + + return load_specific_debug_section (debug, sec, file); +} + +void +free_debug_section (enum dwarf_section_display_enum debug) +{ + struct dwarf_section *section = &debug_displays [debug].section; + + if (section->start == NULL) + return; + + /* PR 17512: file: 0f67f69d. */ + if (section->user_data != NULL) + { + asection * sec = (asection *) section->user_data; + + /* If we are freeing contents that are also pointed to by the BFD + library's section structure then make sure to update those pointers + too. Otherwise, the next time we try to load data for this section + we can end up using a stale pointer. */ + if (section->start == sec->contents) + { + sec->contents = NULL; + sec->flags &= ~ SEC_IN_MEMORY; + sec->compress_status = COMPRESS_SECTION_NONE; + } + } + + free ((char *) section->start); + section->start = NULL; + section->address = 0; + section->size = 0; +} + +void +close_debug_file (void * file) +{ + bfd * abfd = (bfd *) file; + + bfd_close (abfd); +} + +void * +open_debug_file (const char * pathname) +{ + bfd * data; + + data = bfd_openr (pathname, NULL); + if (data == NULL) + return NULL; + + if (! bfd_check_format (data, bfd_object)) + return NULL; + + return data; +} + +static void +dump_dwarf_section (bfd *abfd, asection *section, + void *arg ATTRIBUTE_UNUSED) +{ + const char *name = bfd_get_section_name (abfd, section); + const char *match; + int i; + + if (CONST_STRNEQ (name, ".gnu.linkonce.wi.")) + match = ".debug_info"; + else + match = name; + + for (i = 0; i < max; i++) + if ((strcmp (debug_displays [i].section.uncompressed_name, match) == 0 + || strcmp (debug_displays [i].section.compressed_name, match) == 0) + && debug_displays [i].enabled != NULL + && *debug_displays [i].enabled) + { + struct dwarf_section *sec = &debug_displays [i].section; + + if (strcmp (sec->uncompressed_name, match) == 0) + sec->name = sec->uncompressed_name; + else + sec->name = sec->compressed_name; + if (load_specific_debug_section ((enum dwarf_section_display_enum) i, + section, abfd)) + { + debug_displays [i].display (sec, abfd); + + if (i != info && i != abbrev) + free_debug_section ((enum dwarf_section_display_enum) i); + } + break; + } +} + +/* Dump the dwarf debugging information. */ + +static void +dump_dwarf (bfd *abfd) +{ + bfd * separates; + + is_relocatable = (abfd->flags & (EXEC_P | DYNAMIC)) == 0; + + eh_addr_size = bfd_arch_bits_per_address (abfd) / 8; + + if (bfd_big_endian (abfd)) + byte_get = byte_get_big_endian; + else if (bfd_little_endian (abfd)) + byte_get = byte_get_little_endian; + else + /* PR 17512: file: objdump-s-endless-loop.tekhex. */ + { + warn (_("File %s does not contain any dwarf debug information\n"), + bfd_get_filename (abfd)); + return; + } + + switch (bfd_get_arch (abfd)) + { + case bfd_arch_i386: + switch (bfd_get_mach (abfd)) + { + case bfd_mach_x86_64: + case bfd_mach_x86_64_intel_syntax: + case bfd_mach_x86_64_nacl: + case bfd_mach_x64_32: + case bfd_mach_x64_32_intel_syntax: + case bfd_mach_x64_32_nacl: + init_dwarf_regnames_x86_64 (); + break; + + default: + init_dwarf_regnames_i386 (); + break; + } + break; + + case bfd_arch_iamcu: + init_dwarf_regnames_iamcu (); + break; + + case bfd_arch_aarch64: + init_dwarf_regnames_aarch64(); + break; + + case bfd_arch_s390: + init_dwarf_regnames_s390 (); + break; + + default: + break; + } + + separates = load_separate_debug_file (abfd, bfd_get_filename (abfd)); + + bfd_map_over_sections (abfd, dump_dwarf_section, NULL); + + if (separates) + bfd_map_over_sections (separates, dump_dwarf_section, NULL); + + free_debug_memory (); +} + +/* Read ABFD's stabs section STABSECT_NAME, and return a pointer to + it. Return NULL on failure. */ + +static bfd_byte * +read_section_stabs (bfd *abfd, const char *sect_name, bfd_size_type *size_ptr) +{ + asection *stabsect; + bfd_byte *contents; + + stabsect = bfd_get_section_by_name (abfd, sect_name); + if (stabsect == NULL) + { + printf (_("No %s section present\n\n"), sect_name); + return FALSE; + } + + if (!bfd_malloc_and_get_section (abfd, stabsect, &contents)) + { + non_fatal (_("reading %s section of %s failed: %s"), + sect_name, bfd_get_filename (abfd), + bfd_errmsg (bfd_get_error ())); + exit_status = 1; + free (contents); + return NULL; + } + + *size_ptr = bfd_section_size (abfd, stabsect); + + return contents; +} + +/* Stabs entries use a 12 byte format: + 4 byte string table index + 1 byte stab type + 1 byte stab other field + 2 byte stab desc field + 4 byte stab value + FIXME: This will have to change for a 64 bit object format. */ + +#define STRDXOFF (0) +#define TYPEOFF (4) +#define OTHEROFF (5) +#define DESCOFF (6) +#define VALOFF (8) +#define STABSIZE (12) + +/* Print ABFD's stabs section STABSECT_NAME (in `stabs'), + using string table section STRSECT_NAME (in `strtab'). */ + +static void +print_section_stabs (bfd *abfd, + const char *stabsect_name, + unsigned *string_offset_ptr) +{ + int i; + unsigned file_string_table_offset = 0; + unsigned next_file_string_table_offset = *string_offset_ptr; + bfd_byte *stabp, *stabs_end; + + stabp = stabs; + stabs_end = stabp + stab_size; + + printf (_("Contents of %s section:\n\n"), stabsect_name); + printf ("Symnum n_type n_othr n_desc n_value n_strx String\n"); + + /* Loop through all symbols and print them. + + We start the index at -1 because there is a dummy symbol on + the front of stabs-in-{coff,elf} sections that supplies sizes. */ + for (i = -1; stabp <= stabs_end - STABSIZE; stabp += STABSIZE, i++) + { + const char *name; + unsigned long strx; + unsigned char type, other; + unsigned short desc; + bfd_vma value; + + strx = bfd_h_get_32 (abfd, stabp + STRDXOFF); + type = bfd_h_get_8 (abfd, stabp + TYPEOFF); + other = bfd_h_get_8 (abfd, stabp + OTHEROFF); + desc = bfd_h_get_16 (abfd, stabp + DESCOFF); + value = bfd_h_get_32 (abfd, stabp + VALOFF); + + printf ("\n%-6d ", i); + /* Either print the stab name, or, if unnamed, print its number + again (makes consistent formatting for tools like awk). */ + name = bfd_get_stab_name (type); + if (name != NULL) + printf ("%-6s", name); + else if (type == N_UNDF) + printf ("HdrSym"); + else + printf ("%-6d", type); + printf (" %-6d %-6d ", other, desc); + bfd_printf_vma (abfd, value); + printf (" %-6lu", strx); + + /* Symbols with type == 0 (N_UNDF) specify the length of the + string table associated with this file. We use that info + to know how to relocate the *next* file's string table indices. */ + if (type == N_UNDF) + { + file_string_table_offset = next_file_string_table_offset; + next_file_string_table_offset += value; + } + else + { + bfd_size_type amt = strx + file_string_table_offset; + + /* Using the (possibly updated) string table offset, print the + string (if any) associated with this symbol. */ + if (amt < stabstr_size) + /* PR 17512: file: 079-79389-0.001:0.1. */ + printf (" %.*s", (int)(stabstr_size - amt), strtab + amt); + else + printf (" *"); + } + } + printf ("\n\n"); + *string_offset_ptr = next_file_string_table_offset; +} + +typedef struct +{ + const char * section_name; + const char * string_section_name; + unsigned string_offset; +} +stab_section_names; + +static void +find_stabs_section (bfd *abfd, asection *section, void *names) +{ + int len; + stab_section_names * sought = (stab_section_names *) names; + + /* Check for section names for which stabsect_name is a prefix, to + handle .stab.N, etc. */ + len = strlen (sought->section_name); + + /* If the prefix matches, and the files section name ends with a + nul or a digit, then we match. I.e., we want either an exact + match or a section followed by a number. */ + if (strncmp (sought->section_name, section->name, len) == 0 + && (section->name[len] == 0 + || (section->name[len] == '.' && ISDIGIT (section->name[len + 1])))) + { + if (strtab == NULL) + strtab = read_section_stabs (abfd, sought->string_section_name, + &stabstr_size); + + if (strtab) + { + stabs = read_section_stabs (abfd, section->name, &stab_size); + if (stabs) + print_section_stabs (abfd, section->name, &sought->string_offset); + } + } +} + +static void +dump_stabs_section (bfd *abfd, char *stabsect_name, char *strsect_name) +{ + stab_section_names s; + + s.section_name = stabsect_name; + s.string_section_name = strsect_name; + s.string_offset = 0; + + bfd_map_over_sections (abfd, find_stabs_section, & s); + + free (strtab); + strtab = NULL; +} + +/* Dump the any sections containing stabs debugging information. */ + +static void +dump_stabs (bfd *abfd) +{ + dump_stabs_section (abfd, ".stab", ".stabstr"); + dump_stabs_section (abfd, ".stab.excl", ".stab.exclstr"); + dump_stabs_section (abfd, ".stab.index", ".stab.indexstr"); + + /* For Darwin. */ + dump_stabs_section (abfd, "LC_SYMTAB.stabs", "LC_SYMTAB.stabstr"); + + dump_stabs_section (abfd, "$GDB_SYMBOLS$", "$GDB_STRINGS$"); +} + +static void +dump_bfd_header (bfd *abfd) +{ + char *comma = ""; + + printf (_("architecture: %s, "), + bfd_printable_arch_mach (bfd_get_arch (abfd), + bfd_get_mach (abfd))); + printf (_("flags 0x%08x:\n"), abfd->flags & ~BFD_FLAGS_FOR_BFD_USE_MASK); + +#define PF(x, y) if (abfd->flags & x) {printf("%s%s", comma, y); comma=", ";} + PF (HAS_RELOC, "HAS_RELOC"); + PF (EXEC_P, "EXEC_P"); + PF (HAS_LINENO, "HAS_LINENO"); + PF (HAS_DEBUG, "HAS_DEBUG"); + PF (HAS_SYMS, "HAS_SYMS"); + PF (HAS_LOCALS, "HAS_LOCALS"); + PF (DYNAMIC, "DYNAMIC"); + PF (WP_TEXT, "WP_TEXT"); + PF (D_PAGED, "D_PAGED"); + PF (BFD_IS_RELAXABLE, "BFD_IS_RELAXABLE"); + printf (_("\nstart address 0x")); + bfd_printf_vma (abfd, abfd->start_address); + printf ("\n"); +} + + +static void +dump_bfd_private_header (bfd *abfd) +{ + bfd_print_private_bfd_data (abfd, stdout); +} + +static void +dump_target_specific (bfd *abfd) +{ + const struct objdump_private_desc * const *desc; + struct objdump_private_option *opt; + char *e, *b; + + /* Find the desc. */ + for (desc = objdump_private_vectors; *desc != NULL; desc++) + if ((*desc)->filter (abfd)) + break; + + if (*desc == NULL) + { + non_fatal (_("option -P/--private not supported by this file")); + return; + } + + /* Clear all options. */ + for (opt = (*desc)->options; opt->name; opt++) + opt->selected = FALSE; + + /* Decode options. */ + b = dump_private_options; + do + { + e = strchr (b, ','); + + if (e) + *e = 0; + + for (opt = (*desc)->options; opt->name; opt++) + if (strcmp (opt->name, b) == 0) + { + opt->selected = TRUE; + break; + } + if (opt->name == NULL) + non_fatal (_("target specific dump '%s' not supported"), b); + + if (e) + { + *e = ','; + b = e + 1; + } + } + while (e != NULL); + + /* Dump. */ + (*desc)->dump (abfd); +} + +/* Display a section in hexadecimal format with associated characters. + Each line prefixed by the zero padded address. */ + +static void +dump_section (bfd *abfd, asection *section, void *dummy ATTRIBUTE_UNUSED) +{ + bfd_byte *data = NULL; + bfd_size_type datasize; + bfd_vma addr_offset; + bfd_vma start_offset; + bfd_vma stop_offset; + unsigned int opb = bfd_octets_per_byte (abfd); + /* Bytes per line. */ + const int onaline = 16; + char buf[64]; + int count; + int width; + + if ((section->flags & SEC_HAS_CONTENTS) == 0) + return; + + if (! process_section_p (section)) + return; + + if ((datasize = bfd_section_size (abfd, section)) == 0) + return; + + /* Compute the address range to display. */ + if (start_address == (bfd_vma) -1 + || start_address < section->vma) + start_offset = 0; + else + start_offset = start_address - section->vma; + + if (stop_address == (bfd_vma) -1) + stop_offset = datasize / opb; + else + { + if (stop_address < section->vma) + stop_offset = 0; + else + stop_offset = stop_address - section->vma; + + if (stop_offset > datasize / opb) + stop_offset = datasize / opb; + } + + if (start_offset >= stop_offset) + return; + + printf (_("Contents of section %s:"), section->name); + if (display_file_offsets) + printf (_(" (Starting at file offset: 0x%lx)"), + (unsigned long) (section->filepos + start_offset)); + printf ("\n"); + + if (!bfd_get_full_section_contents (abfd, section, &data)) + { + non_fatal (_("Reading section %s failed because: %s"), + section->name, bfd_errmsg (bfd_get_error ())); + return; + } + + width = 4; + + bfd_sprintf_vma (abfd, buf, start_offset + section->vma); + if (strlen (buf) >= sizeof (buf)) + abort (); + + count = 0; + while (buf[count] == '0' && buf[count+1] != '\0') + count++; + count = strlen (buf) - count; + if (count > width) + width = count; + + bfd_sprintf_vma (abfd, buf, stop_offset + section->vma - 1); + if (strlen (buf) >= sizeof (buf)) + abort (); + + count = 0; + while (buf[count] == '0' && buf[count+1] != '\0') + count++; + count = strlen (buf) - count; + if (count > width) + width = count; + + for (addr_offset = start_offset; + addr_offset < stop_offset; addr_offset += onaline / opb) + { + bfd_size_type j; + + bfd_sprintf_vma (abfd, buf, (addr_offset + section->vma)); + count = strlen (buf); + if ((size_t) count >= sizeof (buf)) + abort (); + + putchar (' '); + while (count < width) + { + putchar ('0'); + count++; + } + fputs (buf + count - width, stdout); + putchar (' '); + + for (j = addr_offset * opb; + j < addr_offset * opb + onaline; j++) + { + if (j < stop_offset * opb) + printf ("%02x", (unsigned) (data[j])); + else + printf (" "); + if ((j & 3) == 3) + printf (" "); + } + + printf (" "); + for (j = addr_offset * opb; + j < addr_offset * opb + onaline; j++) + { + if (j >= stop_offset * opb) + printf (" "); + else + printf ("%c", ISPRINT (data[j]) ? data[j] : '.'); + } + putchar ('\n'); + } + free (data); +} + +/* Actually display the various requested regions. */ + +static void +dump_data (bfd *abfd) +{ + bfd_map_over_sections (abfd, dump_section, NULL); +} + +/* Should perhaps share code and display with nm? */ + +static void +dump_symbols (bfd *abfd ATTRIBUTE_UNUSED, bfd_boolean dynamic) +{ + asymbol **current; + long max_count; + long count; + + if (dynamic) + { + current = dynsyms; + max_count = dynsymcount; + printf ("DYNAMIC SYMBOL TABLE:\n"); + } + else + { + current = syms; + max_count = symcount; + printf ("SYMBOL TABLE:\n"); + } + + if (max_count == 0) + printf (_("no symbols\n")); + + for (count = 0; count < max_count; count++) + { + bfd *cur_bfd; + + if (*current == NULL) + printf (_("no information for symbol number %ld\n"), count); + + else if ((cur_bfd = bfd_asymbol_bfd (*current)) == NULL) + printf (_("could not determine the type of symbol number %ld\n"), + count); + + else if (process_section_p ((* current)->section) + && (dump_special_syms + || !bfd_is_target_special_symbol (cur_bfd, *current))) + { + const char *name = (*current)->name; + + if (do_demangle && name != NULL && *name != '\0') + { + char *alloc; + + /* If we want to demangle the name, we demangle it + here, and temporarily clobber it while calling + bfd_print_symbol. FIXME: This is a gross hack. */ + alloc = bfd_demangle (cur_bfd, name, DMGL_ANSI | DMGL_PARAMS); + if (alloc != NULL) + (*current)->name = alloc; + bfd_print_symbol (cur_bfd, stdout, *current, + bfd_print_symbol_all); + if (alloc != NULL) + { + (*current)->name = name; + free (alloc); + } + } + else + bfd_print_symbol (cur_bfd, stdout, *current, + bfd_print_symbol_all); + printf ("\n"); + } + + current++; + } + printf ("\n\n"); +} + +static void +dump_reloc_set (bfd *abfd, asection *sec, arelent **relpp, long relcount) +{ + arelent **p; + char *last_filename, *last_functionname; + unsigned int last_line; + unsigned int last_discriminator; + + /* Get column headers lined up reasonably. */ + { + static int width; + + if (width == 0) + { + char buf[30]; + + bfd_sprintf_vma (abfd, buf, (bfd_vma) -1); + width = strlen (buf) - 7; + } + printf ("OFFSET %*s TYPE %*s VALUE \n", width, "", 12, ""); + } + + last_filename = NULL; + last_functionname = NULL; + last_line = 0; + last_discriminator = 0; + + for (p = relpp; relcount && *p != NULL; p++, relcount--) + { + arelent *q = *p; + const char *filename, *functionname; + unsigned int linenumber; + unsigned int discriminator; + const char *sym_name; + const char *section_name; + bfd_vma addend2 = 0; + + if (start_address != (bfd_vma) -1 + && q->address < start_address) + continue; + if (stop_address != (bfd_vma) -1 + && q->address > stop_address) + continue; + + if (with_line_numbers + && sec != NULL + && bfd_find_nearest_line_discriminator (abfd, sec, syms, q->address, + &filename, &functionname, + &linenumber, &discriminator)) + { + if (functionname != NULL + && (last_functionname == NULL + || strcmp (functionname, last_functionname) != 0)) + { + printf ("%s():\n", functionname); + if (last_functionname != NULL) + free (last_functionname); + last_functionname = xstrdup (functionname); + } + + if (linenumber > 0 + && (linenumber != last_line + || (filename != NULL + && last_filename != NULL + && filename_cmp (filename, last_filename) != 0) + || (discriminator != last_discriminator))) + { + if (discriminator > 0) + printf ("%s:%u\n", filename == NULL ? "???" : filename, linenumber); + else + printf ("%s:%u (discriminator %u)\n", filename == NULL ? "???" : filename, + linenumber, discriminator); + last_line = linenumber; + last_discriminator = discriminator; + if (last_filename != NULL) + free (last_filename); + if (filename == NULL) + last_filename = NULL; + else + last_filename = xstrdup (filename); + } + } + + if (q->sym_ptr_ptr && *q->sym_ptr_ptr) + { + sym_name = (*(q->sym_ptr_ptr))->name; + section_name = (*(q->sym_ptr_ptr))->section->name; + } + else + { + sym_name = NULL; + section_name = NULL; + } + + bfd_printf_vma (abfd, q->address); + if (q->howto == NULL) + printf (" *unknown* "); + else if (q->howto->name) + { + const char *name = q->howto->name; + + /* R_SPARC_OLO10 relocations contain two addends. + But because 'arelent' lacks enough storage to + store them both, the 64-bit ELF Sparc backend + records this as two relocations. One R_SPARC_LO10 + and one R_SPARC_13, both pointing to the same + address. This is merely so that we have some + place to store both addend fields. + + Undo this transformation, otherwise the output + will be confusing. */ + if (abfd->xvec->flavour == bfd_target_elf_flavour + && elf_tdata(abfd)->elf_header->e_machine == EM_SPARCV9 + && relcount > 1 + && !strcmp (q->howto->name, "R_SPARC_LO10")) + { + arelent *q2 = *(p + 1); + if (q2 != NULL + && q2->howto + && q->address == q2->address + && !strcmp (q2->howto->name, "R_SPARC_13")) + { + name = "R_SPARC_OLO10"; + addend2 = q2->addend; + p++; + } + } + printf (" %-16s ", name); + } + else + printf (" %-16d ", q->howto->type); + + if (sym_name) + { + objdump_print_symname (abfd, NULL, *q->sym_ptr_ptr); + } + else + { + if (section_name == NULL) + section_name = "*unknown*"; + printf ("[%s]", section_name); + } + + if (q->addend) + { + bfd_signed_vma addend = q->addend; + if (addend < 0) + { + printf ("-0x"); + addend = -addend; + } + else + printf ("+0x"); + bfd_printf_vma (abfd, addend); + } + if (addend2) + { + printf ("+0x"); + bfd_printf_vma (abfd, addend2); + } + + printf ("\n"); + } + + if (last_filename != NULL) + free (last_filename); + if (last_functionname != NULL) + free (last_functionname); +} + +static void +dump_relocs_in_section (bfd *abfd, + asection *section, + void *dummy ATTRIBUTE_UNUSED) +{ + arelent **relpp; + long relcount; + long relsize; + + if ( bfd_is_abs_section (section) + || bfd_is_und_section (section) + || bfd_is_com_section (section) + || (! process_section_p (section)) + || ((section->flags & SEC_RELOC) == 0)) + return; + + relsize = bfd_get_reloc_upper_bound (abfd, section); + if (relsize < 0) + bfd_fatal (bfd_get_filename (abfd)); + + printf ("RELOCATION RECORDS FOR [%s]:", section->name); + + if (relsize == 0) + { + printf (" (none)\n\n"); + return; + } + + if ((bfd_get_file_flags (abfd) & (BFD_IN_MEMORY | BFD_LINKER_CREATED)) == 0 + && (((ufile_ptr) relsize > bfd_get_file_size (abfd)) + /* Also check the section's reloc count since if this is negative + (or very large) the computation in bfd_get_reloc_upper_bound + may have resulted in returning a small, positive integer. + See PR 22508 for a reproducer. + + Note - we check against file size rather than section size as + it is possible for there to be more relocs that apply to a + section than there are bytes in that section. */ + || (section->reloc_count > bfd_get_file_size (abfd)))) + { + printf (" (too many: 0x%x)\n", section->reloc_count); + bfd_set_error (bfd_error_file_truncated); + bfd_fatal (bfd_get_filename (abfd)); + } + + relpp = (arelent **) xmalloc (relsize); + relcount = bfd_canonicalize_reloc (abfd, section, relpp, syms); + + if (relcount < 0) + { + printf ("\n"); + non_fatal (_("failed to read relocs in: %s"), bfd_get_filename (abfd)); + bfd_fatal (_("error message was")); + } + else if (relcount == 0) + printf (" (none)\n\n"); + else + { + printf ("\n"); + dump_reloc_set (abfd, section, relpp, relcount); + printf ("\n\n"); + } + free (relpp); +} + +static void +dump_relocs (bfd *abfd) +{ + bfd_map_over_sections (abfd, dump_relocs_in_section, NULL); +} + +static void +dump_dynamic_relocs (bfd *abfd) +{ + long relsize; + arelent **relpp; + long relcount; + + relsize = bfd_get_dynamic_reloc_upper_bound (abfd); + if (relsize < 0) + bfd_fatal (bfd_get_filename (abfd)); + + printf ("DYNAMIC RELOCATION RECORDS"); + + if (relsize == 0) + printf (" (none)\n\n"); + else + { + relpp = (arelent **) xmalloc (relsize); + relcount = bfd_canonicalize_dynamic_reloc (abfd, relpp, dynsyms); + + if (relcount < 0) + bfd_fatal (bfd_get_filename (abfd)); + else if (relcount == 0) + printf (" (none)\n\n"); + else + { + printf ("\n"); + dump_reloc_set (abfd, NULL, relpp, relcount); + printf ("\n\n"); + } + free (relpp); + } +} + +/* Creates a table of paths, to search for source files. */ + +static void +add_include_path (const char *path) +{ + if (path[0] == 0) + return; + include_path_count++; + include_paths = (const char **) + xrealloc (include_paths, include_path_count * sizeof (*include_paths)); +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + if (path[1] == ':' && path[2] == 0) + path = concat (path, ".", (const char *) 0); +#endif + include_paths[include_path_count - 1] = path; +} + +static void +adjust_addresses (bfd *abfd ATTRIBUTE_UNUSED, + asection *section, + void *arg) +{ + if ((section->flags & SEC_DEBUGGING) == 0) + { + bfd_boolean *has_reloc_p = (bfd_boolean *) arg; + section->vma += adjust_section_vma; + if (*has_reloc_p) + section->lma += adjust_section_vma; + } +} + +/* Dump selected contents of ABFD. */ + +static void +dump_bfd (bfd *abfd) +{ + /* If we are adjusting section VMA's, change them all now. Changing + the BFD information is a hack. However, we must do it, or + bfd_find_nearest_line will not do the right thing. */ + if (adjust_section_vma != 0) + { + bfd_boolean has_reloc = (abfd->flags & HAS_RELOC); + bfd_map_over_sections (abfd, adjust_addresses, &has_reloc); + } + + if (! dump_debugging_tags && ! suppress_bfd_header) + printf (_("\n%s: file format %s\n"), bfd_get_filename (abfd), + abfd->xvec->name); + if (dump_ar_hdrs) + print_arelt_descr (stdout, abfd, TRUE); + if (dump_file_header) + dump_bfd_header (abfd); + if (dump_private_headers) + dump_bfd_private_header (abfd); + if (dump_private_options != NULL) + dump_target_specific (abfd); + if (! dump_debugging_tags && ! suppress_bfd_header) + putchar ('\n'); + + if (dump_symtab + || dump_reloc_info + || disassemble + || dump_debugging + || dump_dwarf_section_info) + syms = slurp_symtab (abfd); + + if (dump_section_headers) + dump_headers (abfd); + + if (dump_dynamic_symtab || dump_dynamic_reloc_info + || (disassemble && bfd_get_dynamic_symtab_upper_bound (abfd) > 0)) + dynsyms = slurp_dynamic_symtab (abfd); + if (disassemble) + { + synthcount = bfd_get_synthetic_symtab (abfd, symcount, syms, + dynsymcount, dynsyms, &synthsyms); + if (synthcount < 0) + synthcount = 0; + } + + if (dump_symtab) + dump_symbols (abfd, FALSE); + if (dump_dynamic_symtab) + dump_symbols (abfd, TRUE); + if (dump_dwarf_section_info) + dump_dwarf (abfd); + if (dump_stab_section_info) + dump_stabs (abfd); + if (dump_reloc_info && ! disassemble) + dump_relocs (abfd); + if (dump_dynamic_reloc_info && ! disassemble) + dump_dynamic_relocs (abfd); + if (dump_section_contents) + dump_data (abfd); + if (disassemble) + disassemble_data (abfd); + + if (dump_debugging) + { + void *dhandle; + + dhandle = read_debugging_info (abfd, syms, symcount, TRUE); + if (dhandle != NULL) + { + if (!print_debugging_info (stdout, dhandle, abfd, syms, + bfd_demangle, + dump_debugging_tags ? TRUE : FALSE)) + { + non_fatal (_("%s: printing debugging information failed"), + bfd_get_filename (abfd)); + exit_status = 1; + } + } + /* PR 6483: If there was no STABS or IEEE debug + info in the file, try DWARF instead. */ + else if (! dump_dwarf_section_info) + { + dwarf_select_sections_all (); + dump_dwarf (abfd); + } + } + + if (syms) + { + free (syms); + syms = NULL; + } + + if (dynsyms) + { + free (dynsyms); + dynsyms = NULL; + } + + if (synthsyms) + { + free (synthsyms); + synthsyms = NULL; + } + + symcount = 0; + dynsymcount = 0; + synthcount = 0; +} + +static void +display_object_bfd (bfd *abfd) +{ + char **matching; + + if (bfd_check_format_matches (abfd, bfd_object, &matching)) + { + dump_bfd (abfd); + return; + } + + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + nonfatal (bfd_get_filename (abfd)); + list_matching_formats (matching); + free (matching); + return; + } + + if (bfd_get_error () != bfd_error_file_not_recognized) + { + nonfatal (bfd_get_filename (abfd)); + return; + } + + if (bfd_check_format_matches (abfd, bfd_core, &matching)) + { + dump_bfd (abfd); + return; + } + + nonfatal (bfd_get_filename (abfd)); + + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (matching); + free (matching); + } +} + +static void +display_any_bfd (bfd *file, int level) +{ + /* Decompress sections unless dumping the section contents. */ + if (!dump_section_contents) + file->flags |= BFD_DECOMPRESS; + + /* If the file is an archive, process all of its elements. */ + if (bfd_check_format (file, bfd_archive)) + { + bfd *arfile = NULL; + bfd *last_arfile = NULL; + + if (level == 0) + printf (_("In archive %s:\n"), bfd_get_filename (file)); + else if (level > 100) + { + /* Prevent corrupted files from spinning us into an + infinite loop. 100 is an arbitrary heuristic. */ + fatal (_("Archive nesting is too deep")); + return; + } + else + printf (_("In nested archive %s:\n"), bfd_get_filename (file)); + + for (;;) + { + bfd_set_error (bfd_error_no_error); + + arfile = bfd_openr_next_archived_file (file, arfile); + if (arfile == NULL) + { + if (bfd_get_error () != bfd_error_no_more_archived_files) + nonfatal (bfd_get_filename (file)); + break; + } + + display_any_bfd (arfile, level + 1); + + if (last_arfile != NULL) + { + bfd_close (last_arfile); + /* PR 17512: file: ac585d01. */ + if (arfile == last_arfile) + { + last_arfile = NULL; + break; + } + } + last_arfile = arfile; + } + + if (last_arfile != NULL) + bfd_close (last_arfile); + } + else + display_object_bfd (file); +} + +static void +display_file (char *filename, char *target, bfd_boolean last_file) +{ + bfd *file; + + if (get_file_size (filename) < 1) + { + exit_status = 1; + return; + } + + file = bfd_openr (filename, target); + if (file == NULL) + { + nonfatal (filename); + return; + } + + display_any_bfd (file, 0); + + /* This is an optimization to improve the speed of objdump, especially when + dumping a file with lots of associated debug informatiom. Calling + bfd_close on such a file can take a non-trivial amount of time as there + are lots of lists to walk and buffers to free. This is only really + necessary however if we are about to load another file and we need the + memory back. Otherwise, if we are about to exit, then we can save (a lot + of) time by only doing a quick close, and allowing the OS to reclaim the + memory for us. */ + if (! last_file) + bfd_close (file); + else + bfd_close_all_done (file); +} + +int +main (int argc, char **argv) +{ + int c; + char *target = default_target; + bfd_boolean seenflag = FALSE; + +#if defined (HAVE_SETLOCALE) +#if defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif + setlocale (LC_CTYPE, ""); +#endif + + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + program_name = *argv; + xmalloc_set_program_name (program_name); + bfd_set_error_program_name (program_name); + + START_PROGRESS (program_name, 0); + + expandargv (&argc, &argv); + + bfd_init (); + set_default_bfd_target (); + + while ((c = getopt_long (argc, argv, + "pP:ib:m:M:VvCdDlfFaHhrRtTxsSI:j:wE:zgeGW::", + long_options, (int *) 0)) + != EOF) + { + switch (c) + { + case 0: + break; /* We've been given a long option. */ + case 'm': + machine = optarg; + break; + case 'M': + { + char *options; + if (disassembler_options) + /* Ignore potential memory leak for now. */ + options = concat (disassembler_options, ",", + optarg, (const char *) NULL); + else + options = optarg; + disassembler_options = remove_whitespace_and_extra_commas (options); + } + break; + case 'j': + add_only (optarg); + break; + case 'F': + display_file_offsets = TRUE; + break; + case 'l': + with_line_numbers = TRUE; + break; + case 'b': + target = optarg; + break; + case 'C': + do_demangle = TRUE; + if (optarg != NULL) + { + enum demangling_styles style; + + style = cplus_demangle_name_to_style (optarg); + if (style == unknown_demangling) + fatal (_("unknown demangling style `%s'"), + optarg); + + cplus_demangle_set_style (style); + } + break; + case 'w': + do_wide = wide_output = TRUE; + break; + case OPTION_ADJUST_VMA: + adjust_section_vma = parse_vma (optarg, "--adjust-vma"); + break; + case OPTION_START_ADDRESS: + start_address = parse_vma (optarg, "--start-address"); + if ((stop_address != (bfd_vma) -1) && stop_address <= start_address) + fatal (_("error: the start address should be before the end address")); + break; + case OPTION_STOP_ADDRESS: + stop_address = parse_vma (optarg, "--stop-address"); + if ((start_address != (bfd_vma) -1) && stop_address <= start_address) + fatal (_("error: the stop address should be after the start address")); + break; + case OPTION_PREFIX: + prefix = optarg; + prefix_length = strlen (prefix); + /* Remove an unnecessary trailing '/' */ + while (IS_DIR_SEPARATOR (prefix[prefix_length - 1])) + prefix_length--; + break; + case OPTION_PREFIX_STRIP: + prefix_strip = atoi (optarg); + if (prefix_strip < 0) + fatal (_("error: prefix strip must be non-negative")); + break; + case OPTION_INSN_WIDTH: + insn_width = strtoul (optarg, NULL, 0); + if (insn_width <= 0) + fatal (_("error: instruction width must be positive")); + break; + case OPTION_INLINES: + unwind_inlines = TRUE; + break; + case 'E': + if (strcmp (optarg, "B") == 0) + endian = BFD_ENDIAN_BIG; + else if (strcmp (optarg, "L") == 0) + endian = BFD_ENDIAN_LITTLE; + else + { + nonfatal (_("unrecognized -E option")); + usage (stderr, 1); + } + break; + case OPTION_ENDIAN: + if (strncmp (optarg, "big", strlen (optarg)) == 0) + endian = BFD_ENDIAN_BIG; + else if (strncmp (optarg, "little", strlen (optarg)) == 0) + endian = BFD_ENDIAN_LITTLE; + else + { + non_fatal (_("unrecognized --endian type `%s'"), optarg); + exit_status = 1; + usage (stderr, 1); + } + break; + + case 'f': + dump_file_header = TRUE; + seenflag = TRUE; + break; + case 'i': + formats_info = TRUE; + seenflag = TRUE; + break; + case 'I': + add_include_path (optarg); + break; + case 'p': + dump_private_headers = TRUE; + seenflag = TRUE; + break; + case 'P': + dump_private_options = optarg; + seenflag = TRUE; + break; + case 'x': + dump_private_headers = TRUE; + dump_symtab = TRUE; + dump_reloc_info = TRUE; + dump_file_header = TRUE; + dump_ar_hdrs = TRUE; + dump_section_headers = TRUE; + seenflag = TRUE; + break; + case 't': + dump_symtab = TRUE; + seenflag = TRUE; + break; + case 'T': + dump_dynamic_symtab = TRUE; + seenflag = TRUE; + break; + case 'd': + disassemble = TRUE; + seenflag = TRUE; + break; + case 'z': + disassemble_zeroes = TRUE; + break; + case 'D': + disassemble = TRUE; + disassemble_all = TRUE; + seenflag = TRUE; + break; + case 'S': + disassemble = TRUE; + with_source_code = TRUE; + seenflag = TRUE; + break; + case 'g': + dump_debugging = 1; + seenflag = TRUE; + break; + case 'e': + dump_debugging = 1; + dump_debugging_tags = 1; + do_demangle = TRUE; + seenflag = TRUE; + break; + case 'W': + dump_dwarf_section_info = TRUE; + seenflag = TRUE; + if (optarg) + dwarf_select_sections_by_letters (optarg); + else + dwarf_select_sections_all (); + break; + case OPTION_DWARF: + dump_dwarf_section_info = TRUE; + seenflag = TRUE; + if (optarg) + dwarf_select_sections_by_names (optarg); + else + dwarf_select_sections_all (); + break; + case OPTION_DWARF_DEPTH: + { + char *cp; + dwarf_cutoff_level = strtoul (optarg, & cp, 0); + } + break; + case OPTION_DWARF_START: + { + char *cp; + dwarf_start_die = strtoul (optarg, & cp, 0); + suppress_bfd_header = 1; + } + break; + case OPTION_DWARF_CHECK: + dwarf_check = TRUE; + break; + case 'G': + dump_stab_section_info = TRUE; + seenflag = TRUE; + break; + case 's': + dump_section_contents = TRUE; + seenflag = TRUE; + break; + case 'r': + dump_reloc_info = TRUE; + seenflag = TRUE; + break; + case 'R': + dump_dynamic_reloc_info = TRUE; + seenflag = TRUE; + break; + case 'a': + dump_ar_hdrs = TRUE; + seenflag = TRUE; + break; + case 'h': + dump_section_headers = TRUE; + seenflag = TRUE; + break; + case 'v': + case 'V': + show_version = TRUE; + seenflag = TRUE; + break; + + case 'H': + usage (stdout, 0); + /* No need to set seenflag or to break - usage() does not return. */ + default: + usage (stderr, 1); + } + } + + if (show_version) + print_version ("objdump"); + + if (!seenflag) + usage (stderr, 2); + + if (formats_info) + exit_status = display_info (); + else + { + if (optind == argc) + display_file ("a.out", target, TRUE); + else + for (; optind < argc;) + { + display_file (argv[optind], target, optind == argc - 1); + optind++; + } + } + + free_only_list (); + + END_PROGRESS (program_name); + + return exit_status; +} diff --git a/support/sdbinutils/binutils/objdump.h b/support/sdbinutils/binutils/objdump.h new file mode 100644 index 0000000..1a740db --- /dev/null +++ b/support/sdbinutils/binutils/objdump.h @@ -0,0 +1,53 @@ +/* objdump.h + Copyright (C) 2011-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +struct objdump_private_option +{ + /* Option name. */ + const char *name; + + /* TRUE if the option is selected. Automatically set and cleared by + objdump. */ + unsigned int selected; +}; + +struct objdump_private_desc +{ + /* Help displayed for --help. */ + void (*help)(FILE *stream); + + /* Return TRUE if these options can be applied to ABFD. */ + int (*filter)(bfd *abfd); + + /* Do the actual work: display whatever is requested according to the + options whose SELECTED field is set. */ + void (*dump)(bfd *abfd); + + /* List of options. Terminated by a NULL name. */ + struct objdump_private_option *options; +}; +/* ELF32_AVR specific target. */ +extern const struct objdump_private_desc objdump_private_desc_elf32_avr; + +/* XCOFF specific target. */ +extern const struct objdump_private_desc objdump_private_desc_xcoff; + +/* Mach-O specific target. */ +extern const struct objdump_private_desc objdump_private_desc_mach_o; diff --git a/support/sdbinutils/binutils/od-elf32_avr.c b/support/sdbinutils/binutils/od-elf32_avr.c new file mode 100644 index 0000000..05606a1 --- /dev/null +++ b/support/sdbinutils/binutils/od-elf32_avr.c @@ -0,0 +1,303 @@ +/* od-avrelf.c -- dump information about an AVR elf object file. + Copyright (C) 2011-2018 Free Software Foundation, Inc. + Written by Senthil Kumar Selvaraj, Atmel. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "sysdep.h" +#include +#include +#include +#include "safe-ctype.h" +#include "bfd.h" +#include "objdump.h" +#include "bucomm.h" +#include "bfdlink.h" +#include "bfd.h" +#include "elf/external.h" +#include "elf/internal.h" +#include "elf32-avr.h" + +/* Index of the options in the options[] array. */ +#define OPT_MEMUSAGE 0 +#define OPT_AVRPROP 1 + +/* List of actions. */ +static struct objdump_private_option options[] = + { + { "mem-usage", 0 }, + { "avr-prop", 0}, + { NULL, 0 } + }; + +/* Display help. */ + +static void +elf32_avr_help (FILE *stream) +{ + fprintf (stream, _("\ +For AVR ELF files:\n\ + mem-usage Display memory usage\n\ + avr-prop Display contents of .avr.prop section\n\ +")); +} + +typedef struct tagDeviceInfo +{ + uint32_t flash_start; + uint32_t flash_size; + uint32_t ram_start; + uint32_t ram_size; + uint32_t eeprom_start; + uint32_t eeprom_size; + char * name; +} deviceinfo; + + +/* Return TRUE if ABFD is handled. */ + +static int +elf32_avr_filter (bfd *abfd) +{ + return bfd_get_flavour (abfd) == bfd_target_elf_flavour; +} + +static char* +elf32_avr_get_note_section_contents (bfd *abfd, bfd_size_type *size) +{ + asection *section; + + if ((section = bfd_get_section_by_name (abfd, ".note.gnu.avr.deviceinfo")) == NULL) + return NULL; + + *size = bfd_get_section_size (section); + char *contents = (char *) xmalloc (*size); + bfd_get_section_contents (abfd, section, contents, 0, *size); + + return contents; +} + +static char* elf32_avr_get_note_desc (bfd *abfd, char *contents, + bfd_size_type size) +{ + Elf_External_Note *xnp = (Elf_External_Note *) contents; + Elf_Internal_Note in; + + if (offsetof (Elf_External_Note, name) > size) + return NULL; + + in.type = bfd_get_32 (abfd, xnp->type); + in.namesz = bfd_get_32 (abfd, xnp->namesz); + in.namedata = xnp->name; + if (in.namesz > contents - in.namedata + size) + return NULL; + + in.descsz = bfd_get_32 (abfd, xnp->descsz); + in.descdata = in.namedata + align_power (in.namesz, 2); + if (in.descsz != 0 + && (in.descdata >= contents + size + || in.descsz > contents - in.descdata + size)) + return NULL; + + if (strcmp (in.namedata, "AVR") != 0) + return NULL; + + return in.descdata; +} + +static void +elf32_avr_get_device_info (bfd *abfd, char *description, + deviceinfo *device) +{ + if (description == NULL) + return; + + const bfd_size_type memory_sizes = 6; + + memcpy (device, description, memory_sizes * sizeof(uint32_t)); + device->name = NULL; + + uint32_t *stroffset_table = ((uint32_t *) description) + memory_sizes; + bfd_size_type stroffset_table_size = bfd_get_32 (abfd, stroffset_table); + char *str_table = ((char *) stroffset_table) + stroffset_table_size; + + /* If the only content is the size itself, there's nothing in the table */ + if (stroffset_table_size == 4) + return; + + /* First entry is the device name index. */ + uint32_t device_name_index = bfd_get_32 (abfd, stroffset_table + 1); + + device->name = str_table + device_name_index; +} + +static void +elf32_avr_get_memory_usage (bfd *abfd, + bfd_size_type *text_usage, + bfd_size_type *data_usage, + bfd_size_type *eeprom_usage) +{ + + bfd_size_type avr_datasize = 0; + bfd_size_type avr_textsize = 0; + bfd_size_type avr_bsssize = 0; + bfd_size_type bootloadersize = 0; + bfd_size_type noinitsize = 0; + bfd_size_type eepromsize = 0; + asection *section; + + if ((section = bfd_get_section_by_name (abfd, ".data")) != NULL) + avr_datasize = bfd_section_size (abfd, section); + if ((section = bfd_get_section_by_name (abfd, ".text")) != NULL) + avr_textsize = bfd_section_size (abfd, section); + if ((section = bfd_get_section_by_name (abfd, ".bss")) != NULL) + avr_bsssize = bfd_section_size (abfd, section); + if ((section = bfd_get_section_by_name (abfd, ".bootloader")) != NULL) + bootloadersize = bfd_section_size (abfd, section); + if ((section = bfd_get_section_by_name (abfd, ".noinit")) != NULL) + noinitsize = bfd_section_size (abfd, section); + if ((section = bfd_get_section_by_name (abfd, ".eeprom")) != NULL) + eepromsize = bfd_section_size (abfd, section); + + *text_usage = avr_textsize + avr_datasize + bootloadersize; + *data_usage = avr_datasize + avr_bsssize + noinitsize; + *eeprom_usage = eepromsize; +} + +static void +elf32_avr_dump_mem_usage (bfd *abfd) +{ + char *description = NULL; + bfd_size_type note_section_size = 0; + + deviceinfo device = { 0, 0, 0, 0, 0, 0, NULL }; + device.name = "Unknown"; + + bfd_size_type data_usage = 0; + bfd_size_type text_usage = 0; + bfd_size_type eeprom_usage = 0; + + char *contents = elf32_avr_get_note_section_contents (abfd, + ¬e_section_size); + + if (contents != NULL) + { + description = elf32_avr_get_note_desc (abfd, contents, note_section_size); + elf32_avr_get_device_info (abfd, description, &device); + } + + elf32_avr_get_memory_usage (abfd, &text_usage, &data_usage, + &eeprom_usage); + + printf ("AVR Memory Usage\n" + "----------------\n" + "Device: %s\n\n", device.name); + + /* Text size */ + printf ("Program:%8ld bytes", text_usage); + if (device.flash_size > 0) + printf (" (%2.1f%% Full)", ((float) text_usage / device.flash_size) * 100); + + printf ("\n(.text + .data + .bootloader)\n\n"); + + /* Data size */ + printf ("Data: %8ld bytes", data_usage); + if (device.ram_size > 0) + printf (" (%2.1f%% Full)", ((float) data_usage / device.ram_size) * 100); + + printf ("\n(.data + .bss + .noinit)\n\n"); + + /* EEPROM size */ + if (eeprom_usage > 0) + { + printf ("EEPROM: %8ld bytes", eeprom_usage); + if (device.eeprom_size > 0) + printf (" (%2.1f%% Full)", ((float) eeprom_usage / device.eeprom_size) * 100); + + printf ("\n(.eeprom)\n\n"); + } + + if (contents != NULL) + free (contents); + +} + +static void +elf32_avr_dump_avr_prop (bfd *abfd) +{ + struct avr_property_record_list *r_list; + unsigned int i; + + r_list = avr_elf32_load_property_records (abfd); + if (r_list == NULL) + return; + + printf ("\nContents of `%s' section:\n\n", r_list->section->name); + + printf (" Version: %d\n", r_list->version); + printf (" Flags: %#x\n\n", r_list->flags); + + for (i = 0; i < r_list->record_count; ++i) + { + printf (" %d %s @ %s + %#08lx (%#08lx)\n", + i, + avr_elf32_property_record_name (&r_list->records [i]), + r_list->records [i].section->name, + r_list->records [i].offset, + (bfd_get_section_vma (abfd, r_list->records [i].section) + + r_list->records [i].offset)); + switch (r_list->records [i].type) + { + case RECORD_ORG: + /* Nothing else to print. */ + break; + case RECORD_ORG_AND_FILL: + printf (" Fill: %#08lx\n", + r_list->records [i].data.org.fill); + break; + case RECORD_ALIGN: + printf (" Align: %#08lx\n", + r_list->records [i].data.align.bytes); + break; + case RECORD_ALIGN_AND_FILL: + printf (" Align: %#08lx, Fill: %#08lx\n", + r_list->records [i].data.align.bytes, + r_list->records [i].data.align.fill); + break; + } + } + + free (r_list); +} + +static void +elf32_avr_dump (bfd *abfd) +{ + if (options[OPT_MEMUSAGE].selected) + elf32_avr_dump_mem_usage (abfd); + if (options[OPT_AVRPROP].selected) + elf32_avr_dump_avr_prop (abfd); +} + +const struct objdump_private_desc objdump_private_desc_elf32_avr = + { + elf32_avr_help, + elf32_avr_filter, + elf32_avr_dump, + options + }; diff --git a/support/sdbinutils/binutils/od-macho.c b/support/sdbinutils/binutils/od-macho.c new file mode 100644 index 0000000..09cc218 --- /dev/null +++ b/support/sdbinutils/binutils/od-macho.c @@ -0,0 +1,2214 @@ +/* od-macho.c -- dump information about an Mach-O object file. + Copyright (C) 2011-2018 Free Software Foundation, Inc. + Written by Tristan Gingold, Adacore. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "sysdep.h" +#include +#include +#include "safe-ctype.h" +#include "bfd.h" +#include "objdump.h" +#include "bucomm.h" +#include "dwarf.h" +#include "bfdlink.h" +#include "mach-o.h" +#include "mach-o/external.h" +#include "mach-o/codesign.h" +#include "mach-o/unwind.h" + +/* Index of the options in the options[] array. */ +#define OPT_HEADER 0 +#define OPT_SECTION 1 +#define OPT_MAP 2 +#define OPT_LOAD 3 +#define OPT_DYSYMTAB 4 +#define OPT_CODESIGN 5 +#define OPT_SEG_SPLIT_INFO 6 +#define OPT_COMPACT_UNWIND 7 +#define OPT_FUNCTION_STARTS 8 +#define OPT_DATA_IN_CODE 9 +#define OPT_TWOLEVEL_HINTS 10 +#define OPT_DYLD_INFO 11 + +/* List of actions. */ +static struct objdump_private_option options[] = + { + { "header", 0 }, + { "section", 0 }, + { "map", 0 }, + { "load", 0 }, + { "dysymtab", 0 }, + { "codesign", 0 }, + { "seg_split_info", 0 }, + { "compact_unwind", 0 }, + { "function_starts", 0 }, + { "data_in_code", 0 }, + { "twolevel_hints", 0 }, + { "dyld_info", 0 }, + { NULL, 0 } + }; + +/* Display help. */ + +static void +mach_o_help (FILE *stream) +{ + fprintf (stream, _("\ +For Mach-O files:\n\ + header Display the file header\n\ + section Display the segments and sections commands\n\ + map Display the section map\n\ + load Display the load commands\n\ + dysymtab Display the dynamic symbol table\n\ + codesign Display code signature\n\ + seg_split_info Display segment split info\n\ + compact_unwind Display compact unwinding info\n\ + function_starts Display start address of functions\n\ + data_in_code Display data in code entries\n\ + twolevel_hints Display the two-level namespace lookup hints table\n\ + dyld_info Display dyld information\n\ +")); +} + +/* Return TRUE if ABFD is handled. */ + +static int +mach_o_filter (bfd *abfd) +{ + return bfd_get_flavour (abfd) == bfd_target_mach_o_flavour; +} + +static const bfd_mach_o_xlat_name bfd_mach_o_cpu_name[] = +{ + { "vax", BFD_MACH_O_CPU_TYPE_VAX }, + { "mc680x0", BFD_MACH_O_CPU_TYPE_MC680x0 }, + { "i386", BFD_MACH_O_CPU_TYPE_I386 }, + { "mips", BFD_MACH_O_CPU_TYPE_MIPS }, + { "mc98000", BFD_MACH_O_CPU_TYPE_MC98000 }, + { "hppa", BFD_MACH_O_CPU_TYPE_HPPA }, + { "arm", BFD_MACH_O_CPU_TYPE_ARM }, + { "mc88000", BFD_MACH_O_CPU_TYPE_MC88000 }, + { "sparc", BFD_MACH_O_CPU_TYPE_SPARC }, + { "i860", BFD_MACH_O_CPU_TYPE_I860 }, + { "alpha", BFD_MACH_O_CPU_TYPE_ALPHA }, + { "powerpc", BFD_MACH_O_CPU_TYPE_POWERPC }, + { "powerpc_64", BFD_MACH_O_CPU_TYPE_POWERPC_64 }, + { "x86_64", BFD_MACH_O_CPU_TYPE_X86_64 }, + { "arm64", BFD_MACH_O_CPU_TYPE_ARM64 }, + { NULL, 0} +}; + +static const bfd_mach_o_xlat_name bfd_mach_o_filetype_name[] = +{ + { "object", BFD_MACH_O_MH_OBJECT }, + { "execute", BFD_MACH_O_MH_EXECUTE }, + { "fvmlib", BFD_MACH_O_MH_FVMLIB }, + { "core", BFD_MACH_O_MH_CORE }, + { "preload", BFD_MACH_O_MH_PRELOAD }, + { "dylib", BFD_MACH_O_MH_DYLIB }, + { "dylinker", BFD_MACH_O_MH_DYLINKER }, + { "bundle", BFD_MACH_O_MH_BUNDLE }, + { "dylib_stub", BFD_MACH_O_MH_DYLIB_STUB }, + { "dym", BFD_MACH_O_MH_DSYM }, + { "kext_bundle", BFD_MACH_O_MH_KEXT_BUNDLE }, + { NULL, 0} +}; + +static const bfd_mach_o_xlat_name bfd_mach_o_header_flags_name[] = +{ + { "noundefs", BFD_MACH_O_MH_NOUNDEFS }, + { "incrlink", BFD_MACH_O_MH_INCRLINK }, + { "dyldlink", BFD_MACH_O_MH_DYLDLINK }, + { "bindatload", BFD_MACH_O_MH_BINDATLOAD }, + { "prebound", BFD_MACH_O_MH_PREBOUND }, + { "split_segs", BFD_MACH_O_MH_SPLIT_SEGS }, + { "lazy_init", BFD_MACH_O_MH_LAZY_INIT }, + { "twolevel", BFD_MACH_O_MH_TWOLEVEL }, + { "force_flat", BFD_MACH_O_MH_FORCE_FLAT }, + { "nomultidefs", BFD_MACH_O_MH_NOMULTIDEFS }, + { "nofixprebinding", BFD_MACH_O_MH_NOFIXPREBINDING }, + { "prebindable", BFD_MACH_O_MH_PREBINDABLE }, + { "allmodsbound", BFD_MACH_O_MH_ALLMODSBOUND }, + { "subsections_via_symbols", BFD_MACH_O_MH_SUBSECTIONS_VIA_SYMBOLS }, + { "canonical", BFD_MACH_O_MH_CANONICAL }, + { "weak_defines", BFD_MACH_O_MH_WEAK_DEFINES }, + { "binds_to_weak", BFD_MACH_O_MH_BINDS_TO_WEAK }, + { "allow_stack_execution", BFD_MACH_O_MH_ALLOW_STACK_EXECUTION }, + { "root_safe", BFD_MACH_O_MH_ROOT_SAFE }, + { "setuid_safe", BFD_MACH_O_MH_SETUID_SAFE }, + { "no_reexported_dylibs", BFD_MACH_O_MH_NO_REEXPORTED_DYLIBS }, + { "pie", BFD_MACH_O_MH_PIE }, + { "dead_strippable_dylib", BFD_MACH_O_MH_DEAD_STRIPPABLE_DYLIB }, + { "has_tlv", BFD_MACH_O_MH_HAS_TLV_DESCRIPTORS }, + { "no_heap_execution", BFD_MACH_O_MH_NO_HEAP_EXECUTION }, + { "app_extension_safe", BFD_MACH_O_MH_APP_EXTENSION_SAFE }, + { NULL, 0} +}; + +static const bfd_mach_o_xlat_name bfd_mach_o_load_command_name[] = +{ + { "segment", BFD_MACH_O_LC_SEGMENT}, + { "symtab", BFD_MACH_O_LC_SYMTAB}, + { "symseg", BFD_MACH_O_LC_SYMSEG}, + { "thread", BFD_MACH_O_LC_THREAD}, + { "unixthread", BFD_MACH_O_LC_UNIXTHREAD}, + { "loadfvmlib", BFD_MACH_O_LC_LOADFVMLIB}, + { "idfvmlib", BFD_MACH_O_LC_IDFVMLIB}, + { "ident", BFD_MACH_O_LC_IDENT}, + { "fvmfile", BFD_MACH_O_LC_FVMFILE}, + { "prepage", BFD_MACH_O_LC_PREPAGE}, + { "dysymtab", BFD_MACH_O_LC_DYSYMTAB}, + { "load_dylib", BFD_MACH_O_LC_LOAD_DYLIB}, + { "id_dylib", BFD_MACH_O_LC_ID_DYLIB}, + { "load_dylinker", BFD_MACH_O_LC_LOAD_DYLINKER}, + { "id_dylinker", BFD_MACH_O_LC_ID_DYLINKER}, + { "prebound_dylib", BFD_MACH_O_LC_PREBOUND_DYLIB}, + { "routines", BFD_MACH_O_LC_ROUTINES}, + { "sub_framework", BFD_MACH_O_LC_SUB_FRAMEWORK}, + { "sub_umbrella", BFD_MACH_O_LC_SUB_UMBRELLA}, + { "sub_client", BFD_MACH_O_LC_SUB_CLIENT}, + { "sub_library", BFD_MACH_O_LC_SUB_LIBRARY}, + { "twolevel_hints", BFD_MACH_O_LC_TWOLEVEL_HINTS}, + { "prebind_cksum", BFD_MACH_O_LC_PREBIND_CKSUM}, + { "load_weak_dylib", BFD_MACH_O_LC_LOAD_WEAK_DYLIB}, + { "segment_64", BFD_MACH_O_LC_SEGMENT_64}, + { "routines_64", BFD_MACH_O_LC_ROUTINES_64}, + { "uuid", BFD_MACH_O_LC_UUID}, + { "rpath", BFD_MACH_O_LC_RPATH}, + { "code_signature", BFD_MACH_O_LC_CODE_SIGNATURE}, + { "segment_split_info", BFD_MACH_O_LC_SEGMENT_SPLIT_INFO}, + { "reexport_dylib", BFD_MACH_O_LC_REEXPORT_DYLIB}, + { "lazy_load_dylib", BFD_MACH_O_LC_LAZY_LOAD_DYLIB}, + { "encryption_info", BFD_MACH_O_LC_ENCRYPTION_INFO}, + { "dyld_info", BFD_MACH_O_LC_DYLD_INFO}, + { "load_upward_lib", BFD_MACH_O_LC_LOAD_UPWARD_DYLIB}, + { "version_min_macosx", BFD_MACH_O_LC_VERSION_MIN_MACOSX}, + { "version_min_iphoneos", BFD_MACH_O_LC_VERSION_MIN_IPHONEOS}, + { "function_starts", BFD_MACH_O_LC_FUNCTION_STARTS}, + { "dyld_environment", BFD_MACH_O_LC_DYLD_ENVIRONMENT}, + { "main", BFD_MACH_O_LC_MAIN}, + { "data_in_code", BFD_MACH_O_LC_DATA_IN_CODE}, + { "source_version", BFD_MACH_O_LC_SOURCE_VERSION}, + { "dylib_code_sign_drs", BFD_MACH_O_LC_DYLIB_CODE_SIGN_DRS}, + { "encryption_info_64", BFD_MACH_O_LC_ENCRYPTION_INFO_64}, + { "linker_options", BFD_MACH_O_LC_LINKER_OPTIONS}, + { "linker_optimization_hint", BFD_MACH_O_LC_LINKER_OPTIMIZATION_HINT}, + { NULL, 0} +}; + +static const bfd_mach_o_xlat_name bfd_mach_o_thread_x86_name[] = +{ + { "thread_state32", BFD_MACH_O_x86_THREAD_STATE32}, + { "float_state32", BFD_MACH_O_x86_FLOAT_STATE32}, + { "exception_state32", BFD_MACH_O_x86_EXCEPTION_STATE32}, + { "thread_state64", BFD_MACH_O_x86_THREAD_STATE64}, + { "float_state64", BFD_MACH_O_x86_FLOAT_STATE64}, + { "exception_state64", BFD_MACH_O_x86_EXCEPTION_STATE64}, + { "thread_state", BFD_MACH_O_x86_THREAD_STATE}, + { "float_state", BFD_MACH_O_x86_FLOAT_STATE}, + { "exception_state", BFD_MACH_O_x86_EXCEPTION_STATE}, + { "debug_state32", BFD_MACH_O_x86_DEBUG_STATE32}, + { "debug_state64", BFD_MACH_O_x86_DEBUG_STATE64}, + { "debug_state", BFD_MACH_O_x86_DEBUG_STATE}, + { "state_none", BFD_MACH_O_x86_THREAD_STATE_NONE}, + { NULL, 0 } +}; + +static void +bfd_mach_o_print_flags (const bfd_mach_o_xlat_name *table, + unsigned long val) +{ + int first = 1; + + for (; table->name; table++) + { + if (table->val & val) + { + if (!first) + printf ("+"); + printf ("%s", table->name); + val &= ~table->val; + first = 0; + } + } + if (val) + { + if (!first) + printf ("+"); + printf ("0x%lx", val); + return; + } + if (first) + printf ("-"); +} + +/* Print a bfd_uint64_t, using a platform independent style. */ + +static void +printf_uint64 (bfd_uint64_t v) +{ + printf ("0x%08lx%08lx", + (unsigned long)((v >> 16) >> 16), (unsigned long)(v & 0xffffffffUL)); +} + +static const char * +bfd_mach_o_get_name_or_null (const bfd_mach_o_xlat_name *table, + unsigned long val) +{ + for (; table->name; table++) + if (table->val == val) + return table->name; + return NULL; +} + +static const char * +bfd_mach_o_get_name (const bfd_mach_o_xlat_name *table, unsigned long val) +{ + const char *res = bfd_mach_o_get_name_or_null (table, val); + + if (res == NULL) + return "*UNKNOWN*"; + else + return res; +} + +static void +dump_header (bfd *abfd) +{ + bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd); + bfd_mach_o_header *h = &mdata->header; + + fputs (_("Mach-O header:\n"), stdout); + printf (_(" magic : %08lx\n"), h->magic); + printf (_(" cputype : %08lx (%s)\n"), h->cputype, + bfd_mach_o_get_name (bfd_mach_o_cpu_name, h->cputype)); + printf (_(" cpusubtype: %08lx\n"), h->cpusubtype); + printf (_(" filetype : %08lx (%s)\n"), + h->filetype, + bfd_mach_o_get_name (bfd_mach_o_filetype_name, h->filetype)); + printf (_(" ncmds : %08lx (%lu)\n"), h->ncmds, h->ncmds); + printf (_(" sizeofcmds: %08lx (%lu)\n"), h->sizeofcmds, h->sizeofcmds); + printf (_(" flags : %08lx ("), h->flags); + bfd_mach_o_print_flags (bfd_mach_o_header_flags_name, h->flags); + fputs (_(")\n"), stdout); + printf (_(" reserved : %08x\n"), h->reserved); + putchar ('\n'); +} + +static void +disp_segment_prot (unsigned int prot) +{ + putchar (prot & BFD_MACH_O_PROT_READ ? 'r' : '-'); + putchar (prot & BFD_MACH_O_PROT_WRITE ? 'w' : '-'); + putchar (prot & BFD_MACH_O_PROT_EXECUTE ? 'x' : '-'); +} + +static void +dump_section_map (bfd *abfd) +{ + bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd); + bfd_mach_o_load_command *cmd; + unsigned int sec_nbr = 0; + + fputs (_("Segments and Sections:\n"), stdout); + fputs (_(" #: Segment name Section name Address\n"), stdout); + + for (cmd = mdata->first_command; cmd != NULL; cmd = cmd->next) + { + bfd_mach_o_segment_command *seg; + bfd_mach_o_section *sec; + + if (cmd->type != BFD_MACH_O_LC_SEGMENT + && cmd->type != BFD_MACH_O_LC_SEGMENT_64) + continue; + + seg = &cmd->command.segment; + + printf ("[Segment %-16s ", seg->segname); + printf_vma (seg->vmaddr); + putchar ('-'); + printf_vma (seg->vmaddr + seg->vmsize - 1); + putchar (' '); + disp_segment_prot (seg->initprot); + printf ("]\n"); + + for (sec = seg->sect_head; sec != NULL; sec = sec->next) + { + printf ("%02u: %-16s %-16s ", ++sec_nbr, + sec->segname, sec->sectname); + printf_vma (sec->addr); + putchar (' '); + printf_vma (sec->size); + printf (" %08lx\n", sec->flags); + } + } +} + +static void +dump_section_header (bfd *abfd ATTRIBUTE_UNUSED, bfd_mach_o_section *sec) +{ + printf (" Section: %-16s %-16s (bfdname: %s)\n", + sec->sectname, sec->segname, sec->bfdsection->name); + printf (" addr: "); + printf_vma (sec->addr); + printf (" size: "); + printf_vma (sec->size); + printf (" offset: "); + printf_vma (sec->offset); + printf ("\n"); + printf (" align: %ld", sec->align); + printf (" nreloc: %lu reloff: ", sec->nreloc); + printf_vma (sec->reloff); + printf ("\n"); + printf (" flags: %08lx (type: %s", sec->flags, + bfd_mach_o_get_name (bfd_mach_o_section_type_name, + sec->flags & BFD_MACH_O_SECTION_TYPE_MASK)); + printf (" attr: "); + bfd_mach_o_print_flags (bfd_mach_o_section_attribute_name, + sec->flags & BFD_MACH_O_SECTION_ATTRIBUTES_MASK); + printf (")\n"); + switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK) + { + case BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS: + case BFD_MACH_O_S_LAZY_SYMBOL_POINTERS: + case BFD_MACH_O_S_SYMBOL_STUBS: + printf (" first indirect sym: %lu", sec->reserved1); + printf (" (%u entries)", + bfd_mach_o_section_get_nbr_indirect (abfd, sec)); + break; + default: + printf (" reserved1: 0x%lx", sec->reserved1); + break; + } + switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK) + { + case BFD_MACH_O_S_SYMBOL_STUBS: + printf (" stub size: %lu", sec->reserved2); + break; + default: + printf (" reserved2: 0x%lx", sec->reserved2); + break; + } + printf (" reserved3: 0x%lx\n", sec->reserved3); +} + +static void +dump_segment (bfd *abfd ATTRIBUTE_UNUSED, bfd_mach_o_load_command *cmd) +{ + bfd_mach_o_segment_command *seg = &cmd->command.segment; + bfd_mach_o_section *sec; + + printf (" name: %16s", *seg->segname ? seg->segname : "*none*"); + printf (" nsects: %lu", seg->nsects); + printf (" flags: %lx", seg->flags); + printf (" initprot: "); + disp_segment_prot (seg->initprot); + printf (" maxprot: "); + disp_segment_prot (seg->maxprot); + printf ("\n"); + printf (" vmaddr: "); + printf_vma (seg->vmaddr); + printf (" vmsize: "); + printf_vma (seg->vmsize); + printf ("\n"); + printf (" fileoff: "); + printf_vma (seg->fileoff); + printf (" filesize: "); + printf_vma ((bfd_vma)seg->filesize); + printf (" endoff: "); + printf_vma ((bfd_vma)(seg->fileoff + seg->filesize)); + printf ("\n"); + for (sec = seg->sect_head; sec != NULL; sec = sec->next) + dump_section_header (abfd, sec); +} + +static void +dump_dysymtab (bfd *abfd, bfd_mach_o_load_command *cmd, bfd_boolean verbose) +{ + bfd_mach_o_dysymtab_command *dysymtab = &cmd->command.dysymtab; + bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd); + unsigned int i; + + printf (" local symbols: idx: %10lu num: %-8lu", + dysymtab->ilocalsym, dysymtab->nlocalsym); + printf (" (nxtidx: %lu)\n", + dysymtab->ilocalsym + dysymtab->nlocalsym); + printf (" external symbols: idx: %10lu num: %-8lu", + dysymtab->iextdefsym, dysymtab->nextdefsym); + printf (" (nxtidx: %lu)\n", + dysymtab->iextdefsym + dysymtab->nextdefsym); + printf (" undefined symbols: idx: %10lu num: %-8lu", + dysymtab->iundefsym, dysymtab->nundefsym); + printf (" (nxtidx: %lu)\n", + dysymtab->iundefsym + dysymtab->nundefsym); + printf (" table of content: off: 0x%08lx num: %-8lu", + dysymtab->tocoff, dysymtab->ntoc); + printf (" (endoff: 0x%08lx)\n", + dysymtab->tocoff + dysymtab->ntoc * BFD_MACH_O_TABLE_OF_CONTENT_SIZE); + printf (" module table: off: 0x%08lx num: %-8lu", + dysymtab->modtaboff, dysymtab->nmodtab); + printf (" (endoff: 0x%08lx)\n", + dysymtab->modtaboff + dysymtab->nmodtab + * (mdata->header.version == 2 ? + BFD_MACH_O_DYLIB_MODULE_64_SIZE : BFD_MACH_O_DYLIB_MODULE_SIZE)); + printf (" external reference table: off: 0x%08lx num: %-8lu", + dysymtab->extrefsymoff, dysymtab->nextrefsyms); + printf (" (endoff: 0x%08lx)\n", + dysymtab->extrefsymoff + + dysymtab->nextrefsyms * BFD_MACH_O_REFERENCE_SIZE); + printf (" indirect symbol table: off: 0x%08lx num: %-8lu", + dysymtab->indirectsymoff, dysymtab->nindirectsyms); + printf (" (endoff: 0x%08lx)\n", + dysymtab->indirectsymoff + + dysymtab->nindirectsyms * BFD_MACH_O_INDIRECT_SYMBOL_SIZE); + printf (" external relocation table: off: 0x%08lx num: %-8lu", + dysymtab->extreloff, dysymtab->nextrel); + printf (" (endoff: 0x%08lx)\n", + dysymtab->extreloff + dysymtab->nextrel * BFD_MACH_O_RELENT_SIZE); + printf (" local relocation table: off: 0x%08lx num: %-8lu", + dysymtab->locreloff, dysymtab->nlocrel); + printf (" (endoff: 0x%08lx)\n", + dysymtab->locreloff + dysymtab->nlocrel * BFD_MACH_O_RELENT_SIZE); + + if (!verbose) + return; + + if (dysymtab->ntoc > 0 + || dysymtab->nindirectsyms > 0 + || dysymtab->nextrefsyms > 0) + { + /* Try to read the symbols to display the toc or indirect symbols. */ + bfd_mach_o_read_symtab_symbols (abfd); + } + else if (dysymtab->nmodtab > 0) + { + /* Try to read the strtab to display modules name. */ + bfd_mach_o_read_symtab_strtab (abfd); + } + + for (i = 0; i < dysymtab->nmodtab; i++) + { + bfd_mach_o_dylib_module *module = &dysymtab->dylib_module[i]; + printf (" module %u:\n", i); + printf (" name: %lu", module->module_name_idx); + if (mdata->symtab && mdata->symtab->strtab) + printf (": %s", + mdata->symtab->strtab + module->module_name_idx); + printf ("\n"); + printf (" extdefsym: idx: %8lu num: %lu\n", + module->iextdefsym, module->nextdefsym); + printf (" refsym: idx: %8lu num: %lu\n", + module->irefsym, module->nrefsym); + printf (" localsym: idx: %8lu num: %lu\n", + module->ilocalsym, module->nlocalsym); + printf (" extrel: idx: %8lu num: %lu\n", + module->iextrel, module->nextrel); + printf (" init: idx: %8u num: %u\n", + module->iinit, module->ninit); + printf (" term: idx: %8u num: %u\n", + module->iterm, module->nterm); + printf (" objc_module_info: addr: "); + printf_vma (module->objc_module_info_addr); + printf (" size: %lu\n", module->objc_module_info_size); + } + + if (dysymtab->ntoc > 0) + { + bfd_mach_o_symtab_command *symtab = mdata->symtab; + + printf (" table of content: (symbol/module)\n"); + for (i = 0; i < dysymtab->ntoc; i++) + { + bfd_mach_o_dylib_table_of_content *toc = &dysymtab->dylib_toc[i]; + + printf (" %4u: ", i); + if (symtab && symtab->symbols && toc->symbol_index < symtab->nsyms) + { + const char *name = symtab->symbols[toc->symbol_index].symbol.name; + printf ("%s (%lu)", name ? name : "*invalid*", + toc->symbol_index); + } + else + printf ("%lu", toc->symbol_index); + + printf (" / "); + if (symtab && symtab->strtab + && toc->module_index < dysymtab->nmodtab) + { + bfd_mach_o_dylib_module *mod; + mod = &dysymtab->dylib_module[toc->module_index]; + printf ("%s (%lu)", + symtab->strtab + mod->module_name_idx, + toc->module_index); + } + else + printf ("%lu", toc->module_index); + + printf ("\n"); + } + } + + if (dysymtab->nindirectsyms != 0) + { + printf (" indirect symbols:\n"); + + for (i = 0; i < mdata->nsects; i++) + { + bfd_mach_o_section *sec = mdata->sections[i]; + unsigned int j, first, last; + bfd_mach_o_symtab_command *symtab = mdata->symtab; + bfd_vma addr; + bfd_vma entry_size; + + switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK) + { + case BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS: + case BFD_MACH_O_S_LAZY_SYMBOL_POINTERS: + case BFD_MACH_O_S_SYMBOL_STUBS: + first = sec->reserved1; + last = first + bfd_mach_o_section_get_nbr_indirect (abfd, sec); + addr = sec->addr; + entry_size = bfd_mach_o_section_get_entry_size (abfd, sec); + printf (" for section %s.%s:\n", + sec->segname, sec->sectname); + for (j = first; j < last; j++) + { + unsigned int isym = dysymtab->indirect_syms[j]; + + printf (" "); + printf_vma (addr); + printf (" %5u: 0x%08x", j, isym); + if (isym & BFD_MACH_O_INDIRECT_SYMBOL_LOCAL) + printf (" LOCAL"); + if (isym & BFD_MACH_O_INDIRECT_SYMBOL_ABS) + printf (" ABSOLUTE"); + if (symtab && symtab->symbols + && isym < symtab->nsyms + && symtab->symbols[isym].symbol.name) + printf (" %s", symtab->symbols[isym].symbol.name); + printf ("\n"); + addr += entry_size; + } + break; + default: + break; + } + } + } + if (dysymtab->nextrefsyms > 0) + { + bfd_mach_o_symtab_command *symtab = mdata->symtab; + + printf (" external reference table: (symbol flags)\n"); + for (i = 0; i < dysymtab->nextrefsyms; i++) + { + bfd_mach_o_dylib_reference *ref = &dysymtab->ext_refs[i]; + + printf (" %4u: %5lu 0x%02lx", i, ref->isym, ref->flags); + if (symtab && symtab->symbols + && ref->isym < symtab->nsyms + && symtab->symbols[ref->isym].symbol.name) + printf (" %s", symtab->symbols[ref->isym].symbol.name); + printf ("\n"); + } + } + +} + +static bfd_boolean +load_and_dump (bfd *abfd, ufile_ptr off, unsigned int len, + void (*dump)(bfd *abfd, unsigned char *buf, unsigned int len, + ufile_ptr off)) +{ + unsigned char *buf; + + if (len == 0) + return TRUE; + + buf = xmalloc (len); + + if (bfd_seek (abfd, off, SEEK_SET) == 0 + && bfd_bread (buf, len, abfd) == len) + dump (abfd, buf, len, off); + else + return FALSE; + + free (buf); + return TRUE; +} + +static const bfd_mach_o_xlat_name bfd_mach_o_dyld_rebase_type_name[] = +{ + { "pointer", BFD_MACH_O_REBASE_TYPE_POINTER }, + { "text_abs32", BFD_MACH_O_REBASE_TYPE_TEXT_ABSOLUTE32 }, + { "text_pcrel32", BFD_MACH_O_REBASE_TYPE_TEXT_PCREL32 }, + { NULL, 0 } +}; + +static void +dump_dyld_info_rebase (bfd *abfd, unsigned char *buf, unsigned int len, + ufile_ptr off ATTRIBUTE_UNUSED) +{ + unsigned int i; + bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd); + unsigned int ptrsize = mdata->header.version == 2 ? 8 : 4; + + for (i = 0; i < len; ) + { + unsigned char b = buf[i++]; + unsigned char imm = b & BFD_MACH_O_REBASE_IMMEDIATE_MASK; + bfd_vma leb; + unsigned int leblen; + + printf (" [0x%04x] 0x%02x: ", i, b); + switch (b & BFD_MACH_O_REBASE_OPCODE_MASK) + { + case BFD_MACH_O_REBASE_OPCODE_DONE: + printf ("done\n"); + return; + case BFD_MACH_O_REBASE_OPCODE_SET_TYPE_IMM: + printf ("set_type %s\n", + bfd_mach_o_get_name (bfd_mach_o_dyld_rebase_type_name, imm)); + break; + case BFD_MACH_O_REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: + leb = read_leb128 (buf + i, &leblen, 0, buf + len); + printf ("set segment: %u and offset: 0x%08x\n", + imm, (unsigned) leb); + i += leblen; + break; + case BFD_MACH_O_REBASE_OPCODE_ADD_ADDR_ULEB: + leb = read_leb128 (buf + i, &leblen, 0, buf + len); + printf ("add addr uleb: 0x%08x\n", (unsigned) leb); + i += leblen; + break; + case BFD_MACH_O_REBASE_OPCODE_ADD_ADDR_IMM_SCALED: + printf ("add addr imm scaled: %u\n", imm * ptrsize); + break; + case BFD_MACH_O_REBASE_OPCODE_DO_REBASE_IMM_TIMES: + printf ("rebase imm times: %u\n", imm); + break; + case BFD_MACH_O_REBASE_OPCODE_DO_REBASE_ULEB_TIMES: + leb = read_leb128 (buf + i, &leblen, 0, buf + len); + printf ("rebase uleb times: %u\n", (unsigned) leb); + i += leblen; + break; + case BFD_MACH_O_REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB: + leb = read_leb128 (buf + i, &leblen, 0, buf + len); + printf ("rebase add addr uleb: %u\n", (unsigned) leb); + i += leblen; + break; + case BFD_MACH_O_REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB: + leb = read_leb128 (buf + i, &leblen, 0, buf + len); + printf ("rebase uleb times (%u)", (unsigned) leb); + i += leblen; + leb = read_leb128 (buf + i, &leblen, 0, buf + len); + printf (" skipping uleb (%u)\n", (unsigned) leb); + i += leblen; + break; + default: + printf ("unknown\n"); + return; + } + } + printf (" rebase commands without end!\n"); +} + +static void +dump_dyld_info_bind (bfd *abfd, unsigned char *buf, unsigned int len, + ufile_ptr off ATTRIBUTE_UNUSED) +{ + unsigned int i; + bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd); + unsigned int ptrsize = mdata->header.version == 2 ? 8 : 4; + + for (i = 0; i < len; ) + { + unsigned char b = buf[i++]; + unsigned char imm = b & BFD_MACH_O_BIND_IMMEDIATE_MASK; + bfd_vma leb; + unsigned int leblen; + + printf (" [0x%04x] 0x%02x: ", i, b); + switch (b & BFD_MACH_O_BIND_OPCODE_MASK) + { + case BFD_MACH_O_BIND_OPCODE_DONE: + printf ("done\n"); + return; + case BFD_MACH_O_BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: + printf ("set dylib ordinal imm: %u\n", imm); + break; + case BFD_MACH_O_BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: + leb = read_leb128 (buf + i, &leblen, 0, buf + len); + printf ("set dylib ordinal uleb: %u\n", imm); + i += leblen; + break; + case BFD_MACH_O_BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: + imm = (imm != 0) ? imm | BFD_MACH_O_BIND_OPCODE_MASK : imm; + printf ("set dylib special imm: %d\n", imm); + break; + case BFD_MACH_O_BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: + printf ("set symbol trailing flags imm: 0x%02x, ", imm); + for (; i < len && buf[i] != 0; i++) + putchar (buf[i] >= ' ' && buf[i] < 0x7f ? buf[i] : '?'); + putchar ('\n'); + i++; + break; + case BFD_MACH_O_BIND_OPCODE_SET_TYPE_IMM: + /* Kludge: use the same table as rebase type. */ + printf ("set_type %s\n", + bfd_mach_o_get_name (bfd_mach_o_dyld_rebase_type_name, imm)); + break; + case BFD_MACH_O_BIND_OPCODE_SET_ADDEND_SLEB: + { + bfd_signed_vma svma; + svma = read_leb128 (buf + i, &leblen, 0, buf + len); + printf ("set addend sleb: 0x%08x\n", (unsigned) svma); + i += leblen; + } + break; + case BFD_MACH_O_BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: + leb = read_leb128 (buf + i, &leblen, 0, buf + len); + printf ("set segment: %u and offset: 0x%08x\n", + imm, (unsigned) leb); + i += leblen; + break; + case BFD_MACH_O_BIND_OPCODE_ADD_ADDR_ULEB: + leb = read_leb128 (buf + i, &leblen, 0, buf + len); + printf ("add addr uleb: 0x%08x\n", (unsigned) leb); + i += leblen; + break; + case BFD_MACH_O_BIND_OPCODE_DO_BIND: + printf ("do bind\n"); + break; + case BFD_MACH_O_BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: + leb = read_leb128 (buf + i, &leblen, 0, buf + len); + printf ("do bind add addr uleb: 0x%08x\n", (unsigned) leb); + i += leblen; + break; + case BFD_MACH_O_BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: + printf ("do bind add addr imm scaled: %u\n", imm * ptrsize); + break; + case BFD_MACH_O_BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: + leb = read_leb128 (buf + i, &leblen, 0, buf + len); + printf ("do bind uleb times (%u)", (unsigned) leb); + i += leblen; + leb = read_leb128 (buf + i, &leblen, 0, buf + len); + printf (" skipping uleb (%u)\n", (unsigned) leb); + i += leblen; + break; + default: + printf ("unknown\n"); + return; + } + } + printf (" bind commands without end!\n"); +} + +struct export_info_data +{ + const unsigned char *name; + struct export_info_data *next; +}; + +static void +dump_dyld_info_export_1 (bfd *abfd, unsigned char *buf, unsigned int len, + unsigned int off, struct export_info_data *parent, + struct export_info_data *base) +{ + bfd_vma size; + unsigned int leblen; + unsigned int child_count; + unsigned int i; + + size = read_leb128 (buf + off, &leblen, 0, buf + len); + off += leblen; + + if (size != 0) + { + bfd_vma flags; + struct export_info_data *d; + + flags = read_leb128 (buf + off, &leblen, 0, buf + len); + off += leblen; + + fputs (" ", stdout); + switch (flags & BFD_MACH_O_EXPORT_SYMBOL_FLAGS_KIND_MASK) + { + case BFD_MACH_O_EXPORT_SYMBOL_FLAGS_KIND_REGULAR: + putchar ('-'); + break; + case BFD_MACH_O_EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL: + putchar ('T'); + break; + default: + putchar ('?'); + break; + } + putchar ((flags & BFD_MACH_O_EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION) ? + 'W' : '-'); + + if (flags & BFD_MACH_O_EXPORT_SYMBOL_FLAGS_REEXPORT) + { + bfd_vma lib; + + lib = read_leb128 (buf + off, &leblen, 0, buf + len); + off += leblen; + + fputs (" [reexport] ", stdout); + for (d = base; d != NULL; d = d->next) + printf ("%s", d->name); + + fputs (" (", stdout); + if (buf[off] != 0) + { + fputs ((const char *)buf + off, stdout); + putchar (' '); + off += strlen ((const char *)buf + off); + } + printf ("from dylib %u)\n", (unsigned) lib); + off++; + } + else + { + bfd_vma offset; + bfd_vma resolv = 0; + + offset = read_leb128 (buf + off, &leblen, 0, buf + len); + off += leblen; + + if (flags & BFD_MACH_O_EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER) + { + resolv = read_leb128 (buf + off, &leblen, 0, buf + len); + off += leblen; + } + + printf (" 0x%08x ", (unsigned) offset); + for (d = base; d != NULL; d = d->next) + printf ("%s", d->name); + if (flags & BFD_MACH_O_EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER) + printf (" [resolv: 0x%08x]", (unsigned) resolv); + printf ("\n"); + } + } + + child_count = read_leb128 (buf + off, &leblen, 0, buf + len); + off += leblen; + + for (i = 0; i < child_count; i++) + { + struct export_info_data sub_data; + bfd_vma sub_off; + + sub_data.name = buf + off; + sub_data.next = NULL; + parent->next = &sub_data; + + off += strlen ((const char *)buf + off) + 1; + + sub_off = read_leb128 (buf + off, &leblen, 0, buf + len); + off += leblen; + + dump_dyld_info_export_1 (abfd, buf, len, sub_off, &sub_data, base); + } +} + +static void +dump_dyld_info_export (bfd *abfd, unsigned char *buf, unsigned int len, + ufile_ptr off ATTRIBUTE_UNUSED) +{ + struct export_info_data data; + + data.name = (const unsigned char *) ""; + data.next = NULL; + + printf (" fl offset sym (Flags: Tls Weak)\n"); + dump_dyld_info_export_1 (abfd, buf, len, 0, &data, &data); +} + +static void +dump_dyld_info (bfd *abfd, bfd_mach_o_load_command *cmd, + bfd_boolean verbose) +{ + bfd_mach_o_dyld_info_command *dinfo = &cmd->command.dyld_info; + + printf (" rebase: off: 0x%08x size: %-8u (endoff: 0x%08x)\n", + dinfo->rebase_off, dinfo->rebase_size, + dinfo->rebase_off + dinfo->rebase_size); + printf (" bind: off: 0x%08x size: %-8u (endoff: 0x%08x)\n", + dinfo->bind_off, dinfo->bind_size, + dinfo->bind_off + dinfo->bind_size); + printf (" weak bind: off: 0x%08x size: %-8u (endoff: 0x%08x)\n", + dinfo->weak_bind_off, dinfo->weak_bind_size, + dinfo->weak_bind_off + dinfo->weak_bind_size); + printf (" lazy bind: off: 0x%08x size: %-8u (endoff: 0x%08x)\n", + dinfo->lazy_bind_off, dinfo->lazy_bind_size, + dinfo->lazy_bind_off + dinfo->lazy_bind_size); + printf (" export: off: 0x%08x size: %-8u (endoff: 0x%08x)\n", + dinfo->export_off, dinfo->export_size, + dinfo->export_off + dinfo->export_size); + + if (!verbose) + return; + + printf (" rebase:\n"); + if (!load_and_dump (abfd, dinfo->rebase_off, dinfo->rebase_size, + dump_dyld_info_rebase)) + non_fatal (_("cannot read rebase dyld info")); + + printf (" bind:\n"); + if (!load_and_dump (abfd, dinfo->bind_off, dinfo->bind_size, + dump_dyld_info_bind)) + non_fatal (_("cannot read bind dyld info")); + + printf (" weak bind:\n"); + if (!load_and_dump (abfd, dinfo->weak_bind_off, dinfo->weak_bind_size, + dump_dyld_info_bind)) + non_fatal (_("cannot read weak bind dyld info")); + + printf (" lazy bind:\n"); + if (!load_and_dump (abfd, dinfo->lazy_bind_off, dinfo->lazy_bind_size, + dump_dyld_info_bind)) + non_fatal (_("cannot read lazy bind dyld info")); + + printf (" exported symbols:\n"); + if (!load_and_dump (abfd, dinfo->export_off, dinfo->export_size, + dump_dyld_info_export)) + non_fatal (_("cannot read export symbols dyld info")); +} + +static void +dump_thread (bfd *abfd, bfd_mach_o_load_command *cmd) +{ + bfd_mach_o_thread_command *thread = &cmd->command.thread; + unsigned int j; + bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd); + bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd); + + printf (" nflavours: %lu\n", thread->nflavours); + for (j = 0; j < thread->nflavours; j++) + { + bfd_mach_o_thread_flavour *flavour = &thread->flavours[j]; + const bfd_mach_o_xlat_name *name_table; + + printf (" %2u: flavour: 0x%08lx", j, flavour->flavour); + switch (mdata->header.cputype) + { + case BFD_MACH_O_CPU_TYPE_I386: + case BFD_MACH_O_CPU_TYPE_X86_64: + name_table = bfd_mach_o_thread_x86_name; + break; + default: + name_table = NULL; + break; + } + if (name_table != NULL) + printf (": %s", bfd_mach_o_get_name (name_table, flavour->flavour)); + putchar ('\n'); + + printf (" offset: 0x%08lx size: 0x%08lx\n", + flavour->offset, flavour->size); + if (bed->_bfd_mach_o_print_thread) + { + char *buf = xmalloc (flavour->size); + + if (bfd_seek (abfd, flavour->offset, SEEK_SET) == 0 + && bfd_bread (buf, flavour->size, abfd) == flavour->size) + (*bed->_bfd_mach_o_print_thread)(abfd, flavour, stdout, buf); + + free (buf); + } + } +} + +static const bfd_mach_o_xlat_name bfd_mach_o_cs_magic[] = +{ + { "embedded signature", BFD_MACH_O_CS_MAGIC_EMBEDDED_SIGNATURE }, + { "requirement", BFD_MACH_O_CS_MAGIC_REQUIREMENT }, + { "requirements", BFD_MACH_O_CS_MAGIC_REQUIREMENTS }, + { "code directory", BFD_MACH_O_CS_MAGIC_CODEDIRECTORY }, + { "embedded entitlements", BFD_MACH_O_CS_MAGIC_EMBEDDED_ENTITLEMENTS }, + { "blob wrapper", BFD_MACH_O_CS_MAGIC_BLOB_WRAPPER }, + { NULL, 0 } +}; + +static const bfd_mach_o_xlat_name bfd_mach_o_cs_hash_type[] = +{ + { "no-hash", BFD_MACH_O_CS_NO_HASH }, + { "sha1", BFD_MACH_O_CS_HASH_SHA1 }, + { "sha256", BFD_MACH_O_CS_HASH_SHA256 }, + { "skein 160", BFD_MACH_O_CS_HASH_PRESTANDARD_SKEIN_160x256 }, + { "skein 256", BFD_MACH_O_CS_HASH_PRESTANDARD_SKEIN_256x512 }, + { NULL, 0 } +}; + +static unsigned int +dump_code_signature_blob (bfd *abfd, const unsigned char *buf, unsigned int len); + +static void +dump_code_signature_superblob (bfd *abfd ATTRIBUTE_UNUSED, + const unsigned char *buf, unsigned int len) +{ + unsigned int count; + unsigned int i; + + if (len < 12) + { + printf (_(" [bad block length]\n")); + return; + } + count = bfd_getb32 (buf + 8); + printf (ngettext (" %u index entry:\n", + " %u index entries:\n", + count), + count); + if (len < 12 + 8 * count) + { + printf (_(" [bad block length]\n")); + return; + } + for (i = 0; i < count; i++) + { + unsigned int type; + unsigned int off; + + type = bfd_getb32 (buf + 12 + 8 * i); + off = bfd_getb32 (buf + 12 + 8 * i + 4); + printf (_(" index entry %u: type: %08x, offset: %08x\n"), + i, type, off); + + dump_code_signature_blob (abfd, buf + off, len - off); + } +} + +static void +swap_code_codedirectory_v1_in + (const struct mach_o_codesign_codedirectory_external_v1 *src, + struct mach_o_codesign_codedirectory_v1 *dst) +{ + dst->version = bfd_getb32 (src->version); + dst->flags = bfd_getb32 (src->flags); + dst->hash_offset = bfd_getb32 (src->hash_offset); + dst->ident_offset = bfd_getb32 (src->ident_offset); + dst->nbr_special_slots = bfd_getb32 (src->nbr_special_slots); + dst->nbr_code_slots = bfd_getb32 (src->nbr_code_slots); + dst->code_limit = bfd_getb32 (src->code_limit); + dst->hash_size = src->hash_size[0]; + dst->hash_type = src->hash_type[0]; + dst->spare1 = src->spare1[0]; + dst->page_size = src->page_size[0]; + dst->spare2 = bfd_getb32 (src->spare2); +} + +static void +hexdump (unsigned int start, unsigned int len, + const unsigned char *buf) +{ + unsigned int i, j; + + for (i = 0; i < len; i += 16) + { + printf ("%08x:", start + i); + for (j = 0; j < 16; j++) + { + fputc (j == 8 ? '-' : ' ', stdout); + if (i + j < len) + printf ("%02x", buf[i + j]); + else + fputs (" ", stdout); + } + fputc (' ', stdout); + for (j = 0; j < 16; j++) + { + if (i + j < len) + fputc (ISPRINT (buf[i + j]) ? buf[i + j] : '.', stdout); + else + fputc (' ', stdout); + } + fputc ('\n', stdout); + } +} + +static void +dump_code_signature_codedirectory (bfd *abfd ATTRIBUTE_UNUSED, + const unsigned char *buf, unsigned int len) +{ + struct mach_o_codesign_codedirectory_v1 cd; + const char *id; + + if (len < sizeof (struct mach_o_codesign_codedirectory_external_v1)) + { + printf (_(" [bad block length]\n")); + return; + } + + swap_code_codedirectory_v1_in + ((const struct mach_o_codesign_codedirectory_external_v1 *) (buf + 8), &cd); + + printf (_(" version: %08x\n"), cd.version); + printf (_(" flags: %08x\n"), cd.flags); + printf (_(" hash offset: %08x\n"), cd.hash_offset); + id = (const char *) buf + cd.ident_offset; + printf (_(" ident offset: %08x (- %08x)\n"), + cd.ident_offset, cd.ident_offset + (unsigned) strlen (id) + 1); + printf (_(" identity: %s\n"), id); + printf (_(" nbr special slots: %08x (at offset %08x)\n"), + cd.nbr_special_slots, + cd.hash_offset - cd.nbr_special_slots * cd.hash_size); + printf (_(" nbr code slots: %08x\n"), cd.nbr_code_slots); + printf (_(" code limit: %08x\n"), cd.code_limit); + printf (_(" hash size: %02x\n"), cd.hash_size); + printf (_(" hash type: %02x (%s)\n"), + cd.hash_type, + bfd_mach_o_get_name (bfd_mach_o_cs_hash_type, cd.hash_type)); + printf (_(" spare1: %02x\n"), cd.spare1); + printf (_(" page size: %02x\n"), cd.page_size); + printf (_(" spare2: %08x\n"), cd.spare2); + if (cd.version >= 0x20100) + printf (_(" scatter offset: %08x\n"), + (unsigned) bfd_getb32 (buf + 44)); +} + +static unsigned int +dump_code_signature_blob (bfd *abfd, const unsigned char *buf, unsigned int len) +{ + unsigned int magic; + unsigned int length; + + if (len < 8) + { + printf (_(" [truncated block]\n")); + return 0; + } + magic = bfd_getb32 (buf); + length = bfd_getb32 (buf + 4); + if (magic == 0 || length == 0) + return 0; + + printf (_(" magic : %08x (%s)\n"), magic, + bfd_mach_o_get_name (bfd_mach_o_cs_magic, magic)); + printf (_(" length: %08x\n"), length); + if (length > len) + { + printf (_(" [bad block length]\n")); + return 0; + } + + switch (magic) + { + case BFD_MACH_O_CS_MAGIC_EMBEDDED_SIGNATURE: + dump_code_signature_superblob (abfd, buf, length); + break; + case BFD_MACH_O_CS_MAGIC_CODEDIRECTORY: + dump_code_signature_codedirectory (abfd, buf, length); + break; + default: + hexdump (0, length - 8, buf + 8); + break; + } + return length; +} + +static void +dump_code_signature (bfd *abfd, bfd_mach_o_linkedit_command *cmd) +{ + unsigned char *buf = xmalloc (cmd->datasize); + unsigned int off; + + if (bfd_seek (abfd, cmd->dataoff, SEEK_SET) != 0 + || bfd_bread (buf, cmd->datasize, abfd) != cmd->datasize) + { + non_fatal (_("cannot read code signature data")); + free (buf); + return; + } + for (off = 0; off < cmd->datasize;) + { + unsigned int len; + + len = dump_code_signature_blob (abfd, buf + off, cmd->datasize - off); + + if (len == 0) + break; + off += len; + } + free (buf); +} + +static void +dump_segment_split_info (bfd *abfd, bfd_mach_o_linkedit_command *cmd) +{ + unsigned char *buf = xmalloc (cmd->datasize); + unsigned char *p; + unsigned int len; + bfd_vma addr = 0; + + if (bfd_seek (abfd, cmd->dataoff, SEEK_SET) != 0 + || bfd_bread (buf, cmd->datasize, abfd) != cmd->datasize) + { + non_fatal (_("cannot read segment split info")); + free (buf); + return; + } + if (buf[cmd->datasize - 1] != 0) + { + non_fatal (_("segment split info is not nul terminated")); + free (buf); + return; + } + + switch (buf[0]) + { + case 0: + printf (_(" 32 bit pointers:\n")); + break; + case 1: + printf (_(" 64 bit pointers:\n")); + break; + case 2: + printf (_(" PPC hi-16:\n")); + break; + default: + printf (_(" Unhandled location type %u\n"), buf[0]); + break; + } + for (p = buf + 1; *p != 0; p += len) + { + addr += read_leb128 (p, &len, 0, buf + cmd->datasize); + fputs (" ", stdout); + bfd_printf_vma (abfd, addr); + putchar ('\n'); + } + free (buf); +} + +static void +dump_function_starts (bfd *abfd, bfd_mach_o_linkedit_command *cmd) +{ + unsigned char *buf = xmalloc (cmd->datasize); + unsigned char *end_buf = buf + cmd->datasize; + unsigned char *p; + bfd_vma addr; + + if (bfd_seek (abfd, cmd->dataoff, SEEK_SET) != 0 + || bfd_bread (buf, cmd->datasize, abfd) != cmd->datasize) + { + non_fatal (_("cannot read function starts")); + free (buf); + return; + } + + /* Function starts are delta encoded, starting from the base address. */ + addr = bfd_mach_o_get_base_address (abfd); + + for (p = buf; ;) + { + bfd_vma delta = 0; + unsigned int shift = 0; + + if (*p == 0 || p == end_buf) + break; + while (1) + { + unsigned char b = *p++; + + delta |= (b & 0x7f) << shift; + if ((b & 0x80) == 0) + break; + if (p == end_buf) + { + fputs (" [truncated]\n", stdout); + break; + } + shift += 7; + } + + addr += delta; + fputs (" ", stdout); + bfd_printf_vma (abfd, addr); + putchar ('\n'); + } + free (buf); +} + +static const bfd_mach_o_xlat_name data_in_code_kind_name[] = +{ + { "data", BFD_MACH_O_DICE_KIND_DATA }, + { "1 byte jump table", BFD_MACH_O_DICE_JUMP_TABLES8 }, + { "2 bytes jump table", BFD_MACH_O_DICE_JUMP_TABLES16 }, + { "4 bytes jump table", BFD_MACH_O_DICE_JUMP_TABLES32 }, + { "4 bytes abs jump table", BFD_MACH_O_DICE_ABS_JUMP_TABLES32 }, + { NULL, 0 } +}; + +static void +dump_data_in_code (bfd *abfd, bfd_mach_o_linkedit_command *cmd) +{ + unsigned char *buf; + unsigned char *p; + + if (cmd->datasize == 0) + { + printf (" no data_in_code entries\n"); + return; + } + + buf = xmalloc (cmd->datasize); + if (bfd_seek (abfd, cmd->dataoff, SEEK_SET) != 0 + || bfd_bread (buf, cmd->datasize, abfd) != cmd->datasize) + { + non_fatal (_("cannot read data_in_code")); + free (buf); + return; + } + + printf (" offset length kind\n"); + for (p = buf; p < buf + cmd->datasize; ) + { + struct mach_o_data_in_code_entry_external *dice; + unsigned int offset; + unsigned int length; + unsigned int kind; + + dice = (struct mach_o_data_in_code_entry_external *) p; + + offset = bfd_get_32 (abfd, dice->offset); + length = bfd_get_16 (abfd, dice->length); + kind = bfd_get_16 (abfd, dice->kind); + + printf (" 0x%08x 0x%04x 0x%04x %s\n", offset, length, kind, + bfd_mach_o_get_name (data_in_code_kind_name, kind)); + + p += sizeof (*dice); + } + free (buf); +} + +static void +dump_twolevel_hints (bfd *abfd, bfd_mach_o_twolevel_hints_command *cmd) +{ + size_t sz = 4 * cmd->nhints; + unsigned char *buf; + unsigned char *p; + + buf = xmalloc (sz); + if (bfd_seek (abfd, cmd->offset, SEEK_SET) != 0 + || bfd_bread (buf, sz, abfd) != sz) + { + non_fatal (_("cannot read twolevel hints")); + free (buf); + return; + } + + for (p = buf; p < buf + sz; p += 4) + { + unsigned int v; + unsigned int isub_image; + unsigned int itoc; + + v = bfd_get_32 (abfd, p); + if (bfd_big_endian (abfd)) + { + isub_image = (v >> 24) & 0xff; + itoc = v & 0xffffff; + } + else + { + isub_image = v & 0xff; + itoc = (v >> 8) & 0xffffff; + } + + printf (" %3u %8u\n", isub_image, itoc); + } + free (buf); +} + +static void +dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd, + unsigned int idx, bfd_boolean verbose) +{ + bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd); + const char *cmd_name; + + cmd_name = bfd_mach_o_get_name_or_null + (bfd_mach_o_load_command_name, cmd->type); + printf ("Load command #%-2u (size: %3u, offset: %4u): ", + idx, cmd->len, cmd->offset); + if (cmd_name == NULL) + printf ("0x%02x\n", cmd->type); + else + printf ("%s\n", cmd_name); + + switch (cmd->type) + { + case BFD_MACH_O_LC_SEGMENT: + case BFD_MACH_O_LC_SEGMENT_64: + dump_segment (abfd, cmd); + break; + case BFD_MACH_O_LC_UUID: + { + bfd_mach_o_uuid_command *uuid = &cmd->command.uuid; + unsigned int j; + + printf (" "); + for (j = 0; j < sizeof (uuid->uuid); j ++) + printf (" %02x", uuid->uuid[j]); + putchar ('\n'); + } + break; + case BFD_MACH_O_LC_LOAD_DYLIB: + case BFD_MACH_O_LC_LAZY_LOAD_DYLIB: + case BFD_MACH_O_LC_LOAD_WEAK_DYLIB: + case BFD_MACH_O_LC_REEXPORT_DYLIB: + case BFD_MACH_O_LC_ID_DYLIB: + case BFD_MACH_O_LC_LOAD_UPWARD_DYLIB: + { + bfd_mach_o_dylib_command *dylib = &cmd->command.dylib; + printf (" name: %s\n", dylib->name_str); + printf (" time stamp: 0x%08lx\n", + dylib->timestamp); + printf (" current version: 0x%08lx\n", + dylib->current_version); + printf (" comptibility version: 0x%08lx\n", + dylib->compatibility_version); + } + break; + case BFD_MACH_O_LC_LOAD_DYLINKER: + case BFD_MACH_O_LC_ID_DYLINKER: + printf (" %s\n", cmd->command.dylinker.name_str); + break; + case BFD_MACH_O_LC_DYLD_ENVIRONMENT: + printf (" %s\n", cmd->command.dylinker.name_str); + break; + case BFD_MACH_O_LC_SYMTAB: + { + bfd_mach_o_symtab_command *symtab = &cmd->command.symtab; + printf (" symoff: 0x%08x nsyms: %8u (endoff: 0x%08x)\n", + symtab->symoff, symtab->nsyms, + symtab->symoff + symtab->nsyms + * (mdata->header.version == 2 + ? BFD_MACH_O_NLIST_64_SIZE : BFD_MACH_O_NLIST_SIZE)); + printf (" stroff: 0x%08x strsize: %8u (endoff: 0x%08x)\n", + symtab->stroff, symtab->strsize, + symtab->stroff + symtab->strsize); + break; + } + case BFD_MACH_O_LC_DYSYMTAB: + dump_dysymtab (abfd, cmd, verbose); + break; + case BFD_MACH_O_LC_LOADFVMLIB: + case BFD_MACH_O_LC_IDFVMLIB: + { + bfd_mach_o_fvmlib_command *fvmlib = &cmd->command.fvmlib; + printf (" fvmlib: %s\n", fvmlib->name_str); + printf (" minor version: 0x%08x\n", fvmlib->minor_version); + printf (" header address: 0x%08x\n", fvmlib->header_addr); + } + break; + case BFD_MACH_O_LC_CODE_SIGNATURE: + case BFD_MACH_O_LC_SEGMENT_SPLIT_INFO: + case BFD_MACH_O_LC_FUNCTION_STARTS: + case BFD_MACH_O_LC_DATA_IN_CODE: + case BFD_MACH_O_LC_DYLIB_CODE_SIGN_DRS: + { + bfd_mach_o_linkedit_command *linkedit = &cmd->command.linkedit; + printf + (" dataoff: 0x%08lx datasize: 0x%08lx (endoff: 0x%08lx)\n", + linkedit->dataoff, linkedit->datasize, + linkedit->dataoff + linkedit->datasize); + + if (verbose) + switch (cmd->type) + { + case BFD_MACH_O_LC_CODE_SIGNATURE: + dump_code_signature (abfd, linkedit); + break; + case BFD_MACH_O_LC_SEGMENT_SPLIT_INFO: + dump_segment_split_info (abfd, linkedit); + break; + case BFD_MACH_O_LC_FUNCTION_STARTS: + dump_function_starts (abfd, linkedit); + break; + case BFD_MACH_O_LC_DATA_IN_CODE: + dump_data_in_code (abfd, linkedit); + break; + default: + break; + } + } + break; + case BFD_MACH_O_LC_SUB_FRAMEWORK: + case BFD_MACH_O_LC_SUB_UMBRELLA: + case BFD_MACH_O_LC_SUB_LIBRARY: + case BFD_MACH_O_LC_SUB_CLIENT: + case BFD_MACH_O_LC_RPATH: + { + bfd_mach_o_str_command *strc = &cmd->command.str; + printf (" %s\n", strc->str); + break; + } + case BFD_MACH_O_LC_THREAD: + case BFD_MACH_O_LC_UNIXTHREAD: + dump_thread (abfd, cmd); + break; + case BFD_MACH_O_LC_ENCRYPTION_INFO: + { + bfd_mach_o_encryption_info_command *cryp = + &cmd->command.encryption_info; + printf (" cryptoff: 0x%08x cryptsize: 0x%08x (endoff 0x%08x)" + " cryptid: %u\n", + cryp->cryptoff, cryp->cryptsize, + cryp->cryptoff + cryp->cryptsize, + cryp->cryptid); + } + break; + case BFD_MACH_O_LC_DYLD_INFO: + dump_dyld_info (abfd, cmd, verbose); + break; + case BFD_MACH_O_LC_VERSION_MIN_MACOSX: + case BFD_MACH_O_LC_VERSION_MIN_IPHONEOS: + { + bfd_mach_o_version_min_command *ver = &cmd->command.version_min; + + printf (" %u.%u.%u\n", ver->rel, ver->maj, ver->min); + } + break; + case BFD_MACH_O_LC_SOURCE_VERSION: + { + bfd_mach_o_source_version_command *version = + &cmd->command.source_version; + printf (" version a.b.c.d.e: %u.%u.%u.%u.%u\n", + version->a, version->b, version->c, version->d, version->e); + break; + } + case BFD_MACH_O_LC_PREBOUND_DYLIB: + { + bfd_mach_o_prebound_dylib_command *pbdy = &cmd->command.prebound_dylib; + unsigned char *lm = pbdy->linked_modules; + unsigned int j; + unsigned int last; + + printf (" dylib: %s\n", pbdy->name_str); + printf (" nmodules: %u\n", pbdy->nmodules); + printf (" linked modules (at %u): ", + pbdy->linked_modules_offset - cmd->offset); + last = pbdy->nmodules > 32 ? 32 : pbdy->nmodules; + for (j = 0; j < last; j++) + printf ("%u", (lm[j >> 3] >> (j & 7)) & 1); + if (last < pbdy->nmodules) + printf ("..."); + putchar ('\n'); + break; + } + case BFD_MACH_O_LC_PREBIND_CKSUM: + { + bfd_mach_o_prebind_cksum_command *cksum = &cmd->command.prebind_cksum; + printf (" 0x%08x\n", cksum->cksum); + break; + } + case BFD_MACH_O_LC_TWOLEVEL_HINTS: + { + bfd_mach_o_twolevel_hints_command *hints = + &cmd->command.twolevel_hints; + + printf (" table offset: 0x%08x nbr hints: %u\n", + hints->offset, hints->nhints); + if (verbose) + dump_twolevel_hints (abfd, hints); + break; + } + case BFD_MACH_O_LC_MAIN: + { + bfd_mach_o_main_command *entry = &cmd->command.main; + printf (" entry offset: "); + printf_uint64 (entry->entryoff); + printf ("\n" + " stack size: "); + printf_uint64 (entry->stacksize); + printf ("\n"); + break; + } + default: + break; + } + putchar ('\n'); +} + +static void +dump_load_commands (bfd *abfd, unsigned int cmd32, unsigned int cmd64) +{ + bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd); + bfd_mach_o_load_command *cmd; + unsigned int i; + + for (cmd = mdata->first_command, i = 0; cmd != NULL; cmd = cmd->next, i++) + { + if (cmd32 == 0) + dump_load_command (abfd, cmd, i, FALSE); + else if (cmd->type == cmd32 || cmd->type == cmd64) + dump_load_command (abfd, cmd, i, TRUE); + } +} + +static const char * const unwind_x86_64_regs[] = + {"", "rbx", "r12", "r13", "r14", "r15", "rbp", "???" }; + +static const char * const unwind_x86_regs[] = + {"", "ebx", "ecx", "edx", "edi", "edi", "ebp", "???" }; + +/* Dump x86 or x86-64 compact unwind encoding. Works for both architecture, + as the encoding is the same (but not register names). */ + +static void +dump_unwind_encoding_x86 (unsigned int encoding, unsigned int sz, + const char * const regs_name[]) +{ + unsigned int mode; + + mode = encoding & MACH_O_UNWIND_X86_64_MODE_MASK; + switch (mode) + { + case MACH_O_UNWIND_X86_64_MODE_RBP_FRAME: + { + unsigned int regs; + char pfx = sz == 8 ? 'R' : 'E'; + + regs = encoding & MACH_O_UNWIND_X86_64_RBP_FRAME_REGSITERS; + printf (" %cSP frame", pfx); + if (regs != 0) + { + unsigned int offset; + int i; + + offset = (encoding & MACH_O_UNWIND_X86_64_RBP_FRAME_OFFSET) >> 16; + printf (" at %cBP-%u:", pfx, offset * sz); + for (i = 0; i < 5; i++) + { + unsigned int reg = (regs >> (i * 3)) & 0x7; + if (reg != MACH_O_UNWIND_X86_64_REG_NONE) + printf (" %s", regs_name[reg]); + } + } + } + break; + case MACH_O_UNWIND_X86_64_MODE_STACK_IMMD: + case MACH_O_UNWIND_X86_64_MODE_STACK_IND: + { + unsigned int stack_size; + unsigned int reg_count; + unsigned int reg_perm; + unsigned int regs[6]; + int i, j; + + printf (" frameless"); + stack_size = + (encoding & MACH_O_UNWIND_X86_64_FRAMELESS_STACK_SIZE) >> 16; + reg_count = + (encoding & MACH_O_UNWIND_X86_64_FRAMELESS_REG_COUNT) >> 10; + reg_perm = encoding & MACH_O_UNWIND_X86_64_FRAMELESS_REG_PERMUTATION; + + if (mode == MACH_O_UNWIND_X86_64_MODE_STACK_IMMD) + printf (" size: 0x%03x", stack_size * sz); + else + { + unsigned int stack_adj; + + stack_adj = + (encoding & MACH_O_UNWIND_X86_64_FRAMELESS_STACK_ADJUST) >> 13; + printf (" size at 0x%03x + 0x%02x", stack_size, stack_adj * sz); + } + /* Registers are coded using arithmetic compression: the register + is indexed in range 0-6, the second in range 0-5, the third in + range 0-4, etc. Already used registers are removed in next + ranges. */ +#define DO_PERM(R, NUM) R = reg_perm / NUM; reg_perm -= R * NUM + switch (reg_count) + { + case 6: + case 5: + DO_PERM (regs[0], 120); + DO_PERM (regs[1], 24); + DO_PERM (regs[2], 6); + DO_PERM (regs[3], 2); + DO_PERM (regs[4], 1); + regs[5] = 0; /* Not used if reg_count = 5. */ + break; + case 4: + DO_PERM (regs[0], 60); + DO_PERM (regs[1], 12); + DO_PERM (regs[2], 3); + DO_PERM (regs[3], 1); + break; + case 3: + DO_PERM (regs[0], 20); + DO_PERM (regs[1], 4); + DO_PERM (regs[2], 1); + break; + case 2: + DO_PERM (regs[0], 5); + DO_PERM (regs[1], 1); + break; + case 1: + DO_PERM (regs[0], 1); + break; + case 0: + break; + default: + printf (" [bad reg count]"); + return; + } +#undef DO_PERM + /* Renumber. */ + for (i = reg_count - 1; i >= 0; i--) + { + unsigned int inc = 1; + for (j = 0; j < i; j++) + if (regs[i] >= regs[j]) + inc++; + regs[i] += inc; + } + /* Display. */ + for (i = 0; i < (int) reg_count; i++) + printf (" %s", regs_name[regs[i]]); + } + break; + case MACH_O_UNWIND_X86_64_MODE_DWARF: + printf (" Dwarf offset: 0x%06x", + encoding & MACH_O_UNWIND_X86_64_DWARF_SECTION_OFFSET); + break; + default: + printf (" [unhandled mode]"); + break; + } +} + +/* Dump arm64 compact unwind entries. */ + +static void +dump_unwind_encoding_arm64 (unsigned int encoding) +{ + switch (encoding & MACH_O_UNWIND_ARM64_MODE_MASK) + { + case MACH_O_UNWIND_ARM64_MODE_FRAMELESS: + printf (" frameless"); + break; + case MACH_O_UNWIND_ARM64_MODE_DWARF: + printf (" Dwarf offset: 0x%06x", + encoding & MACH_O_UNWIND_ARM64_DWARF_SECTION_OFFSET); + return; + case MACH_O_UNWIND_ARM64_MODE_FRAME: + printf (" frame"); + break; + default: + printf (" [unhandled mode]"); + return; + } + switch (encoding & MACH_O_UNWIND_ARM64_MODE_MASK) + { + case MACH_O_UNWIND_ARM64_MODE_FRAMELESS: + case MACH_O_UNWIND_ARM64_MODE_FRAME: + if (encoding & MACH_O_UNWIND_ARM64_FRAME_X19_X20_PAIR) + printf (" x19-x20"); + if (encoding & MACH_O_UNWIND_ARM64_FRAME_X21_X22_PAIR) + printf (" x21-x22"); + if (encoding & MACH_O_UNWIND_ARM64_FRAME_X23_X24_PAIR) + printf (" x23-x24"); + if (encoding & MACH_O_UNWIND_ARM64_FRAME_X25_X26_PAIR) + printf (" x25-x26"); + if (encoding & MACH_O_UNWIND_ARM64_FRAME_X27_X28_PAIR) + printf (" x27-x28"); + break; + } + switch (encoding & MACH_O_UNWIND_ARM64_MODE_MASK) + { + case MACH_O_UNWIND_ARM64_MODE_FRAME: + if (encoding & MACH_O_UNWIND_ARM64_FRAME_D8_D9_PAIR) + printf (" d8-d9"); + if (encoding & MACH_O_UNWIND_ARM64_FRAME_D10_D11_PAIR) + printf (" d10-d11"); + if (encoding & MACH_O_UNWIND_ARM64_FRAME_D12_D13_PAIR) + printf (" d12-d13"); + if (encoding & MACH_O_UNWIND_ARM64_FRAME_D14_D15_PAIR) + printf (" d14-d15"); + break; + case MACH_O_UNWIND_ARM64_MODE_FRAMELESS: + printf (" size: %u", + (encoding & MACH_O_UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK) >> 8); + break; + } +} + +static void +dump_unwind_encoding (bfd_mach_o_data_struct *mdata, unsigned int encoding) +{ + printf ("0x%08x", encoding); + if (encoding == 0) + return; + + switch (mdata->header.cputype) + { + case BFD_MACH_O_CPU_TYPE_X86_64: + dump_unwind_encoding_x86 (encoding, 8, unwind_x86_64_regs); + break; + case BFD_MACH_O_CPU_TYPE_I386: + dump_unwind_encoding_x86 (encoding, 4, unwind_x86_regs); + break; + case BFD_MACH_O_CPU_TYPE_ARM64: + dump_unwind_encoding_arm64 (encoding); + break; + default: + printf (" [unhandled cpu]"); + break; + } + if (encoding & MACH_O_UNWIND_HAS_LSDA) + printf (" LSDA"); + if (encoding & MACH_O_UNWIND_PERSONALITY_MASK) + printf (" PERS(%u)", + ((encoding & MACH_O_UNWIND_PERSONALITY_MASK) + >> MACH_O_UNWIND_PERSONALITY_SHIFT)); +} + +static void +dump_obj_compact_unwind (bfd *abfd, + const unsigned char *content, bfd_size_type size) +{ + bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd); + int is_64 = mdata->header.version == 2; + const unsigned char *p; + + printf ("Compact unwind info:\n"); + printf (" start length personality lsda\n"); + + if (is_64) + { + struct mach_o_compact_unwind_64 *e = + (struct mach_o_compact_unwind_64 *) content; + + for (p = content; p < content + size; p += sizeof (*e)) + { + e = (struct mach_o_compact_unwind_64 *) p; + + putchar (' '); + printf_uint64 (bfd_get_64 (abfd, e->start)); + printf (" %08lx", bfd_get_32 (abfd, e->length)); + putchar (' '); + printf_uint64 (bfd_get_64 (abfd, e->personality)); + putchar (' '); + printf_uint64 (bfd_get_64 (abfd, e->lsda)); + putchar ('\n'); + + printf (" encoding: "); + dump_unwind_encoding (mdata, bfd_get_32 (abfd, e->encoding)); + putchar ('\n'); + } + } + else + { + printf ("unhandled\n"); + } +} + +static void +dump_exe_compact_unwind (bfd *abfd, + const unsigned char *content, bfd_size_type size) +{ + bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd); + struct mach_o_unwind_info_header *hdr; + unsigned int version; + unsigned int encodings_offset; + unsigned int encodings_count; + unsigned int personality_offset; + unsigned int personality_count; + unsigned int index_offset; + unsigned int index_count; + struct mach_o_unwind_index_entry *index_entry; + unsigned int i; + + /* The header. */ + printf ("Compact unwind info:\n"); + + hdr = (struct mach_o_unwind_info_header *) content; + if (size < sizeof (*hdr)) + { + printf (" truncated!\n"); + return; + } + + version = bfd_get_32 (abfd, hdr->version); + if (version != MACH_O_UNWIND_SECTION_VERSION) + { + printf (" unknown version: %u\n", version); + return; + } + encodings_offset = bfd_get_32 (abfd, hdr->encodings_array_offset); + encodings_count = bfd_get_32 (abfd, hdr->encodings_array_count); + personality_offset = bfd_get_32 (abfd, hdr->personality_array_offset); + personality_count = bfd_get_32 (abfd, hdr->personality_array_count); + index_offset = bfd_get_32 (abfd, hdr->index_offset); + index_count = bfd_get_32 (abfd, hdr->index_count); + printf (" %u encodings, %u personalities, %u level-1 indexes:\n", + encodings_count, personality_count, index_count); + + /* Personality. */ + if (personality_count > 0) + { + const unsigned char *pers = content + personality_offset; + + printf (" personalities\n"); + for (i = 0; i < personality_count; i++) + printf (" %u: 0x%08x\n", i, + (unsigned) bfd_get_32 (abfd, pers + 4 * i)); + } + + /* Level-1 index. */ + printf (" idx function level2 off lsda off\n"); + + index_entry = (struct mach_o_unwind_index_entry *) (content + index_offset); + for (i = 0; i < index_count; i++) + { + unsigned int func_offset; + unsigned int level2_offset; + unsigned int lsda_offset; + + func_offset = bfd_get_32 (abfd, index_entry->function_offset); + level2_offset = bfd_get_32 (abfd, index_entry->second_level_offset); + lsda_offset = bfd_get_32 (abfd, index_entry->lsda_index_offset); + printf (" %3u 0x%08x 0x%08x 0x%08x\n", + i, func_offset, level2_offset, lsda_offset); + index_entry++; + } + + /* Level-1 index. */ + index_entry = (struct mach_o_unwind_index_entry *) (content + index_offset); + for (i = 0; i < index_count; i++) + { + unsigned int func_offset; + unsigned int level2_offset; + const unsigned char *level2; + unsigned int kind; + + func_offset = bfd_get_32 (abfd, index_entry->function_offset); + level2_offset = bfd_get_32 (abfd, index_entry->second_level_offset); + + /* No level-2 for this index (should be the last index). */ + if (level2_offset == 0) + continue; + + level2 = content + level2_offset; + kind = bfd_get_32 (abfd, level2); + switch (kind) + { + case MACH_O_UNWIND_SECOND_LEVEL_COMPRESSED: + { + struct mach_o_unwind_compressed_second_level_page_header *l2; + unsigned int entry_offset; + unsigned int entry_count; + unsigned int l2_encodings_offset; + unsigned int l2_encodings_count; + const unsigned char *en; + unsigned int j; + + l2 = (struct mach_o_unwind_compressed_second_level_page_header *) + level2; + entry_offset = bfd_get_16 (abfd, l2->entry_page_offset); + entry_count = bfd_get_16 (abfd, l2->entry_count); + l2_encodings_offset = bfd_get_16 (abfd, l2->encodings_offset); + l2_encodings_count = bfd_get_16 (abfd, l2->encodings_count); + + printf (" index %2u: compressed second level: " + "%u entries, %u encodings (at 0x%08x)\n", + i, entry_count, l2_encodings_count, l2_encodings_offset); + printf (" # function eidx encoding\n"); + + en = level2 + entry_offset; + for (j = 0; j < entry_count; j++) + { + unsigned int entry; + unsigned int en_func; + unsigned int enc_idx; + unsigned int encoding; + const unsigned char *enc_addr; + + entry = bfd_get_32 (abfd, en); + en_func = + MACH_O_UNWIND_INFO_COMPRESSED_ENTRY_FUNC_OFFSET (entry); + enc_idx = + MACH_O_UNWIND_INFO_COMPRESSED_ENTRY_ENCODING_INDEX (entry); + if (enc_idx < encodings_count) + enc_addr = content + encodings_offset + + 4 * enc_idx; + else + enc_addr = level2 + l2_encodings_offset + + 4 * (enc_idx - encodings_count); + encoding = bfd_get_32 (abfd, enc_addr); + + printf (" %4u 0x%08x [%3u] ", j, + func_offset + en_func, enc_idx); + dump_unwind_encoding (mdata, encoding); + putchar ('\n'); + + en += 4; + } + } + break; + + case MACH_O_UNWIND_SECOND_LEVEL_REGULAR: + { + struct mach_o_unwind_regular_second_level_page_header *l2; + struct mach_o_unwind_regular_second_level_entry *en; + unsigned int entry_offset; + unsigned int entry_count; + unsigned int j; + + l2 = (struct mach_o_unwind_regular_second_level_page_header *) + level2; + + entry_offset = bfd_get_16 (abfd, l2->entry_page_offset); + entry_count = bfd_get_16 (abfd, l2->entry_count); + printf (" index %2u: regular level 2 at 0x%04x, %u entries\n", + i, entry_offset, entry_count); + printf (" # function encoding\n"); + + en = (struct mach_o_unwind_regular_second_level_entry *) + (level2 + entry_offset); + for (j = 0; j < entry_count; j++) + { + unsigned int en_func; + unsigned int encoding; + + en_func = bfd_get_32 (abfd, en->function_offset); + encoding = bfd_get_32 (abfd, en->encoding); + printf (" %-4u 0x%08x ", j, en_func); + dump_unwind_encoding (mdata, encoding); + putchar ('\n'); + en++; + } + } + break; + + default: + printf (" index %2u: unhandled second level format (%u)\n", + i, kind); + break; + } + + { + struct mach_o_unwind_lsda_index_entry *lsda; + unsigned int lsda_offset; + unsigned int next_lsda_offset; + unsigned int nbr_lsda; + unsigned int j; + + lsda_offset = bfd_get_32 (abfd, index_entry->lsda_index_offset); + next_lsda_offset = bfd_get_32 (abfd, index_entry[1].lsda_index_offset); + lsda = (struct mach_o_unwind_lsda_index_entry *) + (content + lsda_offset); + nbr_lsda = (next_lsda_offset - lsda_offset) / sizeof (*lsda); + for (j = 0; j < nbr_lsda; j++) + { + printf (" lsda %3u: function 0x%08x lsda 0x%08x\n", + j, (unsigned int) bfd_get_32 (abfd, lsda->function_offset), + (unsigned int) bfd_get_32 (abfd, lsda->lsda_offset)); + lsda++; + } + } + index_entry++; + } +} + +static void +dump_section_content (bfd *abfd, + const char *segname, const char *sectname, + void (*dump)(bfd*, const unsigned char*, bfd_size_type)) +{ + bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd); + bfd_mach_o_load_command *cmd; + + for (cmd = mdata->first_command; cmd != NULL; cmd = cmd->next) + { + if (cmd->type == BFD_MACH_O_LC_SEGMENT + || cmd->type == BFD_MACH_O_LC_SEGMENT_64) + { + bfd_mach_o_segment_command *seg = &cmd->command.segment; + bfd_mach_o_section *sec; + for (sec = seg->sect_head; sec != NULL; sec = sec->next) + if (strcmp (sec->segname, segname) == 0 + && strcmp (sec->sectname, sectname) == 0) + { + bfd_size_type size; + asection *bfdsec = sec->bfdsection; + unsigned char *content; + + size = bfd_get_section_size (bfdsec); + content = (unsigned char *) xmalloc (size); + bfd_get_section_contents (abfd, bfdsec, content, 0, size); + + (*dump)(abfd, content, size); + + free (content); + } + } + } +} + +/* Dump ABFD (according to the options[] array). */ + +static void +mach_o_dump (bfd *abfd) +{ + if (options[OPT_HEADER].selected) + dump_header (abfd); + if (options[OPT_SECTION].selected) + dump_load_commands (abfd, BFD_MACH_O_LC_SEGMENT, BFD_MACH_O_LC_SEGMENT_64); + if (options[OPT_MAP].selected) + dump_section_map (abfd); + if (options[OPT_LOAD].selected) + dump_load_commands (abfd, 0, 0); + if (options[OPT_DYSYMTAB].selected) + dump_load_commands (abfd, BFD_MACH_O_LC_DYSYMTAB, 0); + if (options[OPT_CODESIGN].selected) + dump_load_commands (abfd, BFD_MACH_O_LC_CODE_SIGNATURE, 0); + if (options[OPT_SEG_SPLIT_INFO].selected) + dump_load_commands (abfd, BFD_MACH_O_LC_SEGMENT_SPLIT_INFO, 0); + if (options[OPT_FUNCTION_STARTS].selected) + dump_load_commands (abfd, BFD_MACH_O_LC_FUNCTION_STARTS, 0); + if (options[OPT_DATA_IN_CODE].selected) + dump_load_commands (abfd, BFD_MACH_O_LC_DATA_IN_CODE, 0); + if (options[OPT_TWOLEVEL_HINTS].selected) + dump_load_commands (abfd, BFD_MACH_O_LC_TWOLEVEL_HINTS, 0); + if (options[OPT_COMPACT_UNWIND].selected) + { + dump_section_content (abfd, "__LD", "__compact_unwind", + dump_obj_compact_unwind); + dump_section_content (abfd, "__TEXT", "__unwind_info", + dump_exe_compact_unwind); + } + if (options[OPT_DYLD_INFO].selected) + dump_load_commands (abfd, BFD_MACH_O_LC_DYLD_INFO, 0); +} + +/* Vector for Mach-O. */ + +const struct objdump_private_desc objdump_private_desc_mach_o = + { + mach_o_help, + mach_o_filter, + mach_o_dump, + options + }; diff --git a/support/sdbinutils/binutils/od-xcoff.c b/support/sdbinutils/binutils/od-xcoff.c new file mode 100644 index 0000000..6e2a241 --- /dev/null +++ b/support/sdbinutils/binutils/od-xcoff.c @@ -0,0 +1,1842 @@ +/* od-xcoff.c -- dump information about an xcoff object file. + Copyright (C) 2011-2018 Free Software Foundation, Inc. + Written by Tristan Gingold, Adacore. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "sysdep.h" +#include +#include +#include "safe-ctype.h" +#include "bfd.h" +#include "objdump.h" +#include "bucomm.h" +#include "bfdlink.h" +/* Force the support of weak symbols. */ +#ifndef AIX_WEAK_SUPPORT +#define AIX_WEAK_SUPPORT 1 +#endif +#include "coff/internal.h" +#include "coff/rs6000.h" +#include "coff/xcoff.h" +#include "libcoff.h" +#include "libxcoff.h" + +/* Index of the options in the options[] array. */ +#define OPT_FILE_HEADER 0 +#define OPT_AOUT 1 +#define OPT_SECTIONS 2 +#define OPT_SYMS 3 +#define OPT_RELOCS 4 +#define OPT_LINENO 5 +#define OPT_LOADER 6 +#define OPT_EXCEPT 7 +#define OPT_TYPCHK 8 +#define OPT_TRACEBACK 9 +#define OPT_TOC 10 +#define OPT_LDINFO 11 + +/* List of actions. */ +static struct objdump_private_option options[] = + { + { "header", 0 }, + { "aout", 0 }, + { "sections", 0 }, + { "syms", 0 }, + { "relocs", 0 }, + { "lineno", 0 }, + { "loader", 0 }, + { "except", 0 }, + { "typchk", 0 }, + { "traceback", 0 }, + { "toc", 0 }, + { "ldinfo", 0 }, + { NULL, 0 } + }; + +/* Display help. */ + +static void +xcoff_help (FILE *stream) +{ + fprintf (stream, _("\ +For XCOFF files:\n\ + header Display the file header\n\ + aout Display the auxiliary header\n\ + sections Display the section headers\n\ + syms Display the symbols table\n\ + relocs Display the relocation entries\n\ + lineno Display the line number entries\n\ + loader Display loader section\n\ + except Display exception table\n\ + typchk Display type-check section\n\ + traceback Display traceback tags\n\ + toc Display toc symbols\n\ + ldinfo Display loader info in core files\n\ +")); +} + +/* Return TRUE if ABFD is handled. */ + +static int +xcoff_filter (bfd *abfd) +{ + return bfd_get_flavour (abfd) == bfd_target_xcoff_flavour; +} + +/* Translation entry type. The last entry must be {0, NULL}. */ + +struct xlat_table { + unsigned int val; + const char *name; +}; + +/* Display the list of name (from TABLE) for FLAGS, using comma to separate + them. A name is displayed if FLAGS & VAL is not 0. */ + +static void +dump_flags (const struct xlat_table *table, unsigned int flags) +{ + unsigned int r = flags; + int first = 1; + const struct xlat_table *t; + + for (t = table; t->name; t++) + if ((flags & t->val) != 0) + { + r &= ~t->val; + + if (first) + first = 0; + else + putchar (','); + fputs (t->name, stdout); + } + + /* Not decoded flags. */ + if (r != 0) + { + if (!first) + putchar (','); + printf ("0x%x", r); + } +} + +/* Display the name corresponding to VAL from TABLE, using at most + MAXLEN char (possibly passed with spaces). */ + +static void +dump_value (const struct xlat_table *table, unsigned int val, int maxlen) +{ + const struct xlat_table *t; + + for (t = table; t->name; t++) + if (t->val == val) + { + printf ("%-*s", maxlen, t->name); + return; + } + printf ("(%*x)", maxlen - 2, val); +} + +/* Names of f_flags. */ +static const struct xlat_table f_flag_xlat[] = + { + { F_RELFLG, "no-rel" }, + { F_EXEC, "exec" }, + { F_LNNO, "lineno" }, + { F_LSYMS, "lsyms" }, + + { F_FDPR_PROF, "fdpr-prof" }, + { F_FDPR_OPTI, "fdpr-opti" }, + { F_DSA, "dsa" }, + + { F_VARPG, "varprg" }, + + { F_DYNLOAD, "dynload" }, + { F_SHROBJ, "shrobj" }, + { F_NONEXEC, "nonexec" }, + + { 0, NULL } + }; + +/* Names of s_flags. */ +static const struct xlat_table s_flag_xlat[] = + { + { STYP_PAD, "pad" }, + { STYP_DWARF, "dwarf" }, + { STYP_TEXT, "text" }, + { STYP_DATA, "data" }, + { STYP_BSS, "bss" }, + + { STYP_EXCEPT, "except" }, + { STYP_INFO, "info" }, + { STYP_TDATA, "tdata" }, + { STYP_TBSS, "tbss" }, + + { STYP_LOADER, "loader" }, + { STYP_DEBUG, "debug" }, + { STYP_TYPCHK, "typchk" }, + { STYP_OVRFLO, "ovrflo" }, + { 0, NULL } + }; + +/* Names of storage class. */ +static const struct xlat_table sc_xlat[] = + { +#define SC_ENTRY(X) { C_##X, #X } + SC_ENTRY(NULL), + SC_ENTRY(AUTO), + SC_ENTRY(EXT), + SC_ENTRY(STAT), + SC_ENTRY(REG), + SC_ENTRY(EXTDEF), + SC_ENTRY(LABEL), + SC_ENTRY(ULABEL), + SC_ENTRY(MOS), + SC_ENTRY(ARG), + /* SC_ENTRY(STRARG), */ + SC_ENTRY(MOU), + SC_ENTRY(UNTAG), + SC_ENTRY(TPDEF), + SC_ENTRY(USTATIC), + SC_ENTRY(ENTAG), + SC_ENTRY(MOE), + SC_ENTRY(REGPARM), + SC_ENTRY(FIELD), + SC_ENTRY(BLOCK), + SC_ENTRY(FCN), + SC_ENTRY(EOS), + SC_ENTRY(FILE), + SC_ENTRY(LINE), + SC_ENTRY(ALIAS), + SC_ENTRY(HIDDEN), + SC_ENTRY(HIDEXT), + SC_ENTRY(BINCL), + SC_ENTRY(EINCL), + SC_ENTRY(INFO), + SC_ENTRY(WEAKEXT), + SC_ENTRY(DWARF), + + /* Stabs. */ + SC_ENTRY (GSYM), + SC_ENTRY (LSYM), + SC_ENTRY (PSYM), + SC_ENTRY (RSYM), + SC_ENTRY (RPSYM), + SC_ENTRY (STSYM), + SC_ENTRY (TCSYM), + SC_ENTRY (BCOMM), + SC_ENTRY (ECOML), + SC_ENTRY (ECOMM), + SC_ENTRY (DECL), + SC_ENTRY (ENTRY), + SC_ENTRY (FUN), + SC_ENTRY (BSTAT), + SC_ENTRY (ESTAT), + + { 0, NULL } +#undef SC_ENTRY + }; + +/* Names for symbol type. */ +static const struct xlat_table smtyp_xlat[] = + { + { XTY_ER, "ER" }, + { XTY_SD, "SD" }, + { XTY_LD, "LD" }, + { XTY_CM, "CM" }, + { XTY_EM, "EM" }, + { XTY_US, "US" }, + { 0, NULL } + }; + +/* Names for storage-mapping class. */ +static const struct xlat_table smclas_xlat[] = + { +#define SMCLAS_ENTRY(X) { XMC_##X, #X } + SMCLAS_ENTRY (PR), + SMCLAS_ENTRY (RO), + SMCLAS_ENTRY (DB), + SMCLAS_ENTRY (TC), + SMCLAS_ENTRY (UA), + SMCLAS_ENTRY (RW), + SMCLAS_ENTRY (GL), + SMCLAS_ENTRY (XO), + SMCLAS_ENTRY (SV), + SMCLAS_ENTRY (BS), + SMCLAS_ENTRY (DS), + SMCLAS_ENTRY (UC), + SMCLAS_ENTRY (TI), + SMCLAS_ENTRY (TB), + SMCLAS_ENTRY (TC0), + SMCLAS_ENTRY (TD), + SMCLAS_ENTRY (SV64), + SMCLAS_ENTRY (SV3264), + { 0, NULL } +#undef SMCLAS_ENTRY + }; + +/* Names for relocation type. */ +static const struct xlat_table rtype_xlat[] = + { +#define RTYPE_ENTRY(X) { R_##X, #X } + RTYPE_ENTRY (POS), + RTYPE_ENTRY (NEG), + RTYPE_ENTRY (REL), + RTYPE_ENTRY (TOC), + RTYPE_ENTRY (RTB), + RTYPE_ENTRY (GL), + RTYPE_ENTRY (TCL), + RTYPE_ENTRY (BA), + RTYPE_ENTRY (BR), + RTYPE_ENTRY (RL), + RTYPE_ENTRY (RLA), + RTYPE_ENTRY (REF), + RTYPE_ENTRY (TRL), + RTYPE_ENTRY (TRLA), + RTYPE_ENTRY (RRTBI), + RTYPE_ENTRY (RRTBA), + RTYPE_ENTRY (CAI), + RTYPE_ENTRY (CREL), + RTYPE_ENTRY (RBA), + RTYPE_ENTRY (RBAC), + RTYPE_ENTRY (RBR), + RTYPE_ENTRY (RBRC), + RTYPE_ENTRY (TLS), + RTYPE_ENTRY (TLS_IE), + RTYPE_ENTRY (TLS_LD), + RTYPE_ENTRY (TLS_LE), + RTYPE_ENTRY (TLSM), + RTYPE_ENTRY (TLSML), + RTYPE_ENTRY (TOCU), + RTYPE_ENTRY (TOCL), + { 0, NULL } + }; + +/* Simplified section header. */ +struct xcoff32_section +{ + /* NUL terminated name. */ + char name[9]; + + /* Section flags. */ + unsigned int flags; + + /* Offsets in file. */ + ufile_ptr scnptr; + ufile_ptr relptr; + ufile_ptr lnnoptr; + + /* Number of relocs and line numbers. */ + unsigned int nreloc; + unsigned int nlnno; +}; + +/* Simplified symbol. */ + +union xcoff32_symbol +{ + union external_auxent aux; + + struct sym + { + /* Pointer to the NUL-terminated name. */ + char *name; + + /* XCOFF symbol fields. */ + unsigned int val; + unsigned short scnum; + unsigned short ntype; + unsigned char sclass; + unsigned char numaux; + + /* Buffer in case the name is local. */ + union + { + char name[9]; + unsigned int off; + } raw; + } sym; +}; + +/* Important fields to dump the file. */ + +struct xcoff_dump +{ + /* From file header. */ + unsigned short nscns; + unsigned int symptr; + unsigned int nsyms; + unsigned short opthdr; + + /* Sections. */ + struct xcoff32_section *sects; + + /* Symbols. */ + union xcoff32_symbol *syms; + char *strings; + unsigned int strings_size; +}; + +/* Print a symbol (if possible). */ + +static void +xcoff32_print_symbol (struct xcoff_dump *data, unsigned int symndx) +{ + if (data->syms != NULL + && symndx < data->nsyms + && data->syms[symndx].sym.name != NULL) + printf ("%s", data->syms[symndx].sym.name); + else + printf ("%u", symndx); +} + +/* Dump the file header. */ + +static void +dump_xcoff32_file_header (bfd *abfd, struct external_filehdr *fhdr, + struct xcoff_dump *data) +{ + unsigned int timdat = bfd_h_get_32 (abfd, fhdr->f_timdat); + unsigned short flags = bfd_h_get_16 (abfd, fhdr->f_flags); + + printf (_(" nbr sections: %d\n"), data->nscns); + printf (_(" time and date: 0x%08x - "), timdat); + if (timdat == 0) + printf (_("not set\n")); + else + { + /* Not correct on all platforms, but works on unix. */ + time_t t = timdat; + fputs (ctime (&t), stdout); + } + printf (_(" symbols off: 0x%08x\n"), data->symptr); + printf (_(" nbr symbols: %d\n"), data->nsyms); + printf (_(" opt hdr sz: %d\n"), data->opthdr); + printf (_(" flags: 0x%04x "), flags); + dump_flags (f_flag_xlat, flags); + putchar ('\n'); +} + +/* Dump the a.out header. */ + +static void +dump_xcoff32_aout_header (bfd *abfd, struct xcoff_dump *data) +{ + AOUTHDR auxhdr; + unsigned short magic; + unsigned int sz = data->opthdr; + + printf (_("Auxiliary header:\n")); + if (data->opthdr == 0) + { + printf (_(" No aux header\n")); + return; + } + if (data->opthdr > sizeof (auxhdr)) + { + printf (_("warning: optional header size too large (> %d)\n"), + (int)sizeof (auxhdr)); + sz = sizeof (auxhdr); + } + if (bfd_bread (&auxhdr, sz, abfd) != sz) + { + non_fatal (_("cannot read auxhdr")); + return; + } + + magic = bfd_h_get_16 (abfd, auxhdr.magic); + /* We don't translate these strings as they are fields name. */ + printf (" o_mflag (magic): 0x%04x 0%04o\n", magic, magic); + printf (" o_vstamp: 0x%04x\n", + (unsigned short)bfd_h_get_16 (abfd, auxhdr.vstamp)); + printf (" o_tsize: 0x%08x\n", + (unsigned int)bfd_h_get_32 (abfd, auxhdr.tsize)); + printf (" o_dsize: 0x%08x\n", + (unsigned int)bfd_h_get_32 (abfd, auxhdr.dsize)); + printf (" o_entry: 0x%08x\n", + (unsigned int)bfd_h_get_32 (abfd, auxhdr.entry)); + printf (" o_text_start: 0x%08x\n", + (unsigned int)bfd_h_get_32 (abfd, auxhdr.text_start)); + printf (" o_data_start: 0x%08x\n", + (unsigned int)bfd_h_get_32 (abfd, auxhdr.data_start)); + if (sz == offsetof (AOUTHDR, o_toc)) + return; + printf (" o_toc: 0x%08x\n", + (unsigned int)bfd_h_get_32 (abfd, auxhdr.o_toc)); + printf (" o_snentry: 0x%04x\n", + (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_snentry)); + printf (" o_sntext: 0x%04x\n", + (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_sntext)); + printf (" o_sndata: 0x%04x\n", + (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_sndata)); + printf (" o_sntoc: 0x%04x\n", + (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_sntoc)); + printf (" o_snloader: 0x%04x\n", + (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_snloader)); + printf (" o_snbss: 0x%04x\n", + (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_snbss)); + printf (" o_algntext: %u\n", + (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_algntext)); + printf (" o_algndata: %u\n", + (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_algndata)); + printf (" o_modtype: 0x%04x", + (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_modtype)); + if (ISPRINT (auxhdr.o_modtype[0]) && ISPRINT (auxhdr.o_modtype[1])) + printf (" (%c%c)", auxhdr.o_modtype[0], auxhdr.o_modtype[1]); + putchar ('\n'); + printf (" o_cputype: 0x%04x\n", + (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_cputype)); + printf (" o_maxstack: 0x%08x\n", + (unsigned int)bfd_h_get_32 (abfd, auxhdr.o_maxstack)); + printf (" o_maxdata: 0x%08x\n", + (unsigned int)bfd_h_get_32 (abfd, auxhdr.o_maxdata)); +#if 0 + printf (" o_debugger: 0x%08x\n", + (unsigned int)bfd_h_get_32 (abfd, auxhdr.o_debugger)); +#endif +} + +/* Dump the sections header. */ + +static void +dump_xcoff32_sections_header (bfd *abfd, struct xcoff_dump *data) +{ + unsigned int i; + unsigned int off; + + off = sizeof (struct external_filehdr) + data->opthdr; + printf (_("Section headers (at %u+%u=0x%08x to 0x%08x):\n"), + (unsigned int)sizeof (struct external_filehdr), data->opthdr, off, + off + (unsigned int)sizeof (struct external_scnhdr) * data->nscns); + if (data->nscns == 0) + { + printf (_(" No section header\n")); + return; + } + if (bfd_seek (abfd, off, SEEK_SET) != 0) + { + non_fatal (_("cannot read section header")); + return; + } + /* We don't translate this string as it consists in fields name. */ + printf (" # Name paddr vaddr size scnptr relptr lnnoptr nrel nlnno\n"); + for (i = 0; i < data->nscns; i++) + { + struct external_scnhdr scn; + unsigned int flags; + + if (bfd_bread (&scn, sizeof (scn), abfd) != sizeof (scn)) + { + non_fatal (_("cannot read section header")); + return; + } + flags = bfd_h_get_32 (abfd, scn.s_flags); + printf ("%2d %-8.8s %08x %08x %08x %08x %08x %08x %-5d %-5d\n", + i + 1, scn.s_name, + (unsigned int)bfd_h_get_32 (abfd, scn.s_paddr), + (unsigned int)bfd_h_get_32 (abfd, scn.s_vaddr), + (unsigned int)bfd_h_get_32 (abfd, scn.s_size), + (unsigned int)bfd_h_get_32 (abfd, scn.s_scnptr), + (unsigned int)bfd_h_get_32 (abfd, scn.s_relptr), + (unsigned int)bfd_h_get_32 (abfd, scn.s_lnnoptr), + (unsigned int)bfd_h_get_16 (abfd, scn.s_nreloc), + (unsigned int)bfd_h_get_16 (abfd, scn.s_nlnno)); + printf (_(" Flags: %08x "), flags); + + if (~flags == 0) + { + /* Stripped executable ? */ + putchar ('\n'); + } + else if (flags & STYP_OVRFLO) + printf (_("overflow - nreloc: %u, nlnno: %u\n"), + (unsigned int)bfd_h_get_32 (abfd, scn.s_paddr), + (unsigned int)bfd_h_get_32 (abfd, scn.s_vaddr)); + else + { + dump_flags (s_flag_xlat, flags); + putchar ('\n'); + } + } +} + +/* Read section table. */ + +static void +xcoff32_read_sections (bfd *abfd, struct xcoff_dump *data) +{ + int i; + + if (bfd_seek (abfd, sizeof (struct external_filehdr) + data->opthdr, + SEEK_SET) != 0) + { + non_fatal (_("cannot read section headers")); + return; + } + + data->sects = xmalloc (data->nscns * sizeof (struct xcoff32_section)); + for (i = 0; i < data->nscns; i++) + { + struct external_scnhdr scn; + struct xcoff32_section *s = &data->sects[i]; + + if (bfd_bread (&scn, sizeof (scn), abfd) != sizeof (scn)) + { + non_fatal (_("cannot read section header")); + free (data->sects); + data->sects = NULL; + return; + } + memcpy (s->name, scn.s_name, 8); + s->name[8] = 0; + s->flags = bfd_h_get_32 (abfd, scn.s_flags); + + s->scnptr = bfd_h_get_32 (abfd, scn.s_scnptr); + s->relptr = bfd_h_get_32 (abfd, scn.s_relptr); + s->lnnoptr = bfd_h_get_32 (abfd, scn.s_lnnoptr); + + s->nreloc = bfd_h_get_16 (abfd, scn.s_nreloc); + s->nlnno = bfd_h_get_16 (abfd, scn.s_nlnno); + + if (s->flags == STYP_OVRFLO) + { + if (s->nreloc > 0 && s->nreloc <= data->nscns) + data->sects[s->nreloc - 1].nreloc = + bfd_h_get_32 (abfd, scn.s_paddr); + if (s->nlnno > 0 && s->nlnno <= data->nscns) + data->sects[s->nlnno - 1].nlnno = + bfd_h_get_32 (abfd, scn.s_vaddr); + } + } +} + +/* Read symbols. */ + +static void +xcoff32_read_symbols (bfd *abfd, struct xcoff_dump *data) +{ + unsigned int i; + char stsz_arr[4]; + unsigned int stptr; + + if (data->nsyms == 0) + return; + + stptr = data->symptr + + data->nsyms * (unsigned)sizeof (struct external_syment); + + /* Read string table. */ + if (bfd_seek (abfd, stptr, SEEK_SET) != 0 + || bfd_bread (&stsz_arr, sizeof (stsz_arr), abfd) != sizeof (stsz_arr)) + { + non_fatal (_("cannot read strings table length")); + data->strings_size = 0; + } + else + { + data->strings_size = bfd_h_get_32 (abfd, stsz_arr); + if (data->strings_size > sizeof (stsz_arr)) + { + unsigned int remsz = data->strings_size - sizeof (stsz_arr); + + data->strings = xmalloc (data->strings_size); + + memcpy (data->strings, stsz_arr, sizeof (stsz_arr)); + if (bfd_bread (data->strings + sizeof (stsz_arr), remsz, abfd) + != remsz) + { + non_fatal (_("cannot read strings table")); + goto clean; + } + } + } + + if (bfd_seek (abfd, data->symptr, SEEK_SET) != 0) + { + non_fatal (_("cannot read symbol table")); + goto clean; + } + + data->syms = (union xcoff32_symbol *) + xmalloc (data->nsyms * sizeof (union xcoff32_symbol)); + + for (i = 0; i < data->nsyms; i++) + { + struct external_syment sym; + int j; + union xcoff32_symbol *s = &data->syms[i]; + + if (bfd_bread (&sym, sizeof (sym), abfd) != sizeof (sym)) + { + non_fatal (_("cannot read symbol entry")); + goto clean; + } + + s->sym.val = bfd_h_get_32 (abfd, sym.e_value); + s->sym.scnum = bfd_h_get_16 (abfd, sym.e_scnum); + s->sym.ntype = bfd_h_get_16 (abfd, sym.e_type); + s->sym.sclass = bfd_h_get_8 (abfd, sym.e_sclass); + s->sym.numaux = bfd_h_get_8 (abfd, sym.e_numaux); + + if (sym.e.e_name[0]) + { + memcpy (s->sym.raw.name, sym.e.e_name, sizeof (sym.e.e_name)); + s->sym.raw.name[8] = 0; + s->sym.name = s->sym.raw.name; + } + else + { + unsigned int soff = bfd_h_get_32 (abfd, sym.e.e.e_offset); + + if ((s->sym.sclass & DBXMASK) == 0 && soff < data->strings_size) + s->sym.name = data->strings + soff; + else + { + s->sym.name = NULL; + s->sym.raw.off = soff; + } + } + + for (j = 0; j < s->sym.numaux; j++, i++) + { + if (bfd_bread (&s[j + 1].aux, + sizeof (union external_auxent), abfd) + != sizeof (union external_auxent)) + { + non_fatal (_("cannot read symbol aux entry")); + goto clean; + } + } + } + return; + clean: + free (data->syms); + data->syms = NULL; + free (data->strings); + data->strings = NULL; +} + +/* Dump xcoff symbols. */ + +static void +dump_xcoff32_symbols (bfd *abfd, struct xcoff_dump *data) +{ + unsigned int i; + asection *debugsec; + char *debug = NULL; + + printf (_("Symbols table (strtable at 0x%08x)"), + data->symptr + + data->nsyms * (unsigned)sizeof (struct external_syment)); + if (data->nsyms == 0 || data->syms == NULL) + { + printf (_(":\n No symbols\n")); + return; + } + + /* Read strings table. */ + if (data->strings_size == 0) + printf (_(" (no strings):\n")); + else + printf (_(" (strings size: %08x):\n"), data->strings_size); + + /* Read debug section. */ + debugsec = bfd_get_section_by_name (abfd, ".debug"); + if (debugsec != NULL) + { + bfd_size_type size; + + size = bfd_get_section_size (debugsec); + debug = (char *) xmalloc (size); + bfd_get_section_contents (abfd, debugsec, debug, 0, size); + } + + /* Translators: 'sc' is for storage class, 'off' for offset. */ + printf (_(" # sc value section type aux name/off\n")); + for (i = 0; i < data->nsyms; i++) + { + union xcoff32_symbol *s = &data->syms[i]; + int j; + + printf ("%3u ", i); + dump_value (sc_xlat, s->sym.sclass, 10); + printf (" %08x ", s->sym.val); + if (s->sym.scnum > 0 && s->sym.scnum <= data->nscns) + { + if (data->sects != NULL) + printf ("%-8s", data->sects[s->sym.scnum - 1].name); + else + printf ("%-8u", s->sym.scnum); + } + else + switch ((signed short)s->sym.scnum) + { + case N_DEBUG: + printf ("N_DEBUG "); + break; + case N_ABS: + printf ("N_ABS "); + break; + case N_UNDEF: + printf ("N_UNDEF "); + break; + default: + printf ("(%04x) ", s->sym.scnum); + } + printf (" %04x %3u ", s->sym.ntype, s->sym.numaux); + if (s->sym.name != NULL) + printf ("%s", s->sym.name); + else + { + if ((s->sym.sclass & DBXMASK) != 0 && debug != NULL) + printf ("%s", debug + s->sym.raw.off); + else + printf ("%08x", s->sym.raw.off); + } + putchar ('\n'); + + for (j = 0; j < s->sym.numaux; j++, i++) + { + union external_auxent *aux = &s[j + 1].aux; + + printf (" %3u ", i + 1); + switch (s->sym.sclass) + { + case C_STAT: + /* Section length, number of relocs and line number. */ + printf (_(" scnlen: %08x nreloc: %-6u nlinno: %-6u\n"), + (unsigned)bfd_h_get_32 (abfd, aux->x_scn.x_scnlen), + (unsigned)bfd_h_get_16 (abfd, aux->x_scn.x_nreloc), + (unsigned)bfd_h_get_16 (abfd, aux->x_scn.x_nlinno)); + break; + case C_DWARF: + /* Section length and number of relocs. */ + printf (_(" scnlen: %08x nreloc: %-6u\n"), + (unsigned)bfd_h_get_32 (abfd, aux->x_scn.x_scnlen), + (unsigned)bfd_h_get_16 (abfd, aux->x_scn.x_nreloc)); + break; + case C_EXT: + case C_WEAKEXT: + case C_HIDEXT: + if (j == 0 && s->sym.numaux > 1) + { + /* Function aux entry (Do not translate). */ + printf (" exptr: %08x fsize: %08x lnnoptr: %08x endndx: %u\n", + (unsigned)bfd_h_get_32 (abfd, aux->x_sym.x_tagndx), + (unsigned)bfd_h_get_32 + (abfd, aux->x_sym.x_misc.x_fsize), + (unsigned)bfd_h_get_32 + (abfd, aux->x_sym.x_fcnary.x_fcn.x_lnnoptr), + (unsigned)bfd_h_get_32 + (abfd, aux->x_sym.x_fcnary.x_fcn.x_endndx)); + } + else if (j == 1 || (j == 0 && s->sym.numaux == 1)) + { + /* csect aux entry. */ + unsigned char smtyp; + unsigned int scnlen; + + smtyp = bfd_h_get_8 (abfd, aux->x_csect.x_smtyp); + scnlen = bfd_h_get_32 (abfd, aux->x_csect.x_scnlen); + + if (smtyp == XTY_LD) + printf (" scnsym: %-8u", scnlen); + else + printf (" scnlen: %08x", scnlen); + printf (" h: parm=%08x sn=%04x al: 2**%u", + (unsigned)bfd_h_get_32 (abfd, aux->x_csect.x_parmhash), + (unsigned)bfd_h_get_16 (abfd, aux->x_csect.x_snhash), + SMTYP_ALIGN (smtyp)); + printf (" typ: "); + dump_value (smtyp_xlat, SMTYP_SMTYP (smtyp), 2); + printf (" cl: "); + dump_value + (smclas_xlat, + (unsigned)bfd_h_get_8 (abfd, aux->x_csect.x_smclas), 6); + putchar ('\n'); + } + else + /* Do not translate - generic field name. */ + printf ("aux\n"); + break; + case C_FILE: + { + unsigned int off; + + printf (" ftype: %02x ", + (unsigned)bfd_h_get_8 (abfd, aux->x_file.x_ftype)); + if (aux->x_file.x_n.x_fname[0] != 0) + printf ("fname: %.14s", aux->x_file.x_n.x_fname); + else + { + off = (unsigned)bfd_h_get_32 + (abfd, aux->x_file.x_n.x_n.x_offset); + if (data->strings != NULL && off < data->strings_size) + printf (" %s", data->strings + off); + else + printf (_("offset: %08x"), off); + } + putchar ('\n'); + } + break; + case C_BLOCK: + case C_FCN: + printf (" lnno: %u\n", + (unsigned)bfd_h_get_16 + (abfd, aux->x_sym.x_misc.x_lnsz.x_lnno)); + break; + default: + /* Do not translate - generic field name. */ + printf ("aux\n"); + break; + } + } + + } + free (debug); +} + +/* Dump xcoff relocation entries. */ + +static void +dump_xcoff32_relocs (bfd *abfd, struct xcoff_dump *data) +{ + unsigned int i; + + if (data->sects == NULL) + { + non_fatal (_("cannot read section headers")); + return; + } + + for (i = 0; i < data->nscns; i++) + { + struct xcoff32_section *sect = &data->sects[i]; + unsigned int nrel = sect->nreloc; + unsigned int j; + + if (nrel == 0) + continue; + printf (_("Relocations for %s (%u)\n"), sect->name, nrel); + if (bfd_seek (abfd, sect->relptr, SEEK_SET) != 0) + { + non_fatal (_("cannot read relocations")); + continue; + } + /* Do not translate: fields name. */ + printf ("vaddr sgn mod sz type symndx symbol\n"); + for (j = 0; j < nrel; j++) + { + struct external_reloc rel; + unsigned char rsize; + unsigned int symndx; + + if (bfd_bread (&rel, sizeof (rel), abfd) != sizeof (rel)) + { + non_fatal (_("cannot read relocation entry")); + return; + } + rsize = bfd_h_get_8 (abfd, rel.r_size); + printf ("%08x %c %c %-2u ", + (unsigned int)bfd_h_get_32 (abfd, rel.r_vaddr), + rsize & 0x80 ? 'S' : 'U', + rsize & 0x40 ? 'm' : ' ', + (rsize & 0x3f) + 1); + dump_value (rtype_xlat, bfd_h_get_8 (abfd, rel.r_type), 6); + symndx = bfd_h_get_32 (abfd, rel.r_symndx); + printf ("%-6u ", symndx); + xcoff32_print_symbol (data, symndx); + putchar ('\n'); + } + putchar ('\n'); + } +} + +/* Dump xcoff line number entries. */ + +static void +dump_xcoff32_lineno (bfd *abfd, struct xcoff_dump *data) +{ + unsigned int i; + + if (data->sects == NULL) + { + non_fatal (_("cannot read section headers")); + return; + } + + for (i = 0; i < data->nscns; i++) + { + struct xcoff32_section *sect = &data->sects[i]; + unsigned int nlnno = sect->nlnno; + unsigned int j; + + if (nlnno == 0) + continue; + printf (_("Line numbers for %s (%u)\n"), sect->name, nlnno); + if (bfd_seek (abfd, sect->lnnoptr, SEEK_SET) != 0) + { + non_fatal (_("cannot read line numbers")); + continue; + } + /* Line number, symbol index and physical address. */ + printf (_("lineno symndx/paddr\n")); + for (j = 0; j < nlnno; j++) + { + struct external_lineno ln; + unsigned int no; + + if (bfd_bread (&ln, sizeof (ln), abfd) != sizeof (ln)) + { + non_fatal (_("cannot read line number entry")); + return; + } + no = bfd_h_get_16 (abfd, ln.l_lnno); + printf (" %-6u ", no); + if (no == 0) + { + unsigned int symndx = bfd_h_get_32 (abfd, ln.l_addr.l_symndx); + xcoff32_print_symbol (data, symndx); + } + else + printf ("0x%08x", + (unsigned int)bfd_h_get_32 (abfd, ln.l_addr.l_paddr)); + putchar ('\n'); + } + } +} + +/* Dump xcoff loader section. */ + +static void +dump_xcoff32_loader (bfd *abfd) +{ + asection *loader; + bfd_size_type size = 0; + struct external_ldhdr *lhdr; + struct external_ldsym *ldsym; + struct external_ldrel *ldrel; + bfd_byte *ldr_data; + unsigned int version; + unsigned int ndsyms; + unsigned int ndrel; + unsigned int stlen; + unsigned int stoff; + unsigned int impoff; + unsigned int nimpid; + unsigned int i; + const char *p; + + loader = bfd_get_section_by_name (abfd, ".loader"); + + if (loader == NULL) + { + printf (_("no .loader section in file\n")); + return; + } + size = bfd_get_section_size (loader); + if (size < sizeof (*lhdr)) + { + printf (_("section .loader is too short\n")); + return; + } + + ldr_data = (bfd_byte *) xmalloc (size); + bfd_get_section_contents (abfd, loader, ldr_data, 0, size); + lhdr = (struct external_ldhdr *)ldr_data; + printf (_("Loader header:\n")); + version = bfd_h_get_32 (abfd, lhdr->l_version); + printf (_(" version: %u\n"), version); + if (version != 1) + { + printf (_(" Unhandled version\n")); + free (ldr_data); + return; + } + ndsyms = bfd_h_get_32 (abfd, lhdr->l_nsyms); + printf (_(" nbr symbols: %u\n"), ndsyms); + ndrel = bfd_h_get_32 (abfd, lhdr->l_nreloc); + printf (_(" nbr relocs: %u\n"), ndrel); + /* Import string table length. */ + printf (_(" import strtab len: %u\n"), + (unsigned) bfd_h_get_32 (abfd, lhdr->l_istlen)); + nimpid = bfd_h_get_32 (abfd, lhdr->l_nimpid); + printf (_(" nbr import files: %u\n"), nimpid); + impoff = bfd_h_get_32 (abfd, lhdr->l_impoff); + printf (_(" import file off: %u\n"), impoff); + stlen = bfd_h_get_32 (abfd, lhdr->l_stlen); + printf (_(" string table len: %u\n"), stlen); + stoff = bfd_h_get_32 (abfd, lhdr->l_stoff); + printf (_(" string table off: %u\n"), stoff); + + ldsym = (struct external_ldsym *)(ldr_data + sizeof (*lhdr)); + printf (_("Dynamic symbols:\n")); + /* Do not translate: field names. */ + printf (" # value sc IFEW ty class file pa name\n"); + for (i = 0; i < ndsyms; i++, ldsym++) + { + unsigned char smtype; + + printf (_(" %4u %08x %3u "), i, + (unsigned)bfd_h_get_32 (abfd, ldsym->l_value), + (unsigned)bfd_h_get_16 (abfd, ldsym->l_scnum)); + smtype = bfd_h_get_8 (abfd, ldsym->l_smtype); + putchar (smtype & 0x40 ? 'I' : ' '); + putchar (smtype & 0x20 ? 'F' : ' '); + putchar (smtype & 0x10 ? 'E' : ' '); + putchar (smtype & 0x08 ? 'W' : ' '); + putchar (' '); + dump_value (smtyp_xlat, SMTYP_SMTYP (smtype), 2); + putchar (' '); + dump_value + (smclas_xlat, (unsigned)bfd_h_get_8 (abfd, ldsym->l_smclas), 6); + printf (_(" %3u %3u "), + (unsigned)bfd_h_get_32 (abfd, ldsym->l_ifile), + (unsigned)bfd_h_get_32 (abfd, ldsym->l_parm)); + if (ldsym->_l._l_name[0] != 0) + printf ("%-.8s", ldsym->_l._l_name); + else + { + unsigned int off = bfd_h_get_32 (abfd, ldsym->_l._l_l._l_offset); + if (off > stlen) + printf (_("(bad offset: %u)"), off); + else + printf ("%s", ldr_data + stoff + off); + } + putchar ('\n'); + } + + printf (_("Dynamic relocs:\n")); + /* Do not translate fields name. */ + printf (" vaddr sec sz typ sym\n"); + ldrel = (struct external_ldrel *)(ldr_data + sizeof (*lhdr) + + ndsyms * sizeof (*ldsym)); + for (i = 0; i < ndrel; i++, ldrel++) + { + unsigned int rsize; + unsigned int rtype; + unsigned int symndx; + + rsize = bfd_h_get_8 (abfd, ldrel->l_rtype + 0); + rtype = bfd_h_get_8 (abfd, ldrel->l_rtype + 1); + + printf (" %08x %3u %c%c %2u ", + (unsigned)bfd_h_get_32 (abfd, ldrel->l_vaddr), + (unsigned)bfd_h_get_16 (abfd, ldrel->l_rsecnm), + rsize & 0x80 ? 'S' : 'U', + rsize & 0x40 ? 'm' : ' ', + (rsize & 0x3f) + 1); + dump_value (rtype_xlat, rtype, 6); + symndx = bfd_h_get_32 (abfd, ldrel->l_symndx); + switch (symndx) + { + case 0: + printf (".text"); + break; + case 1: + printf (".data"); + break; + case 2: + printf (".bss"); + break; + default: + printf ("%u", symndx - 3); + break; + } + putchar ('\n'); + } + + printf (_("Import files:\n")); + p = (char *)ldr_data + impoff; + for (i = 0; i < nimpid; i++) + { + int n1, n2, n3; + + n1 = strlen (p); + n2 = strlen (p + n1 + 1); + n3 = strlen (p + n1 + 1 + n2+ 1); + printf (" %2u: %s,%s,%s\n", i, + p, p + n1 + 1, p + n1 + n2 + 2); + p += n1 + n2 + n3 + 3; + } + + free (ldr_data); +} + +/* Dump xcoff exception section. */ + +static void +dump_xcoff32_except (bfd *abfd, struct xcoff_dump *data) +{ + asection *sec; + bfd_size_type size = 0; + bfd_byte *excp_data; + struct external_exceptab *exceptab; + unsigned int i; + + sec = bfd_get_section_by_name (abfd, ".except"); + + if (sec == NULL) + { + printf (_("no .except section in file\n")); + return; + } + size = bfd_get_section_size (sec); + excp_data = (bfd_byte *) xmalloc (size); + bfd_get_section_contents (abfd, sec, excp_data, 0, size); + exceptab = (struct external_exceptab *)excp_data; + + printf (_("Exception table:\n")); + /* Do not translate fields name. */ + printf ("lang reason sym/addr\n"); + for (i = 0; i * sizeof (*exceptab) < size; i++, exceptab++) + { + unsigned int reason; + unsigned int addr; + + addr = bfd_get_32 (abfd, exceptab->e_addr.e_paddr); + reason = bfd_get_8 (abfd, exceptab->e_reason); + printf (" %02x %02x ", + (unsigned) bfd_get_8 (abfd, exceptab->e_lang), reason); + if (reason == 0) + xcoff32_print_symbol (data, addr); + else + printf ("@%08x", addr); + putchar ('\n'); + } + free (excp_data); +} + +/* Dump xcoff type-check section. */ + +static void +dump_xcoff32_typchk (bfd *abfd) +{ + asection *sec; + bfd_size_type size = 0; + bfd_byte *data; + unsigned int i; + + sec = bfd_get_section_by_name (abfd, ".typchk"); + + if (sec == NULL) + { + printf (_("no .typchk section in file\n")); + return; + } + size = bfd_get_section_size (sec); + data = (bfd_byte *) xmalloc (size); + bfd_get_section_contents (abfd, sec, data, 0, size); + + printf (_("Type-check section:\n")); + /* Do not translate field names. */ + printf ("offset len lang-id general-hash language-hash\n"); + for (i = 0; i < size;) + { + unsigned int len; + + len = bfd_get_16 (abfd, data + i); + printf ("%08x: %-4u ", i, len); + i += 2; + + if (len == 10) + { + /* Expected format. */ + printf ("%04x %08x %08x\n", + (unsigned) bfd_get_16 (abfd, data + i), + (unsigned) bfd_get_32 (abfd, data + i + 2), + (unsigned) bfd_get_32 (abfd, data + i + 2 + 4)); + } + else + { + unsigned int j; + + for (j = 0; j < len; j++) + { + if (j % 16 == 0) + printf ("\n "); + printf (" %02x", (unsigned char)data[i + j]); + } + putchar ('\n'); + } + i += len; + } + free (data); +} + +/* Dump xcoff traceback tags section. */ + +static void +dump_xcoff32_tbtags (bfd *abfd, + const char *text, bfd_size_type text_size, + unsigned int text_start, unsigned int func_start) +{ + unsigned int i; + + if (func_start - text_start > text_size) + { + printf (_(" address beyond section size\n")); + return; + } + for (i = func_start - text_start; i < text_size; i+= 4) + if (bfd_get_32 (abfd, text + i) == 0) + { + unsigned int tb1; + unsigned int tb2; + unsigned int off; + + printf (_(" tags at %08x\n"), i + 4); + if (i + 8 >= text_size) + goto truncated; + + tb1 = bfd_get_32 (abfd, text + i + 4); + tb2 = bfd_get_32 (abfd, text + i + 8); + off = i + 12; + printf (" version: %u, lang: %u, global_link: %u, is_eprol: %u, has_tboff: %u, int_proc: %u\n", + (tb1 >> 24) & 0xff, + (tb1 >> 16) & 0xff, + (tb1 >> 15) & 1, + (tb1 >> 14) & 1, + (tb1 >> 13) & 1, + (tb1 >> 12) & 1); + printf (" has_ctl: %u, tocless: %u, fp_pres: %u, log_abort: %u, int_hndl: %u\n", + (tb1 >> 11) & 1, + (tb1 >> 10) & 1, + (tb1 >> 9) & 1, + (tb1 >> 8) & 1, + (tb1 >> 7) & 1); + printf (" name_pres: %u, uses_alloca: %u, cl_dis_inv: %u, saves_cr: %u, saves_lr: %u\n", + (tb1 >> 6) & 1, + (tb1 >> 5) & 1, + (tb1 >> 2) & 7, + (tb1 >> 1) & 1, + (tb1 >> 0) & 1); + printf (" stores_bc: %u, fixup: %u, fpr_saved: %-2u, spare3: %u, gpr_saved: %-2u\n", + (tb2 >> 31) & 1, + (tb2 >> 30) & 1, + (tb2 >> 24) & 63, + (tb2 >> 22) & 3, + (tb2 >> 16) & 63); + printf (" fixparms: %-3u floatparms: %-3u parm_on_stk: %u\n", + (tb2 >> 8) & 0xff, + (tb2 >> 1) & 0x7f, + (tb2 >> 0) & 1); + + if (((tb2 >> 1) & 0x7fff) != 0) + { + unsigned int parminfo; + + if (off >= text_size) + goto truncated; + parminfo = bfd_get_32 (abfd, text + off); + off += 4; + printf (" parminfo: 0x%08x\n", parminfo); + } + + if ((tb1 >> 13) & 1) + { + unsigned int tboff; + + if (off >= text_size) + goto truncated; + tboff = bfd_get_32 (abfd, text + off); + off += 4; + printf (" tb_offset: 0x%08x (start=0x%08x)\n", + tboff, text_start + i - tboff); + } + if ((tb1 >> 7) & 1) + { + unsigned int hand_mask; + + if (off >= text_size) + goto truncated; + hand_mask = bfd_get_32 (abfd, text + off); + off += 4; + printf (" hand_mask_offset: 0x%08x\n", hand_mask); + } + if ((tb1 >> 11) & 1) + { + unsigned int ctl_info; + unsigned int j; + + if (off >= text_size) + goto truncated; + ctl_info = bfd_get_32 (abfd, text + off); + off += 4; + printf (_(" number of CTL anchors: %u\n"), ctl_info); + for (j = 0; j < ctl_info; j++) + { + if (off >= text_size) + goto truncated; + printf (" CTL[%u]: %08x\n", + j, (unsigned)bfd_get_32 (abfd, text + off)); + off += 4; + } + } + if ((tb1 >> 6) & 1) + { + unsigned int name_len; + unsigned int j; + + if (off >= text_size) + goto truncated; + name_len = bfd_get_16 (abfd, text + off); + off += 2; + printf (_(" Name (len: %u): "), name_len); + if (off + name_len >= text_size) + { + printf (_("[truncated]\n")); + goto truncated; + } + for (j = 0; j < name_len; j++) + if (ISPRINT (text[off + j])) + putchar (text[off + j]); + else + printf ("[%02x]", (unsigned char)text[off + j]); + putchar ('\n'); + off += name_len; + } + if ((tb1 >> 5) & 1) + { + if (off >= text_size) + goto truncated; + printf (" alloca reg: %u\n", + (unsigned) bfd_get_8 (abfd, text + off)); + off++; + } + printf (_(" (end of tags at %08x)\n"), text_start + off); + return; + } + printf (_(" no tags found\n")); + return; + + truncated: + printf (_(" Truncated .text section\n")); + return; +} + +static void +dump_xcoff32_traceback (bfd *abfd, struct xcoff_dump *data) +{ + unsigned int i; + unsigned int scnum_text = -1; + unsigned int text_vma; + asection *text_sec; + bfd_size_type text_size; + char *text; + + if (data->syms == NULL || data->sects == NULL) + return; + + /* Read text section. */ + text_sec = bfd_get_section_by_name (abfd, ".text"); + if (text_sec == NULL) + return; + text_vma = bfd_get_section_vma (abfd, text_sec); + + text_size = bfd_get_section_size (text_sec); + text = (char *) xmalloc (text_size); + bfd_get_section_contents (abfd, text_sec, text, 0, text_size); + + for (i = 0; i < data->nscns; i++) + if (data->sects[i].flags == STYP_TEXT) + { + scnum_text = i + 1; + break; + } + if (scnum_text == (unsigned int)-1) + return; + + for (i = 0; i < data->nsyms; i++) + { + union xcoff32_symbol *s = &data->syms[i]; + + switch (s->sym.sclass) + { + case C_EXT: + case C_HIDEXT: + case C_WEAKEXT: + if (s->sym.scnum == scnum_text + && s->sym.numaux > 0) + { + union external_auxent *aux = &s[s->sym.numaux].aux; + + unsigned int smtyp; + unsigned int smclas; + + smtyp = bfd_h_get_8 (abfd, aux->x_csect.x_smtyp); + smclas = bfd_h_get_8 (abfd, aux->x_csect.x_smclas); + if (SMTYP_SMTYP (smtyp) == XTY_LD + && (smclas == XMC_PR + || smclas == XMC_GL + || smclas == XMC_XO)) + { + printf ("%08x: ", s->sym.val); + xcoff32_print_symbol (data, i); + putchar ('\n'); + dump_xcoff32_tbtags (abfd, text, text_size, + text_vma, s->sym.val); + } + } + break; + default: + break; + } + i += s->sym.numaux; + } + free (text); +} + +/* Dump the TOC symbols. */ + +static void +dump_xcoff32_toc (bfd *abfd, struct xcoff_dump *data) +{ + unsigned int i; + unsigned int nbr_ent; + unsigned int size; + + printf (_("TOC:\n")); + + if (data->syms == NULL) + return; + + nbr_ent = 0; + size = 0; + + for (i = 0; i < data->nsyms; i++) + { + union xcoff32_symbol *s = &data->syms[i]; + + switch (s->sym.sclass) + { + case C_EXT: + case C_HIDEXT: + case C_WEAKEXT: + if (s->sym.numaux > 0) + { + union external_auxent *aux = &s[s->sym.numaux].aux; + unsigned int smclas; + unsigned int ent_sz; + + smclas = bfd_h_get_8 (abfd, aux->x_csect.x_smclas); + if (smclas == XMC_TC + || smclas == XMC_TD + || smclas == XMC_TC0) + { + ent_sz = bfd_h_get_32 (abfd, aux->x_scn.x_scnlen); + printf ("%08x %08x ", + s->sym.val, ent_sz); + xcoff32_print_symbol (data, i); + putchar ('\n'); + nbr_ent++; + size += ent_sz; + } + } + break; + default: + break; + } + i += s->sym.numaux; + } + printf (_("Nbr entries: %-8u Size: %08x (%u)\n"), + nbr_ent, size, size); +} + +/* Handle an rs6000 xcoff file. */ + +static void +dump_xcoff32 (bfd *abfd, struct external_filehdr *fhdr) +{ + struct xcoff_dump data; + + data.nscns = bfd_h_get_16 (abfd, fhdr->f_nscns); + data.symptr = bfd_h_get_32 (abfd, fhdr->f_symptr); + data.nsyms = bfd_h_get_32 (abfd, fhdr->f_nsyms); + data.opthdr = bfd_h_get_16 (abfd, fhdr->f_opthdr); + data.sects = NULL; + data.syms = NULL; + data.strings = NULL; + data.strings_size = 0; + + if (options[OPT_FILE_HEADER].selected) + dump_xcoff32_file_header (abfd, fhdr, &data); + + if (options[OPT_AOUT].selected) + dump_xcoff32_aout_header (abfd, &data); + + if (options[OPT_SYMS].selected + || options[OPT_RELOCS].selected + || options[OPT_LINENO].selected + || options[OPT_TRACEBACK].selected) + xcoff32_read_sections (abfd, &data); + + if (options[OPT_SECTIONS].selected) + dump_xcoff32_sections_header (abfd, &data); + + if (options[OPT_SYMS].selected + || options[OPT_RELOCS].selected + || options[OPT_LINENO].selected + || options[OPT_EXCEPT].selected + || options[OPT_TRACEBACK].selected + || options[OPT_TOC].selected) + xcoff32_read_symbols (abfd, &data); + + if (options[OPT_SYMS].selected) + dump_xcoff32_symbols (abfd, &data); + + if (options[OPT_RELOCS].selected) + dump_xcoff32_relocs (abfd, &data); + + if (options[OPT_LINENO].selected) + dump_xcoff32_lineno (abfd, &data); + + if (options[OPT_LOADER].selected) + dump_xcoff32_loader (abfd); + + if (options[OPT_EXCEPT].selected) + dump_xcoff32_except (abfd, &data); + + if (options[OPT_TYPCHK].selected) + dump_xcoff32_typchk (abfd); + + if (options[OPT_TRACEBACK].selected) + dump_xcoff32_traceback (abfd, &data); + + if (options[OPT_TOC].selected) + dump_xcoff32_toc (abfd, &data); + + free (data.sects); + free (data.strings); + free (data.syms); +} + +/* Dump ABFD (according to the options[] array). */ + +static void +xcoff_dump_obj (bfd *abfd) +{ + struct external_filehdr fhdr; + unsigned short magic; + + /* Read file header. */ + if (bfd_seek (abfd, 0, SEEK_SET) != 0 + || bfd_bread (&fhdr, sizeof (fhdr), abfd) != sizeof (fhdr)) + { + non_fatal (_("cannot read header")); + return; + } + + /* Decoding. We don't use the bfd/coff function to get all the fields. */ + magic = bfd_h_get_16 (abfd, fhdr.f_magic); + if (options[OPT_FILE_HEADER].selected) + { + printf (_("File header:\n")); + printf (_(" magic: 0x%04x (0%04o) "), magic, magic); + switch (magic) + { + case U802WRMAGIC: + printf (_("(WRMAGIC: writable text segments)")); + break; + case U802ROMAGIC: + printf (_("(ROMAGIC: readonly sharablee text segments)")); + break; + case U802TOCMAGIC: + printf (_("(TOCMAGIC: readonly text segments and TOC)")); + break; + default: + printf (_("unknown magic")); + break; + } + putchar ('\n'); + } + if (magic == U802ROMAGIC || magic == U802WRMAGIC || magic == U802TOCMAGIC) + dump_xcoff32 (abfd, &fhdr); + else + printf (_(" Unhandled magic\n")); +} + +/* Handle an AIX dumpx core file. */ + +static void +dump_dumpx_core (bfd *abfd, struct external_core_dumpx *hdr) +{ + if (options[OPT_FILE_HEADER].selected) + { + printf (" signal: %u\n", bfd_h_get_8 (abfd, hdr->c_signo)); + printf (" flags: 0x%02x\n", bfd_h_get_8 (abfd, hdr->c_flag)); + printf (" entries: %u\n", + (unsigned) bfd_h_get_16 (abfd, hdr->c_entries)); +#ifdef BFD64 + printf (" fdsinfox: offset: 0x%08" BFD_VMA_FMT "x\n", + bfd_h_get_64 (abfd, hdr->c_fdsinfox)); + printf (" loader: offset: 0x%08" BFD_VMA_FMT "x, " + "size: 0x%" BFD_VMA_FMT"x\n", + bfd_h_get_64 (abfd, hdr->c_loader), + bfd_h_get_64 (abfd, hdr->c_lsize)); + printf (" thr: offset: 0x%08" BFD_VMA_FMT "x, nbr: %u\n", + bfd_h_get_64 (abfd, hdr->c_thr), + (unsigned) bfd_h_get_32 (abfd, hdr->c_n_thr)); + printf (" segregions: offset: 0x%08" BFD_VMA_FMT "x, " + "nbr: %" BFD_VMA_FMT "u\n", + bfd_h_get_64 (abfd, hdr->c_segregion), + bfd_h_get_64 (abfd, hdr->c_segs)); + printf (" stack: offset: 0x%08" BFD_VMA_FMT "x, " + "org: 0x%" BFD_VMA_FMT"x, " + "size: 0x%" BFD_VMA_FMT"x\n", + bfd_h_get_64 (abfd, hdr->c_stack), + bfd_h_get_64 (abfd, hdr->c_stackorg), + bfd_h_get_64 (abfd, hdr->c_size)); + printf (" data: offset: 0x%08" BFD_VMA_FMT "x, " + "org: 0x%" BFD_VMA_FMT"x, " + "size: 0x%" BFD_VMA_FMT"x\n", + bfd_h_get_64 (abfd, hdr->c_data), + bfd_h_get_64 (abfd, hdr->c_dataorg), + bfd_h_get_64 (abfd, hdr->c_datasize)); + printf (" sdata: org: 0x%" BFD_VMA_FMT"x, " + "size: 0x%" BFD_VMA_FMT"x\n", + bfd_h_get_64 (abfd, hdr->c_sdorg), + bfd_h_get_64 (abfd, hdr->c_sdsize)); + printf (" vmmregions: offset: 0x%" BFD_VMA_FMT"x, " + "num: 0x%" BFD_VMA_FMT"x\n", + bfd_h_get_64 (abfd, hdr->c_vmm), + bfd_h_get_64 (abfd, hdr->c_vmmregions)); + printf (" impl: 0x%08x\n", + (unsigned) bfd_h_get_32 (abfd, hdr->c_impl)); + printf (" cprs: 0x%" BFD_VMA_FMT "x\n", + bfd_h_get_64 (abfd, hdr->c_cprs)); +#endif + } + if (options[OPT_LDINFO].selected) + { +#ifdef BFD64 + file_ptr off = (file_ptr) bfd_h_get_64 (abfd, hdr->c_loader); + bfd_size_type len = (bfd_size_type) bfd_h_get_64 (abfd, hdr->c_lsize); + char *ldr; + + ldr = xmalloc (len); + if (bfd_seek (abfd, off, SEEK_SET) != 0 + || bfd_bread (ldr, len, abfd) != len) + non_fatal (_("cannot read loader info table")); + else + { + char *p; + + printf ("\n" + "ld info:\n"); + printf (" next core off textorg textsize dataorg datasize\n"); + p = ldr; + while (1) + { + struct external_ld_info32 *l = (struct external_ld_info32 *)p; + unsigned int next; + size_t n1; + + next = bfd_h_get_32 (abfd, l->ldinfo_next); + printf (" %08x %08x %08x %08x %08x %08x\n", + next, + (unsigned) bfd_h_get_32 (abfd, l->core_offset), + (unsigned) bfd_h_get_32 (abfd, l->ldinfo_textorg), + (unsigned) bfd_h_get_32 (abfd, l->ldinfo_textsize), + (unsigned) bfd_h_get_32 (abfd, l->ldinfo_dataorg), + (unsigned) bfd_h_get_32 (abfd, l->ldinfo_datasize)); + n1 = strlen ((char *) l->ldinfo_filename); + printf (" %s %s\n", + l->ldinfo_filename, l->ldinfo_filename + n1 + 1); + if (next == 0) + break; + p += next; + } + } +#else + printf (_("\n" + "ldinfo dump not supported in 32 bits environments\n")); +#endif + } +} + +/* Dump a core file. */ + +static void +xcoff_dump_core (bfd *abfd) +{ + struct external_core_dumpx hdr; + unsigned int version; + + /* Read file header. */ + if (bfd_seek (abfd, 0, SEEK_SET) != 0 + || bfd_bread (&hdr, sizeof (hdr), abfd) != sizeof (hdr)) + { + non_fatal (_("cannot core read header")); + return; + } + + version = bfd_h_get_32 (abfd, hdr.c_version); + if (options[OPT_FILE_HEADER].selected) + { + printf (_("Core header:\n")); + printf (_(" version: 0x%08x "), version); + switch (version) + { + case CORE_DUMPX_VERSION: + printf (_("(dumpx format - aix4.3 / 32 bits)")); + break; + case CORE_DUMPXX_VERSION: + printf (_("(dumpxx format - aix5.0 / 64 bits)")); + break; + default: + printf (_("unknown format")); + break; + } + putchar ('\n'); + } + if (version == CORE_DUMPX_VERSION) + dump_dumpx_core (abfd, &hdr); + else + printf (_(" Unhandled magic\n")); +} + +/* Dump an XCOFF file. */ + +static void +xcoff_dump (bfd *abfd) +{ + /* We rely on BFD to decide if the file is a core file. Note that core + files are only supported on native environment by BFD. */ + switch (bfd_get_format (abfd)) + { + case bfd_core: + xcoff_dump_core (abfd); + break; + default: + xcoff_dump_obj (abfd); + break; + } +} + +/* Vector for xcoff. */ + +const struct objdump_private_desc objdump_private_desc_xcoff = + { + xcoff_help, + xcoff_filter, + xcoff_dump, + options + }; diff --git a/support/sdbinutils/binutils/prdbg.c b/support/sdbinutils/binutils/prdbg.c new file mode 100644 index 0000000..4b9fa06 --- /dev/null +++ b/support/sdbinutils/binutils/prdbg.c @@ -0,0 +1,2838 @@ +/* prdbg.c -- Print out generic debugging information. + Copyright (C) 1995-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor . + Tags style generation written by Salvador E. Tropea . + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* This file prints out the generic debugging information, by + supplying a set of routines to debug_write. */ + +#include "sysdep.h" +#include +#include "bfd.h" +#include "libiberty.h" +#include "demangle.h" +#include "debug.h" +#include "budbg.h" + +/* This is the structure we use as a handle for these routines. */ + +struct pr_handle +{ + /* File to print information to. */ + FILE *f; + /* Current indentation level. */ + unsigned int indent; + /* Type stack. */ + struct pr_stack *stack; + /* Parameter number we are about to output. */ + int parameter; + /* The following are used only by the tags code (tg_). */ + /* Name of the file we are using. */ + char *filename; + /* The BFD. */ + bfd *abfd; + /* The symbols table for this BFD. */ + asymbol **syms; + /* Pointer to a function to demangle symbols. */ + char *(*demangler) (bfd *, const char *, int); +}; + +/* The type stack. */ + +struct pr_stack +{ + /* Next element on the stack. */ + struct pr_stack *next; + /* This element. */ + char *type; + /* Current visibility of fields if this is a class. */ + enum debug_visibility visibility; + /* Name of the current method we are handling. */ + const char *method; + /* The following are used only by the tags code (tg_). */ + /* Type for the container (struct, union, class, union class). */ + const char *flavor; + /* A comma separated list of parent classes. */ + char *parents; + /* How many parents contains parents. */ + int num_parents; +}; + +static void indent (struct pr_handle *); +static bfd_boolean push_type (struct pr_handle *, const char *); +static bfd_boolean prepend_type (struct pr_handle *, const char *); +static bfd_boolean append_type (struct pr_handle *, const char *); +static bfd_boolean substitute_type (struct pr_handle *, const char *); +static bfd_boolean indent_type (struct pr_handle *); +static char *pop_type (struct pr_handle *); +static void print_vma (bfd_vma, char *, bfd_boolean, bfd_boolean); +static bfd_boolean pr_fix_visibility + (struct pr_handle *, enum debug_visibility); +static bfd_boolean pr_start_compilation_unit (void *, const char *); +static bfd_boolean pr_start_source (void *, const char *); +static bfd_boolean pr_empty_type (void *); +static bfd_boolean pr_void_type (void *); +static bfd_boolean pr_int_type (void *, unsigned int, bfd_boolean); +static bfd_boolean pr_float_type (void *, unsigned int); +static bfd_boolean pr_complex_type (void *, unsigned int); +static bfd_boolean pr_bool_type (void *, unsigned int); +static bfd_boolean pr_enum_type + (void *, const char *, const char **, bfd_signed_vma *); +static bfd_boolean pr_pointer_type (void *); +static bfd_boolean pr_function_type (void *, int, bfd_boolean); +static bfd_boolean pr_reference_type (void *); +static bfd_boolean pr_range_type (void *, bfd_signed_vma, bfd_signed_vma); +static bfd_boolean pr_array_type + (void *, bfd_signed_vma, bfd_signed_vma, bfd_boolean); +static bfd_boolean pr_set_type (void *, bfd_boolean); +static bfd_boolean pr_offset_type (void *); +static bfd_boolean pr_method_type (void *, bfd_boolean, int, bfd_boolean); +static bfd_boolean pr_const_type (void *); +static bfd_boolean pr_volatile_type (void *); +static bfd_boolean pr_start_struct_type + (void *, const char *, unsigned int, bfd_boolean, unsigned int); +static bfd_boolean pr_struct_field + (void *, const char *, bfd_vma, bfd_vma, enum debug_visibility); +static bfd_boolean pr_end_struct_type (void *); +static bfd_boolean pr_start_class_type + (void *, const char *, unsigned int, bfd_boolean, unsigned int, + bfd_boolean, bfd_boolean); +static bfd_boolean pr_class_static_member + (void *, const char *, const char *, enum debug_visibility); +static bfd_boolean pr_class_baseclass + (void *, bfd_vma, bfd_boolean, enum debug_visibility); +static bfd_boolean pr_class_start_method (void *, const char *); +static bfd_boolean pr_class_method_variant + (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean, + bfd_vma, bfd_boolean); +static bfd_boolean pr_class_static_method_variant + (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean); +static bfd_boolean pr_class_end_method (void *); +static bfd_boolean pr_end_class_type (void *); +static bfd_boolean pr_typedef_type (void *, const char *); +static bfd_boolean pr_tag_type + (void *, const char *, unsigned int, enum debug_type_kind); +static bfd_boolean pr_typdef (void *, const char *); +static bfd_boolean pr_tag (void *, const char *); +static bfd_boolean pr_int_constant (void *, const char *, bfd_vma); +static bfd_boolean pr_float_constant (void *, const char *, double); +static bfd_boolean pr_typed_constant (void *, const char *, bfd_vma); +static bfd_boolean pr_variable + (void *, const char *, enum debug_var_kind, bfd_vma); +static bfd_boolean pr_start_function (void *, const char *, bfd_boolean); +static bfd_boolean pr_function_parameter + (void *, const char *, enum debug_parm_kind, bfd_vma); +static bfd_boolean pr_start_block (void *, bfd_vma); +static bfd_boolean pr_end_block (void *, bfd_vma); +static bfd_boolean pr_end_function (void *); +static bfd_boolean pr_lineno (void *, const char *, unsigned long, bfd_vma); +static bfd_boolean append_parent (struct pr_handle *, const char *); +/* Only used by tg_ code. */ +static bfd_boolean tg_fix_visibility + (struct pr_handle *, enum debug_visibility); +static void find_address_in_section (bfd *, asection *, void *); +static void translate_addresses (bfd *, char *, FILE *, asymbol **); +static const char *visibility_name (enum debug_visibility); +/* Tags style replacements. */ +static bfd_boolean tg_start_compilation_unit (void *, const char *); +static bfd_boolean tg_start_source (void *, const char *); +static bfd_boolean tg_enum_type + (void *, const char *, const char **, bfd_signed_vma *); +static bfd_boolean tg_start_struct_type + (void *, const char *, unsigned int, bfd_boolean, unsigned int); +static bfd_boolean pr_struct_field + (void *, const char *, bfd_vma, bfd_vma, enum debug_visibility); +static bfd_boolean tg_struct_field + (void *, const char *, bfd_vma, bfd_vma, enum debug_visibility); +static bfd_boolean tg_struct_field + (void *, const char *, bfd_vma, bfd_vma, enum debug_visibility); +static bfd_boolean tg_end_struct_type (void *); +static bfd_boolean tg_start_class_type + (void *, const char *, unsigned int, bfd_boolean, unsigned int, bfd_boolean, bfd_boolean); +static bfd_boolean tg_class_static_member + (void *, const char *, const char *, enum debug_visibility); +static bfd_boolean tg_class_baseclass + (void *, bfd_vma, bfd_boolean, enum debug_visibility); +static bfd_boolean tg_class_method_variant + (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean, bfd_vma, bfd_boolean); +static bfd_boolean tg_class_static_method_variant + (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean); +static bfd_boolean tg_end_class_type (void *); +static bfd_boolean tg_tag_type + (void *, const char *, unsigned int, enum debug_type_kind); +static bfd_boolean tg_typdef (void *, const char *); +static bfd_boolean tg_tag (void *, const char *); +static bfd_boolean tg_int_constant (void *, const char *, bfd_vma); +static bfd_boolean tg_float_constant (void *, const char *, double); +static bfd_boolean tg_typed_constant (void *, const char *, bfd_vma); +static bfd_boolean tg_variable + (void *, const char *, enum debug_var_kind, bfd_vma); +static bfd_boolean tg_start_function (void *, const char *, bfd_boolean); +static bfd_boolean tg_function_parameter + (void *, const char *, enum debug_parm_kind, bfd_vma); +static bfd_boolean tg_start_block (void *, bfd_vma); +static bfd_boolean tg_end_block (void *, bfd_vma); +static bfd_boolean tg_lineno (void *, const char *, unsigned long, bfd_vma); + +static const struct debug_write_fns pr_fns = +{ + pr_start_compilation_unit, + pr_start_source, + pr_empty_type, + pr_void_type, + pr_int_type, + pr_float_type, + pr_complex_type, + pr_bool_type, + pr_enum_type, + pr_pointer_type, + pr_function_type, + pr_reference_type, + pr_range_type, + pr_array_type, + pr_set_type, + pr_offset_type, + pr_method_type, + pr_const_type, + pr_volatile_type, + pr_start_struct_type, + pr_struct_field, + pr_end_struct_type, + pr_start_class_type, + pr_class_static_member, + pr_class_baseclass, + pr_class_start_method, + pr_class_method_variant, + pr_class_static_method_variant, + pr_class_end_method, + pr_end_class_type, + pr_typedef_type, + pr_tag_type, + pr_typdef, + pr_tag, + pr_int_constant, + pr_float_constant, + pr_typed_constant, + pr_variable, + pr_start_function, + pr_function_parameter, + pr_start_block, + pr_end_block, + pr_end_function, + pr_lineno +}; + +static const struct debug_write_fns tg_fns = +{ + tg_start_compilation_unit, + tg_start_source, + pr_empty_type, /* Same, push_type. */ + pr_void_type, /* Same, push_type. */ + pr_int_type, /* Same, push_type. */ + pr_float_type, /* Same, push_type. */ + pr_complex_type, /* Same, push_type. */ + pr_bool_type, /* Same, push_type. */ + tg_enum_type, + pr_pointer_type, /* Same, changes to pointer. */ + pr_function_type, /* Same, push_type. */ + pr_reference_type, /* Same, changes to reference. */ + pr_range_type, /* FIXME: What's that?. */ + pr_array_type, /* Same, push_type. */ + pr_set_type, /* FIXME: What's that?. */ + pr_offset_type, /* FIXME: What's that?. */ + pr_method_type, /* Same. */ + pr_const_type, /* Same, changes to const. */ + pr_volatile_type, /* Same, changes to volatile. */ + tg_start_struct_type, + tg_struct_field, + tg_end_struct_type, + tg_start_class_type, + tg_class_static_member, + tg_class_baseclass, + pr_class_start_method, /* Same, remembers that's a method. */ + tg_class_method_variant, + tg_class_static_method_variant, + pr_class_end_method, /* Same, forgets that's a method. */ + tg_end_class_type, + pr_typedef_type, /* Same, just push type. */ + tg_tag_type, + tg_typdef, + tg_tag, + tg_int_constant, /* Untested. */ + tg_float_constant, /* Untested. */ + tg_typed_constant, /* Untested. */ + tg_variable, + tg_start_function, + tg_function_parameter, + tg_start_block, + tg_end_block, + pr_end_function, /* Same, does nothing. */ + tg_lineno +}; + +/* Print out the generic debugging information recorded in dhandle. */ + +bfd_boolean +print_debugging_info (FILE *f, void *dhandle, bfd *abfd, asymbol **syms, + char * (*demangler) (struct bfd *, const char *, int), + bfd_boolean as_tags) +{ + struct pr_handle info; + + info.f = f; + info.indent = 0; + info.stack = NULL; + info.parameter = 0; + info.filename = NULL; + info.abfd = abfd; + info.syms = syms; + info.demangler = demangler; + + if (as_tags) + { + fputs ("!_TAG_FILE_FORMAT\t2\t/extended format/\n", f); + fputs ("!_TAG_FILE_SORTED\t0\t/0=unsorted, 1=sorted/\n", f); + fputs ("!_TAG_PROGRAM_AUTHOR\tIan Lance Taylor, Salvador E. Tropea and others\t//\n", f); + fputs ("!_TAG_PROGRAM_NAME\tobjdump\t/From GNU binutils/\n", f); + } + + return as_tags ? debug_write (dhandle, &tg_fns, (void *) & info) + : debug_write (dhandle, &pr_fns, (void *) & info); +} + +/* Indent to the current indentation level. */ + +static void +indent (struct pr_handle *info) +{ + unsigned int i; + + for (i = 0; i < info->indent; i++) + putc (' ', info->f); +} + +/* Push a type on the type stack. */ + +static bfd_boolean +push_type (struct pr_handle *info, const char *type) +{ + struct pr_stack *n; + + if (type == NULL) + return FALSE; + + n = (struct pr_stack *) xmalloc (sizeof *n); + memset (n, 0, sizeof *n); + + n->type = xstrdup (type); + n->visibility = DEBUG_VISIBILITY_IGNORE; + n->method = NULL; + n->next = info->stack; + info->stack = n; + + return TRUE; +} + +/* Prepend a string onto the type on the top of the type stack. */ + +static bfd_boolean +prepend_type (struct pr_handle *info, const char *s) +{ + char *n; + + assert (info->stack != NULL); + + n = (char *) xmalloc (strlen (s) + strlen (info->stack->type) + 1); + sprintf (n, "%s%s", s, info->stack->type); + free (info->stack->type); + info->stack->type = n; + + return TRUE; +} + +/* Append a string to the type on the top of the type stack. */ + +static bfd_boolean +append_type (struct pr_handle *info, const char *s) +{ + unsigned int len; + + if (s == NULL) + return FALSE; + + assert (info->stack != NULL); + + len = strlen (info->stack->type); + info->stack->type = (char *) xrealloc (info->stack->type, + len + strlen (s) + 1); + strcpy (info->stack->type + len, s); + + return TRUE; +} + +/* Append a string to the parents on the top of the type stack. */ + +static bfd_boolean +append_parent (struct pr_handle *info, const char *s) +{ + unsigned int len; + + if (s == NULL) + return FALSE; + + assert (info->stack != NULL); + + len = info->stack->parents ? strlen (info->stack->parents) : 0; + info->stack->parents = (char *) xrealloc (info->stack->parents, + len + strlen (s) + 1); + strcpy (info->stack->parents + len, s); + + return TRUE; +} + +/* We use an underscore to indicate where the name should go in a type + string. This function substitutes a string for the underscore. If + there is no underscore, the name follows the type. */ + +static bfd_boolean +substitute_type (struct pr_handle *info, const char *s) +{ + char *u; + + assert (info->stack != NULL); + + u = strchr (info->stack->type, '|'); + if (u != NULL) + { + char *n; + + n = (char *) xmalloc (strlen (info->stack->type) + strlen (s)); + + memcpy (n, info->stack->type, u - info->stack->type); + strcpy (n + (u - info->stack->type), s); + strcat (n, u + 1); + + free (info->stack->type); + info->stack->type = n; + + return TRUE; + } + + if (strchr (s, '|') != NULL + && (strchr (info->stack->type, '{') != NULL + || strchr (info->stack->type, '(') != NULL)) + { + if (! prepend_type (info, "(") + || ! append_type (info, ")")) + return FALSE; + } + + if (*s == '\0') + return TRUE; + + return (append_type (info, " ") + && append_type (info, s)); +} + +/* Indent the type at the top of the stack by appending spaces. */ + +static bfd_boolean +indent_type (struct pr_handle *info) +{ + unsigned int i; + + for (i = 0; i < info->indent; i++) + { + if (! append_type (info, " ")) + return FALSE; + } + + return TRUE; +} + +/* Pop a type from the type stack. */ + +static char * +pop_type (struct pr_handle *info) +{ + struct pr_stack *o; + char *ret; + + assert (info->stack != NULL); + + o = info->stack; + info->stack = o->next; + ret = o->type; + free (o); + + return ret; +} + +/* Print a VMA value into a string. */ + +static void +print_vma (bfd_vma vma, char *buf, bfd_boolean unsignedp, bfd_boolean hexp) +{ + if (sizeof (vma) <= sizeof (unsigned long)) + { + if (hexp) + sprintf (buf, "0x%lx", (unsigned long) vma); + else if (unsignedp) + sprintf (buf, "%lu", (unsigned long) vma); + else + sprintf (buf, "%ld", (long) vma); + } +#if BFD_HOST_64BIT_LONG_LONG + else if (sizeof (vma) <= sizeof (unsigned long long)) + { +#ifndef __MSVCRT__ + if (hexp) + sprintf (buf, "0x%llx", (unsigned long long) vma); + else if (unsignedp) + sprintf (buf, "%llu", (unsigned long long) vma); + else + sprintf (buf, "%lld", (long long) vma); +#else + if (hexp) + sprintf (buf, "0x%I64x", (unsigned long long) vma); + else if (unsignedp) + sprintf (buf, "%I64u", (unsigned long long) vma); + else + sprintf (buf, "%I64d", (long long) vma); +#endif + } +#endif + else + { + buf[0] = '0'; + buf[1] = 'x'; + sprintf_vma (buf + 2, vma); + } +} + +/* Start a new compilation unit. */ + +static bfd_boolean +pr_start_compilation_unit (void *p, const char *filename) +{ + struct pr_handle *info = (struct pr_handle *) p; + + assert (info->indent == 0); + + fprintf (info->f, "%s:\n", filename); + + return TRUE; +} + +/* Start a source file within a compilation unit. */ + +static bfd_boolean +pr_start_source (void *p, const char *filename) +{ + struct pr_handle *info = (struct pr_handle *) p; + + assert (info->indent == 0); + + fprintf (info->f, " %s:\n", filename); + + return TRUE; +} + +/* Push an empty type onto the type stack. */ + +static bfd_boolean +pr_empty_type (void *p) +{ + struct pr_handle *info = (struct pr_handle *) p; + + return push_type (info, ""); +} + +/* Push a void type onto the type stack. */ + +static bfd_boolean +pr_void_type (void *p) +{ + struct pr_handle *info = (struct pr_handle *) p; + + return push_type (info, "void"); +} + +/* Push an integer type onto the type stack. */ + +static bfd_boolean +pr_int_type (void *p, unsigned int size, bfd_boolean unsignedp) +{ + struct pr_handle *info = (struct pr_handle *) p; + char ab[40]; + + sprintf (ab, "%sint%d", unsignedp ? "u" : "", size * 8); + return push_type (info, ab); +} + +/* Push a floating type onto the type stack. */ + +static bfd_boolean +pr_float_type (void *p, unsigned int size) +{ + struct pr_handle *info = (struct pr_handle *) p; + char ab[40]; + + if (size == 4) + return push_type (info, "float"); + else if (size == 8) + return push_type (info, "double"); + + sprintf (ab, "float%d", size * 8); + return push_type (info, ab); +} + +/* Push a complex type onto the type stack. */ + +static bfd_boolean +pr_complex_type (void *p, unsigned int size) +{ + struct pr_handle *info = (struct pr_handle *) p; + + if (! pr_float_type (p, size)) + return FALSE; + + return prepend_type (info, "complex "); +} + +/* Push a bfd_boolean type onto the type stack. */ + +static bfd_boolean +pr_bool_type (void *p, unsigned int size) +{ + struct pr_handle *info = (struct pr_handle *) p; + char ab[40]; + + sprintf (ab, "bool%d", size * 8); + + return push_type (info, ab); +} + +/* Push an enum type onto the type stack. */ + +static bfd_boolean +pr_enum_type (void *p, const char *tag, const char **names, + bfd_signed_vma *values) +{ + struct pr_handle *info = (struct pr_handle *) p; + unsigned int i; + bfd_signed_vma val; + + if (! push_type (info, "enum ")) + return FALSE; + if (tag != NULL) + { + if (! append_type (info, tag) + || ! append_type (info, " ")) + return FALSE; + } + if (! append_type (info, "{ ")) + return FALSE; + + if (names == NULL) + { + if (! append_type (info, "/* undefined */")) + return FALSE; + } + else + { + val = 0; + for (i = 0; names[i] != NULL; i++) + { + if (i > 0) + { + if (! append_type (info, ", ")) + return FALSE; + } + + if (! append_type (info, names[i])) + return FALSE; + + if (values[i] != val) + { + char ab[22]; + + print_vma (values[i], ab, FALSE, FALSE); + if (! append_type (info, " = ") + || ! append_type (info, ab)) + return FALSE; + val = values[i]; + } + + ++val; + } + } + + return append_type (info, " }"); +} + +/* Turn the top type on the stack into a pointer. */ + +static bfd_boolean +pr_pointer_type (void *p) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *s; + + assert (info->stack != NULL); + + s = strchr (info->stack->type, '|'); + if (s != NULL && s[1] == '[') + return substitute_type (info, "(*|)"); + return substitute_type (info, "*|"); +} + +/* Turn the top type on the stack into a function returning that type. */ + +static bfd_boolean +pr_function_type (void *p, int argcount, bfd_boolean varargs) +{ + struct pr_handle *info = (struct pr_handle *) p; + char **arg_types; + unsigned int len; + char *s; + + assert (info->stack != NULL); + + len = 10; + + if (argcount <= 0) + { + arg_types = NULL; + len += 15; + } + else + { + int i; + + arg_types = (char **) xmalloc (argcount * sizeof *arg_types); + for (i = argcount - 1; i >= 0; i--) + { + if (! substitute_type (info, "")) + { + free (arg_types); + return FALSE; + } + arg_types[i] = pop_type (info); + if (arg_types[i] == NULL) + { + free (arg_types); + return FALSE; + } + len += strlen (arg_types[i]) + 2; + } + if (varargs) + len += 5; + } + + /* Now the return type is on the top of the stack. */ + + s = (char *) xmalloc (len); + LITSTRCPY (s, "(|) ("); + + if (argcount < 0) + strcat (s, "/* unknown */"); + else + { + int i; + + for (i = 0; i < argcount; i++) + { + if (i > 0) + strcat (s, ", "); + strcat (s, arg_types[i]); + } + if (varargs) + { + if (i > 0) + strcat (s, ", "); + strcat (s, "..."); + } + if (argcount > 0) + free (arg_types); + } + + strcat (s, ")"); + + if (! substitute_type (info, s)) + return FALSE; + + free (s); + + return TRUE; +} + +/* Turn the top type on the stack into a reference to that type. */ + +static bfd_boolean +pr_reference_type (void *p) +{ + struct pr_handle *info = (struct pr_handle *) p; + + assert (info->stack != NULL); + + return substitute_type (info, "&|"); +} + +/* Make a range type. */ + +static bfd_boolean +pr_range_type (void *p, bfd_signed_vma lower, bfd_signed_vma upper) +{ + struct pr_handle *info = (struct pr_handle *) p; + char abl[22], abu[22]; + + assert (info->stack != NULL); + + if (! substitute_type (info, "")) + return FALSE; + + print_vma (lower, abl, FALSE, FALSE); + print_vma (upper, abu, FALSE, FALSE); + + return (prepend_type (info, "range (") + && append_type (info, "):") + && append_type (info, abl) + && append_type (info, ":") + && append_type (info, abu)); +} + +/* Make an array type. */ + +static bfd_boolean +pr_array_type (void *p, bfd_signed_vma lower, bfd_signed_vma upper, + bfd_boolean stringp) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *range_type; + char abl[22], abu[22], ab[50]; + + range_type = pop_type (info); + if (range_type == NULL) + return FALSE; + + if (lower == 0) + { + if (upper == -1) + sprintf (ab, "|[]"); + else + { + print_vma (upper + 1, abu, FALSE, FALSE); + sprintf (ab, "|[%s]", abu); + } + } + else + { + print_vma (lower, abl, FALSE, FALSE); + print_vma (upper, abu, FALSE, FALSE); + sprintf (ab, "|[%s:%s]", abl, abu); + } + + if (! substitute_type (info, ab)) + return FALSE; + + if (strcmp (range_type, "int") != 0) + { + if (! append_type (info, ":") + || ! append_type (info, range_type)) + return FALSE; + } + + if (stringp) + { + if (! append_type (info, " /* string */")) + return FALSE; + } + + return TRUE; +} + +/* Make a set type. */ + +static bfd_boolean +pr_set_type (void *p, bfd_boolean bitstringp) +{ + struct pr_handle *info = (struct pr_handle *) p; + + if (! substitute_type (info, "")) + return FALSE; + + if (! prepend_type (info, "set { ") + || ! append_type (info, " }")) + return FALSE; + + if (bitstringp) + { + if (! append_type (info, "/* bitstring */")) + return FALSE; + } + + return TRUE; +} + +/* Make an offset type. */ + +static bfd_boolean +pr_offset_type (void *p) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + + if (! substitute_type (info, "")) + return FALSE; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + return (substitute_type (info, "") + && prepend_type (info, " ") + && prepend_type (info, t) + && append_type (info, "::|")); +} + +/* Make a method type. */ + +static bfd_boolean +pr_method_type (void *p, bfd_boolean domain, int argcount, bfd_boolean varargs) +{ + struct pr_handle *info = (struct pr_handle *) p; + unsigned int len; + char *domain_type; + char **arg_types; + char *s; + + len = 10; + + if (! domain) + domain_type = NULL; + else + { + if (! substitute_type (info, "")) + return FALSE; + domain_type = pop_type (info); + if (domain_type == NULL) + return FALSE; + if (CONST_STRNEQ (domain_type, "class ") + && strchr (domain_type + sizeof "class " - 1, ' ') == NULL) + domain_type += sizeof "class " - 1; + else if (CONST_STRNEQ (domain_type, "union class ") + && (strchr (domain_type + sizeof "union class " - 1, ' ') + == NULL)) + domain_type += sizeof "union class " - 1; + len += strlen (domain_type); + } + + if (argcount <= 0) + { + arg_types = NULL; + len += 15; + } + else + { + int i; + + arg_types = (char **) xmalloc (argcount * sizeof *arg_types); + for (i = argcount - 1; i >= 0; i--) + { + if (! substitute_type (info, "")) + { + free (arg_types); + return FALSE; + } + arg_types[i] = pop_type (info); + if (arg_types[i] == NULL) + { + free (arg_types); + return FALSE; + } + len += strlen (arg_types[i]) + 2; + } + if (varargs) + len += 5; + } + + /* Now the return type is on the top of the stack. */ + + s = (char *) xmalloc (len); + if (! domain) + *s = '\0'; + else + strcpy (s, domain_type); + strcat (s, "::| ("); + + if (argcount < 0) + strcat (s, "/* unknown */"); + else + { + int i; + + for (i = 0; i < argcount; i++) + { + if (i > 0) + strcat (s, ", "); + strcat (s, arg_types[i]); + } + if (varargs) + { + if (i > 0) + strcat (s, ", "); + strcat (s, "..."); + } + if (argcount > 0) + free (arg_types); + } + + strcat (s, ")"); + + if (! substitute_type (info, s)) + return FALSE; + + free (s); + + return TRUE; +} + +/* Make a const qualified type. */ + +static bfd_boolean +pr_const_type (void *p) +{ + struct pr_handle *info = (struct pr_handle *) p; + + return substitute_type (info, "const |"); +} + +/* Make a volatile qualified type. */ + +static bfd_boolean +pr_volatile_type (void *p) +{ + struct pr_handle *info = (struct pr_handle *) p; + + return substitute_type (info, "volatile |"); +} + +/* Start accumulating a struct type. */ + +static bfd_boolean +pr_start_struct_type (void *p, const char *tag, unsigned int id, + bfd_boolean structp, unsigned int size) +{ + struct pr_handle *info = (struct pr_handle *) p; + + info->indent += 2; + + if (! push_type (info, structp ? "struct " : "union ")) + return FALSE; + if (tag != NULL) + { + if (! append_type (info, tag)) + return FALSE; + } + else + { + char idbuf[20]; + + sprintf (idbuf, "%%anon%u", id); + if (! append_type (info, idbuf)) + return FALSE; + } + + if (! append_type (info, " {")) + return FALSE; + if (size != 0 || tag != NULL) + { + char ab[30]; + + if (! append_type (info, " /*")) + return FALSE; + + if (size != 0) + { + sprintf (ab, " size %u", size); + if (! append_type (info, ab)) + return FALSE; + } + if (tag != NULL) + { + sprintf (ab, " id %u", id); + if (! append_type (info, ab)) + return FALSE; + } + if (! append_type (info, " */")) + return FALSE; + } + if (! append_type (info, "\n")) + return FALSE; + + info->stack->visibility = DEBUG_VISIBILITY_PUBLIC; + + return indent_type (info); +} + +/* Output the visibility of a field in a struct. */ + +static bfd_boolean +pr_fix_visibility (struct pr_handle *info, enum debug_visibility visibility) +{ + const char *s = NULL; + char *t; + unsigned int len; + + assert (info->stack != NULL); + + if (info->stack->visibility == visibility) + return TRUE; + + switch (visibility) + { + case DEBUG_VISIBILITY_PUBLIC: + s = "public"; + break; + case DEBUG_VISIBILITY_PRIVATE: + s = "private"; + break; + case DEBUG_VISIBILITY_PROTECTED: + s = "protected"; + break; + case DEBUG_VISIBILITY_IGNORE: + s = "/* ignore */"; + break; + default: + abort (); + return FALSE; + } + + /* Trim off a trailing space in the struct string, to make the + output look a bit better, then stick on the visibility string. */ + + t = info->stack->type; + len = strlen (t); + assert (t[len - 1] == ' '); + t[len - 1] = '\0'; + + if (! append_type (info, s) + || ! append_type (info, ":\n") + || ! indent_type (info)) + return FALSE; + + info->stack->visibility = visibility; + + return TRUE; +} + +/* Add a field to a struct type. */ + +static bfd_boolean +pr_struct_field (void *p, const char *name, bfd_vma bitpos, bfd_vma bitsize, + enum debug_visibility visibility) +{ + struct pr_handle *info = (struct pr_handle *) p; + char ab[22]; + char *t; + + if (! substitute_type (info, name)) + return FALSE; + + if (! append_type (info, "; /* ")) + return FALSE; + + if (bitsize != 0) + { + print_vma (bitsize, ab, TRUE, FALSE); + if (! append_type (info, "bitsize ") + || ! append_type (info, ab) + || ! append_type (info, ", ")) + return FALSE; + } + + print_vma (bitpos, ab, TRUE, FALSE); + if (! append_type (info, "bitpos ") + || ! append_type (info, ab) + || ! append_type (info, " */\n") + || ! indent_type (info)) + return FALSE; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + if (! pr_fix_visibility (info, visibility)) + return FALSE; + + return append_type (info, t); +} + +/* Finish a struct type. */ + +static bfd_boolean +pr_end_struct_type (void *p) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *s; + + assert (info->stack != NULL); + assert (info->indent >= 2); + + info->indent -= 2; + + /* Change the trailing indentation to have a close brace. */ + s = info->stack->type + strlen (info->stack->type) - 2; + assert (s[0] == ' ' && s[1] == ' ' && s[2] == '\0'); + + *s++ = '}'; + *s = '\0'; + + return TRUE; +} + +/* Start a class type. */ + +static bfd_boolean +pr_start_class_type (void *p, const char *tag, unsigned int id, + bfd_boolean structp, unsigned int size, + bfd_boolean vptr, bfd_boolean ownvptr) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *tv = NULL; + + info->indent += 2; + + if (vptr && ! ownvptr) + { + tv = pop_type (info); + if (tv == NULL) + return FALSE; + } + + if (! push_type (info, structp ? "class " : "union class ")) + return FALSE; + if (tag != NULL) + { + if (! append_type (info, tag)) + return FALSE; + } + else + { + char idbuf[20]; + + sprintf (idbuf, "%%anon%u", id); + if (! append_type (info, idbuf)) + return FALSE; + } + + if (! append_type (info, " {")) + return FALSE; + if (size != 0 || vptr || ownvptr || tag != NULL) + { + if (! append_type (info, " /*")) + return FALSE; + + if (size != 0) + { + char ab[20]; + + sprintf (ab, "%u", size); + if (! append_type (info, " size ") + || ! append_type (info, ab)) + return FALSE; + } + + if (vptr) + { + if (! append_type (info, " vtable ")) + return FALSE; + if (ownvptr) + { + if (! append_type (info, "self ")) + return FALSE; + } + else + { + if (! append_type (info, tv) + || ! append_type (info, " ")) + return FALSE; + } + } + + if (tag != NULL) + { + char ab[30]; + + sprintf (ab, " id %u", id); + if (! append_type (info, ab)) + return FALSE; + } + + if (! append_type (info, " */")) + return FALSE; + } + + info->stack->visibility = DEBUG_VISIBILITY_PRIVATE; + + return (append_type (info, "\n") + && indent_type (info)); +} + +/* Add a static member to a class. */ + +static bfd_boolean +pr_class_static_member (void *p, const char *name, const char *physname, + enum debug_visibility visibility) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + + if (! substitute_type (info, name)) + return FALSE; + + if (! prepend_type (info, "static ") + || ! append_type (info, "; /* ") + || ! append_type (info, physname) + || ! append_type (info, " */\n") + || ! indent_type (info)) + return FALSE; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + if (! pr_fix_visibility (info, visibility)) + return FALSE; + + return append_type (info, t); +} + +/* Add a base class to a class. */ + +static bfd_boolean +pr_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean is_virtual, + enum debug_visibility visibility) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + const char *prefix; + char ab[22]; + char *s, *l, *n; + + assert (info->stack != NULL && info->stack->next != NULL); + + if (! substitute_type (info, "")) + return FALSE; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + if (CONST_STRNEQ (t, "class ")) + t += sizeof "class " - 1; + + /* Push it back on to take advantage of the prepend_type and + append_type routines. */ + if (! push_type (info, t)) + return FALSE; + + if (is_virtual) + { + if (! prepend_type (info, "virtual ")) + return FALSE; + } + + switch (visibility) + { + case DEBUG_VISIBILITY_PUBLIC: + prefix = "public "; + break; + case DEBUG_VISIBILITY_PROTECTED: + prefix = "protected "; + break; + case DEBUG_VISIBILITY_PRIVATE: + prefix = "private "; + break; + default: + prefix = "/* unknown visibility */ "; + break; + } + + if (! prepend_type (info, prefix)) + return FALSE; + + if (bitpos != 0) + { + print_vma (bitpos, ab, TRUE, FALSE); + if (! append_type (info, " /* bitpos ") + || ! append_type (info, ab) + || ! append_type (info, " */")) + return FALSE; + } + + /* Now the top of the stack is something like "public A / * bitpos + 10 * /". The next element on the stack is something like "class + xx { / * size 8 * /\n...". We want to substitute the top of the + stack in before the {. */ + s = strchr (info->stack->next->type, '{'); + assert (s != NULL); + --s; + + /* If there is already a ':', then we already have a baseclass, and + we must append this one after a comma. */ + for (l = info->stack->next->type; l != s; l++) + if (*l == ':') + break; + if (! prepend_type (info, l == s ? " : " : ", ")) + return FALSE; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + n = (char *) xmalloc (strlen (info->stack->type) + strlen (t) + 1); + memcpy (n, info->stack->type, s - info->stack->type); + strcpy (n + (s - info->stack->type), t); + strcat (n, s); + + free (info->stack->type); + info->stack->type = n; + + free (t); + + return TRUE; +} + +/* Start adding a method to a class. */ + +static bfd_boolean +pr_class_start_method (void *p, const char *name) +{ + struct pr_handle *info = (struct pr_handle *) p; + + assert (info->stack != NULL); + info->stack->method = name; + return TRUE; +} + +/* Add a variant to a method. */ + +static bfd_boolean +pr_class_method_variant (void *p, const char *physname, + enum debug_visibility visibility, + bfd_boolean constp, bfd_boolean volatilep, + bfd_vma voffset, bfd_boolean context) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *method_type; + char *context_type; + + assert (info->stack != NULL); + assert (info->stack->next != NULL); + + /* Put the const and volatile qualifiers on the type. */ + if (volatilep) + { + if (! append_type (info, " volatile")) + return FALSE; + } + if (constp) + { + if (! append_type (info, " const")) + return FALSE; + } + + /* Stick the name of the method into its type. */ + if (! substitute_type (info, + (context + ? info->stack->next->next->method + : info->stack->next->method))) + return FALSE; + + /* Get the type. */ + method_type = pop_type (info); + if (method_type == NULL) + return FALSE; + + /* Pull off the context type if there is one. */ + if (! context) + context_type = NULL; + else + { + context_type = pop_type (info); + if (context_type == NULL) + return FALSE; + } + + /* Now the top of the stack is the class. */ + + if (! pr_fix_visibility (info, visibility)) + return FALSE; + + if (! append_type (info, method_type) + || ! append_type (info, " /* ") + || ! append_type (info, physname) + || ! append_type (info, " ")) + return FALSE; + if (context || voffset != 0) + { + char ab[22]; + + if (context) + { + if (! append_type (info, "context ") + || ! append_type (info, context_type) + || ! append_type (info, " ")) + return FALSE; + } + print_vma (voffset, ab, TRUE, FALSE); + if (! append_type (info, "voffset ") + || ! append_type (info, ab)) + return FALSE; + } + + return (append_type (info, " */;\n") + && indent_type (info)); +} + +/* Add a static variant to a method. */ + +static bfd_boolean +pr_class_static_method_variant (void *p, const char *physname, + enum debug_visibility visibility, + bfd_boolean constp, bfd_boolean volatilep) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *method_type; + + assert (info->stack != NULL); + assert (info->stack->next != NULL); + assert (info->stack->next->method != NULL); + + /* Put the const and volatile qualifiers on the type. */ + if (volatilep) + { + if (! append_type (info, " volatile")) + return FALSE; + } + if (constp) + { + if (! append_type (info, " const")) + return FALSE; + } + + /* Mark it as static. */ + if (! prepend_type (info, "static ")) + return FALSE; + + /* Stick the name of the method into its type. */ + if (! substitute_type (info, info->stack->next->method)) + return FALSE; + + /* Get the type. */ + method_type = pop_type (info); + if (method_type == NULL) + return FALSE; + + /* Now the top of the stack is the class. */ + + if (! pr_fix_visibility (info, visibility)) + return FALSE; + + return (append_type (info, method_type) + && append_type (info, " /* ") + && append_type (info, physname) + && append_type (info, " */;\n") + && indent_type (info)); +} + +/* Finish up a method. */ + +static bfd_boolean +pr_class_end_method (void *p) +{ + struct pr_handle *info = (struct pr_handle *) p; + + info->stack->method = NULL; + return TRUE; +} + +/* Finish up a class. */ + +static bfd_boolean +pr_end_class_type (void *p) +{ + return pr_end_struct_type (p); +} + +/* Push a type on the stack using a typedef name. */ + +static bfd_boolean +pr_typedef_type (void *p, const char *name) +{ + struct pr_handle *info = (struct pr_handle *) p; + + return push_type (info, name); +} + +/* Push a type on the stack using a tag name. */ + +static bfd_boolean +pr_tag_type (void *p, const char *name, unsigned int id, + enum debug_type_kind kind) +{ + struct pr_handle *info = (struct pr_handle *) p; + const char *t, *tag; + char idbuf[22]; + + switch (kind) + { + case DEBUG_KIND_STRUCT: + t = "struct "; + break; + case DEBUG_KIND_UNION: + t = "union "; + break; + case DEBUG_KIND_ENUM: + t = "enum "; + break; + case DEBUG_KIND_CLASS: + t = "class "; + break; + case DEBUG_KIND_UNION_CLASS: + t = "union class "; + break; + default: + abort (); + return FALSE; + } + + if (! push_type (info, t)) + return FALSE; + if (name != NULL) + tag = name; + else + { + sprintf (idbuf, "%%anon%u", id); + tag = idbuf; + } + + if (! append_type (info, tag)) + return FALSE; + if (name != NULL && kind != DEBUG_KIND_ENUM) + { + sprintf (idbuf, " /* id %u */", id); + if (! append_type (info, idbuf)) + return FALSE; + } + + return TRUE; +} + +/* Output a typedef. */ + +static bfd_boolean +pr_typdef (void *p, const char *name) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *s; + + if (! substitute_type (info, name)) + return FALSE; + + s = pop_type (info); + if (s == NULL) + return FALSE; + + indent (info); + fprintf (info->f, "typedef %s;\n", s); + + free (s); + + return TRUE; +} + +/* Output a tag. The tag should already be in the string on the + stack, so all we have to do here is print it out. */ + +static bfd_boolean +pr_tag (void *p, const char *name ATTRIBUTE_UNUSED) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + indent (info); + fprintf (info->f, "%s;\n", t); + + free (t); + + return TRUE; +} + +/* Output an integer constant. */ + +static bfd_boolean +pr_int_constant (void *p, const char *name, bfd_vma val) +{ + struct pr_handle *info = (struct pr_handle *) p; + char ab[22]; + + indent (info); + print_vma (val, ab, FALSE, FALSE); + fprintf (info->f, "const int %s = %s;\n", name, ab); + return TRUE; +} + +/* Output a floating point constant. */ + +static bfd_boolean +pr_float_constant (void *p, const char *name, double val) +{ + struct pr_handle *info = (struct pr_handle *) p; + + indent (info); + fprintf (info->f, "const double %s = %g;\n", name, val); + return TRUE; +} + +/* Output a typed constant. */ + +static bfd_boolean +pr_typed_constant (void *p, const char *name, bfd_vma val) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + char ab[22]; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + indent (info); + print_vma (val, ab, FALSE, FALSE); + fprintf (info->f, "const %s %s = %s;\n", t, name, ab); + + free (t); + + return TRUE; +} + +/* Output a variable. */ + +static bfd_boolean +pr_variable (void *p, const char *name, enum debug_var_kind kind, + bfd_vma val) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + char ab[22]; + + if (! substitute_type (info, name)) + return FALSE; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + indent (info); + switch (kind) + { + case DEBUG_STATIC: + case DEBUG_LOCAL_STATIC: + fprintf (info->f, "static "); + break; + case DEBUG_REGISTER: + fprintf (info->f, "register "); + break; + default: + break; + } + print_vma (val, ab, TRUE, TRUE); + fprintf (info->f, "%s /* %s */;\n", t, ab); + + free (t); + + return TRUE; +} + +/* Start outputting a function. */ + +static bfd_boolean +pr_start_function (void *p, const char *name, bfd_boolean global) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + + if (! substitute_type (info, name)) + return FALSE; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + indent (info); + if (! global) + fprintf (info->f, "static "); + fprintf (info->f, "%s (", t); + + info->parameter = 1; + + return TRUE; +} + +/* Output a function parameter. */ + +static bfd_boolean +pr_function_parameter (void *p, const char *name, + enum debug_parm_kind kind, bfd_vma val) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + char ab[22]; + + if (kind == DEBUG_PARM_REFERENCE + || kind == DEBUG_PARM_REF_REG) + { + if (! pr_reference_type (p)) + return FALSE; + } + + if (! substitute_type (info, name)) + return FALSE; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + if (info->parameter != 1) + fprintf (info->f, ", "); + + if (kind == DEBUG_PARM_REG || kind == DEBUG_PARM_REF_REG) + fprintf (info->f, "register "); + + print_vma (val, ab, TRUE, TRUE); + fprintf (info->f, "%s /* %s */", t, ab); + + free (t); + + ++info->parameter; + + return TRUE; +} + +/* Start writing out a block. */ + +static bfd_boolean +pr_start_block (void *p, bfd_vma addr) +{ + struct pr_handle *info = (struct pr_handle *) p; + char ab[22]; + + if (info->parameter > 0) + { + fprintf (info->f, ")\n"); + info->parameter = 0; + } + + indent (info); + print_vma (addr, ab, TRUE, TRUE); + fprintf (info->f, "{ /* %s */\n", ab); + + info->indent += 2; + + return TRUE; +} + +/* Write out line number information. */ + +static bfd_boolean +pr_lineno (void *p, const char *filename, unsigned long lineno, bfd_vma addr) +{ + struct pr_handle *info = (struct pr_handle *) p; + char ab[22]; + + indent (info); + print_vma (addr, ab, TRUE, TRUE); + fprintf (info->f, "/* file %s line %lu addr %s */\n", filename, lineno, ab); + + return TRUE; +} + +/* Finish writing out a block. */ + +static bfd_boolean +pr_end_block (void *p, bfd_vma addr) +{ + struct pr_handle *info = (struct pr_handle *) p; + char ab[22]; + + info->indent -= 2; + + indent (info); + print_vma (addr, ab, TRUE, TRUE); + fprintf (info->f, "} /* %s */\n", ab); + + return TRUE; +} + +/* Finish writing out a function. */ + +static bfd_boolean +pr_end_function (void *p ATTRIBUTE_UNUSED) +{ + return TRUE; +} + +/* Tags style generation functions start here. */ + +/* Variables for address to line translation. */ +static bfd_vma pc; +static const char *filename; +static const char *functionname; +static unsigned int line; +static bfd_boolean found; + +/* Look for an address in a section. This is called via + bfd_map_over_sections. */ + +static void +find_address_in_section (bfd *abfd, asection *section, void *data) +{ + bfd_vma vma; + bfd_size_type size; + asymbol **syms = (asymbol **) data; + + if (found) + return; + + if ((bfd_get_section_flags (abfd, section) & SEC_ALLOC) == 0) + return; + + vma = bfd_get_section_vma (abfd, section); + if (pc < vma) + return; + + size = bfd_get_section_size (section); + if (pc >= vma + size) + return; + + found = bfd_find_nearest_line (abfd, section, syms, pc - vma, + &filename, &functionname, &line); +} + +static void +translate_addresses (bfd *abfd, char *addr_hex, FILE *f, asymbol **syms) +{ + pc = bfd_scan_vma (addr_hex, NULL, 16); + found = FALSE; + bfd_map_over_sections (abfd, find_address_in_section, syms); + + if (! found) + fprintf (f, "??"); + else + fprintf (f, "%u", line); +} + +/* Start a new compilation unit. */ + +static bfd_boolean +tg_start_compilation_unit (void * p, const char *fname ATTRIBUTE_UNUSED) +{ + struct pr_handle *info = (struct pr_handle *) p; + + free (info->filename); + /* Should it be relative? best way to do it here?. */ + info->filename = strdup (fname); + + return TRUE; +} + +/* Start a source file within a compilation unit. */ + +static bfd_boolean +tg_start_source (void *p, const char *fname) +{ + struct pr_handle *info = (struct pr_handle *) p; + + free (info->filename); + /* Should it be relative? best way to do it here?. */ + info->filename = strdup (fname); + + return TRUE; +} + +/* Push an enum type onto the type stack. */ + +static bfd_boolean +tg_enum_type (void *p, const char *tag, const char **names, + bfd_signed_vma *values) +{ + struct pr_handle *info = (struct pr_handle *) p; + unsigned int i; + const char *name; + char ab[22]; + + if (! pr_enum_type (p, tag, names, values)) + return FALSE; + + name = tag ? tag : "unknown"; + /* Generate an entry for the enum. */ + if (tag) + fprintf (info->f, "%s\t%s\t0;\"\tkind:e\ttype:%s\n", tag, + info->filename, info->stack->type); + + /* Generate entries for the values. */ + if (names != NULL) + { + for (i = 0; names[i] != NULL; i++) + { + print_vma (values[i], ab, FALSE, FALSE); + fprintf (info->f, "%s\t%s\t0;\"\tkind:g\tenum:%s\tvalue:%s\n", + names[i], info->filename, name, ab); + } + } + + return TRUE; +} + +/* Start accumulating a struct type. */ + +static bfd_boolean +tg_start_struct_type (void *p, const char *tag, unsigned int id, + bfd_boolean structp, + unsigned int size ATTRIBUTE_UNUSED) +{ + struct pr_handle *info = (struct pr_handle *) p; + const char *name; + char idbuf[20]; + + if (tag != NULL) + name = tag; + else + { + name = idbuf; + sprintf (idbuf, "%%anon%u", id); + } + + if (! push_type (info, name)) + return FALSE; + + info->stack->flavor = structp ? "struct" : "union"; + + fprintf (info->f, "%s\t%s\t0;\"\tkind:%c\n", name, info->filename, + info->stack->flavor[0]); + + info->stack->visibility = DEBUG_VISIBILITY_PUBLIC; + + return indent_type (info); +} + +/* Output the visibility of a field in a struct. */ + +static bfd_boolean +tg_fix_visibility (struct pr_handle *info, enum debug_visibility visibility) +{ + assert (info->stack != NULL); + + if (info->stack->visibility == visibility) + return TRUE; + + assert (info->stack->visibility != DEBUG_VISIBILITY_IGNORE); + + info->stack->visibility = visibility; + + return TRUE; +} + +/* Add a field to a struct type. */ + +static bfd_boolean +tg_struct_field (void *p, const char *name, bfd_vma bitpos ATTRIBUTE_UNUSED, + bfd_vma bitsize ATTRIBUTE_UNUSED, + enum debug_visibility visibility) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + if (! tg_fix_visibility (info, visibility)) + return FALSE; + + /* It happens, a bug? */ + if (! name[0]) + return TRUE; + + fprintf (info->f, "%s\t%s\t0;\"\tkind:m\ttype:%s\t%s:%s\taccess:%s\n", + name, info->filename, t, info->stack->flavor, info->stack->type, + visibility_name (visibility)); + + return TRUE; +} + +/* Finish a struct type. */ + +static bfd_boolean +tg_end_struct_type (void *p ATTRIBUTE_UNUSED) +{ + assert (((struct pr_handle *) p)->stack != NULL); + + return TRUE; +} + +/* Start a class type. */ + +static bfd_boolean +tg_start_class_type (void *p, const char *tag, unsigned int id, + bfd_boolean structp, unsigned int size, + bfd_boolean vptr, bfd_boolean ownvptr) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *tv = NULL; + const char *name; + + info->indent += 2; + + if (vptr && ! ownvptr) + { + tv = pop_type (info); + if (tv == NULL) + return FALSE; + } + + if (tag != NULL) + name = tag; + else + { + char idbuf[20]; + + sprintf (idbuf, "%%anon%u", id); + name = idbuf; + } + + if (! push_type (info, name)) + return FALSE; + + info->stack->flavor = structp ? "class" : "union class"; + info->stack->parents = NULL; + info->stack->num_parents = 0; + + if (size != 0 || vptr || ownvptr || tag != NULL) + { + if (vptr) + { + if (! append_type (info, " vtable ")) + return FALSE; + if (ownvptr) + { + if (! append_type (info, "self ")) + return FALSE; + } + else + { + if (! append_type (info, tv) + || ! append_type (info, " ")) + return FALSE; + } + } + } + + info->stack->visibility = DEBUG_VISIBILITY_PRIVATE; + + return TRUE; +} + +/* Add a static member to a class. */ + +static bfd_boolean +tg_class_static_member (void *p, const char *name, + const char *physname ATTRIBUTE_UNUSED, + enum debug_visibility visibility) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + int len_var, len_class; + char *full_name; + + len_var = strlen (name); + len_class = strlen (info->stack->next->type); + full_name = (char *) xmalloc (len_var + len_class + 3); + if (! full_name) + return FALSE; + sprintf (full_name, "%s::%s", info->stack->next->type, name); + + if (! substitute_type (info, full_name)) + { + free (full_name); + return FALSE; + } + + if (! prepend_type (info, "static ")) + { + free (full_name); + return FALSE; + } + + t = pop_type (info); + if (t == NULL) + { + free (full_name); + return FALSE; + } + + if (! tg_fix_visibility (info, visibility)) + { + free (t); + free (full_name); + return FALSE; + } + + fprintf (info->f, "%s\t%s\t0;\"\tkind:x\ttype:%s\tclass:%s\taccess:%s\n", + name, info->filename, t, info->stack->type, + visibility_name (visibility)); + free (t); + free (full_name); + + return TRUE; +} + +/* Add a base class to a class. */ + +static bfd_boolean +tg_class_baseclass (void *p, bfd_vma bitpos ATTRIBUTE_UNUSED, + bfd_boolean is_virtual, enum debug_visibility visibility) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + const char *prefix; + + assert (info->stack != NULL && info->stack->next != NULL); + + t = pop_type (info); + if (t == NULL) + return FALSE; + + if (CONST_STRNEQ (t, "class ")) + t += sizeof "class " - 1; + + /* Push it back on to take advantage of the prepend_type and + append_type routines. */ + if (! push_type (info, t)) + return FALSE; + + if (is_virtual) + { + if (! prepend_type (info, "virtual ")) + return FALSE; + } + + switch (visibility) + { + case DEBUG_VISIBILITY_PUBLIC: + prefix = "public "; + break; + case DEBUG_VISIBILITY_PROTECTED: + prefix = "protected "; + break; + case DEBUG_VISIBILITY_PRIVATE: + prefix = "private "; + break; + default: + prefix = "/* unknown visibility */ "; + break; + } + + if (! prepend_type (info, prefix)) + return FALSE; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + if (info->stack->num_parents && ! append_parent (info, ", ")) + return FALSE; + + if (! append_parent (info, t)) + return FALSE; + info->stack->num_parents++; + + free (t); + + return TRUE; +} + +/* Add a variant to a method. */ + +static bfd_boolean +tg_class_method_variant (void *p, const char *physname ATTRIBUTE_UNUSED, + enum debug_visibility visibility, + bfd_boolean constp, bfd_boolean volatilep, + bfd_vma voffset ATTRIBUTE_UNUSED, + bfd_boolean context) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *method_type; + char *context_type; + char *method_name; + + assert (info->stack != NULL); + assert (info->stack->next != NULL); + + /* Put the const and volatile qualifiers on the type. */ + if (volatilep) + { + if (! append_type (info, " volatile")) + return FALSE; + } + if (constp) + { + if (! append_type (info, " const")) + return FALSE; + } + + method_name = strdup (context ? info->stack->next->next->method + : info->stack->next->method); + + /* Stick the name of the method into its type. */ + if (! substitute_type (info, method_name)) + { + free (method_name); + return FALSE; + } + + /* Get the type. */ + method_type = pop_type (info); + if (method_type == NULL) + { + free (method_name); + return FALSE; + } + + /* Pull off the context type if there is one. */ + if (! context) + context_type = NULL; + else + { + context_type = pop_type (info); + if (context_type == NULL) + { + free (method_type); + free (method_name); + return FALSE; + } + } + + /* Now the top of the stack is the class. */ + if (! tg_fix_visibility (info, visibility)) + { + free (method_type); + free (method_name); + free (context_type); + return FALSE; + } + + fprintf (info->f, "%s\t%s\t0;\"\tkind:p\ttype:%s\tclass:%s\n", + method_name, info->filename, method_type, info->stack->type); + free (method_type); + free (method_name); + free (context_type); + + return TRUE; +} + +/* Add a static variant to a method. */ + +static bfd_boolean +tg_class_static_method_variant (void *p, + const char *physname ATTRIBUTE_UNUSED, + enum debug_visibility visibility, + bfd_boolean constp, bfd_boolean volatilep) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *method_type; + char *method_name; + + assert (info->stack != NULL); + assert (info->stack->next != NULL); + assert (info->stack->next->method != NULL); + + /* Put the const and volatile qualifiers on the type. */ + if (volatilep) + { + if (! append_type (info, " volatile")) + return FALSE; + } + if (constp) + { + if (! append_type (info, " const")) + return FALSE; + } + + /* Mark it as static. */ + if (! prepend_type (info, "static ")) + return FALSE; + + method_name = strdup (info->stack->next->method); + /* Stick the name of the method into its type. */ + if (! substitute_type (info, info->stack->next->method)) + { + free (method_name); + return FALSE; + } + + /* Get the type. */ + method_type = pop_type (info); + if (method_type == NULL) + { + free (method_name); + return FALSE; + } + + /* Now the top of the stack is the class. */ + if (! tg_fix_visibility (info, visibility)) + { + free (method_type); + free (method_name); + return FALSE; + } + + fprintf (info->f, "%s\t%s\t0;\"\tkind:p\ttype:%s\tclass:%s\taccess:%s\n", + method_name, info->filename, method_type, info->stack->type, + visibility_name (visibility)); + free (method_type); + free (method_name); + + return TRUE; +} + +/* Finish up a class. */ + +static bfd_boolean +tg_end_class_type (void *p) +{ + struct pr_handle *info = (struct pr_handle *) p; + + fprintf (info->f, "%s\t%s\t0;\"\tkind:c\ttype:%s", info->stack->type, + info->filename, info->stack->flavor); + if (info->stack->num_parents) + { + fprintf (info->f, "\tinherits:%s", info->stack->parents); + free (info->stack->parents); + } + fputc ('\n', info->f); + + return tg_end_struct_type (p); +} + +/* Push a type on the stack using a tag name. */ + +static bfd_boolean +tg_tag_type (void *p, const char *name, unsigned int id, + enum debug_type_kind kind) +{ + struct pr_handle *info = (struct pr_handle *) p; + const char *t, *tag; + char idbuf[20]; + + switch (kind) + { + case DEBUG_KIND_STRUCT: + t = "struct "; + break; + case DEBUG_KIND_UNION: + t = "union "; + break; + case DEBUG_KIND_ENUM: + t = "enum "; + break; + case DEBUG_KIND_CLASS: + t = "class "; + break; + case DEBUG_KIND_UNION_CLASS: + t = "union class "; + break; + default: + abort (); + return FALSE; + } + + if (! push_type (info, t)) + return FALSE; + if (name != NULL) + tag = name; + else + { + sprintf (idbuf, "%%anon%u", id); + tag = idbuf; + } + + if (! append_type (info, tag)) + return FALSE; + + return TRUE; +} + +/* Output a typedef. */ + +static bfd_boolean +tg_typdef (void *p, const char *name) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *s; + + s = pop_type (info); + if (s == NULL) + return FALSE; + + fprintf (info->f, "%s\t%s\t0;\"\tkind:t\ttype:%s\n", name, + info->filename, s); + + free (s); + + return TRUE; +} + +/* Output a tag. The tag should already be in the string on the + stack, so all we have to do here is print it out. */ + +static bfd_boolean +tg_tag (void *p ATTRIBUTE_UNUSED, const char *name ATTRIBUTE_UNUSED) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + + t = pop_type (info); + if (t == NULL) + return FALSE; + free (t); + + return TRUE; +} + +/* Output an integer constant. */ + +static bfd_boolean +tg_int_constant (void *p, const char *name, bfd_vma val) +{ + struct pr_handle *info = (struct pr_handle *) p; + char ab[22]; + + indent (info); + print_vma (val, ab, FALSE, FALSE); + fprintf (info->f, "%s\t%s\t0;\"\tkind:v\ttype:const int\tvalue:%s\n", + name, info->filename, ab); + return TRUE; +} + +/* Output a floating point constant. */ + +static bfd_boolean +tg_float_constant (void *p, const char *name, double val) +{ + struct pr_handle *info = (struct pr_handle *) p; + + indent (info); + fprintf (info->f, "%s\t%s\t0;\"\tkind:v\ttype:const double\tvalue:%g\n", + name, info->filename, val); + return TRUE; +} + +/* Output a typed constant. */ + +static bfd_boolean +tg_typed_constant (void *p, const char *name, bfd_vma val) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + char ab[22]; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + indent (info); + print_vma (val, ab, FALSE, FALSE); + fprintf (info->f, "%s\t%s\t0;\"\tkind:v\ttype:const %s\tvalue:%s\n", + name, info->filename, t, ab); + + free (t); + + return TRUE; +} + +/* Output a variable. */ + +static bfd_boolean +tg_variable (void *p, const char *name, enum debug_var_kind kind, + bfd_vma val ATTRIBUTE_UNUSED) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t, *dname, *from_class; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + dname = NULL; + if (info->demangler) + dname = info->demangler (info->abfd, name, DMGL_ANSI | DMGL_PARAMS); + + from_class = NULL; + if (dname != NULL) + { + char *sep; + sep = strstr (dname, "::"); + if (sep) + { + *sep = 0; + name = sep + 2; + from_class = dname; + } + else + /* Obscure types as vts and type_info nodes. */ + name = dname; + } + + fprintf (info->f, "%s\t%s\t0;\"\tkind:v\ttype:%s", name, info->filename, t); + + switch (kind) + { + case DEBUG_STATIC: + case DEBUG_LOCAL_STATIC: + fprintf (info->f, "\tfile:"); + break; + case DEBUG_REGISTER: + fprintf (info->f, "\tregister:"); + break; + default: + break; + } + + if (from_class) + fprintf (info->f, "\tclass:%s", from_class); + + if (dname) + free (dname); + + fprintf (info->f, "\n"); + + free (t); + + return TRUE; +} + +/* Start outputting a function. */ + +static bfd_boolean +tg_start_function (void *p, const char *name, bfd_boolean global) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *dname; + + if (! global) + info->stack->flavor = "static"; + else + info->stack->flavor = NULL; + + dname = NULL; + if (info->demangler) + dname = info->demangler (info->abfd, name, DMGL_ANSI | DMGL_PARAMS); + + if (! substitute_type (info, dname ? dname : name)) + return FALSE; + + info->stack->method = NULL; + if (dname != NULL) + { + char *sep; + sep = strstr (dname, "::"); + if (sep) + { + info->stack->method = dname; + *sep = 0; + name = sep + 2; + } + else + { + info->stack->method = ""; + name = dname; + } + sep = strchr (name, '('); + if (sep) + *sep = 0; + /* Obscure functions as type_info function. */ + } + + info->stack->parents = strdup (name); + + if (! info->stack->method && ! append_type (info, "(")) + return FALSE; + + info->parameter = 1; + + return TRUE; +} + +/* Output a function parameter. */ + +static bfd_boolean +tg_function_parameter (void *p, const char *name, enum debug_parm_kind kind, + bfd_vma val ATTRIBUTE_UNUSED) +{ + struct pr_handle *info = (struct pr_handle *) p; + char *t; + + if (kind == DEBUG_PARM_REFERENCE + || kind == DEBUG_PARM_REF_REG) + { + if (! pr_reference_type (p)) + return FALSE; + } + + if (! substitute_type (info, name)) + return FALSE; + + t = pop_type (info); + if (t == NULL) + return FALSE; + + if (! info->stack->method) + { + if (info->parameter != 1 && ! append_type (info, ", ")) + return FALSE; + + if (kind == DEBUG_PARM_REG || kind == DEBUG_PARM_REF_REG) + if (! append_type (info, "register ")) + return FALSE; + + if (! append_type (info, t)) + return FALSE; + } + + free (t); + + ++info->parameter; + + return TRUE; +} + +/* Start writing out a block. */ + +static bfd_boolean +tg_start_block (void *p, bfd_vma addr) +{ + struct pr_handle *info = (struct pr_handle *) p; + char ab[22], kind, *partof; + char *t; + bfd_boolean local; + + if (info->parameter > 0) + { + info->parameter = 0; + + /* Delayed name. */ + fprintf (info->f, "%s\t%s\t", info->stack->parents, info->filename); + free (info->stack->parents); + + print_vma (addr, ab, TRUE, TRUE); + translate_addresses (info->abfd, ab, info->f, info->syms); + local = info->stack->flavor != NULL; + if (info->stack->method && *info->stack->method) + { + kind = 'm'; + partof = (char *) info->stack->method; + } + else + { + kind = 'f'; + partof = NULL; + if (! info->stack->method && ! append_type (info, ")")) + return FALSE; + } + t = pop_type (info); + if (t == NULL) + return FALSE; + fprintf (info->f, ";\"\tkind:%c\ttype:%s", kind, t); + if (local) + fputs ("\tfile:", info->f); + if (partof) + { + fprintf (info->f, "\tclass:%s", partof); + free (partof); + } + fputc ('\n', info->f); + } + + return TRUE; +} + +/* Write out line number information. */ + +static bfd_boolean +tg_lineno (void *p ATTRIBUTE_UNUSED, const char *fname ATTRIBUTE_UNUSED, + unsigned long lineno ATTRIBUTE_UNUSED, + bfd_vma addr ATTRIBUTE_UNUSED) +{ + return TRUE; +} + +/* Finish writing out a block. */ + +static bfd_boolean +tg_end_block (void *p ATTRIBUTE_UNUSED, bfd_vma addr ATTRIBUTE_UNUSED) +{ + return TRUE; +} + +/* Convert the visibility value into a human readable name. */ + +static const char * +visibility_name (enum debug_visibility visibility) +{ + const char *s; + + switch (visibility) + { + case DEBUG_VISIBILITY_PUBLIC: + s = "public"; + break; + case DEBUG_VISIBILITY_PRIVATE: + s = "private"; + break; + case DEBUG_VISIBILITY_PROTECTED: + s = "protected"; + break; + case DEBUG_VISIBILITY_IGNORE: + s = "/* ignore */"; + break; + default: + abort (); + return FALSE; + } + return s; +} diff --git a/support/sdbinutils/binutils/ranlib.sh b/support/sdbinutils/binutils/ranlib.sh new file mode 100755 index 0000000..8873c2d --- /dev/null +++ b/support/sdbinutils/binutils/ranlib.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# A simple ranlib script, to use less disk space than a ranlib program. +# Copyright (C) 2004-2018 Free Software Foundation, Inc. + +# This program is part of GNU Binutils. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. */ + +ar s "$1" diff --git a/support/sdbinutils/binutils/rclex.c b/support/sdbinutils/binutils/rclex.c new file mode 100644 index 0000000..8db499f --- /dev/null +++ b/support/sdbinutils/binutils/rclex.c @@ -0,0 +1,904 @@ +/* rclex.c -- lexer for Windows rc files parser */ + +/* Copyright (C) 1997-2018 Free Software Foundation, Inc. + + Written by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + + +/* This is a lexer used by the Windows rc file parser. It basically + just recognized a bunch of keywords. */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" +#include "libiberty.h" +#include "safe-ctype.h" +#include "windres.h" +#include "rcparse.h" + +#include + +/* Whether we are in rcdata mode, in which we returns the lengths of + strings. */ + +static int rcdata_mode; + +/* Whether we are suppressing lines from cpp (including windows.h or + headers from your C sources may bring in externs and typedefs). + When active, we return IGNORED_TOKEN, which lets us ignore these + outside of resource constructs. Thus, it isn't required to protect + all the non-preprocessor lines in your header files with #ifdef + RC_INVOKED. It also means your RC file can't include other RC + files if they're named "*.h". Sorry. Name them *.rch or whatever. */ + +static int suppress_cpp_data; + +#define IGNORE_CPP(x) (suppress_cpp_data ? IGNORED_TOKEN : (x)) + +/* The first filename we detect in the cpp output. We use this to + tell included files from the original file. */ + +static char *initial_fn; + +/* List of allocated strings. */ + +struct alloc_string +{ + struct alloc_string *next; + char *s; +}; + +static struct alloc_string *strings; + +struct rclex_keywords +{ + const char *name; + int tok; +}; + +#define K(KEY) { #KEY, KEY } +#define KRT(KEY) { #KEY, RT_##KEY } + +static const struct rclex_keywords keywds[] = +{ + K(ACCELERATORS), K(ALT), K(ANICURSOR), K(ANIICON), K(ASCII), + K(AUTO3STATE), K(AUTOCHECKBOX), K(AUTORADIOBUTTON), + K(BEDIT), { "BEGIN", BEG }, K(BITMAP), K(BLOCK), K(BUTTON), + K(CAPTION), K(CHARACTERISTICS), K(CHECKBOX), K(CHECKED), + K(CLASS), K(COMBOBOX), K(CONTROL), K(CTEXT), K(CURSOR), + K(DEFPUSHBUTTON), K(DIALOG), K(DIALOGEX), K(DISCARDABLE), + K(DLGINCLUDE), K(DLGINIT), + K(EDITTEXT), K(END), K(EXSTYLE), + K(FILEFLAGS), K(FILEFLAGSMASK), K(FILEOS), K(FILESUBTYPE), + K(FILETYPE), K(FILEVERSION), K(FIXED), K(FONT), K(FONTDIR), + K(GRAYED), KRT(GROUP_CURSOR), KRT(GROUP_ICON), K(GROUPBOX), + K(HEDIT), K(HELP), K(HTML), + K(ICON), K(IEDIT), K(IMPURE), K(INACTIVE), + K(LANGUAGE), K(LISTBOX), K(LOADONCALL), K(LTEXT), + K(MANIFEST), K(MENU), K(MENUBARBREAK), K(MENUBREAK), + K(MENUEX), K(MENUITEM), K(MESSAGETABLE), K(MOVEABLE), + K(NOINVERT), K(NOT), + K(PLUGPLAY), K(POPUP), K(PRELOAD), K(PRODUCTVERSION), + K(PURE), K(PUSHBOX), K(PUSHBUTTON), + K(RADIOBUTTON), K(RCDATA), K(RTEXT), + K(SCROLLBAR), K(SEPARATOR), K(SHIFT), K(STATE3), + K(STRINGTABLE), K(STYLE), + K(TOOLBAR), + K(USERBUTTON), + K(VALUE), { "VERSION", VERSIONK }, K(VERSIONINFO), + K(VIRTKEY), K(VXD), + { NULL, 0 }, +}; + +/* External input stream from resrc */ +extern FILE *cpp_pipe; + +/* Lexical scanner helpers. */ +static int rclex_lastch = -1; +static size_t rclex_tok_max = 0; +static size_t rclex_tok_pos = 0; +static char *rclex_tok = NULL; + +static int +rclex_translatekeyword (const char *key) +{ + if (key && ISUPPER (key[0])) + { + const struct rclex_keywords *kw = &keywds[0]; + + do + { + if (! strcmp (kw->name, key)) + return kw->tok; + ++kw; + } + while (kw->name != NULL); + } + return STRING; +} + +/* Handle a C preprocessor line. */ + +static void +cpp_line (void) +{ + const char *s = rclex_tok; + int line; + char *send, *fn; + size_t len, mlen; + + ++s; + while (ISSPACE (*s)) + ++s; + + /* Check for #pragma code_page ( DEFAULT | ). */ + len = strlen (s); + mlen = strlen ("pragma"); + if (len > mlen && memcmp (s, "pragma", mlen) == 0 && ISSPACE (s[mlen])) + { + const char *end; + + s += mlen + 1; + while (ISSPACE (*s)) + ++s; + len = strlen (s); + mlen = strlen ("code_page"); + if (len <= mlen || memcmp (s, "code_page", mlen) != 0) + /* FIXME: We ought to issue a warning message about an unrecognised pragma. */ + return; + s += mlen; + while (ISSPACE (*s)) + ++s; + if (*s != '(') + /* FIXME: We ought to issue an error message about a malformed pragma. */ + return; + ++s; + while (ISSPACE (*s)) + ++s; + if (*s == 0 || (end = strchr (s, ')')) == NULL) + /* FIXME: We ought to issue an error message about a malformed pragma. */ + return; + len = (size_t) (end - s); + fn = xmalloc (len + 1); + if (len) + memcpy (fn, s, len); + fn[len] = 0; + while (len > 0 && (fn[len - 1] > 0 && fn[len - 1] <= 0x20)) + fn[--len] = 0; + if (! len || (len == strlen ("DEFAULT") && strcasecmp (fn, "DEFAULT") == 0)) + wind_current_codepage = wind_default_codepage; + else if (len > 0) + { + rc_uint_type ncp; + + if (fn[0] == '0' && (fn[1] == 'x' || fn[1] == 'X')) + ncp = (rc_uint_type) strtol (fn + 2, NULL, 16); + else + ncp = (rc_uint_type) strtol (fn, NULL, 10); + if (ncp == CP_UTF16 || ! unicode_is_valid_codepage (ncp)) + fatal (_("invalid value specified for pragma code_page.\n")); + wind_current_codepage = ncp; + } + free (fn); + return; + } + + line = strtol (s, &send, 0); + if (*send != '\0' && ! ISSPACE (*send)) + return; + + /* Subtract 1 because we are about to count the newline. */ + rc_lineno = line - 1; + + s = send; + while (ISSPACE (*s)) + ++s; + + if (*s != '"') + return; + + ++s; + send = strchr (s, '"'); + if (send == NULL) + return; + + fn = xmalloc (send - s + 1); + strncpy (fn, s, send - s); + fn[send - s] = '\0'; + + free (rc_filename); + rc_filename = fn; + + if (! initial_fn) + { + initial_fn = xmalloc (strlen (fn) + 1); + strcpy (initial_fn, fn); + } + + /* Allow the initial file, regardless of name. Suppress all other + files if they end in ".h" (this allows included "*.rc"). */ + if (strcmp (initial_fn, fn) == 0 + || strcmp (fn + strlen (fn) - 2, ".h") != 0) + suppress_cpp_data = 0; + else + suppress_cpp_data = 1; +} + +/* Allocate a string of a given length. */ + +static char * +get_string (int len) +{ + struct alloc_string *as; + + as = xmalloc (sizeof *as); + as->s = xmalloc (len); + + as->next = strings; + strings = as; + + return as->s; +} + +/* Handle a quoted string. The quotes are stripped. A pair of quotes + in a string are turned into a single quote. Adjacent strings are + merged separated by whitespace are merged, as in C. */ + +static char * +handle_quotes (rc_uint_type *len) +{ + const char *input = rclex_tok; + char *ret, *s; + const char *t; + int ch; + int num_xdigits; + + ret = get_string (strlen (input) + 1); + + s = ret; + t = input; + if (*t == '"') + ++t; + while (*t != '\0') + { + if (*t == '\\') + { + ++t; + switch (*t) + { + case '\0': + rcparse_warning ("backslash at end of string"); + break; + + case '\"': + rcparse_warning ("use \"\" to put \" in a string"); + *s++ = '"'; + ++t; + break; + + case 'a': + *s++ = ESCAPE_B; /* Strange, but true... */ + ++t; + break; + + case 'b': + *s++ = ESCAPE_B; + ++t; + break; + + case 'f': + *s++ = ESCAPE_F; + ++t; + break; + + case 'n': + *s++ = ESCAPE_N; + ++t; + break; + + case 'r': + *s++ = ESCAPE_R; + ++t; + break; + + case 't': + *s++ = ESCAPE_T; + ++t; + break; + + case 'v': + *s++ = ESCAPE_V; + ++t; + break; + + case '\\': + *s++ = *t++; + break; + + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + ch = *t - '0'; + ++t; + if (*t >= '0' && *t <= '7') + { + ch = (ch << 3) | (*t - '0'); + ++t; + if (*t >= '0' && *t <= '7') + { + ch = (ch << 3) | (*t - '0'); + ++t; + } + } + *s++ = ch; + break; + + case 'x': case 'X': + ++t; + ch = 0; + /* We only handle single byte chars here. Make sure + we finish an escape sequence like "/xB0ABC" after + the first two digits. */ + num_xdigits = 2; + while (num_xdigits--) + { + if (*t >= '0' && *t <= '9') + ch = (ch << 4) | (*t - '0'); + else if (*t >= 'a' && *t <= 'f') + ch = (ch << 4) | (*t - 'a' + 10); + else if (*t >= 'A' && *t <= 'F') + ch = (ch << 4) | (*t - 'A' + 10); + else + break; + ++t; + } + *s++ = ch; + break; + + default: + rcparse_warning ("unrecognized escape sequence"); + *s++ = '\\'; + *s++ = *t++; + break; + } + } + else if (*t != '"') + *s++ = *t++; + else if (t[1] == '\0') + break; + else if (t[1] == '"') + { + *s++ = '"'; + t += 2; + } + else + { + ++t; + if (! ISSPACE (*t)) + rcparse_warning ("unexpected character after '\"'"); + while (ISSPACE (*t)) + { + if ((*t) == '\n') + ++rc_lineno; + ++t; + } + if (*t == '\0') + break; + assert (*t == '"'); + ++t; + } + } + + *s = '\0'; + + *len = s - ret; + + return ret; +} + +/* Allocate a unicode string of a given length. */ + +static unichar * +get_unistring (int len) +{ + return (unichar *) get_string (len * sizeof (unichar)); +} + +/* Handle a quoted unicode string. The quotes are stripped. A pair of quotes + in a string are turned into a single quote. Adjacent strings are + merged separated by whitespace are merged, as in C. */ + +static unichar * +handle_uniquotes (rc_uint_type *len) +{ + const char *input = rclex_tok; + unichar *ret, *s; + const char *t; + int ch; + int num_xdigits; + + ret = get_unistring (strlen (input) + 1); + + s = ret; + t = input; + if ((*t == 'L' || *t == 'l') && t[1] == '"') + t += 2; + else if (*t == '"') + ++t; + while (*t != '\0') + { + if (*t == '\\') + { + ++t; + switch (*t) + { + case '\0': + rcparse_warning ("backslash at end of string"); + break; + + case '\"': + rcparse_warning ("use \"\" to put \" in a string"); + break; + + case 'a': + *s++ = ESCAPE_B; /* Strange, but true... */ + ++t; + break; + + case 'b': + *s++ = ESCAPE_B; + ++t; + break; + + case 'f': + *s++ = ESCAPE_F; + ++t; + break; + + case 'n': + *s++ = ESCAPE_N; + ++t; + break; + + case 'r': + *s++ = ESCAPE_R; + ++t; + break; + + case 't': + *s++ = ESCAPE_T; + ++t; + break; + + case 'v': + *s++ = ESCAPE_V; + ++t; + break; + + case '\\': + *s++ = (unichar) *t++; + break; + + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + ch = *t - '0'; + ++t; + if (*t >= '0' && *t <= '7') + { + ch = (ch << 3) | (*t - '0'); + ++t; + if (*t >= '0' && *t <= '7') + { + ch = (ch << 3) | (*t - '0'); + ++t; + } + } + *s++ = (unichar) ch; + break; + + case 'x': case 'X': + ++t; + ch = 0; + /* We only handle two byte chars here. Make sure + we finish an escape sequence like "/xB0ABC" after + the first two digits. */ + num_xdigits = 4; + while (num_xdigits--) + { + if (*t >= '0' && *t <= '9') + ch = (ch << 4) | (*t - '0'); + else if (*t >= 'a' && *t <= 'f') + ch = (ch << 4) | (*t - 'a' + 10); + else if (*t >= 'A' && *t <= 'F') + ch = (ch << 4) | (*t - 'A' + 10); + else + break; + ++t; + } + *s++ = (unichar) ch; + break; + + default: + rcparse_warning ("unrecognized escape sequence"); + *s++ = '\\'; + *s++ = (unichar) *t++; + break; + } + } + else if (*t != '"') + *s++ = (unichar) *t++; + else if (t[1] == '\0') + break; + else if (t[1] == '"') + { + *s++ = '"'; + t += 2; + } + else + { + ++t; + assert (ISSPACE (*t)); + while (ISSPACE (*t)) + { + if ((*t) == '\n') + ++rc_lineno; + ++t; + } + if (*t == '\0') + break; + assert (*t == '"'); + ++t; + } + } + + *s = '\0'; + + *len = s - ret; + + return ret; +} + +/* Discard all the strings we have allocated. The parser calls this + when it no longer needs them. */ + +void +rcparse_discard_strings (void) +{ + struct alloc_string *as; + + as = strings; + while (as != NULL) + { + struct alloc_string *n; + + free (as->s); + n = as->next; + free (as); + as = n; + } + + strings = NULL; +} + +/* Enter rcdata mode. */ +void +rcparse_rcdata (void) +{ + rcdata_mode = 1; +} + +/* Go back to normal mode from rcdata mode. */ +void +rcparse_normal (void) +{ + rcdata_mode = 0; +} + +static void +rclex_tok_add_char (int ch) +{ + if (! rclex_tok || rclex_tok_max <= rclex_tok_pos) + { + char *h = xmalloc (rclex_tok_max + 9); + + if (! h) + abort (); + if (rclex_tok) + { + memcpy (h, rclex_tok, rclex_tok_pos + 1); + free (rclex_tok); + } + else + rclex_tok_pos = 0; + rclex_tok_max += 8; + rclex_tok = h; + } + if (ch != -1) + rclex_tok[rclex_tok_pos++] = (char) ch; + rclex_tok[rclex_tok_pos] = 0; +} + +static int +rclex_readch (void) +{ + int r = -1; + + if ((r = rclex_lastch) != -1) + rclex_lastch = -1; + else + { + char ch; + do + { + if (! cpp_pipe || feof (cpp_pipe) + || fread (&ch, 1, 1,cpp_pipe) != 1) + break; + r = ((int) ch) & 0xff; + } + while (r == 0 || r == '\r'); + } + rclex_tok_add_char (r); + return r; +} + +static int +rclex_peekch (void) +{ + int r; + + if ((r = rclex_lastch) == -1) + { + if ((r = rclex_readch ()) != -1) + { + rclex_lastch = r; + if (rclex_tok_pos > 0) + rclex_tok[--rclex_tok_pos] = 0; + } + } + return r; +} + +static void +rclex_string (void) +{ + int c; + + while ((c = rclex_peekch ()) != -1) + { + if (c == '\n') + break; + if (c == '\\') + { + rclex_readch (); + if ((c = rclex_peekch ()) == -1 || c == '\n') + break; + rclex_readch (); + } + else if (rclex_readch () == '"') + { + /* PR 6714 + Skip any whitespace after the end of the double quotes. */ + do + { + c = rclex_peekch (); + if (ISSPACE (c)) + rclex_readch (); + else + c = -1; + } + while (c != -1); + + if (rclex_peekch () == '"') + rclex_readch (); + else + break; + } + } +} + +static rc_uint_type +read_digit (int ch) +{ + rc_uint_type base = 10; + rc_uint_type ret, val; + int warned = 0; + + ret = 0; + if (ch == '0') + { + base = 8; + switch (rclex_peekch ()) + { + case 'o': case 'O': + rclex_readch (); + base = 8; + break; + + case 'x': case 'X': + rclex_readch (); + base = 16; + break; + } + } + else + ret = (rc_uint_type) (ch - '0'); + while ((ch = rclex_peekch ()) != -1) + { + if (ISDIGIT (ch)) + val = (rc_uint_type) (ch - '0'); + else if (ch >= 'a' && ch <= 'f') + val = (rc_uint_type) ((ch - 'a') + 10); + else if (ch >= 'A' && ch <= 'F') + val = (rc_uint_type) ((ch - 'A') + 10); + else + break; + rclex_readch (); + if (! warned && val >= base) + { + warned = 1; + rcparse_warning ("digit exceeds base"); + } + ret *= base; + ret += val; + } + return ret; +} + +/* yyparser entry method. */ + +int +yylex (void) +{ + char *s; + unichar *us; + rc_uint_type length; + int ch; + + /* Make sure that rclex_tok is initialized. */ + if (! rclex_tok) + rclex_tok_add_char (-1); + + do + { + do + { + /* Clear token. */ + rclex_tok_pos = 0; + rclex_tok[0] = 0; + + if ((ch = rclex_readch ()) == -1) + return -1; + if (ch == '\n') + ++rc_lineno; + } + while (ch <= 0x20); + + switch (ch) + { + case '#': + while ((ch = rclex_peekch ()) != -1 && ch != '\n') + rclex_readch (); + cpp_line (); + ch = IGNORED_TOKEN; + break; + + case '{': + ch = IGNORE_CPP (BEG); + break; + + case '}': + ch = IGNORE_CPP (END); + break; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + yylval.i.val = read_digit (ch); + yylval.i.dword = 0; + switch (rclex_peekch ()) + { + case 'l': case 'L': + rclex_readch (); + yylval.i.dword = 1; + break; + } + ch = IGNORE_CPP (NUMBER); + break; + case '"': + rclex_string (); + ch = IGNORE_CPP ((! rcdata_mode ? QUOTEDSTRING : SIZEDSTRING)); + if (ch == IGNORED_TOKEN) + break; + s = handle_quotes (&length); + if (! rcdata_mode) + yylval.s = s; + else + { + yylval.ss.length = length; + yylval.ss.s = s; + } + break; + case 'L': case 'l': + if (rclex_peekch () == '"') + { + rclex_readch (); + rclex_string (); + ch = IGNORE_CPP ((! rcdata_mode ? QUOTEDUNISTRING : SIZEDUNISTRING)); + if (ch == IGNORED_TOKEN) + break; + us = handle_uniquotes (&length); + if (! rcdata_mode) + yylval.uni = us; + else + { + yylval.suni.length = length; + yylval.suni.s = us; + } + break; + } + /* Fall through. */ + default: + if (ISIDST (ch) || ch=='$') + { + while ((ch = rclex_peekch ()) != -1 + && (ISIDNUM (ch) || ch == '$' || ch == '.' + || ch == ':' || ch == '\\' || ch == '/' + || ch == '_' || ch == '-') + ) + rclex_readch (); + ch = IGNORE_CPP (rclex_translatekeyword (rclex_tok)); + if (ch == STRING) + { + s = get_string (strlen (rclex_tok) + 1); + strcpy (s, rclex_tok); + yylval.s = s; + } + else if (ch == BLOCK) + { + const char *hs = NULL; + + switch (yylex ()) + { + case STRING: + case QUOTEDSTRING: + hs = yylval.s; + break; + case SIZEDSTRING: + hs = yylval.s = yylval.ss.s; + break; + } + if (! hs) + { + rcparse_warning ("BLOCK expects a string as argument."); + ch = IGNORED_TOKEN; + } + else if (! strcmp (hs, "StringFileInfo")) + ch = BLOCKSTRINGFILEINFO; + else if (! strcmp (hs, "VarFileInfo")) + ch = BLOCKVARFILEINFO; + } + break; + } + ch = IGNORE_CPP (ch); + break; + } + } + while (ch == IGNORED_TOKEN); + + return ch; +} diff --git a/support/sdbinutils/binutils/rcparse.c b/support/sdbinutils/binutils/rcparse.c new file mode 100644 index 0000000..5c07c6c --- /dev/null +++ b/support/sdbinutils/binutils/rcparse.c @@ -0,0 +1,4703 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "3.0.4" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* Copy the first part of user declarations. */ +#line 1 "rcparse.y" /* yacc.c:339 */ + /* rcparse.y -- parser for Windows rc files + Copyright (C) 1997-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Support. + Extended by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + + +/* This is a parser for Windows rc files. It is based on the parser + by Gunther Ebert . */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" +#include "libiberty.h" +#include "windres.h" +#include "safe-ctype.h" + +/* The current language. */ + +static unsigned short language; + +/* The resource information during a sub statement. */ + +static rc_res_res_info sub_res_info; + +/* Dialog information. This is built by the nonterminals styles and + controls. */ + +static rc_dialog dialog; + +/* This is used when building a style. It is modified by the + nonterminal styleexpr. */ + +static unsigned long style; + +/* These are used when building a control. They are set before using + control_params. */ + +static rc_uint_type base_style; +static rc_uint_type default_style; +static rc_res_id class; +static rc_res_id res_text_field; +static unichar null_unichar; + +/* This is used for COMBOBOX, LISTBOX and EDITTEXT which + do not allow resource 'text' field in control definition. */ +static const rc_res_id res_null_text = { 1, {{0, &null_unichar}}}; + + +#line 132 "rcparse.c" /* yacc.c:339 */ + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* In a future release of Bison, this section will be replaced + by #include "y.tab.h". */ +#ifndef YY_YY_RCPARSE_H_INCLUDED +# define YY_YY_RCPARSE_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + BEG = 258, + END = 259, + ACCELERATORS = 260, + VIRTKEY = 261, + ASCII = 262, + NOINVERT = 263, + SHIFT = 264, + CONTROL = 265, + ALT = 266, + BITMAP = 267, + CURSOR = 268, + DIALOG = 269, + DIALOGEX = 270, + EXSTYLE = 271, + CAPTION = 272, + CLASS = 273, + STYLE = 274, + AUTO3STATE = 275, + AUTOCHECKBOX = 276, + AUTORADIOBUTTON = 277, + CHECKBOX = 278, + COMBOBOX = 279, + CTEXT = 280, + DEFPUSHBUTTON = 281, + EDITTEXT = 282, + GROUPBOX = 283, + LISTBOX = 284, + LTEXT = 285, + PUSHBOX = 286, + PUSHBUTTON = 287, + RADIOBUTTON = 288, + RTEXT = 289, + SCROLLBAR = 290, + STATE3 = 291, + USERBUTTON = 292, + BEDIT = 293, + HEDIT = 294, + IEDIT = 295, + FONT = 296, + ICON = 297, + ANICURSOR = 298, + ANIICON = 299, + DLGINCLUDE = 300, + DLGINIT = 301, + FONTDIR = 302, + HTML = 303, + MANIFEST = 304, + PLUGPLAY = 305, + VXD = 306, + TOOLBAR = 307, + BUTTON = 308, + LANGUAGE = 309, + CHARACTERISTICS = 310, + VERSIONK = 311, + MENU = 312, + MENUEX = 313, + MENUITEM = 314, + SEPARATOR = 315, + POPUP = 316, + CHECKED = 317, + GRAYED = 318, + HELP = 319, + INACTIVE = 320, + MENUBARBREAK = 321, + MENUBREAK = 322, + MESSAGETABLE = 323, + RCDATA = 324, + STRINGTABLE = 325, + VERSIONINFO = 326, + FILEVERSION = 327, + PRODUCTVERSION = 328, + FILEFLAGSMASK = 329, + FILEFLAGS = 330, + FILEOS = 331, + FILETYPE = 332, + FILESUBTYPE = 333, + BLOCKSTRINGFILEINFO = 334, + BLOCKVARFILEINFO = 335, + VALUE = 336, + BLOCK = 337, + MOVEABLE = 338, + FIXED = 339, + PURE = 340, + IMPURE = 341, + PRELOAD = 342, + LOADONCALL = 343, + DISCARDABLE = 344, + NOT = 345, + QUOTEDUNISTRING = 346, + QUOTEDSTRING = 347, + STRING = 348, + NUMBER = 349, + SIZEDUNISTRING = 350, + SIZEDSTRING = 351, + IGNORED_TOKEN = 352, + NEG = 353 + }; +#endif +/* Tokens. */ +#define BEG 258 +#define END 259 +#define ACCELERATORS 260 +#define VIRTKEY 261 +#define ASCII 262 +#define NOINVERT 263 +#define SHIFT 264 +#define CONTROL 265 +#define ALT 266 +#define BITMAP 267 +#define CURSOR 268 +#define DIALOG 269 +#define DIALOGEX 270 +#define EXSTYLE 271 +#define CAPTION 272 +#define CLASS 273 +#define STYLE 274 +#define AUTO3STATE 275 +#define AUTOCHECKBOX 276 +#define AUTORADIOBUTTON 277 +#define CHECKBOX 278 +#define COMBOBOX 279 +#define CTEXT 280 +#define DEFPUSHBUTTON 281 +#define EDITTEXT 282 +#define GROUPBOX 283 +#define LISTBOX 284 +#define LTEXT 285 +#define PUSHBOX 286 +#define PUSHBUTTON 287 +#define RADIOBUTTON 288 +#define RTEXT 289 +#define SCROLLBAR 290 +#define STATE3 291 +#define USERBUTTON 292 +#define BEDIT 293 +#define HEDIT 294 +#define IEDIT 295 +#define FONT 296 +#define ICON 297 +#define ANICURSOR 298 +#define ANIICON 299 +#define DLGINCLUDE 300 +#define DLGINIT 301 +#define FONTDIR 302 +#define HTML 303 +#define MANIFEST 304 +#define PLUGPLAY 305 +#define VXD 306 +#define TOOLBAR 307 +#define BUTTON 308 +#define LANGUAGE 309 +#define CHARACTERISTICS 310 +#define VERSIONK 311 +#define MENU 312 +#define MENUEX 313 +#define MENUITEM 314 +#define SEPARATOR 315 +#define POPUP 316 +#define CHECKED 317 +#define GRAYED 318 +#define HELP 319 +#define INACTIVE 320 +#define MENUBARBREAK 321 +#define MENUBREAK 322 +#define MESSAGETABLE 323 +#define RCDATA 324 +#define STRINGTABLE 325 +#define VERSIONINFO 326 +#define FILEVERSION 327 +#define PRODUCTVERSION 328 +#define FILEFLAGSMASK 329 +#define FILEFLAGS 330 +#define FILEOS 331 +#define FILETYPE 332 +#define FILESUBTYPE 333 +#define BLOCKSTRINGFILEINFO 334 +#define BLOCKVARFILEINFO 335 +#define VALUE 336 +#define BLOCK 337 +#define MOVEABLE 338 +#define FIXED 339 +#define PURE 340 +#define IMPURE 341 +#define PRELOAD 342 +#define LOADONCALL 343 +#define DISCARDABLE 344 +#define NOT 345 +#define QUOTEDUNISTRING 346 +#define QUOTEDSTRING 347 +#define STRING 348 +#define NUMBER 349 +#define SIZEDUNISTRING 350 +#define SIZEDSTRING 351 +#define IGNORED_TOKEN 352 +#define NEG 353 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 68 "rcparse.y" /* yacc.c:355 */ + + rc_accelerator acc; + rc_accelerator *pacc; + rc_dialog_control *dialog_control; + rc_menuitem *menuitem; + struct + { + rc_rcdata_item *first; + rc_rcdata_item *last; + } rcdata; + rc_rcdata_item *rcdata_item; + rc_fixed_versioninfo *fixver; + rc_ver_info *verinfo; + rc_ver_stringtable *verstringtable; + rc_ver_stringinfo *verstring; + rc_ver_varinfo *vervar; + rc_toolbar_item *toobar_item; + rc_res_id id; + rc_res_res_info res_info; + struct + { + rc_uint_type on; + rc_uint_type off; + } memflags; + struct + { + rc_uint_type val; + /* Nonzero if this number was explicitly specified as long. */ + int dword; + } i; + rc_uint_type il; + rc_uint_type is; + const char *s; + struct + { + rc_uint_type length; + const char *s; + } ss; + unichar *uni; + struct + { + rc_uint_type length; + const unichar *s; + } suni; + +#line 414 "rcparse.c" /* yacc.c:355 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_RCPARSE_H_INCLUDED */ + +/* Copy the second part of user declarations. */ + +#line 431 "rcparse.c" /* yacc.c:358 */ + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 2 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 830 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 112 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 102 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 276 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 520 + +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 353 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 105, 100, 2, + 110, 111, 103, 101, 108, 102, 2, 104, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 109, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 99, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 98, 2, 106, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 107 +}; + +#if YYDEBUG + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 178, 178, 180, 181, 182, 183, 184, 185, 186, + 187, 188, 189, 190, 191, 192, 193, 194, 200, 211, + 214, 235, 240, 252, 272, 282, 286, 291, 298, 302, + 307, 311, 315, 319, 328, 340, 354, 352, 379, 377, + 406, 404, 436, 439, 445, 447, 453, 457, 462, 466, + 470, 483, 498, 513, 528, 532, 536, 540, 546, 548, + 560, 559, 572, 571, 584, 583, 596, 595, 611, 610, + 623, 622, 636, 647, 657, 656, 669, 668, 681, 680, + 693, 692, 705, 704, 719, 724, 730, 736, 743, 742, + 758, 757, 770, 769, 782, 781, 793, 792, 805, 804, + 817, 816, 829, 828, 841, 840, 854, 852, 873, 884, + 895, 907, 918, 921, 925, 930, 940, 943, 953, 952, + 959, 958, 965, 964, 972, 984, 997, 1006, 1017, 1020, + 1037, 1041, 1045, 1053, 1056, 1060, 1067, 1071, 1075, 1079, + 1083, 1087, 1096, 1107, 1110, 1127, 1131, 1135, 1139, 1143, + 1147, 1151, 1155, 1165, 1178, 1178, 1190, 1194, 1201, 1209, + 1217, 1225, 1234, 1243, 1252, 1262, 1261, 1266, 1268, 1273, + 1278, 1286, 1290, 1295, 1300, 1305, 1310, 1315, 1320, 1325, + 1330, 1341, 1348, 1358, 1364, 1365, 1384, 1409, 1420, 1425, + 1432, 1439, 1444, 1449, 1454, 1459, 1474, 1477, 1481, 1489, + 1492, 1500, 1503, 1511, 1514, 1523, 1528, 1537, 1541, 1551, + 1556, 1560, 1571, 1577, 1583, 1588, 1593, 1604, 1609, 1621, + 1626, 1638, 1643, 1648, 1653, 1658, 1663, 1668, 1678, 1682, + 1690, 1695, 1710, 1714, 1723, 1727, 1739, 1744, 1760, 1764, + 1776, 1780, 1802, 1806, 1810, 1814, 1821, 1825, 1835, 1838, + 1847, 1856, 1865, 1869, 1873, 1878, 1883, 1888, 1893, 1898, + 1903, 1908, 1913, 1918, 1929, 1938, 1949, 1953, 1957, 1962, + 1967, 1972, 1978, 1983, 1988, 1993, 1998 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || 0 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "BEG", "END", "ACCELERATORS", "VIRTKEY", + "ASCII", "NOINVERT", "SHIFT", "CONTROL", "ALT", "BITMAP", "CURSOR", + "DIALOG", "DIALOGEX", "EXSTYLE", "CAPTION", "CLASS", "STYLE", + "AUTO3STATE", "AUTOCHECKBOX", "AUTORADIOBUTTON", "CHECKBOX", "COMBOBOX", + "CTEXT", "DEFPUSHBUTTON", "EDITTEXT", "GROUPBOX", "LISTBOX", "LTEXT", + "PUSHBOX", "PUSHBUTTON", "RADIOBUTTON", "RTEXT", "SCROLLBAR", "STATE3", + "USERBUTTON", "BEDIT", "HEDIT", "IEDIT", "FONT", "ICON", "ANICURSOR", + "ANIICON", "DLGINCLUDE", "DLGINIT", "FONTDIR", "HTML", "MANIFEST", + "PLUGPLAY", "VXD", "TOOLBAR", "BUTTON", "LANGUAGE", "CHARACTERISTICS", + "VERSIONK", "MENU", "MENUEX", "MENUITEM", "SEPARATOR", "POPUP", + "CHECKED", "GRAYED", "HELP", "INACTIVE", "MENUBARBREAK", "MENUBREAK", + "MESSAGETABLE", "RCDATA", "STRINGTABLE", "VERSIONINFO", "FILEVERSION", + "PRODUCTVERSION", "FILEFLAGSMASK", "FILEFLAGS", "FILEOS", "FILETYPE", + "FILESUBTYPE", "BLOCKSTRINGFILEINFO", "BLOCKVARFILEINFO", "VALUE", + "BLOCK", "MOVEABLE", "FIXED", "PURE", "IMPURE", "PRELOAD", "LOADONCALL", + "DISCARDABLE", "NOT", "QUOTEDUNISTRING", "QUOTEDSTRING", "STRING", + "NUMBER", "SIZEDUNISTRING", "SIZEDSTRING", "IGNORED_TOKEN", "'|'", "'^'", + "'&'", "'+'", "'-'", "'*'", "'/'", "'%'", "'~'", "NEG", "','", "'='", + "'('", "')'", "$accept", "input", "accelerator", "acc_entries", + "acc_entry", "acc_event", "acc_options", "acc_option", "bitmap", + "cursor", "dialog", "$@1", "$@2", "$@3", "exstyle", "styles", "controls", + "control", "$@4", "$@5", "$@6", "$@7", "$@8", "$@9", "$@10", "$@11", + "$@12", "$@13", "$@14", "$@15", "$@16", "$@17", "$@18", "$@19", "$@20", + "$@21", "$@22", "$@23", "$@24", "control_params", "cresid", "optresidc", + "resid", "opt_control_data", "control_styleexpr", "$@25", + "icon_styleexpr", "$@26", "control_params_styleexpr", "$@27", "font", + "icon", "language", "menu", "menuitems", "menuitem", "menuitem_flags", + "menuitem_flag", "menuex", "menuexitems", "menuexitem", "messagetable", + "optrcdata_data", "$@28", "optrcdata_data_int", "rcdata_data", + "stringtable", "$@29", "string_data", "rcdata_id", "user", "toolbar", + "toolbar_data", "versioninfo", "fixedverinfo", "verblocks", + "verstringtables", "vervals", "vertrans", "id", "resname", "resref", + "suboptions", "memflags_move_discard", "memflags_move", "memflag", + "file_name", "res_unicode_string_concat", "res_unicode_string", + "res_unicode_sizedstring", "res_unicode_sizedstring_concat", + "sizedstring", "sizedunistring", "styleexpr", "parennumber", + "optcnumexpr", "cnumexpr", "numexpr", "sizednumexpr", "cposnumexpr", + "posnumexpr", "sizedposnumexpr", YY_NULLPTR +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 352, 124, 94, + 38, 43, 45, 42, 47, 37, 126, 353, 44, 61, + 40, 41 +}; +# endif + +#define YYPACT_NINF -446 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-446))) + +#define YYTABLE_NINF -231 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int16 yypact[] = +{ + -446, 75, -446, 317, -446, -446, -446, -446, -446, -446, + 317, 317, -446, -446, -446, -446, -446, -446, -446, -446, + -446, -446, -446, -446, -446, -446, 463, -446, -446, -446, + 589, -446, 317, 317, 317, -93, 626, 209, -446, 437, + -446, -446, -446, -446, -446, -446, -446, -446, -446, -446, + -446, -446, -446, -446, -446, -446, -446, -446, -446, -446, + -446, -446, -446, 317, 317, 317, 317, 317, 317, 317, + 317, -446, -446, 526, 317, -446, 317, 317, 317, 317, + 317, 317, 317, 317, -446, 317, 317, 317, -446, -446, + -446, -446, -446, -446, -446, -446, -446, 267, 675, 675, + 275, 275, 675, 675, 491, 404, 441, 675, 168, 256, + 719, 379, 397, 213, 213, -446, -446, -446, -446, -446, + 719, 379, 397, 213, 213, -446, -446, -446, -446, -93, + -446, -446, -446, -446, -446, -446, -446, -446, -446, -65, + 144, 144, -446, -446, -93, -446, -446, -446, -446, 317, + 317, 317, 317, 317, 317, 317, -446, -446, 18, -446, + 21, 317, -93, -93, 31, 140, 155, 126, -93, -93, + -446, -446, -446, -446, -446, 47, 177, -446, -446, 212, + -446, -446, -446, -34, -446, -446, -93, -93, -446, -446, + -36, -5, -446, -446, -25, -5, -446, -446, 119, 131, + -93, -446, -93, -446, -446, -446, -446, 54, 68, 84, + 626, 2, -446, 2, 68, 84, 144, 87, -93, -93, + 25, -446, 95, -446, -5, -446, 95, 62, -446, 102, + -93, -93, 177, -446, -446, 2, -446, -446, 552, -446, + -93, -446, 306, -446, -446, -446, 76, -93, -446, 8, + 6, -5, -446, -446, 68, 84, 626, -446, -446, -446, + -446, -446, -446, 167, -446, -446, -446, -446, -446, 271, + -446, -446, -446, -446, -446, -446, -446, 763, -446, -93, + 161, -446, 11, -446, 197, -5, 552, -446, 374, 548, + -446, 178, -446, -446, -446, 190, -446, -93, -446, 3, + -446, -446, 317, -5, 306, -47, 317, 317, 317, 317, + 306, -446, 565, -446, -446, 194, 201, -1, -446, -93, + 639, -446, -5, -446, -5, 143, -33, -446, 317, 110, + -446, 105, -93, -446, -446, -446, 676, -446, -446, -446, + -446, -5, -446, -446, 311, 311, 311, 311, 311, -446, + 311, 311, -446, 311, -446, 311, 311, 311, 311, 311, + -446, 311, 306, 311, 311, 311, 306, -446, -446, 104, + -42, -5, -446, -446, 713, 207, 99, 317, 113, -5, + -446, -446, -446, -446, -446, 317, -446, -446, 317, -446, + 317, -446, -446, -446, -446, -446, 317, -446, 115, 317, + 120, -446, -446, -446, 317, -446, -33, -446, 95, -446, + -446, -5, 152, -446, 317, 317, 317, 317, -446, -93, + 317, 317, -446, 317, -446, 317, 317, 317, 317, 317, + -446, 317, -446, 153, -446, 317, 317, 317, -93, -446, + -93, -5, 311, 159, -446, -446, -446, -446, -93, -446, + -446, -446, -446, -446, -446, -446, -446, -446, 317, -446, + -446, -446, -93, -93, -446, -446, -93, -93, 173, 15, + -446, -47, -93, -93, 317, -446, -446, -93, 110, -93, + 27, 180, 244, 29, -93, -446, -446, -93, 317, -446, + -446, -446, -93, -93, -47, 273, -93, 192, -47, 273, + -93, 273, -93, 110, -446, 273, 317, 110, -446, 273, + -446, 273, -446, 193, -446, -446, -446, -47, -75, -446 +}; + + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint16 yydefact[] = +{ + 2, 0, 1, 0, 212, 232, 233, 208, 266, 17, + 0, 0, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 15, 14, 16, 0, 206, 207, 205, + 265, 252, 0, 0, 0, 0, 251, 0, 268, 0, + 212, 219, 217, 219, 219, 217, 217, 179, 180, 177, + 178, 172, 174, 175, 176, 212, 212, 212, 219, 173, + 188, 212, 171, 0, 0, 0, 0, 0, 0, 0, + 0, 255, 254, 0, 0, 126, 0, 0, 0, 0, + 0, 0, 0, 0, 165, 0, 0, 0, 221, 222, + 223, 224, 225, 226, 227, 213, 267, 0, 0, 0, + 42, 42, 0, 0, 0, 0, 0, 0, 0, 0, + 276, 275, 274, 272, 273, 269, 270, 271, 253, 250, + 263, 262, 261, 259, 260, 256, 257, 258, 167, 0, + 214, 216, 19, 228, 229, 220, 34, 218, 35, 0, + 0, 0, 124, 125, 0, 128, 143, 153, 196, 0, + 0, 0, 0, 0, 0, 0, 154, 182, 0, 215, + 0, 0, 0, 0, 0, 0, 0, 0, 248, 248, + 191, 192, 193, 194, 195, 0, 156, 170, 166, 0, + 18, 23, 20, 0, 24, 43, 0, 0, 184, 127, + 0, 0, 129, 142, 0, 0, 144, 187, 0, 0, + 248, 249, 248, 181, 240, 238, 155, 157, 158, 159, + 160, 0, 236, 168, 235, 234, 0, 21, 0, 0, + 0, 131, 0, 230, 133, 148, 145, 0, 199, 0, + 248, 248, 164, 239, 241, 169, 237, 264, 0, 36, + 38, 183, 0, 186, 231, 133, 0, 146, 143, 0, + 0, 0, 189, 190, 161, 162, 163, 28, 29, 30, + 31, 32, 33, 22, 25, 44, 44, 40, 185, 130, + 128, 136, 137, 138, 139, 140, 141, 0, 135, 248, + 0, 143, 0, 197, 0, 203, 0, 27, 0, 0, + 44, 0, 134, 147, 149, 0, 143, 248, 201, 0, + 26, 58, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 58, 0, 132, 150, 0, 0, 0, 198, 0, + 0, 48, 45, 46, 49, 207, 0, 246, 0, 47, + 242, 0, 0, 55, 57, 54, 0, 58, 151, 143, + 200, 0, 204, 37, 112, 112, 112, 112, 112, 70, + 112, 112, 78, 112, 90, 112, 112, 112, 112, 112, + 102, 112, 0, 112, 112, 112, 0, 59, 243, 0, + 0, 0, 56, 39, 0, 0, 0, 0, 0, 115, + 114, 60, 62, 64, 68, 0, 74, 76, 0, 80, + 0, 92, 94, 96, 98, 100, 0, 104, 210, 0, + 0, 66, 82, 88, 0, 247, 0, 244, 50, 41, + 152, 0, 0, 113, 0, 0, 0, 0, 71, 0, + 0, 0, 79, 0, 91, 0, 0, 0, 0, 0, + 103, 0, 211, 0, 209, 0, 0, 0, 0, 245, + 51, 202, 0, 0, 61, 63, 65, 69, 0, 75, + 77, 81, 93, 95, 97, 99, 101, 105, 0, 67, + 83, 89, 0, 52, 111, 118, 0, 0, 0, 116, + 53, 0, 0, 0, 0, 154, 84, 0, 119, 0, + 116, 0, 0, 116, 0, 122, 108, 248, 0, 117, + 120, 85, 248, 248, 0, 116, 249, 0, 0, 116, + 249, 116, 249, 123, 109, 116, 0, 121, 86, 116, + 72, 116, 110, 0, 87, 73, 106, 0, 248, 107 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -446, -446, -446, -446, -446, -446, -446, -236, -446, -446, + -446, -446, -446, -446, 184, -262, -273, -446, -446, -446, + -446, -446, -446, -446, -446, -446, -446, -446, -446, -446, + -446, -446, -446, -446, -446, -446, -446, -446, -446, 219, + -446, 442, -123, 274, -446, -446, -446, -446, -446, -446, + -446, -446, -446, -446, 77, -446, 101, 88, -446, -239, + -446, -446, -109, -446, -446, -446, -446, -446, -446, -446, + -446, -446, -446, -446, -446, -446, -446, -446, -446, -24, + -245, 4, 169, 211, 270, 710, 175, -178, 5, -173, + 157, -156, -122, -445, -325, -161, -30, -3, 26, -446, + 20, -446 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 1, 12, 160, 182, 183, 263, 264, 13, 14, + 15, 265, 266, 290, 140, 288, 320, 367, 414, 415, + 416, 435, 417, 385, 420, 421, 388, 423, 436, 437, + 390, 425, 426, 427, 428, 429, 396, 431, 517, 418, + 443, 377, 378, 476, 466, 471, 492, 498, 487, 494, + 16, 17, 18, 19, 165, 192, 246, 278, 20, 166, + 196, 21, 175, 176, 206, 207, 22, 128, 158, 61, + 23, 24, 220, 25, 108, 167, 250, 317, 299, 26, + 27, 399, 37, 99, 98, 95, 136, 379, 223, 212, + 213, 214, 215, 329, 330, 200, 201, 419, 36, 217, + 380, 30 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int16 yytable[] = +{ + 35, 368, 62, 340, 289, 75, 28, 318, 202, 280, + 283, 281, 222, 224, 296, 74, 226, 227, 475, 177, + 208, 29, 178, 370, 221, 180, 478, 287, 312, 241, + 475, 28, 475, 74, 188, 225, 38, 39, 336, 230, + 236, 231, 295, 326, 161, 407, 29, 327, 406, 503, + 300, 203, 327, 507, 209, 5, 6, 315, 71, 72, + 73, 327, 236, 328, 374, 248, 5, 6, 328, 252, + 253, 119, 518, 285, 216, 2, 254, 328, 242, 270, + 341, 439, 129, 130, 131, 243, 5, 6, 284, 110, + 111, 112, 113, 114, 115, 116, 117, 204, 205, 159, + 375, 144, 120, 121, 122, 123, 124, 125, 126, 127, + 255, 74, 31, 181, 164, 8, 74, 398, 293, 74, + 32, 398, 228, 74, 33, 322, 324, 10, 34, 3, + 197, 11, 186, 187, 229, 485, 316, 490, 271, 272, + 273, 274, 275, 276, 189, 4, 168, 169, 170, 171, + 172, 173, 174, 5, 6, 179, 218, 219, 185, 193, + 162, 163, 232, 376, 233, 294, 5, 6, 7, 8, + 74, 148, 9, 257, 258, 259, 260, 261, 262, 234, + 184, 10, 313, 251, 277, 11, 5, 6, 239, 240, + 5, 6, 245, 408, 314, 238, 247, 249, 338, 190, + 298, 191, 210, 74, 339, 198, 199, 411, 370, 97, + 267, 410, 84, 371, 194, 405, 195, 279, 268, 282, + 194, 413, 195, 432, 104, 105, 106, 244, 434, 244, + 109, 244, 244, 441, -230, -230, 237, 190, 8, 191, + 149, 150, 151, 152, 153, 154, 155, 28, 489, 194, + 10, 195, 297, 194, 11, 195, 102, 103, 256, 156, + 442, 458, 29, 85, 86, 87, 194, 465, 195, 319, + 132, 31, 204, 205, 138, 286, 475, 142, 143, 32, + 323, 474, 147, 33, 157, 141, 335, 34, 488, 342, + 244, 139, 88, 89, 90, 91, 92, 93, 94, 321, + 506, 516, 372, 331, 332, 333, 334, 204, 205, 325, + 85, 86, 87, 100, 101, 28, 81, 82, 83, 464, + 211, 85, 86, 87, 29, 369, 495, 244, 107, 244, + 29, 499, 501, 271, 272, 273, 274, 275, 276, 88, + 89, 90, 91, 92, 93, 94, 269, 291, 133, 134, + 88, 89, 90, 91, 92, 93, 94, 519, 88, 89, + 90, 91, 92, 93, 94, 292, 482, 28, 235, 0, + 404, 28, 0, 0, 412, 0, 0, 301, 440, 277, + 0, 244, 400, 0, 244, 0, 400, 0, 0, 448, + 302, 303, 304, 305, 0, 0, 433, 5, 6, 7, + 8, 438, 5, 6, 0, 8, 0, 145, 462, 0, + 463, 31, 10, 244, 0, 306, 11, 10, 467, 32, + 0, 11, 0, 33, 0, 0, 0, 34, 307, 308, + 309, 310, 469, 470, 0, 0, 472, 473, 0, 477, + 0, 0, 479, 480, 146, 0, 244, 483, 0, 484, + 0, 0, 0, 0, 493, 468, 0, 496, 85, 86, + 87, 0, 500, 502, 0, 0, 505, 0, 40, 0, + 509, 481, 511, 0, 0, 41, 42, 43, 44, 78, + 79, 80, 81, 82, 83, 497, 0, 88, 89, 90, + 91, 92, 93, 94, 0, 85, 86, 87, 79, 80, + 81, 82, 83, 513, 45, 46, 47, 48, 49, 50, + 0, 51, 52, 53, 54, 55, 0, 0, 0, 0, + 56, 57, 0, 0, 88, 89, 90, 91, 92, 93, + 94, 58, 59, 0, 60, 76, 77, 78, 79, 80, + 81, 82, 83, 0, 0, 85, 86, 87, 96, 0, + 0, 311, 0, 0, 5, 6, 7, 8, 257, 258, + 259, 260, 261, 262, 302, 303, 304, 305, 337, 10, + 0, 0, 0, 11, 88, 89, 90, 91, 92, 93, + 94, 302, 303, 304, 305, 31, 0, 0, 0, 306, + 0, 0, 0, 32, 0, 0, 0, 33, 0, 0, + 0, 34, 307, 308, 309, 310, 306, 422, 0, 424, + 0, 0, 0, 0, 0, 430, 0, 0, 0, 307, + 308, 309, 310, 0, 76, 77, 78, 79, 80, 81, + 82, 83, 0, 444, 445, 446, 447, 118, 0, 449, + 450, 0, 451, 343, 452, 453, 454, 455, 456, 344, + 457, 0, 0, 0, 459, 460, 461, 0, 0, 345, + 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, + 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 373, 366, 0, 0, 0, 0, 344, 63, 64, 65, + 66, 67, 68, 69, 70, 0, 345, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, + 359, 360, 361, 362, 363, 364, 365, 409, 366, 0, + 0, 0, 0, 344, 76, 77, 78, 79, 80, 81, + 82, 83, 0, 345, 346, 347, 348, 349, 350, 351, + 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 486, 366, 0, 491, 88, 89, + 90, 91, 92, 93, 94, 0, 0, 133, 134, 504, + 0, 0, 0, 508, 0, 510, 0, 0, 0, 512, + 0, 0, 0, 514, 0, 515, 0, 381, 382, 383, + 384, 0, 386, 387, 0, 389, 0, 391, 392, 393, + 394, 395, 0, 397, 0, 401, 402, 403, 135, 137, + 135, 135, 137, 137, 0, 0, 0, 135, 77, 78, + 79, 80, 81, 82, 83, 271, 272, 273, 274, 275, + 276 +}; + +static const yytype_int16 yycheck[] = +{ + 3, 326, 26, 4, 266, 35, 1, 4, 169, 248, + 4, 3, 190, 191, 3, 108, 194, 195, 3, 1, + 176, 1, 4, 98, 60, 4, 471, 263, 290, 4, + 3, 26, 3, 108, 3, 60, 10, 11, 311, 200, + 213, 202, 281, 90, 109, 370, 26, 94, 90, 494, + 286, 4, 94, 498, 176, 91, 92, 296, 32, 33, + 34, 94, 235, 110, 337, 3, 91, 92, 110, 230, + 231, 74, 517, 251, 108, 0, 232, 110, 53, 3, + 81, 406, 85, 86, 87, 60, 91, 92, 82, 63, + 64, 65, 66, 67, 68, 69, 70, 95, 96, 129, + 339, 104, 76, 77, 78, 79, 80, 81, 82, 83, + 232, 108, 94, 92, 144, 94, 108, 362, 279, 108, + 102, 366, 3, 108, 106, 303, 304, 106, 110, 54, + 4, 110, 162, 163, 3, 108, 297, 108, 62, 63, + 64, 65, 66, 67, 4, 70, 149, 150, 151, 152, + 153, 154, 155, 91, 92, 158, 186, 187, 161, 4, + 140, 141, 108, 341, 96, 4, 91, 92, 93, 94, + 108, 3, 97, 6, 7, 8, 9, 10, 11, 95, + 160, 106, 4, 81, 108, 110, 91, 92, 218, 219, + 91, 92, 222, 371, 4, 108, 226, 227, 4, 59, + 3, 61, 176, 108, 3, 79, 80, 108, 98, 40, + 240, 4, 3, 108, 59, 111, 61, 247, 242, 249, + 59, 108, 61, 108, 55, 56, 57, 222, 108, 224, + 61, 226, 227, 411, 91, 92, 216, 59, 94, 61, + 72, 73, 74, 75, 76, 77, 78, 242, 4, 59, + 106, 61, 282, 59, 110, 61, 45, 46, 232, 3, + 108, 108, 242, 54, 55, 56, 59, 108, 61, 299, + 3, 94, 95, 96, 99, 108, 3, 102, 103, 102, + 304, 108, 107, 106, 109, 101, 310, 110, 108, 319, + 285, 16, 83, 84, 85, 86, 87, 88, 89, 302, + 108, 108, 332, 306, 307, 308, 309, 95, 96, 304, + 54, 55, 56, 43, 44, 310, 103, 104, 105, 442, + 108, 54, 55, 56, 304, 328, 487, 322, 58, 324, + 310, 492, 493, 62, 63, 64, 65, 66, 67, 83, + 84, 85, 86, 87, 88, 89, 245, 270, 92, 93, + 83, 84, 85, 86, 87, 88, 89, 518, 83, 84, + 85, 86, 87, 88, 89, 277, 475, 362, 211, -1, + 366, 366, -1, -1, 377, -1, -1, 3, 408, 108, + -1, 376, 362, -1, 379, -1, 366, -1, -1, 419, + 16, 17, 18, 19, -1, -1, 399, 91, 92, 93, + 94, 404, 91, 92, -1, 94, -1, 3, 438, -1, + 440, 94, 106, 408, -1, 41, 110, 106, 448, 102, + -1, 110, -1, 106, -1, -1, -1, 110, 54, 55, + 56, 57, 462, 463, -1, -1, 466, 467, -1, 469, + -1, -1, 472, 473, 3, -1, 441, 477, -1, 479, + -1, -1, -1, -1, 484, 458, -1, 487, 54, 55, + 56, -1, 492, 493, -1, -1, 496, -1, 5, -1, + 500, 474, 502, -1, -1, 12, 13, 14, 15, 100, + 101, 102, 103, 104, 105, 488, -1, 83, 84, 85, + 86, 87, 88, 89, -1, 54, 55, 56, 101, 102, + 103, 104, 105, 506, 41, 42, 43, 44, 45, 46, + -1, 48, 49, 50, 51, 52, -1, -1, -1, -1, + 57, 58, -1, -1, 83, 84, 85, 86, 87, 88, + 89, 68, 69, -1, 71, 98, 99, 100, 101, 102, + 103, 104, 105, -1, -1, 54, 55, 56, 111, -1, + -1, 3, -1, -1, 91, 92, 93, 94, 6, 7, + 8, 9, 10, 11, 16, 17, 18, 19, 3, 106, + -1, -1, -1, 110, 83, 84, 85, 86, 87, 88, + 89, 16, 17, 18, 19, 94, -1, -1, -1, 41, + -1, -1, -1, 102, -1, -1, -1, 106, -1, -1, + -1, 110, 54, 55, 56, 57, 41, 388, -1, 390, + -1, -1, -1, -1, -1, 396, -1, -1, -1, 54, + 55, 56, 57, -1, 98, 99, 100, 101, 102, 103, + 104, 105, -1, 414, 415, 416, 417, 111, -1, 420, + 421, -1, 423, 4, 425, 426, 427, 428, 429, 10, + 431, -1, -1, -1, 435, 436, 437, -1, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 4, 42, -1, -1, -1, -1, 10, 98, 99, 100, + 101, 102, 103, 104, 105, -1, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 4, 42, -1, + -1, -1, -1, 10, 98, 99, 100, 101, 102, 103, + 104, 105, -1, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 480, 42, -1, 483, 83, 84, + 85, 86, 87, 88, 89, -1, -1, 92, 93, 495, + -1, -1, -1, 499, -1, 501, -1, -1, -1, 505, + -1, -1, -1, 509, -1, 511, -1, 345, 346, 347, + 348, -1, 350, 351, -1, 353, -1, 355, 356, 357, + 358, 359, -1, 361, -1, 363, 364, 365, 98, 99, + 100, 101, 102, 103, -1, -1, -1, 107, 99, 100, + 101, 102, 103, 104, 105, 62, 63, 64, 65, 66, + 67 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 113, 0, 54, 70, 91, 92, 93, 94, 97, + 106, 110, 114, 120, 121, 122, 162, 163, 164, 165, + 170, 173, 178, 182, 183, 185, 191, 192, 200, 212, + 213, 94, 102, 106, 110, 209, 210, 194, 210, 210, + 5, 12, 13, 14, 15, 41, 42, 43, 44, 45, + 46, 48, 49, 50, 51, 52, 57, 58, 68, 69, + 71, 181, 191, 98, 99, 100, 101, 102, 103, 104, + 105, 210, 210, 210, 108, 208, 98, 99, 100, 101, + 102, 103, 104, 105, 3, 54, 55, 56, 83, 84, + 85, 86, 87, 88, 89, 197, 111, 194, 196, 195, + 196, 196, 195, 195, 194, 194, 194, 196, 186, 194, + 210, 210, 210, 210, 210, 210, 210, 210, 111, 209, + 210, 210, 210, 210, 210, 210, 210, 210, 179, 209, + 209, 209, 3, 92, 93, 197, 198, 197, 198, 16, + 126, 126, 198, 198, 209, 3, 3, 198, 3, 72, + 73, 74, 75, 76, 77, 78, 3, 198, 180, 208, + 115, 109, 212, 212, 208, 166, 171, 187, 209, 209, + 209, 209, 209, 209, 209, 174, 175, 1, 4, 209, + 4, 92, 116, 117, 212, 209, 208, 208, 3, 4, + 59, 61, 167, 4, 59, 61, 172, 4, 79, 80, + 207, 208, 207, 4, 95, 96, 176, 177, 203, 204, + 210, 108, 201, 202, 203, 204, 108, 211, 208, 208, + 184, 60, 199, 200, 199, 60, 199, 199, 3, 3, + 207, 207, 108, 96, 95, 202, 201, 212, 108, 208, + 208, 4, 53, 60, 200, 208, 168, 208, 3, 208, + 188, 81, 207, 207, 203, 204, 210, 6, 7, 8, + 9, 10, 11, 118, 119, 123, 124, 208, 191, 168, + 3, 62, 63, 64, 65, 66, 67, 108, 169, 208, + 171, 3, 208, 4, 82, 199, 108, 119, 127, 127, + 125, 166, 169, 207, 4, 171, 3, 208, 3, 190, + 119, 3, 16, 17, 18, 19, 41, 54, 55, 56, + 57, 3, 127, 4, 4, 171, 207, 189, 4, 208, + 128, 209, 199, 191, 199, 200, 90, 94, 110, 205, + 206, 209, 209, 209, 209, 191, 128, 3, 4, 3, + 4, 81, 208, 4, 10, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 42, 129, 206, 209, + 98, 108, 208, 4, 128, 171, 199, 153, 154, 199, + 212, 153, 153, 153, 153, 135, 153, 153, 138, 153, + 142, 153, 153, 153, 153, 153, 148, 153, 192, 193, + 212, 153, 153, 153, 193, 111, 90, 206, 199, 4, + 4, 108, 209, 108, 130, 131, 132, 134, 151, 209, + 136, 137, 151, 139, 151, 143, 144, 145, 146, 147, + 151, 149, 108, 209, 108, 133, 140, 141, 209, 206, + 208, 199, 108, 152, 151, 151, 151, 151, 208, 151, + 151, 151, 151, 151, 151, 151, 151, 151, 108, 151, + 151, 151, 208, 208, 154, 108, 156, 208, 209, 208, + 208, 157, 208, 208, 108, 3, 155, 208, 205, 208, + 208, 209, 174, 208, 208, 108, 155, 160, 108, 4, + 108, 155, 158, 208, 161, 207, 208, 209, 159, 207, + 208, 207, 208, 205, 155, 208, 108, 205, 155, 208, + 155, 208, 155, 209, 155, 155, 108, 150, 205, 207 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 112, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 114, 115, + 115, 116, 116, 117, 117, 118, 118, 118, 119, 119, + 119, 119, 119, 119, 120, 121, 123, 122, 124, 122, + 125, 122, 126, 126, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, + 130, 129, 131, 129, 132, 129, 133, 129, 134, 129, + 135, 129, 129, 129, 136, 129, 137, 129, 138, 129, + 139, 129, 140, 129, 129, 129, 129, 129, 141, 129, + 142, 129, 143, 129, 144, 129, 145, 129, 146, 129, + 147, 129, 148, 129, 149, 129, 150, 129, 151, 151, + 151, 152, 153, 153, 154, 154, 155, 155, 157, 156, + 159, 158, 161, 160, 162, 163, 164, 165, 166, 166, + 167, 167, 167, 168, 168, 168, 169, 169, 169, 169, + 169, 169, 170, 171, 171, 172, 172, 172, 172, 172, + 172, 172, 172, 173, 175, 174, 176, 176, 177, 177, + 177, 177, 177, 177, 177, 179, 178, 180, 180, 180, + 180, 181, 181, 181, 181, 181, 181, 181, 181, 181, + 181, 182, 182, 183, 184, 184, 184, 185, 186, 186, + 186, 186, 186, 186, 186, 186, 187, 187, 187, 188, + 188, 189, 189, 190, 190, 191, 191, 192, 192, 193, + 193, 193, 194, 194, 194, 194, 194, 195, 195, 196, + 196, 197, 197, 197, 197, 197, 197, 197, 198, 198, + 199, 199, 200, 200, 201, 201, 202, 202, 203, 203, + 204, 204, 205, 205, 205, 205, 206, 206, 207, 207, + 208, 209, 210, 210, 210, 210, 210, 210, 210, 210, + 210, 210, 210, 210, 211, 212, 213, 213, 213, 213, + 213, 213, 213, 213, 213, 213, 213 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 6, 0, + 2, 2, 4, 1, 1, 1, 3, 2, 1, 1, + 1, 1, 1, 1, 4, 4, 0, 13, 0, 13, + 0, 14, 0, 3, 0, 3, 3, 3, 3, 3, + 5, 6, 7, 8, 3, 3, 4, 3, 0, 2, + 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, + 0, 3, 11, 12, 0, 4, 0, 4, 0, 3, + 0, 4, 0, 4, 6, 8, 10, 11, 0, 4, + 0, 3, 0, 4, 0, 4, 0, 4, 0, 4, + 0, 4, 0, 3, 0, 4, 0, 15, 6, 8, + 9, 2, 0, 2, 1, 1, 0, 3, 0, 3, + 0, 3, 0, 3, 4, 4, 3, 6, 0, 2, + 4, 2, 6, 0, 3, 2, 1, 1, 1, 1, + 1, 1, 6, 0, 2, 2, 3, 5, 2, 5, + 6, 7, 9, 4, 0, 2, 0, 1, 1, 1, + 1, 3, 3, 3, 2, 0, 6, 0, 3, 4, + 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 6, 4, 8, 0, 3, 2, 6, 0, 6, + 6, 3, 3, 3, 3, 3, 0, 5, 7, 0, + 5, 0, 5, 0, 3, 1, 1, 1, 1, 2, + 1, 2, 0, 2, 3, 4, 3, 0, 2, 0, + 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, + 1, 2, 1, 2, 3, 4, 1, 3, 0, 1, + 2, 1, 1, 3, 2, 2, 3, 3, 3, 3, + 3, 3, 3, 3, 2, 1, 1, 3, 2, 3, + 3, 3, 3, 3, 3, 3, 3 +}; + + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +{ + unsigned long int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +yystrlen (const char *yystr) +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +yystpcpy (char *yydest, const char *yysrc) +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +{ + YYUSE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 18: +#line 201 "rcparse.y" /* yacc.c:1646 */ + { + define_accelerator ((yyvsp[-5].id), &(yyvsp[-3].res_info), (yyvsp[-1].pacc)); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 1978 "rcparse.c" /* yacc.c:1646 */ + break; + + case 19: +#line 211 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.pacc) = NULL; + } +#line 1986 "rcparse.c" /* yacc.c:1646 */ + break; + + case 20: +#line 215 "rcparse.y" /* yacc.c:1646 */ + { + rc_accelerator *a; + + a = (rc_accelerator *) res_alloc (sizeof *a); + *a = (yyvsp[0].acc); + if ((yyvsp[-1].pacc) == NULL) + (yyval.pacc) = a; + else + { + rc_accelerator **pp; + + for (pp = &(yyvsp[-1].pacc)->next; *pp != NULL; pp = &(*pp)->next) + ; + *pp = a; + (yyval.pacc) = (yyvsp[-1].pacc); + } + } +#line 2008 "rcparse.c" /* yacc.c:1646 */ + break; + + case 21: +#line 236 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.acc) = (yyvsp[-1].acc); + (yyval.acc).id = (yyvsp[0].il); + } +#line 2017 "rcparse.c" /* yacc.c:1646 */ + break; + + case 22: +#line 241 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.acc) = (yyvsp[-3].acc); + (yyval.acc).id = (yyvsp[-2].il); + (yyval.acc).flags |= (yyvsp[0].is); + if (((yyval.acc).flags & ACC_VIRTKEY) == 0 + && ((yyval.acc).flags & (ACC_SHIFT | ACC_CONTROL)) != 0) + rcparse_warning (_("inappropriate modifiers for non-VIRTKEY")); + } +#line 2030 "rcparse.c" /* yacc.c:1646 */ + break; + + case 23: +#line 253 "rcparse.y" /* yacc.c:1646 */ + { + const char *s = (yyvsp[0].s); + char ch; + + (yyval.acc).next = NULL; + (yyval.acc).id = 0; + ch = *s; + if (ch != '^') + (yyval.acc).flags = 0; + else + { + (yyval.acc).flags = ACC_CONTROL | ACC_VIRTKEY; + ++s; + ch = TOUPPER (s[0]); + } + (yyval.acc).key = ch; + if (s[1] != '\0') + rcparse_warning (_("accelerator should only be one character")); + } +#line 2054 "rcparse.c" /* yacc.c:1646 */ + break; + + case 24: +#line 273 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.acc).next = NULL; + (yyval.acc).flags = 0; + (yyval.acc).id = 0; + (yyval.acc).key = (yyvsp[0].il); + } +#line 2065 "rcparse.c" /* yacc.c:1646 */ + break; + + case 25: +#line 283 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = (yyvsp[0].is); + } +#line 2073 "rcparse.c" /* yacc.c:1646 */ + break; + + case 26: +#line 287 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = (yyvsp[-2].is) | (yyvsp[0].is); + } +#line 2081 "rcparse.c" /* yacc.c:1646 */ + break; + + case 27: +#line 292 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = (yyvsp[-1].is) | (yyvsp[0].is); + } +#line 2089 "rcparse.c" /* yacc.c:1646 */ + break; + + case 28: +#line 299 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = ACC_VIRTKEY; + } +#line 2097 "rcparse.c" /* yacc.c:1646 */ + break; + + case 29: +#line 303 "rcparse.y" /* yacc.c:1646 */ + { + /* This is just the absence of VIRTKEY. */ + (yyval.is) = 0; + } +#line 2106 "rcparse.c" /* yacc.c:1646 */ + break; + + case 30: +#line 308 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = ACC_NOINVERT; + } +#line 2114 "rcparse.c" /* yacc.c:1646 */ + break; + + case 31: +#line 312 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = ACC_SHIFT; + } +#line 2122 "rcparse.c" /* yacc.c:1646 */ + break; + + case 32: +#line 316 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = ACC_CONTROL; + } +#line 2130 "rcparse.c" /* yacc.c:1646 */ + break; + + case 33: +#line 320 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = ACC_ALT; + } +#line 2138 "rcparse.c" /* yacc.c:1646 */ + break; + + case 34: +#line 329 "rcparse.y" /* yacc.c:1646 */ + { + define_bitmap ((yyvsp[-3].id), &(yyvsp[-1].res_info), (yyvsp[0].s)); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 2149 "rcparse.c" /* yacc.c:1646 */ + break; + + case 35: +#line 341 "rcparse.y" /* yacc.c:1646 */ + { + define_cursor ((yyvsp[-3].id), &(yyvsp[-1].res_info), (yyvsp[0].s)); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 2160 "rcparse.c" /* yacc.c:1646 */ + break; + + case 36: +#line 354 "rcparse.y" /* yacc.c:1646 */ + { + memset (&dialog, 0, sizeof dialog); + dialog.x = (yyvsp[-3].il); + dialog.y = (yyvsp[-2].il); + dialog.width = (yyvsp[-1].il); + dialog.height = (yyvsp[0].il); + dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU; + dialog.exstyle = (yyvsp[-4].il); + dialog.menu.named = 1; + dialog.class.named = 1; + dialog.font = NULL; + dialog.ex = NULL; + dialog.controls = NULL; + sub_res_info = (yyvsp[-5].res_info); + style = 0; + } +#line 2181 "rcparse.c" /* yacc.c:1646 */ + break; + + case 37: +#line 371 "rcparse.y" /* yacc.c:1646 */ + { + define_dialog ((yyvsp[-12].id), &sub_res_info, &dialog); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 2192 "rcparse.c" /* yacc.c:1646 */ + break; + + case 38: +#line 379 "rcparse.y" /* yacc.c:1646 */ + { + memset (&dialog, 0, sizeof dialog); + dialog.x = (yyvsp[-3].il); + dialog.y = (yyvsp[-2].il); + dialog.width = (yyvsp[-1].il); + dialog.height = (yyvsp[0].il); + dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU; + dialog.exstyle = (yyvsp[-4].il); + dialog.menu.named = 1; + dialog.class.named = 1; + dialog.font = NULL; + dialog.ex = ((rc_dialog_ex *) + res_alloc (sizeof (rc_dialog_ex))); + memset (dialog.ex, 0, sizeof (rc_dialog_ex)); + dialog.controls = NULL; + sub_res_info = (yyvsp[-5].res_info); + style = 0; + } +#line 2215 "rcparse.c" /* yacc.c:1646 */ + break; + + case 39: +#line 398 "rcparse.y" /* yacc.c:1646 */ + { + define_dialog ((yyvsp[-12].id), &sub_res_info, &dialog); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 2226 "rcparse.c" /* yacc.c:1646 */ + break; + + case 40: +#line 406 "rcparse.y" /* yacc.c:1646 */ + { + memset (&dialog, 0, sizeof dialog); + dialog.x = (yyvsp[-4].il); + dialog.y = (yyvsp[-3].il); + dialog.width = (yyvsp[-2].il); + dialog.height = (yyvsp[-1].il); + dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU; + dialog.exstyle = (yyvsp[-5].il); + dialog.menu.named = 1; + dialog.class.named = 1; + dialog.font = NULL; + dialog.ex = ((rc_dialog_ex *) + res_alloc (sizeof (rc_dialog_ex))); + memset (dialog.ex, 0, sizeof (rc_dialog_ex)); + dialog.ex->help = (yyvsp[0].il); + dialog.controls = NULL; + sub_res_info = (yyvsp[-6].res_info); + style = 0; + } +#line 2250 "rcparse.c" /* yacc.c:1646 */ + break; + + case 41: +#line 426 "rcparse.y" /* yacc.c:1646 */ + { + define_dialog ((yyvsp[-13].id), &sub_res_info, &dialog); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 2261 "rcparse.c" /* yacc.c:1646 */ + break; + + case 42: +#line 436 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.il) = 0; + } +#line 2269 "rcparse.c" /* yacc.c:1646 */ + break; + + case 43: +#line 440 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.il) = (yyvsp[0].il); + } +#line 2277 "rcparse.c" /* yacc.c:1646 */ + break; + + case 45: +#line 448 "rcparse.y" /* yacc.c:1646 */ + { + dialog.style |= WS_CAPTION; + style |= WS_CAPTION; + dialog.caption = (yyvsp[0].uni); + } +#line 2287 "rcparse.c" /* yacc.c:1646 */ + break; + + case 46: +#line 454 "rcparse.y" /* yacc.c:1646 */ + { + dialog.class = (yyvsp[0].id); + } +#line 2295 "rcparse.c" /* yacc.c:1646 */ + break; + + case 47: +#line 459 "rcparse.y" /* yacc.c:1646 */ + { + dialog.style = style; + } +#line 2303 "rcparse.c" /* yacc.c:1646 */ + break; + + case 48: +#line 463 "rcparse.y" /* yacc.c:1646 */ + { + dialog.exstyle = (yyvsp[0].il); + } +#line 2311 "rcparse.c" /* yacc.c:1646 */ + break; + + case 49: +#line 467 "rcparse.y" /* yacc.c:1646 */ + { + res_unistring_to_id (& dialog.class, (yyvsp[0].uni)); + } +#line 2319 "rcparse.c" /* yacc.c:1646 */ + break; + + case 50: +#line 471 "rcparse.y" /* yacc.c:1646 */ + { + dialog.style |= DS_SETFONT; + style |= DS_SETFONT; + dialog.pointsize = (yyvsp[-2].il); + dialog.font = (yyvsp[0].uni); + if (dialog.ex != NULL) + { + dialog.ex->weight = 0; + dialog.ex->italic = 0; + dialog.ex->charset = 1; + } + } +#line 2336 "rcparse.c" /* yacc.c:1646 */ + break; + + case 51: +#line 484 "rcparse.y" /* yacc.c:1646 */ + { + dialog.style |= DS_SETFONT; + style |= DS_SETFONT; + dialog.pointsize = (yyvsp[-3].il); + dialog.font = (yyvsp[-1].uni); + if (dialog.ex == NULL) + rcparse_warning (_("extended FONT requires DIALOGEX")); + else + { + dialog.ex->weight = (yyvsp[0].il); + dialog.ex->italic = 0; + dialog.ex->charset = 1; + } + } +#line 2355 "rcparse.c" /* yacc.c:1646 */ + break; + + case 52: +#line 499 "rcparse.y" /* yacc.c:1646 */ + { + dialog.style |= DS_SETFONT; + style |= DS_SETFONT; + dialog.pointsize = (yyvsp[-4].il); + dialog.font = (yyvsp[-2].uni); + if (dialog.ex == NULL) + rcparse_warning (_("extended FONT requires DIALOGEX")); + else + { + dialog.ex->weight = (yyvsp[-1].il); + dialog.ex->italic = (yyvsp[0].il); + dialog.ex->charset = 1; + } + } +#line 2374 "rcparse.c" /* yacc.c:1646 */ + break; + + case 53: +#line 514 "rcparse.y" /* yacc.c:1646 */ + { + dialog.style |= DS_SETFONT; + style |= DS_SETFONT; + dialog.pointsize = (yyvsp[-5].il); + dialog.font = (yyvsp[-3].uni); + if (dialog.ex == NULL) + rcparse_warning (_("extended FONT requires DIALOGEX")); + else + { + dialog.ex->weight = (yyvsp[-2].il); + dialog.ex->italic = (yyvsp[-1].il); + dialog.ex->charset = (yyvsp[0].il); + } + } +#line 2393 "rcparse.c" /* yacc.c:1646 */ + break; + + case 54: +#line 529 "rcparse.y" /* yacc.c:1646 */ + { + dialog.menu = (yyvsp[0].id); + } +#line 2401 "rcparse.c" /* yacc.c:1646 */ + break; + + case 55: +#line 533 "rcparse.y" /* yacc.c:1646 */ + { + sub_res_info.characteristics = (yyvsp[0].il); + } +#line 2409 "rcparse.c" /* yacc.c:1646 */ + break; + + case 56: +#line 537 "rcparse.y" /* yacc.c:1646 */ + { + sub_res_info.language = (yyvsp[-1].il) | ((yyvsp[0].il) << SUBLANG_SHIFT); + } +#line 2417 "rcparse.c" /* yacc.c:1646 */ + break; + + case 57: +#line 541 "rcparse.y" /* yacc.c:1646 */ + { + sub_res_info.version = (yyvsp[0].il); + } +#line 2425 "rcparse.c" /* yacc.c:1646 */ + break; + + case 59: +#line 549 "rcparse.y" /* yacc.c:1646 */ + { + rc_dialog_control **pp; + + for (pp = &dialog.controls; *pp != NULL; pp = &(*pp)->next) + ; + *pp = (yyvsp[0].dialog_control); + } +#line 2437 "rcparse.c" /* yacc.c:1646 */ + break; + + case 60: +#line 560 "rcparse.y" /* yacc.c:1646 */ + { + default_style = BS_AUTO3STATE | WS_TABSTOP; + base_style = BS_AUTO3STATE; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = (yyvsp[0].id); + } +#line 2449 "rcparse.c" /* yacc.c:1646 */ + break; + + case 61: +#line 568 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2457 "rcparse.c" /* yacc.c:1646 */ + break; + + case 62: +#line 572 "rcparse.y" /* yacc.c:1646 */ + { + default_style = BS_AUTOCHECKBOX | WS_TABSTOP; + base_style = BS_AUTOCHECKBOX; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = (yyvsp[0].id); + } +#line 2469 "rcparse.c" /* yacc.c:1646 */ + break; + + case 63: +#line 580 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2477 "rcparse.c" /* yacc.c:1646 */ + break; + + case 64: +#line 584 "rcparse.y" /* yacc.c:1646 */ + { + default_style = BS_AUTORADIOBUTTON | WS_TABSTOP; + base_style = BS_AUTORADIOBUTTON; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = (yyvsp[0].id); + } +#line 2489 "rcparse.c" /* yacc.c:1646 */ + break; + + case 65: +#line 592 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2497 "rcparse.c" /* yacc.c:1646 */ + break; + + case 66: +#line 596 "rcparse.y" /* yacc.c:1646 */ + { + default_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + base_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_EDIT; + res_text_field = (yyvsp[0].id); + } +#line 2509 "rcparse.c" /* yacc.c:1646 */ + break; + + case 67: +#line 604 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + if (dialog.ex == NULL) + rcparse_warning (_("BEDIT requires DIALOGEX")); + res_string_to_id (&(yyval.dialog_control)->class, "BEDIT"); + } +#line 2520 "rcparse.c" /* yacc.c:1646 */ + break; + + case 68: +#line 611 "rcparse.y" /* yacc.c:1646 */ + { + default_style = BS_CHECKBOX | WS_TABSTOP; + base_style = BS_CHECKBOX | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = (yyvsp[0].id); + } +#line 2532 "rcparse.c" /* yacc.c:1646 */ + break; + + case 69: +#line 619 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2540 "rcparse.c" /* yacc.c:1646 */ + break; + + case 70: +#line 623 "rcparse.y" /* yacc.c:1646 */ + { + /* This is as per MSDN documentation. With some (???) + versions of MS rc.exe their is no default style. */ + default_style = CBS_SIMPLE | WS_TABSTOP; + base_style = 0; + class.named = 0; + class.u.id = CTL_COMBOBOX; + res_text_field = res_null_text; + } +#line 2554 "rcparse.c" /* yacc.c:1646 */ + break; + + case 71: +#line 633 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2562 "rcparse.c" /* yacc.c:1646 */ + break; + + case 72: +#line 638 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = define_control ((yyvsp[-9].id), (yyvsp[-8].il), (yyvsp[-5].il), (yyvsp[-4].il), (yyvsp[-3].il), (yyvsp[-2].il), (yyvsp[-7].id), style, (yyvsp[-1].il)); + if ((yyvsp[0].rcdata_item) != NULL) + { + if (dialog.ex == NULL) + rcparse_warning (_("control data requires DIALOGEX")); + (yyval.dialog_control)->data = (yyvsp[0].rcdata_item); + } + } +#line 2576 "rcparse.c" /* yacc.c:1646 */ + break; + + case 73: +#line 649 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = define_control ((yyvsp[-10].id), (yyvsp[-9].il), (yyvsp[-6].il), (yyvsp[-5].il), (yyvsp[-4].il), (yyvsp[-3].il), (yyvsp[-8].id), style, (yyvsp[-2].il)); + if (dialog.ex == NULL) + rcparse_warning (_("help ID requires DIALOGEX")); + (yyval.dialog_control)->help = (yyvsp[-1].il); + (yyval.dialog_control)->data = (yyvsp[0].rcdata_item); + } +#line 2588 "rcparse.c" /* yacc.c:1646 */ + break; + + case 74: +#line 657 "rcparse.y" /* yacc.c:1646 */ + { + default_style = SS_CENTER | WS_GROUP; + base_style = SS_CENTER; + class.named = 0; + class.u.id = CTL_STATIC; + res_text_field = (yyvsp[0].id); + } +#line 2600 "rcparse.c" /* yacc.c:1646 */ + break; + + case 75: +#line 665 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2608 "rcparse.c" /* yacc.c:1646 */ + break; + + case 76: +#line 669 "rcparse.y" /* yacc.c:1646 */ + { + default_style = BS_DEFPUSHBUTTON | WS_TABSTOP; + base_style = BS_DEFPUSHBUTTON | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = (yyvsp[0].id); + } +#line 2620 "rcparse.c" /* yacc.c:1646 */ + break; + + case 77: +#line 677 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2628 "rcparse.c" /* yacc.c:1646 */ + break; + + case 78: +#line 681 "rcparse.y" /* yacc.c:1646 */ + { + default_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + base_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_EDIT; + res_text_field = res_null_text; + } +#line 2640 "rcparse.c" /* yacc.c:1646 */ + break; + + case 79: +#line 689 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2648 "rcparse.c" /* yacc.c:1646 */ + break; + + case 80: +#line 693 "rcparse.y" /* yacc.c:1646 */ + { + default_style = BS_GROUPBOX; + base_style = BS_GROUPBOX; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = (yyvsp[0].id); + } +#line 2660 "rcparse.c" /* yacc.c:1646 */ + break; + + case 81: +#line 701 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2668 "rcparse.c" /* yacc.c:1646 */ + break; + + case 82: +#line 705 "rcparse.y" /* yacc.c:1646 */ + { + default_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + base_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_EDIT; + res_text_field = (yyvsp[0].id); + } +#line 2680 "rcparse.c" /* yacc.c:1646 */ + break; + + case 83: +#line 713 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + if (dialog.ex == NULL) + rcparse_warning (_("IEDIT requires DIALOGEX")); + res_string_to_id (&(yyval.dialog_control)->class, "HEDIT"); + } +#line 2691 "rcparse.c" /* yacc.c:1646 */ + break; + + case 84: +#line 720 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = define_icon_control ((yyvsp[-4].id), (yyvsp[-3].il), (yyvsp[-2].il), (yyvsp[-1].il), 0, 0, 0, (yyvsp[0].rcdata_item), + dialog.ex); + } +#line 2700 "rcparse.c" /* yacc.c:1646 */ + break; + + case 85: +#line 726 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = define_icon_control ((yyvsp[-6].id), (yyvsp[-5].il), (yyvsp[-4].il), (yyvsp[-3].il), 0, 0, 0, (yyvsp[0].rcdata_item), + dialog.ex); + } +#line 2709 "rcparse.c" /* yacc.c:1646 */ + break; + + case 86: +#line 732 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = define_icon_control ((yyvsp[-8].id), (yyvsp[-7].il), (yyvsp[-6].il), (yyvsp[-5].il), style, (yyvsp[-1].il), 0, (yyvsp[0].rcdata_item), + dialog.ex); + } +#line 2718 "rcparse.c" /* yacc.c:1646 */ + break; + + case 87: +#line 738 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = define_icon_control ((yyvsp[-9].id), (yyvsp[-8].il), (yyvsp[-7].il), (yyvsp[-6].il), style, (yyvsp[-2].il), (yyvsp[-1].il), (yyvsp[0].rcdata_item), + dialog.ex); + } +#line 2727 "rcparse.c" /* yacc.c:1646 */ + break; + + case 88: +#line 743 "rcparse.y" /* yacc.c:1646 */ + { + default_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + base_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_EDIT; + res_text_field = (yyvsp[0].id); + } +#line 2739 "rcparse.c" /* yacc.c:1646 */ + break; + + case 89: +#line 751 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + if (dialog.ex == NULL) + rcparse_warning (_("IEDIT requires DIALOGEX")); + res_string_to_id (&(yyval.dialog_control)->class, "IEDIT"); + } +#line 2750 "rcparse.c" /* yacc.c:1646 */ + break; + + case 90: +#line 758 "rcparse.y" /* yacc.c:1646 */ + { + default_style = LBS_NOTIFY | WS_BORDER; + base_style = LBS_NOTIFY | WS_BORDER; + class.named = 0; + class.u.id = CTL_LISTBOX; + res_text_field = res_null_text; + } +#line 2762 "rcparse.c" /* yacc.c:1646 */ + break; + + case 91: +#line 766 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2770 "rcparse.c" /* yacc.c:1646 */ + break; + + case 92: +#line 770 "rcparse.y" /* yacc.c:1646 */ + { + default_style = SS_LEFT | WS_GROUP; + base_style = SS_LEFT; + class.named = 0; + class.u.id = CTL_STATIC; + res_text_field = (yyvsp[0].id); + } +#line 2782 "rcparse.c" /* yacc.c:1646 */ + break; + + case 93: +#line 778 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2790 "rcparse.c" /* yacc.c:1646 */ + break; + + case 94: +#line 782 "rcparse.y" /* yacc.c:1646 */ + { + default_style = BS_PUSHBOX | WS_TABSTOP; + base_style = BS_PUSHBOX; + class.named = 0; + class.u.id = CTL_BUTTON; + } +#line 2801 "rcparse.c" /* yacc.c:1646 */ + break; + + case 95: +#line 789 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2809 "rcparse.c" /* yacc.c:1646 */ + break; + + case 96: +#line 793 "rcparse.y" /* yacc.c:1646 */ + { + default_style = BS_PUSHBUTTON | WS_TABSTOP; + base_style = BS_PUSHBUTTON | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = (yyvsp[0].id); + } +#line 2821 "rcparse.c" /* yacc.c:1646 */ + break; + + case 97: +#line 801 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2829 "rcparse.c" /* yacc.c:1646 */ + break; + + case 98: +#line 805 "rcparse.y" /* yacc.c:1646 */ + { + default_style = BS_RADIOBUTTON | WS_TABSTOP; + base_style = BS_RADIOBUTTON; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = (yyvsp[0].id); + } +#line 2841 "rcparse.c" /* yacc.c:1646 */ + break; + + case 99: +#line 813 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2849 "rcparse.c" /* yacc.c:1646 */ + break; + + case 100: +#line 817 "rcparse.y" /* yacc.c:1646 */ + { + default_style = SS_RIGHT | WS_GROUP; + base_style = SS_RIGHT; + class.named = 0; + class.u.id = CTL_STATIC; + res_text_field = (yyvsp[0].id); + } +#line 2861 "rcparse.c" /* yacc.c:1646 */ + break; + + case 101: +#line 825 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2869 "rcparse.c" /* yacc.c:1646 */ + break; + + case 102: +#line 829 "rcparse.y" /* yacc.c:1646 */ + { + default_style = SBS_HORZ; + base_style = 0; + class.named = 0; + class.u.id = CTL_SCROLLBAR; + res_text_field = res_null_text; + } +#line 2881 "rcparse.c" /* yacc.c:1646 */ + break; + + case 103: +#line 837 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2889 "rcparse.c" /* yacc.c:1646 */ + break; + + case 104: +#line 841 "rcparse.y" /* yacc.c:1646 */ + { + default_style = BS_3STATE | WS_TABSTOP; + base_style = BS_3STATE; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = (yyvsp[0].id); + } +#line 2901 "rcparse.c" /* yacc.c:1646 */ + break; + + case 105: +#line 849 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = (yyvsp[0].dialog_control); + } +#line 2909 "rcparse.c" /* yacc.c:1646 */ + break; + + case 106: +#line 854 "rcparse.y" /* yacc.c:1646 */ + { style = WS_CHILD | WS_VISIBLE; } +#line 2915 "rcparse.c" /* yacc.c:1646 */ + break; + + case 107: +#line 856 "rcparse.y" /* yacc.c:1646 */ + { + rc_res_id cid; + cid.named = 0; + cid.u.id = CTL_BUTTON; + (yyval.dialog_control) = define_control ((yyvsp[-13].id), (yyvsp[-12].il), (yyvsp[-10].il), (yyvsp[-8].il), (yyvsp[-6].il), (yyvsp[-4].il), cid, + style, (yyvsp[0].il)); + } +#line 2927 "rcparse.c" /* yacc.c:1646 */ + break; + + case 108: +#line 874 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = define_control (res_text_field, (yyvsp[-5].il), (yyvsp[-4].il), (yyvsp[-3].il), (yyvsp[-2].il), (yyvsp[-1].il), class, + default_style | WS_CHILD | WS_VISIBLE, 0); + if ((yyvsp[0].rcdata_item) != NULL) + { + if (dialog.ex == NULL) + rcparse_warning (_("control data requires DIALOGEX")); + (yyval.dialog_control)->data = (yyvsp[0].rcdata_item); + } + } +#line 2942 "rcparse.c" /* yacc.c:1646 */ + break; + + case 109: +#line 886 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = define_control (res_text_field, (yyvsp[-7].il), (yyvsp[-6].il), (yyvsp[-5].il), (yyvsp[-4].il), (yyvsp[-3].il), class, style, (yyvsp[-1].il)); + if ((yyvsp[0].rcdata_item) != NULL) + { + if (dialog.ex == NULL) + rcparse_warning (_("control data requires DIALOGEX")); + (yyval.dialog_control)->data = (yyvsp[0].rcdata_item); + } + } +#line 2956 "rcparse.c" /* yacc.c:1646 */ + break; + + case 110: +#line 897 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.dialog_control) = define_control (res_text_field, (yyvsp[-8].il), (yyvsp[-7].il), (yyvsp[-6].il), (yyvsp[-5].il), (yyvsp[-4].il), class, style, (yyvsp[-2].il)); + if (dialog.ex == NULL) + rcparse_warning (_("help ID requires DIALOGEX")); + (yyval.dialog_control)->help = (yyvsp[-1].il); + (yyval.dialog_control)->data = (yyvsp[0].rcdata_item); + } +#line 2968 "rcparse.c" /* yacc.c:1646 */ + break; + + case 111: +#line 908 "rcparse.y" /* yacc.c:1646 */ + { + if ((yyvsp[0].id).named) + res_unistring_to_id (&(yyval.id), (yyvsp[0].id).u.n.name); + else + (yyval.id)=(yyvsp[0].id); + } +#line 2979 "rcparse.c" /* yacc.c:1646 */ + break; + + case 112: +#line 918 "rcparse.y" /* yacc.c:1646 */ + { + res_string_to_id (&(yyval.id), ""); + } +#line 2987 "rcparse.c" /* yacc.c:1646 */ + break; + + case 113: +#line 921 "rcparse.y" /* yacc.c:1646 */ + { (yyval.id)=(yyvsp[-1].id); } +#line 2993 "rcparse.c" /* yacc.c:1646 */ + break; + + case 114: +#line 926 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 0; + (yyval.id).u.id = (yyvsp[0].il); + } +#line 3002 "rcparse.c" /* yacc.c:1646 */ + break; + + case 115: +#line 931 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 1; + (yyval.id).u.n.name = (yyvsp[0].uni); + (yyval.id).u.n.length = unichar_len ((yyvsp[0].uni)); + } +#line 3012 "rcparse.c" /* yacc.c:1646 */ + break; + + case 116: +#line 940 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.rcdata_item) = NULL; + } +#line 3020 "rcparse.c" /* yacc.c:1646 */ + break; + + case 117: +#line 944 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.rcdata_item) = (yyvsp[-1].rcdata).first; + } +#line 3028 "rcparse.c" /* yacc.c:1646 */ + break; + + case 118: +#line 953 "rcparse.y" /* yacc.c:1646 */ + { style = WS_CHILD | WS_VISIBLE; } +#line 3034 "rcparse.c" /* yacc.c:1646 */ + break; + + case 120: +#line 959 "rcparse.y" /* yacc.c:1646 */ + { style = SS_ICON | WS_CHILD | WS_VISIBLE; } +#line 3040 "rcparse.c" /* yacc.c:1646 */ + break; + + case 122: +#line 965 "rcparse.y" /* yacc.c:1646 */ + { style = base_style | WS_CHILD | WS_VISIBLE; } +#line 3046 "rcparse.c" /* yacc.c:1646 */ + break; + + case 124: +#line 973 "rcparse.y" /* yacc.c:1646 */ + { + define_font ((yyvsp[-3].id), &(yyvsp[-1].res_info), (yyvsp[0].s)); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 3057 "rcparse.c" /* yacc.c:1646 */ + break; + + case 125: +#line 985 "rcparse.y" /* yacc.c:1646 */ + { + define_icon ((yyvsp[-3].id), &(yyvsp[-1].res_info), (yyvsp[0].s)); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 3068 "rcparse.c" /* yacc.c:1646 */ + break; + + case 126: +#line 998 "rcparse.y" /* yacc.c:1646 */ + { + language = (yyvsp[-1].il) | ((yyvsp[0].il) << SUBLANG_SHIFT); + } +#line 3076 "rcparse.c" /* yacc.c:1646 */ + break; + + case 127: +#line 1007 "rcparse.y" /* yacc.c:1646 */ + { + define_menu ((yyvsp[-5].id), &(yyvsp[-3].res_info), (yyvsp[-1].menuitem)); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 3087 "rcparse.c" /* yacc.c:1646 */ + break; + + case 128: +#line 1017 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = NULL; + } +#line 3095 "rcparse.c" /* yacc.c:1646 */ + break; + + case 129: +#line 1021 "rcparse.y" /* yacc.c:1646 */ + { + if ((yyvsp[-1].menuitem) == NULL) + (yyval.menuitem) = (yyvsp[0].menuitem); + else + { + rc_menuitem **pp; + + for (pp = &(yyvsp[-1].menuitem)->next; *pp != NULL; pp = &(*pp)->next) + ; + *pp = (yyvsp[0].menuitem); + (yyval.menuitem) = (yyvsp[-1].menuitem); + } + } +#line 3113 "rcparse.c" /* yacc.c:1646 */ + break; + + case 130: +#line 1038 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = define_menuitem ((yyvsp[-2].uni), (yyvsp[-1].il), (yyvsp[0].is), 0, 0, NULL); + } +#line 3121 "rcparse.c" /* yacc.c:1646 */ + break; + + case 131: +#line 1042 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = define_menuitem (NULL, 0, 0, 0, 0, NULL); + } +#line 3129 "rcparse.c" /* yacc.c:1646 */ + break; + + case 132: +#line 1046 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = define_menuitem ((yyvsp[-4].uni), 0, (yyvsp[-3].is), 0, 0, (yyvsp[-1].menuitem)); + } +#line 3137 "rcparse.c" /* yacc.c:1646 */ + break; + + case 133: +#line 1053 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = 0; + } +#line 3145 "rcparse.c" /* yacc.c:1646 */ + break; + + case 134: +#line 1057 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = (yyvsp[-2].is) | (yyvsp[0].is); + } +#line 3153 "rcparse.c" /* yacc.c:1646 */ + break; + + case 135: +#line 1061 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = (yyvsp[-1].is) | (yyvsp[0].is); + } +#line 3161 "rcparse.c" /* yacc.c:1646 */ + break; + + case 136: +#line 1068 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = MENUITEM_CHECKED; + } +#line 3169 "rcparse.c" /* yacc.c:1646 */ + break; + + case 137: +#line 1072 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = MENUITEM_GRAYED; + } +#line 3177 "rcparse.c" /* yacc.c:1646 */ + break; + + case 138: +#line 1076 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = MENUITEM_HELP; + } +#line 3185 "rcparse.c" /* yacc.c:1646 */ + break; + + case 139: +#line 1080 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = MENUITEM_INACTIVE; + } +#line 3193 "rcparse.c" /* yacc.c:1646 */ + break; + + case 140: +#line 1084 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = MENUITEM_MENUBARBREAK; + } +#line 3201 "rcparse.c" /* yacc.c:1646 */ + break; + + case 141: +#line 1088 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.is) = MENUITEM_MENUBREAK; + } +#line 3209 "rcparse.c" /* yacc.c:1646 */ + break; + + case 142: +#line 1097 "rcparse.y" /* yacc.c:1646 */ + { + define_menu ((yyvsp[-5].id), &(yyvsp[-3].res_info), (yyvsp[-1].menuitem)); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 3220 "rcparse.c" /* yacc.c:1646 */ + break; + + case 143: +#line 1107 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = NULL; + } +#line 3228 "rcparse.c" /* yacc.c:1646 */ + break; + + case 144: +#line 1111 "rcparse.y" /* yacc.c:1646 */ + { + if ((yyvsp[-1].menuitem) == NULL) + (yyval.menuitem) = (yyvsp[0].menuitem); + else + { + rc_menuitem **pp; + + for (pp = &(yyvsp[-1].menuitem)->next; *pp != NULL; pp = &(*pp)->next) + ; + *pp = (yyvsp[0].menuitem); + (yyval.menuitem) = (yyvsp[-1].menuitem); + } + } +#line 3246 "rcparse.c" /* yacc.c:1646 */ + break; + + case 145: +#line 1128 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = define_menuitem ((yyvsp[0].uni), 0, 0, 0, 0, NULL); + } +#line 3254 "rcparse.c" /* yacc.c:1646 */ + break; + + case 146: +#line 1132 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = define_menuitem ((yyvsp[-1].uni), (yyvsp[0].il), 0, 0, 0, NULL); + } +#line 3262 "rcparse.c" /* yacc.c:1646 */ + break; + + case 147: +#line 1136 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = define_menuitem ((yyvsp[-3].uni), (yyvsp[-2].il), (yyvsp[-1].il), (yyvsp[0].il), 0, NULL); + } +#line 3270 "rcparse.c" /* yacc.c:1646 */ + break; + + case 148: +#line 1140 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = define_menuitem (NULL, 0, 0, 0, 0, NULL); + } +#line 3278 "rcparse.c" /* yacc.c:1646 */ + break; + + case 149: +#line 1144 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = define_menuitem ((yyvsp[-3].uni), 0, 0, 0, 0, (yyvsp[-1].menuitem)); + } +#line 3286 "rcparse.c" /* yacc.c:1646 */ + break; + + case 150: +#line 1148 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = define_menuitem ((yyvsp[-4].uni), (yyvsp[-3].il), 0, 0, 0, (yyvsp[-1].menuitem)); + } +#line 3294 "rcparse.c" /* yacc.c:1646 */ + break; + + case 151: +#line 1152 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = define_menuitem ((yyvsp[-5].uni), (yyvsp[-4].il), (yyvsp[-3].il), 0, 0, (yyvsp[-1].menuitem)); + } +#line 3302 "rcparse.c" /* yacc.c:1646 */ + break; + + case 152: +#line 1157 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.menuitem) = define_menuitem ((yyvsp[-7].uni), (yyvsp[-6].il), (yyvsp[-5].il), (yyvsp[-4].il), (yyvsp[-3].il), (yyvsp[-1].menuitem)); + } +#line 3310 "rcparse.c" /* yacc.c:1646 */ + break; + + case 153: +#line 1166 "rcparse.y" /* yacc.c:1646 */ + { + define_messagetable ((yyvsp[-3].id), &(yyvsp[-1].res_info), (yyvsp[0].s)); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 3321 "rcparse.c" /* yacc.c:1646 */ + break; + + case 154: +#line 1178 "rcparse.y" /* yacc.c:1646 */ + { + rcparse_rcdata (); + } +#line 3329 "rcparse.c" /* yacc.c:1646 */ + break; + + case 155: +#line 1182 "rcparse.y" /* yacc.c:1646 */ + { + rcparse_normal (); + (yyval.rcdata) = (yyvsp[0].rcdata); + } +#line 3338 "rcparse.c" /* yacc.c:1646 */ + break; + + case 156: +#line 1190 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.rcdata).first = NULL; + (yyval.rcdata).last = NULL; + } +#line 3347 "rcparse.c" /* yacc.c:1646 */ + break; + + case 157: +#line 1195 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.rcdata) = (yyvsp[0].rcdata); + } +#line 3355 "rcparse.c" /* yacc.c:1646 */ + break; + + case 158: +#line 1202 "rcparse.y" /* yacc.c:1646 */ + { + rc_rcdata_item *ri; + + ri = define_rcdata_string ((yyvsp[0].ss).s, (yyvsp[0].ss).length); + (yyval.rcdata).first = ri; + (yyval.rcdata).last = ri; + } +#line 3367 "rcparse.c" /* yacc.c:1646 */ + break; + + case 159: +#line 1210 "rcparse.y" /* yacc.c:1646 */ + { + rc_rcdata_item *ri; + + ri = define_rcdata_unistring ((yyvsp[0].suni).s, (yyvsp[0].suni).length); + (yyval.rcdata).first = ri; + (yyval.rcdata).last = ri; + } +#line 3379 "rcparse.c" /* yacc.c:1646 */ + break; + + case 160: +#line 1218 "rcparse.y" /* yacc.c:1646 */ + { + rc_rcdata_item *ri; + + ri = define_rcdata_number ((yyvsp[0].i).val, (yyvsp[0].i).dword); + (yyval.rcdata).first = ri; + (yyval.rcdata).last = ri; + } +#line 3391 "rcparse.c" /* yacc.c:1646 */ + break; + + case 161: +#line 1226 "rcparse.y" /* yacc.c:1646 */ + { + rc_rcdata_item *ri; + + ri = define_rcdata_string ((yyvsp[0].ss).s, (yyvsp[0].ss).length); + (yyval.rcdata).first = (yyvsp[-2].rcdata).first; + (yyvsp[-2].rcdata).last->next = ri; + (yyval.rcdata).last = ri; + } +#line 3404 "rcparse.c" /* yacc.c:1646 */ + break; + + case 162: +#line 1235 "rcparse.y" /* yacc.c:1646 */ + { + rc_rcdata_item *ri; + + ri = define_rcdata_unistring ((yyvsp[0].suni).s, (yyvsp[0].suni).length); + (yyval.rcdata).first = (yyvsp[-2].rcdata).first; + (yyvsp[-2].rcdata).last->next = ri; + (yyval.rcdata).last = ri; + } +#line 3417 "rcparse.c" /* yacc.c:1646 */ + break; + + case 163: +#line 1244 "rcparse.y" /* yacc.c:1646 */ + { + rc_rcdata_item *ri; + + ri = define_rcdata_number ((yyvsp[0].i).val, (yyvsp[0].i).dword); + (yyval.rcdata).first = (yyvsp[-2].rcdata).first; + (yyvsp[-2].rcdata).last->next = ri; + (yyval.rcdata).last = ri; + } +#line 3430 "rcparse.c" /* yacc.c:1646 */ + break; + + case 164: +#line 1253 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.rcdata)=(yyvsp[-1].rcdata); + } +#line 3438 "rcparse.c" /* yacc.c:1646 */ + break; + + case 165: +#line 1262 "rcparse.y" /* yacc.c:1646 */ + { sub_res_info = (yyvsp[-1].res_info); rcparse_rcdata (); } +#line 3444 "rcparse.c" /* yacc.c:1646 */ + break; + + case 166: +#line 1263 "rcparse.y" /* yacc.c:1646 */ + { rcparse_normal (); } +#line 3450 "rcparse.c" /* yacc.c:1646 */ + break; + + case 168: +#line 1269 "rcparse.y" /* yacc.c:1646 */ + { + define_stringtable (&sub_res_info, (yyvsp[-1].il), (yyvsp[0].suni).s, (yyvsp[0].suni).length); + rcparse_discard_strings (); + } +#line 3459 "rcparse.c" /* yacc.c:1646 */ + break; + + case 169: +#line 1274 "rcparse.y" /* yacc.c:1646 */ + { + define_stringtable (&sub_res_info, (yyvsp[-2].il), (yyvsp[0].suni).s, (yyvsp[0].suni).length); + rcparse_discard_strings (); + } +#line 3468 "rcparse.c" /* yacc.c:1646 */ + break; + + case 170: +#line 1279 "rcparse.y" /* yacc.c:1646 */ + { + rcparse_warning (_("invalid stringtable resource.")); + abort (); + } +#line 3477 "rcparse.c" /* yacc.c:1646 */ + break; + + case 171: +#line 1287 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id)=(yyvsp[0].id); + } +#line 3485 "rcparse.c" /* yacc.c:1646 */ + break; + + case 172: +#line 1291 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 0; + (yyval.id).u.id = 23; + } +#line 3494 "rcparse.c" /* yacc.c:1646 */ + break; + + case 173: +#line 1296 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 0; + (yyval.id).u.id = RT_RCDATA; + } +#line 3503 "rcparse.c" /* yacc.c:1646 */ + break; + + case 174: +#line 1301 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 0; + (yyval.id).u.id = RT_MANIFEST; + } +#line 3512 "rcparse.c" /* yacc.c:1646 */ + break; + + case 175: +#line 1306 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 0; + (yyval.id).u.id = RT_PLUGPLAY; + } +#line 3521 "rcparse.c" /* yacc.c:1646 */ + break; + + case 176: +#line 1311 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 0; + (yyval.id).u.id = RT_VXD; + } +#line 3530 "rcparse.c" /* yacc.c:1646 */ + break; + + case 177: +#line 1316 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 0; + (yyval.id).u.id = RT_DLGINCLUDE; + } +#line 3539 "rcparse.c" /* yacc.c:1646 */ + break; + + case 178: +#line 1321 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 0; + (yyval.id).u.id = RT_DLGINIT; + } +#line 3548 "rcparse.c" /* yacc.c:1646 */ + break; + + case 179: +#line 1326 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 0; + (yyval.id).u.id = RT_ANICURSOR; + } +#line 3557 "rcparse.c" /* yacc.c:1646 */ + break; + + case 180: +#line 1331 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 0; + (yyval.id).u.id = RT_ANIICON; + } +#line 3566 "rcparse.c" /* yacc.c:1646 */ + break; + + case 181: +#line 1342 "rcparse.y" /* yacc.c:1646 */ + { + define_user_data ((yyvsp[-5].id), (yyvsp[-4].id), &(yyvsp[-3].res_info), (yyvsp[-1].rcdata).first); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 3577 "rcparse.c" /* yacc.c:1646 */ + break; + + case 182: +#line 1349 "rcparse.y" /* yacc.c:1646 */ + { + define_user_file ((yyvsp[-3].id), (yyvsp[-2].id), &(yyvsp[-1].res_info), (yyvsp[0].s)); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 3588 "rcparse.c" /* yacc.c:1646 */ + break; + + case 183: +#line 1359 "rcparse.y" /* yacc.c:1646 */ + { + define_toolbar ((yyvsp[-7].id), &(yyvsp[-5].res_info), (yyvsp[-4].il), (yyvsp[-3].il), (yyvsp[-1].toobar_item)); + } +#line 3596 "rcparse.c" /* yacc.c:1646 */ + break; + + case 184: +#line 1364 "rcparse.y" /* yacc.c:1646 */ + { (yyval.toobar_item)= NULL; } +#line 3602 "rcparse.c" /* yacc.c:1646 */ + break; + + case 185: +#line 1366 "rcparse.y" /* yacc.c:1646 */ + { + rc_toolbar_item *c,*n; + c = (yyvsp[-2].toobar_item); + n= (rc_toolbar_item *) + res_alloc (sizeof (rc_toolbar_item)); + if (c != NULL) + while (c->next != NULL) + c = c->next; + n->prev = c; + n->next = NULL; + if (c != NULL) + c->next = n; + n->id = (yyvsp[0].id); + if ((yyvsp[-2].toobar_item) == NULL) + (yyval.toobar_item) = n; + else + (yyval.toobar_item) = (yyvsp[-2].toobar_item); + } +#line 3625 "rcparse.c" /* yacc.c:1646 */ + break; + + case 186: +#line 1385 "rcparse.y" /* yacc.c:1646 */ + { + rc_toolbar_item *c,*n; + c = (yyvsp[-1].toobar_item); + n= (rc_toolbar_item *) + res_alloc (sizeof (rc_toolbar_item)); + if (c != NULL) + while (c->next != NULL) + c = c->next; + n->prev = c; + n->next = NULL; + if (c != NULL) + c->next = n; + n->id.named = 0; + n->id.u.id = 0; + if ((yyvsp[-1].toobar_item) == NULL) + (yyval.toobar_item) = n; + else + (yyval.toobar_item) = (yyvsp[-1].toobar_item); + } +#line 3649 "rcparse.c" /* yacc.c:1646 */ + break; + + case 187: +#line 1410 "rcparse.y" /* yacc.c:1646 */ + { + define_versioninfo ((yyvsp[-5].id), language, (yyvsp[-3].fixver), (yyvsp[-1].verinfo)); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } +#line 3660 "rcparse.c" /* yacc.c:1646 */ + break; + + case 188: +#line 1420 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.fixver) = ((rc_fixed_versioninfo *) + res_alloc (sizeof (rc_fixed_versioninfo))); + memset ((yyval.fixver), 0, sizeof (rc_fixed_versioninfo)); + } +#line 3670 "rcparse.c" /* yacc.c:1646 */ + break; + + case 189: +#line 1427 "rcparse.y" /* yacc.c:1646 */ + { + (yyvsp[-5].fixver)->file_version_ms = ((yyvsp[-3].il) << 16) | ((yyvsp[-2].il) & 0xffff); + (yyvsp[-5].fixver)->file_version_ls = ((yyvsp[-1].il) << 16) | ((yyvsp[0].il) & 0xffff); + (yyval.fixver) = (yyvsp[-5].fixver); + } +#line 3680 "rcparse.c" /* yacc.c:1646 */ + break; + + case 190: +#line 1434 "rcparse.y" /* yacc.c:1646 */ + { + (yyvsp[-5].fixver)->product_version_ms = ((yyvsp[-3].il) << 16) | ((yyvsp[-2].il) & 0xffff); + (yyvsp[-5].fixver)->product_version_ls = ((yyvsp[-1].il) << 16) | ((yyvsp[0].il) & 0xffff); + (yyval.fixver) = (yyvsp[-5].fixver); + } +#line 3690 "rcparse.c" /* yacc.c:1646 */ + break; + + case 191: +#line 1440 "rcparse.y" /* yacc.c:1646 */ + { + (yyvsp[-2].fixver)->file_flags_mask = (yyvsp[0].il); + (yyval.fixver) = (yyvsp[-2].fixver); + } +#line 3699 "rcparse.c" /* yacc.c:1646 */ + break; + + case 192: +#line 1445 "rcparse.y" /* yacc.c:1646 */ + { + (yyvsp[-2].fixver)->file_flags = (yyvsp[0].il); + (yyval.fixver) = (yyvsp[-2].fixver); + } +#line 3708 "rcparse.c" /* yacc.c:1646 */ + break; + + case 193: +#line 1450 "rcparse.y" /* yacc.c:1646 */ + { + (yyvsp[-2].fixver)->file_os = (yyvsp[0].il); + (yyval.fixver) = (yyvsp[-2].fixver); + } +#line 3717 "rcparse.c" /* yacc.c:1646 */ + break; + + case 194: +#line 1455 "rcparse.y" /* yacc.c:1646 */ + { + (yyvsp[-2].fixver)->file_type = (yyvsp[0].il); + (yyval.fixver) = (yyvsp[-2].fixver); + } +#line 3726 "rcparse.c" /* yacc.c:1646 */ + break; + + case 195: +#line 1460 "rcparse.y" /* yacc.c:1646 */ + { + (yyvsp[-2].fixver)->file_subtype = (yyvsp[0].il); + (yyval.fixver) = (yyvsp[-2].fixver); + } +#line 3735 "rcparse.c" /* yacc.c:1646 */ + break; + + case 196: +#line 1474 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.verinfo) = NULL; + } +#line 3743 "rcparse.c" /* yacc.c:1646 */ + break; + + case 197: +#line 1478 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.verinfo) = append_ver_stringfileinfo ((yyvsp[-4].verinfo), (yyvsp[-1].verstringtable)); + } +#line 3751 "rcparse.c" /* yacc.c:1646 */ + break; + + case 198: +#line 1482 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.verinfo) = append_ver_varfileinfo ((yyvsp[-6].verinfo), (yyvsp[-2].uni), (yyvsp[-1].vervar)); + } +#line 3759 "rcparse.c" /* yacc.c:1646 */ + break; + + case 199: +#line 1489 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.verstringtable) = NULL; + } +#line 3767 "rcparse.c" /* yacc.c:1646 */ + break; + + case 200: +#line 1493 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.verstringtable) = append_ver_stringtable ((yyvsp[-4].verstringtable), (yyvsp[-3].s), (yyvsp[-1].verstring)); + } +#line 3775 "rcparse.c" /* yacc.c:1646 */ + break; + + case 201: +#line 1500 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.verstring) = NULL; + } +#line 3783 "rcparse.c" /* yacc.c:1646 */ + break; + + case 202: +#line 1504 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.verstring) = append_verval ((yyvsp[-4].verstring), (yyvsp[-2].uni), (yyvsp[0].uni)); + } +#line 3791 "rcparse.c" /* yacc.c:1646 */ + break; + + case 203: +#line 1511 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.vervar) = NULL; + } +#line 3799 "rcparse.c" /* yacc.c:1646 */ + break; + + case 204: +#line 1515 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.vervar) = append_vertrans ((yyvsp[-2].vervar), (yyvsp[-1].il), (yyvsp[0].il)); + } +#line 3807 "rcparse.c" /* yacc.c:1646 */ + break; + + case 205: +#line 1524 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 0; + (yyval.id).u.id = (yyvsp[0].il); + } +#line 3816 "rcparse.c" /* yacc.c:1646 */ + break; + + case 206: +#line 1529 "rcparse.y" /* yacc.c:1646 */ + { + res_unistring_to_id (&(yyval.id), (yyvsp[0].uni)); + } +#line 3824 "rcparse.c" /* yacc.c:1646 */ + break; + + case 207: +#line 1538 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.uni) = (yyvsp[0].uni); + } +#line 3832 "rcparse.c" /* yacc.c:1646 */ + break; + + case 208: +#line 1542 "rcparse.y" /* yacc.c:1646 */ + { + unichar *h = NULL; + unicode_from_ascii ((rc_uint_type *) NULL, &h, (yyvsp[0].s)); + (yyval.uni) = h; + } +#line 3842 "rcparse.c" /* yacc.c:1646 */ + break; + + case 209: +#line 1552 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.id).named = 0; + (yyval.id).u.id = (yyvsp[-1].il); + } +#line 3851 "rcparse.c" /* yacc.c:1646 */ + break; + + case 210: +#line 1557 "rcparse.y" /* yacc.c:1646 */ + { + res_unistring_to_id (&(yyval.id), (yyvsp[0].uni)); + } +#line 3859 "rcparse.c" /* yacc.c:1646 */ + break; + + case 211: +#line 1561 "rcparse.y" /* yacc.c:1646 */ + { + res_unistring_to_id (&(yyval.id), (yyvsp[-1].uni)); + } +#line 3867 "rcparse.c" /* yacc.c:1646 */ + break; + + case 212: +#line 1571 "rcparse.y" /* yacc.c:1646 */ + { + memset (&(yyval.res_info), 0, sizeof (rc_res_res_info)); + (yyval.res_info).language = language; + /* FIXME: Is this the right default? */ + (yyval.res_info).memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE; + } +#line 3878 "rcparse.c" /* yacc.c:1646 */ + break; + + case 213: +#line 1578 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.res_info) = (yyvsp[-1].res_info); + (yyval.res_info).memflags |= (yyvsp[0].memflags).on; + (yyval.res_info).memflags &=~ (yyvsp[0].memflags).off; + } +#line 3888 "rcparse.c" /* yacc.c:1646 */ + break; + + case 214: +#line 1584 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.res_info) = (yyvsp[-2].res_info); + (yyval.res_info).characteristics = (yyvsp[0].il); + } +#line 3897 "rcparse.c" /* yacc.c:1646 */ + break; + + case 215: +#line 1589 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.res_info) = (yyvsp[-3].res_info); + (yyval.res_info).language = (yyvsp[-1].il) | ((yyvsp[0].il) << SUBLANG_SHIFT); + } +#line 3906 "rcparse.c" /* yacc.c:1646 */ + break; + + case 216: +#line 1594 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.res_info) = (yyvsp[-2].res_info); + (yyval.res_info).version = (yyvsp[0].il); + } +#line 3915 "rcparse.c" /* yacc.c:1646 */ + break; + + case 217: +#line 1604 "rcparse.y" /* yacc.c:1646 */ + { + memset (&(yyval.res_info), 0, sizeof (rc_res_res_info)); + (yyval.res_info).language = language; + (yyval.res_info).memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE; + } +#line 3925 "rcparse.c" /* yacc.c:1646 */ + break; + + case 218: +#line 1610 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.res_info) = (yyvsp[-1].res_info); + (yyval.res_info).memflags |= (yyvsp[0].memflags).on; + (yyval.res_info).memflags &=~ (yyvsp[0].memflags).off; + } +#line 3935 "rcparse.c" /* yacc.c:1646 */ + break; + + case 219: +#line 1621 "rcparse.y" /* yacc.c:1646 */ + { + memset (&(yyval.res_info), 0, sizeof (rc_res_res_info)); + (yyval.res_info).language = language; + (yyval.res_info).memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE; + } +#line 3945 "rcparse.c" /* yacc.c:1646 */ + break; + + case 220: +#line 1627 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.res_info) = (yyvsp[-1].res_info); + (yyval.res_info).memflags |= (yyvsp[0].memflags).on; + (yyval.res_info).memflags &=~ (yyvsp[0].memflags).off; + } +#line 3955 "rcparse.c" /* yacc.c:1646 */ + break; + + case 221: +#line 1639 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.memflags).on = MEMFLAG_MOVEABLE; + (yyval.memflags).off = 0; + } +#line 3964 "rcparse.c" /* yacc.c:1646 */ + break; + + case 222: +#line 1644 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.memflags).on = 0; + (yyval.memflags).off = MEMFLAG_MOVEABLE; + } +#line 3973 "rcparse.c" /* yacc.c:1646 */ + break; + + case 223: +#line 1649 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.memflags).on = MEMFLAG_PURE; + (yyval.memflags).off = 0; + } +#line 3982 "rcparse.c" /* yacc.c:1646 */ + break; + + case 224: +#line 1654 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.memflags).on = 0; + (yyval.memflags).off = MEMFLAG_PURE; + } +#line 3991 "rcparse.c" /* yacc.c:1646 */ + break; + + case 225: +#line 1659 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.memflags).on = MEMFLAG_PRELOAD; + (yyval.memflags).off = 0; + } +#line 4000 "rcparse.c" /* yacc.c:1646 */ + break; + + case 226: +#line 1664 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.memflags).on = 0; + (yyval.memflags).off = MEMFLAG_PRELOAD; + } +#line 4009 "rcparse.c" /* yacc.c:1646 */ + break; + + case 227: +#line 1669 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.memflags).on = MEMFLAG_DISCARDABLE; + (yyval.memflags).off = 0; + } +#line 4018 "rcparse.c" /* yacc.c:1646 */ + break; + + case 228: +#line 1679 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.s) = (yyvsp[0].s); + } +#line 4026 "rcparse.c" /* yacc.c:1646 */ + break; + + case 229: +#line 1683 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.s) = (yyvsp[0].s); + } +#line 4034 "rcparse.c" /* yacc.c:1646 */ + break; + + case 230: +#line 1691 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.uni) = (yyvsp[0].uni); + } +#line 4042 "rcparse.c" /* yacc.c:1646 */ + break; + + case 231: +#line 1696 "rcparse.y" /* yacc.c:1646 */ + { + rc_uint_type l1 = unichar_len ((yyvsp[-1].uni)); + rc_uint_type l2 = unichar_len ((yyvsp[0].uni)); + unichar *h = (unichar *) res_alloc ((l1 + l2 + 1) * sizeof (unichar)); + if (l1 != 0) + memcpy (h, (yyvsp[-1].uni), l1 * sizeof (unichar)); + if (l2 != 0) + memcpy (h + l1, (yyvsp[0].uni), l2 * sizeof (unichar)); + h[l1 + l2] = 0; + (yyval.uni) = h; + } +#line 4058 "rcparse.c" /* yacc.c:1646 */ + break; + + case 232: +#line 1711 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.uni) = unichar_dup ((yyvsp[0].uni)); + } +#line 4066 "rcparse.c" /* yacc.c:1646 */ + break; + + case 233: +#line 1715 "rcparse.y" /* yacc.c:1646 */ + { + unichar *h = NULL; + unicode_from_ascii ((rc_uint_type *) NULL, &h, (yyvsp[0].s)); + (yyval.uni) = h; + } +#line 4076 "rcparse.c" /* yacc.c:1646 */ + break; + + case 234: +#line 1724 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.suni) = (yyvsp[0].suni); + } +#line 4084 "rcparse.c" /* yacc.c:1646 */ + break; + + case 235: +#line 1728 "rcparse.y" /* yacc.c:1646 */ + { + unichar *h = NULL; + rc_uint_type l = 0; + unicode_from_ascii_len (&l, &h, (yyvsp[0].ss).s, (yyvsp[0].ss).length); + (yyval.suni).s = h; + (yyval.suni).length = l; + } +#line 4096 "rcparse.c" /* yacc.c:1646 */ + break; + + case 236: +#line 1740 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.suni) = (yyvsp[0].suni); + } +#line 4104 "rcparse.c" /* yacc.c:1646 */ + break; + + case 237: +#line 1745 "rcparse.y" /* yacc.c:1646 */ + { + rc_uint_type l1 = (yyvsp[-1].suni).length; + rc_uint_type l2 = (yyvsp[0].suni).length; + unichar *h = (unichar *) res_alloc ((l1 + l2 + 1) * sizeof (unichar)); + if (l1 != 0) + memcpy (h, (yyvsp[-1].suni).s, l1 * sizeof (unichar)); + if (l2 != 0) + memcpy (h + l1, (yyvsp[0].suni).s, l2 * sizeof (unichar)); + h[l1 + l2] = 0; + (yyval.suni).length = l1 + l2; + (yyval.suni).s = h; + } +#line 4121 "rcparse.c" /* yacc.c:1646 */ + break; + + case 238: +#line 1761 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.ss) = (yyvsp[0].ss); + } +#line 4129 "rcparse.c" /* yacc.c:1646 */ + break; + + case 239: +#line 1765 "rcparse.y" /* yacc.c:1646 */ + { + rc_uint_type l = (yyvsp[-1].ss).length + (yyvsp[0].ss).length; + char *h = (char *) res_alloc (l); + memcpy (h, (yyvsp[-1].ss).s, (yyvsp[-1].ss).length); + memcpy (h + (yyvsp[-1].ss).length, (yyvsp[0].ss).s, (yyvsp[0].ss).length); + (yyval.ss).s = h; + (yyval.ss).length = l; + } +#line 4142 "rcparse.c" /* yacc.c:1646 */ + break; + + case 240: +#line 1777 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.suni) = (yyvsp[0].suni); + } +#line 4150 "rcparse.c" /* yacc.c:1646 */ + break; + + case 241: +#line 1781 "rcparse.y" /* yacc.c:1646 */ + { + rc_uint_type l = (yyvsp[-1].suni).length + (yyvsp[0].suni).length; + unichar *h = (unichar *) res_alloc (l * sizeof (unichar)); + memcpy (h, (yyvsp[-1].suni).s, (yyvsp[-1].suni).length * sizeof (unichar)); + memcpy (h + (yyvsp[-1].suni).length, (yyvsp[0].suni).s, (yyvsp[0].suni).length * sizeof (unichar)); + (yyval.suni).s = h; + (yyval.suni).length = l; + } +#line 4163 "rcparse.c" /* yacc.c:1646 */ + break; + + case 242: +#line 1803 "rcparse.y" /* yacc.c:1646 */ + { + style |= (yyvsp[0].il); + } +#line 4171 "rcparse.c" /* yacc.c:1646 */ + break; + + case 243: +#line 1807 "rcparse.y" /* yacc.c:1646 */ + { + style &=~ (yyvsp[0].il); + } +#line 4179 "rcparse.c" /* yacc.c:1646 */ + break; + + case 244: +#line 1811 "rcparse.y" /* yacc.c:1646 */ + { + style |= (yyvsp[0].il); + } +#line 4187 "rcparse.c" /* yacc.c:1646 */ + break; + + case 245: +#line 1815 "rcparse.y" /* yacc.c:1646 */ + { + style &=~ (yyvsp[0].il); + } +#line 4195 "rcparse.c" /* yacc.c:1646 */ + break; + + case 246: +#line 1822 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.il) = (yyvsp[0].i).val; + } +#line 4203 "rcparse.c" /* yacc.c:1646 */ + break; + + case 247: +#line 1826 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.il) = (yyvsp[-1].il); + } +#line 4211 "rcparse.c" /* yacc.c:1646 */ + break; + + case 248: +#line 1835 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.il) = 0; + } +#line 4219 "rcparse.c" /* yacc.c:1646 */ + break; + + case 249: +#line 1839 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.il) = (yyvsp[0].il); + } +#line 4227 "rcparse.c" /* yacc.c:1646 */ + break; + + case 250: +#line 1848 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.il) = (yyvsp[0].il); + } +#line 4235 "rcparse.c" /* yacc.c:1646 */ + break; + + case 251: +#line 1857 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.il) = (yyvsp[0].i).val; + } +#line 4243 "rcparse.c" /* yacc.c:1646 */ + break; + + case 252: +#line 1866 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i) = (yyvsp[0].i); + } +#line 4251 "rcparse.c" /* yacc.c:1646 */ + break; + + case 253: +#line 1870 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i) = (yyvsp[-1].i); + } +#line 4259 "rcparse.c" /* yacc.c:1646 */ + break; + + case 254: +#line 1874 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = ~ (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[0].i).dword; + } +#line 4268 "rcparse.c" /* yacc.c:1646 */ + break; + + case 255: +#line 1879 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = - (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[0].i).dword; + } +#line 4277 "rcparse.c" /* yacc.c:1646 */ + break; + + case 256: +#line 1884 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val * (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4286 "rcparse.c" /* yacc.c:1646 */ + break; + + case 257: +#line 1889 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val / ((yyvsp[0].i).val ? (yyvsp[0].i).val : 1); + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4295 "rcparse.c" /* yacc.c:1646 */ + break; + + case 258: +#line 1894 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val % ((yyvsp[0].i).val ? (yyvsp[0].i).val : 1); + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4304 "rcparse.c" /* yacc.c:1646 */ + break; + + case 259: +#line 1899 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val + (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4313 "rcparse.c" /* yacc.c:1646 */ + break; + + case 260: +#line 1904 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val - (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4322 "rcparse.c" /* yacc.c:1646 */ + break; + + case 261: +#line 1909 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val & (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4331 "rcparse.c" /* yacc.c:1646 */ + break; + + case 262: +#line 1914 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val ^ (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4340 "rcparse.c" /* yacc.c:1646 */ + break; + + case 263: +#line 1919 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val | (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4349 "rcparse.c" /* yacc.c:1646 */ + break; + + case 264: +#line 1930 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.il) = (yyvsp[0].il); + } +#line 4357 "rcparse.c" /* yacc.c:1646 */ + break; + + case 265: +#line 1939 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.il) = (yyvsp[0].i).val; + } +#line 4365 "rcparse.c" /* yacc.c:1646 */ + break; + + case 266: +#line 1950 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i) = (yyvsp[0].i); + } +#line 4373 "rcparse.c" /* yacc.c:1646 */ + break; + + case 267: +#line 1954 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i) = (yyvsp[-1].i); + } +#line 4381 "rcparse.c" /* yacc.c:1646 */ + break; + + case 268: +#line 1958 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = ~ (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[0].i).dword; + } +#line 4390 "rcparse.c" /* yacc.c:1646 */ + break; + + case 269: +#line 1963 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val * (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4399 "rcparse.c" /* yacc.c:1646 */ + break; + + case 270: +#line 1968 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val / ((yyvsp[0].i).val ? (yyvsp[0].i).val : 1); + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4408 "rcparse.c" /* yacc.c:1646 */ + break; + + case 271: +#line 1973 "rcparse.y" /* yacc.c:1646 */ + { + /* PR 17512: file: 89105a25. */ + (yyval.i).val = (yyvsp[-2].i).val % ((yyvsp[0].i).val ? (yyvsp[0].i).val : 1); + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4418 "rcparse.c" /* yacc.c:1646 */ + break; + + case 272: +#line 1979 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val + (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4427 "rcparse.c" /* yacc.c:1646 */ + break; + + case 273: +#line 1984 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val - (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4436 "rcparse.c" /* yacc.c:1646 */ + break; + + case 274: +#line 1989 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val & (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4445 "rcparse.c" /* yacc.c:1646 */ + break; + + case 275: +#line 1994 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val ^ (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4454 "rcparse.c" /* yacc.c:1646 */ + break; + + case 276: +#line 1999 "rcparse.y" /* yacc.c:1646 */ + { + (yyval.i).val = (yyvsp[-2].i).val | (yyvsp[0].i).val; + (yyval.i).dword = (yyvsp[-2].i).dword || (yyvsp[0].i).dword; + } +#line 4463 "rcparse.c" /* yacc.c:1646 */ + break; + + +#line 4467 "rcparse.c" /* yacc.c:1646 */ + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} +#line 2005 "rcparse.y" /* yacc.c:1906 */ + + +/* Set the language from the command line. */ + +void +rcparse_set_language (int lang) +{ + language = lang; +} diff --git a/support/sdbinutils/binutils/rcparse.h b/support/sdbinutils/binutils/rcparse.h new file mode 100644 index 0000000..9ca7ef3 --- /dev/null +++ b/support/sdbinutils/binutils/rcparse.h @@ -0,0 +1,308 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef YY_YY_RCPARSE_H_INCLUDED +# define YY_YY_RCPARSE_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + BEG = 258, + END = 259, + ACCELERATORS = 260, + VIRTKEY = 261, + ASCII = 262, + NOINVERT = 263, + SHIFT = 264, + CONTROL = 265, + ALT = 266, + BITMAP = 267, + CURSOR = 268, + DIALOG = 269, + DIALOGEX = 270, + EXSTYLE = 271, + CAPTION = 272, + CLASS = 273, + STYLE = 274, + AUTO3STATE = 275, + AUTOCHECKBOX = 276, + AUTORADIOBUTTON = 277, + CHECKBOX = 278, + COMBOBOX = 279, + CTEXT = 280, + DEFPUSHBUTTON = 281, + EDITTEXT = 282, + GROUPBOX = 283, + LISTBOX = 284, + LTEXT = 285, + PUSHBOX = 286, + PUSHBUTTON = 287, + RADIOBUTTON = 288, + RTEXT = 289, + SCROLLBAR = 290, + STATE3 = 291, + USERBUTTON = 292, + BEDIT = 293, + HEDIT = 294, + IEDIT = 295, + FONT = 296, + ICON = 297, + ANICURSOR = 298, + ANIICON = 299, + DLGINCLUDE = 300, + DLGINIT = 301, + FONTDIR = 302, + HTML = 303, + MANIFEST = 304, + PLUGPLAY = 305, + VXD = 306, + TOOLBAR = 307, + BUTTON = 308, + LANGUAGE = 309, + CHARACTERISTICS = 310, + VERSIONK = 311, + MENU = 312, + MENUEX = 313, + MENUITEM = 314, + SEPARATOR = 315, + POPUP = 316, + CHECKED = 317, + GRAYED = 318, + HELP = 319, + INACTIVE = 320, + MENUBARBREAK = 321, + MENUBREAK = 322, + MESSAGETABLE = 323, + RCDATA = 324, + STRINGTABLE = 325, + VERSIONINFO = 326, + FILEVERSION = 327, + PRODUCTVERSION = 328, + FILEFLAGSMASK = 329, + FILEFLAGS = 330, + FILEOS = 331, + FILETYPE = 332, + FILESUBTYPE = 333, + BLOCKSTRINGFILEINFO = 334, + BLOCKVARFILEINFO = 335, + VALUE = 336, + BLOCK = 337, + MOVEABLE = 338, + FIXED = 339, + PURE = 340, + IMPURE = 341, + PRELOAD = 342, + LOADONCALL = 343, + DISCARDABLE = 344, + NOT = 345, + QUOTEDUNISTRING = 346, + QUOTEDSTRING = 347, + STRING = 348, + NUMBER = 349, + SIZEDUNISTRING = 350, + SIZEDSTRING = 351, + IGNORED_TOKEN = 352, + NEG = 353 + }; +#endif +/* Tokens. */ +#define BEG 258 +#define END 259 +#define ACCELERATORS 260 +#define VIRTKEY 261 +#define ASCII 262 +#define NOINVERT 263 +#define SHIFT 264 +#define CONTROL 265 +#define ALT 266 +#define BITMAP 267 +#define CURSOR 268 +#define DIALOG 269 +#define DIALOGEX 270 +#define EXSTYLE 271 +#define CAPTION 272 +#define CLASS 273 +#define STYLE 274 +#define AUTO3STATE 275 +#define AUTOCHECKBOX 276 +#define AUTORADIOBUTTON 277 +#define CHECKBOX 278 +#define COMBOBOX 279 +#define CTEXT 280 +#define DEFPUSHBUTTON 281 +#define EDITTEXT 282 +#define GROUPBOX 283 +#define LISTBOX 284 +#define LTEXT 285 +#define PUSHBOX 286 +#define PUSHBUTTON 287 +#define RADIOBUTTON 288 +#define RTEXT 289 +#define SCROLLBAR 290 +#define STATE3 291 +#define USERBUTTON 292 +#define BEDIT 293 +#define HEDIT 294 +#define IEDIT 295 +#define FONT 296 +#define ICON 297 +#define ANICURSOR 298 +#define ANIICON 299 +#define DLGINCLUDE 300 +#define DLGINIT 301 +#define FONTDIR 302 +#define HTML 303 +#define MANIFEST 304 +#define PLUGPLAY 305 +#define VXD 306 +#define TOOLBAR 307 +#define BUTTON 308 +#define LANGUAGE 309 +#define CHARACTERISTICS 310 +#define VERSIONK 311 +#define MENU 312 +#define MENUEX 313 +#define MENUITEM 314 +#define SEPARATOR 315 +#define POPUP 316 +#define CHECKED 317 +#define GRAYED 318 +#define HELP 319 +#define INACTIVE 320 +#define MENUBARBREAK 321 +#define MENUBREAK 322 +#define MESSAGETABLE 323 +#define RCDATA 324 +#define STRINGTABLE 325 +#define VERSIONINFO 326 +#define FILEVERSION 327 +#define PRODUCTVERSION 328 +#define FILEFLAGSMASK 329 +#define FILEFLAGS 330 +#define FILEOS 331 +#define FILETYPE 332 +#define FILESUBTYPE 333 +#define BLOCKSTRINGFILEINFO 334 +#define BLOCKVARFILEINFO 335 +#define VALUE 336 +#define BLOCK 337 +#define MOVEABLE 338 +#define FIXED 339 +#define PURE 340 +#define IMPURE 341 +#define PRELOAD 342 +#define LOADONCALL 343 +#define DISCARDABLE 344 +#define NOT 345 +#define QUOTEDUNISTRING 346 +#define QUOTEDSTRING 347 +#define STRING 348 +#define NUMBER 349 +#define SIZEDUNISTRING 350 +#define SIZEDSTRING 351 +#define IGNORED_TOKEN 352 +#define NEG 353 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 68 "rcparse.y" /* yacc.c:1909 */ + + rc_accelerator acc; + rc_accelerator *pacc; + rc_dialog_control *dialog_control; + rc_menuitem *menuitem; + struct + { + rc_rcdata_item *first; + rc_rcdata_item *last; + } rcdata; + rc_rcdata_item *rcdata_item; + rc_fixed_versioninfo *fixver; + rc_ver_info *verinfo; + rc_ver_stringtable *verstringtable; + rc_ver_stringinfo *verstring; + rc_ver_varinfo *vervar; + rc_toolbar_item *toobar_item; + rc_res_id id; + rc_res_res_info res_info; + struct + { + rc_uint_type on; + rc_uint_type off; + } memflags; + struct + { + rc_uint_type val; + /* Nonzero if this number was explicitly specified as long. */ + int dword; + } i; + rc_uint_type il; + rc_uint_type is; + const char *s; + struct + { + rc_uint_type length; + const char *s; + } ss; + unichar *uni; + struct + { + rc_uint_type length; + const unichar *s; + } suni; + +#line 296 "rcparse.h" /* yacc.c:1909 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_RCPARSE_H_INCLUDED */ diff --git a/support/sdbinutils/binutils/rcparse.y b/support/sdbinutils/binutils/rcparse.y new file mode 100644 index 0000000..cf499b3 --- /dev/null +++ b/support/sdbinutils/binutils/rcparse.y @@ -0,0 +1,2013 @@ +%{ /* rcparse.y -- parser for Windows rc files + Copyright (C) 1997-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Support. + Extended by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + + +/* This is a parser for Windows rc files. It is based on the parser + by Gunther Ebert . */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" +#include "libiberty.h" +#include "windres.h" +#include "safe-ctype.h" + +/* The current language. */ + +static unsigned short language; + +/* The resource information during a sub statement. */ + +static rc_res_res_info sub_res_info; + +/* Dialog information. This is built by the nonterminals styles and + controls. */ + +static rc_dialog dialog; + +/* This is used when building a style. It is modified by the + nonterminal styleexpr. */ + +static unsigned long style; + +/* These are used when building a control. They are set before using + control_params. */ + +static rc_uint_type base_style; +static rc_uint_type default_style; +static rc_res_id class; +static rc_res_id res_text_field; +static unichar null_unichar; + +/* This is used for COMBOBOX, LISTBOX and EDITTEXT which + do not allow resource 'text' field in control definition. */ +static const rc_res_id res_null_text = { 1, {{0, &null_unichar}}}; + +%} + +%union +{ + rc_accelerator acc; + rc_accelerator *pacc; + rc_dialog_control *dialog_control; + rc_menuitem *menuitem; + struct + { + rc_rcdata_item *first; + rc_rcdata_item *last; + } rcdata; + rc_rcdata_item *rcdata_item; + rc_fixed_versioninfo *fixver; + rc_ver_info *verinfo; + rc_ver_stringtable *verstringtable; + rc_ver_stringinfo *verstring; + rc_ver_varinfo *vervar; + rc_toolbar_item *toobar_item; + rc_res_id id; + rc_res_res_info res_info; + struct + { + rc_uint_type on; + rc_uint_type off; + } memflags; + struct + { + rc_uint_type val; + /* Nonzero if this number was explicitly specified as long. */ + int dword; + } i; + rc_uint_type il; + rc_uint_type is; + const char *s; + struct + { + rc_uint_type length; + const char *s; + } ss; + unichar *uni; + struct + { + rc_uint_type length; + const unichar *s; + } suni; +}; + +%token BEG END +%token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT +%token BITMAP +%token CURSOR +%token DIALOG DIALOGEX EXSTYLE CAPTION CLASS STYLE +%token AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON CHECKBOX COMBOBOX CTEXT +%token DEFPUSHBUTTON EDITTEXT GROUPBOX LISTBOX LTEXT PUSHBOX PUSHBUTTON +%token RADIOBUTTON RTEXT SCROLLBAR STATE3 USERBUTTON +%token BEDIT HEDIT IEDIT +%token FONT +%token ICON +%token ANICURSOR ANIICON DLGINCLUDE DLGINIT FONTDIR HTML MANIFEST PLUGPLAY VXD TOOLBAR BUTTON +%token LANGUAGE CHARACTERISTICS VERSIONK +%token MENU MENUEX MENUITEM SEPARATOR POPUP CHECKED GRAYED HELP INACTIVE +%token MENUBARBREAK MENUBREAK +%token MESSAGETABLE +%token RCDATA +%token STRINGTABLE +%token VERSIONINFO FILEVERSION PRODUCTVERSION FILEFLAGSMASK FILEFLAGS +%token FILEOS FILETYPE FILESUBTYPE BLOCKSTRINGFILEINFO BLOCKVARFILEINFO +%token VALUE +%token BLOCK +%token MOVEABLE FIXED PURE IMPURE PRELOAD LOADONCALL DISCARDABLE +%token NOT +%token QUOTEDUNISTRING +%token QUOTEDSTRING STRING +%token NUMBER +%token SIZEDUNISTRING +%token SIZEDSTRING +%token IGNORED_TOKEN + +%type acc_entries +%type acc_entry acc_event +%type control control_params +%type menuitems menuitem menuexitems menuexitem +%type optrcdata_data optrcdata_data_int rcdata_data +%type opt_control_data +%type fixedverinfo +%type verblocks +%type verstringtables +%type vervals +%type vertrans +%type toolbar_data +%type suboptions memflags_move_discard memflags_move +%type memflag +%type id rcdata_id optresidc resref resid cresid +%type exstyle parennumber +%type numexpr posnumexpr cnumexpr optcnumexpr cposnumexpr +%type acc_options acc_option menuitem_flags menuitem_flag +%type file_name +%type res_unicode_string resname res_unicode_string_concat +%type sizedstring +%type sizedunistring res_unicode_sizedstring res_unicode_sizedstring_concat +%type sizednumexpr sizedposnumexpr + +%left '|' +%left '^' +%left '&' +%left '+' '-' +%left '*' '/' '%' +%right '~' NEG + +%% + +input: + /* empty */ + | input accelerator + | input bitmap + | input cursor + | input dialog + | input font + | input icon + | input language + | input menu + | input menuex + | input messagetable + | input stringtable + | input toolbar + | input user + | input versioninfo + | input IGNORED_TOKEN + ; + +/* Accelerator resources. */ + +accelerator: + id ACCELERATORS suboptions BEG acc_entries END + { + define_accelerator ($1, &$3, $5); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + ; + +acc_entries: + /* empty */ + { + $$ = NULL; + } + | acc_entries acc_entry + { + rc_accelerator *a; + + a = (rc_accelerator *) res_alloc (sizeof *a); + *a = $2; + if ($1 == NULL) + $$ = a; + else + { + rc_accelerator **pp; + + for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next) + ; + *pp = a; + $$ = $1; + } + } + ; + +acc_entry: + acc_event cposnumexpr + { + $$ = $1; + $$.id = $2; + } + | acc_event cposnumexpr ',' acc_options + { + $$ = $1; + $$.id = $2; + $$.flags |= $4; + if (($$.flags & ACC_VIRTKEY) == 0 + && ($$.flags & (ACC_SHIFT | ACC_CONTROL)) != 0) + rcparse_warning (_("inappropriate modifiers for non-VIRTKEY")); + } + ; + +acc_event: + QUOTEDSTRING + { + const char *s = $1; + char ch; + + $$.next = NULL; + $$.id = 0; + ch = *s; + if (ch != '^') + $$.flags = 0; + else + { + $$.flags = ACC_CONTROL | ACC_VIRTKEY; + ++s; + ch = TOUPPER (s[0]); + } + $$.key = ch; + if (s[1] != '\0') + rcparse_warning (_("accelerator should only be one character")); + } + | posnumexpr + { + $$.next = NULL; + $$.flags = 0; + $$.id = 0; + $$.key = $1; + } + ; + +acc_options: + acc_option + { + $$ = $1; + } + | acc_options ',' acc_option + { + $$ = $1 | $3; + } + /* I've had one report that the comma is optional. */ + | acc_options acc_option + { + $$ = $1 | $2; + } + ; + +acc_option: + VIRTKEY + { + $$ = ACC_VIRTKEY; + } + | ASCII + { + /* This is just the absence of VIRTKEY. */ + $$ = 0; + } + | NOINVERT + { + $$ = ACC_NOINVERT; + } + | SHIFT + { + $$ = ACC_SHIFT; + } + | CONTROL + { + $$ = ACC_CONTROL; + } + | ALT + { + $$ = ACC_ALT; + } + ; + +/* Bitmap resources. */ + +bitmap: + id BITMAP memflags_move file_name + { + define_bitmap ($1, &$3, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + ; + +/* Cursor resources. */ + +cursor: + id CURSOR memflags_move_discard file_name + { + define_cursor ($1, &$3, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + ; + +/* Dialog resources. */ + +dialog: + id DIALOG memflags_move exstyle posnumexpr cnumexpr cnumexpr + cnumexpr + { + memset (&dialog, 0, sizeof dialog); + dialog.x = $5; + dialog.y = $6; + dialog.width = $7; + dialog.height = $8; + dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU; + dialog.exstyle = $4; + dialog.menu.named = 1; + dialog.class.named = 1; + dialog.font = NULL; + dialog.ex = NULL; + dialog.controls = NULL; + sub_res_info = $3; + style = 0; + } + styles BEG controls END + { + define_dialog ($1, &sub_res_info, &dialog); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr + cnumexpr + { + memset (&dialog, 0, sizeof dialog); + dialog.x = $5; + dialog.y = $6; + dialog.width = $7; + dialog.height = $8; + dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU; + dialog.exstyle = $4; + dialog.menu.named = 1; + dialog.class.named = 1; + dialog.font = NULL; + dialog.ex = ((rc_dialog_ex *) + res_alloc (sizeof (rc_dialog_ex))); + memset (dialog.ex, 0, sizeof (rc_dialog_ex)); + dialog.controls = NULL; + sub_res_info = $3; + style = 0; + } + styles BEG controls END + { + define_dialog ($1, &sub_res_info, &dialog); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr + cnumexpr cnumexpr + { + memset (&dialog, 0, sizeof dialog); + dialog.x = $5; + dialog.y = $6; + dialog.width = $7; + dialog.height = $8; + dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU; + dialog.exstyle = $4; + dialog.menu.named = 1; + dialog.class.named = 1; + dialog.font = NULL; + dialog.ex = ((rc_dialog_ex *) + res_alloc (sizeof (rc_dialog_ex))); + memset (dialog.ex, 0, sizeof (rc_dialog_ex)); + dialog.ex->help = $9; + dialog.controls = NULL; + sub_res_info = $3; + style = 0; + } + styles BEG controls END + { + define_dialog ($1, &sub_res_info, &dialog); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + ; + +exstyle: + /* empty */ + { + $$ = 0; + } + | EXSTYLE '=' numexpr + { + $$ = $3; + } + ; + +styles: + /* empty */ + | styles CAPTION res_unicode_string_concat + { + dialog.style |= WS_CAPTION; + style |= WS_CAPTION; + dialog.caption = $3; + } + | styles CLASS id + { + dialog.class = $3; + } + | styles STYLE + styleexpr + { + dialog.style = style; + } + | styles EXSTYLE numexpr + { + dialog.exstyle = $3; + } + | styles CLASS res_unicode_string_concat + { + res_unistring_to_id (& dialog.class, $3); + } + | styles FONT numexpr ',' res_unicode_string_concat + { + dialog.style |= DS_SETFONT; + style |= DS_SETFONT; + dialog.pointsize = $3; + dialog.font = $5; + if (dialog.ex != NULL) + { + dialog.ex->weight = 0; + dialog.ex->italic = 0; + dialog.ex->charset = 1; + } + } + | styles FONT numexpr ',' res_unicode_string_concat cnumexpr + { + dialog.style |= DS_SETFONT; + style |= DS_SETFONT; + dialog.pointsize = $3; + dialog.font = $5; + if (dialog.ex == NULL) + rcparse_warning (_("extended FONT requires DIALOGEX")); + else + { + dialog.ex->weight = $6; + dialog.ex->italic = 0; + dialog.ex->charset = 1; + } + } + | styles FONT numexpr ',' res_unicode_string_concat cnumexpr cnumexpr + { + dialog.style |= DS_SETFONT; + style |= DS_SETFONT; + dialog.pointsize = $3; + dialog.font = $5; + if (dialog.ex == NULL) + rcparse_warning (_("extended FONT requires DIALOGEX")); + else + { + dialog.ex->weight = $6; + dialog.ex->italic = $7; + dialog.ex->charset = 1; + } + } + | styles FONT numexpr ',' res_unicode_string_concat cnumexpr cnumexpr cnumexpr + { + dialog.style |= DS_SETFONT; + style |= DS_SETFONT; + dialog.pointsize = $3; + dialog.font = $5; + if (dialog.ex == NULL) + rcparse_warning (_("extended FONT requires DIALOGEX")); + else + { + dialog.ex->weight = $6; + dialog.ex->italic = $7; + dialog.ex->charset = $8; + } + } + | styles MENU id + { + dialog.menu = $3; + } + | styles CHARACTERISTICS numexpr + { + sub_res_info.characteristics = $3; + } + | styles LANGUAGE numexpr cnumexpr + { + sub_res_info.language = $3 | ($4 << SUBLANG_SHIFT); + } + | styles VERSIONK numexpr + { + sub_res_info.version = $3; + } + ; + +controls: + /* empty */ + | controls control + { + rc_dialog_control **pp; + + for (pp = &dialog.controls; *pp != NULL; pp = &(*pp)->next) + ; + *pp = $2; + } + ; + +control: + AUTO3STATE optresidc + { + default_style = BS_AUTO3STATE | WS_TABSTOP; + base_style = BS_AUTO3STATE; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = $2; + } + control_params + { + $$ = $4; + } + | AUTOCHECKBOX optresidc + { + default_style = BS_AUTOCHECKBOX | WS_TABSTOP; + base_style = BS_AUTOCHECKBOX; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = $2; + } + control_params + { + $$ = $4; + } + | AUTORADIOBUTTON optresidc + { + default_style = BS_AUTORADIOBUTTON | WS_TABSTOP; + base_style = BS_AUTORADIOBUTTON; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = $2; + } + control_params + { + $$ = $4; + } + | BEDIT optresidc + { + default_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + base_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_EDIT; + res_text_field = $2; + } + control_params + { + $$ = $4; + if (dialog.ex == NULL) + rcparse_warning (_("BEDIT requires DIALOGEX")); + res_string_to_id (&$$->class, "BEDIT"); + } + | CHECKBOX optresidc + { + default_style = BS_CHECKBOX | WS_TABSTOP; + base_style = BS_CHECKBOX | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = $2; + } + control_params + { + $$ = $4; + } + | COMBOBOX + { + /* This is as per MSDN documentation. With some (???) + versions of MS rc.exe their is no default style. */ + default_style = CBS_SIMPLE | WS_TABSTOP; + base_style = 0; + class.named = 0; + class.u.id = CTL_COMBOBOX; + res_text_field = res_null_text; + } + control_params + { + $$ = $3; + } + | CONTROL optresidc numexpr cresid control_styleexpr cnumexpr + cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data + { + $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10); + if ($11 != NULL) + { + if (dialog.ex == NULL) + rcparse_warning (_("control data requires DIALOGEX")); + $$->data = $11; + } + } + | CONTROL optresidc numexpr cresid control_styleexpr cnumexpr + cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data + { + $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10); + if (dialog.ex == NULL) + rcparse_warning (_("help ID requires DIALOGEX")); + $$->help = $11; + $$->data = $12; + } + | CTEXT optresidc + { + default_style = SS_CENTER | WS_GROUP; + base_style = SS_CENTER; + class.named = 0; + class.u.id = CTL_STATIC; + res_text_field = $2; + } + control_params + { + $$ = $4; + } + | DEFPUSHBUTTON optresidc + { + default_style = BS_DEFPUSHBUTTON | WS_TABSTOP; + base_style = BS_DEFPUSHBUTTON | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = $2; + } + control_params + { + $$ = $4; + } + | EDITTEXT + { + default_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + base_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_EDIT; + res_text_field = res_null_text; + } + control_params + { + $$ = $3; + } + | GROUPBOX optresidc + { + default_style = BS_GROUPBOX; + base_style = BS_GROUPBOX; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = $2; + } + control_params + { + $$ = $4; + } + | HEDIT optresidc + { + default_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + base_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_EDIT; + res_text_field = $2; + } + control_params + { + $$ = $4; + if (dialog.ex == NULL) + rcparse_warning (_("IEDIT requires DIALOGEX")); + res_string_to_id (&$$->class, "HEDIT"); + } + | ICON resref numexpr cnumexpr cnumexpr opt_control_data + { + $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $6, + dialog.ex); + } + | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr + opt_control_data + { + $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $8, + dialog.ex); + } + | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr + icon_styleexpr optcnumexpr opt_control_data + { + $$ = define_icon_control ($2, $3, $4, $5, style, $9, 0, $10, + dialog.ex); + } + | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr + icon_styleexpr cnumexpr cnumexpr opt_control_data + { + $$ = define_icon_control ($2, $3, $4, $5, style, $9, $10, $11, + dialog.ex); + } + | IEDIT optresidc + { + default_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + base_style = ES_LEFT | WS_BORDER | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_EDIT; + res_text_field = $2; + } + control_params + { + $$ = $4; + if (dialog.ex == NULL) + rcparse_warning (_("IEDIT requires DIALOGEX")); + res_string_to_id (&$$->class, "IEDIT"); + } + | LISTBOX + { + default_style = LBS_NOTIFY | WS_BORDER; + base_style = LBS_NOTIFY | WS_BORDER; + class.named = 0; + class.u.id = CTL_LISTBOX; + res_text_field = res_null_text; + } + control_params + { + $$ = $3; + } + | LTEXT optresidc + { + default_style = SS_LEFT | WS_GROUP; + base_style = SS_LEFT; + class.named = 0; + class.u.id = CTL_STATIC; + res_text_field = $2; + } + control_params + { + $$ = $4; + } + | PUSHBOX optresidc + { + default_style = BS_PUSHBOX | WS_TABSTOP; + base_style = BS_PUSHBOX; + class.named = 0; + class.u.id = CTL_BUTTON; + } + control_params + { + $$ = $4; + } + | PUSHBUTTON optresidc + { + default_style = BS_PUSHBUTTON | WS_TABSTOP; + base_style = BS_PUSHBUTTON | WS_TABSTOP; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = $2; + } + control_params + { + $$ = $4; + } + | RADIOBUTTON optresidc + { + default_style = BS_RADIOBUTTON | WS_TABSTOP; + base_style = BS_RADIOBUTTON; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = $2; + } + control_params + { + $$ = $4; + } + | RTEXT optresidc + { + default_style = SS_RIGHT | WS_GROUP; + base_style = SS_RIGHT; + class.named = 0; + class.u.id = CTL_STATIC; + res_text_field = $2; + } + control_params + { + $$ = $4; + } + | SCROLLBAR + { + default_style = SBS_HORZ; + base_style = 0; + class.named = 0; + class.u.id = CTL_SCROLLBAR; + res_text_field = res_null_text; + } + control_params + { + $$ = $3; + } + | STATE3 optresidc + { + default_style = BS_3STATE | WS_TABSTOP; + base_style = BS_3STATE; + class.named = 0; + class.u.id = CTL_BUTTON; + res_text_field = $2; + } + control_params + { + $$ = $4; + } + | USERBUTTON resref numexpr ',' numexpr ',' numexpr ',' + numexpr ',' numexpr ',' + { style = WS_CHILD | WS_VISIBLE; } + styleexpr optcnumexpr + { + rc_res_id cid; + cid.named = 0; + cid.u.id = CTL_BUTTON; + $$ = define_control ($2, $3, $5, $7, $9, $11, cid, + style, $15); + } + ; + +/* Parameters for a control. The static variables DEFAULT_STYLE, + BASE_STYLE, and CLASS must be initialized before this nonterminal + is used. DEFAULT_STYLE is the style to use if no style expression + is specified. BASE_STYLE is the base style to use if a style + expression is specified; the style expression modifies the base + style. CLASS is the class of the control. */ + +control_params: + numexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data + { + $$ = define_control (res_text_field, $1, $2, $3, $4, $5, class, + default_style | WS_CHILD | WS_VISIBLE, 0); + if ($6 != NULL) + { + if (dialog.ex == NULL) + rcparse_warning (_("control data requires DIALOGEX")); + $$->data = $6; + } + } + | numexpr cnumexpr cnumexpr cnumexpr cnumexpr + control_params_styleexpr optcnumexpr opt_control_data + { + $$ = define_control (res_text_field, $1, $2, $3, $4, $5, class, style, $7); + if ($8 != NULL) + { + if (dialog.ex == NULL) + rcparse_warning (_("control data requires DIALOGEX")); + $$->data = $8; + } + } + | numexpr cnumexpr cnumexpr cnumexpr cnumexpr + control_params_styleexpr cnumexpr cnumexpr opt_control_data + { + $$ = define_control (res_text_field, $1, $2, $3, $4, $5, class, style, $7); + if (dialog.ex == NULL) + rcparse_warning (_("help ID requires DIALOGEX")); + $$->help = $8; + $$->data = $9; + } + ; + +cresid: + ',' resid + { + if ($2.named) + res_unistring_to_id (&$$, $2.u.n.name); + else + $$=$2; + } + ; + +optresidc: + /* empty */ + { + res_string_to_id (&$$, ""); + } + | resid ',' { $$=$1; } + ; + +resid: + posnumexpr + { + $$.named = 0; + $$.u.id = $1; + } + | res_unicode_string_concat + { + $$.named = 1; + $$.u.n.name = $1; + $$.u.n.length = unichar_len ($1); + } + ; + +opt_control_data: + /* empty */ + { + $$ = NULL; + } + | BEG optrcdata_data END + { + $$ = $2.first; + } + ; + +/* These only exist to parse a reduction out of a common case. */ + +control_styleexpr: + ',' + { style = WS_CHILD | WS_VISIBLE; } + styleexpr + ; + +icon_styleexpr: + ',' + { style = SS_ICON | WS_CHILD | WS_VISIBLE; } + styleexpr + ; + +control_params_styleexpr: + ',' + { style = base_style | WS_CHILD | WS_VISIBLE; } + styleexpr + ; + +/* Font resources. */ + +font: + id FONT memflags_move_discard file_name + { + define_font ($1, &$3, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + ; + +/* Icon resources. */ + +icon: + id ICON memflags_move_discard file_name + { + define_icon ($1, &$3, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + ; + +/* Language command. This changes the static variable language, which + affects all subsequent resources. */ + +language: + LANGUAGE numexpr cnumexpr + { + language = $2 | ($3 << SUBLANG_SHIFT); + } + ; + +/* Menu resources. */ + +menu: + id MENU suboptions BEG menuitems END + { + define_menu ($1, &$3, $5); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + ; + +menuitems: + /* empty */ + { + $$ = NULL; + } + | menuitems menuitem + { + if ($1 == NULL) + $$ = $2; + else + { + rc_menuitem **pp; + + for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next) + ; + *pp = $2; + $$ = $1; + } + } + ; + +menuitem: + MENUITEM res_unicode_string_concat cnumexpr menuitem_flags + { + $$ = define_menuitem ($2, $3, $4, 0, 0, NULL); + } + | MENUITEM SEPARATOR + { + $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL); + } + | POPUP res_unicode_string_concat menuitem_flags BEG menuitems END + { + $$ = define_menuitem ($2, 0, $3, 0, 0, $5); + } + ; + +menuitem_flags: + /* empty */ + { + $$ = 0; + } + | menuitem_flags ',' menuitem_flag + { + $$ = $1 | $3; + } + | menuitem_flags menuitem_flag + { + $$ = $1 | $2; + } + ; + +menuitem_flag: + CHECKED + { + $$ = MENUITEM_CHECKED; + } + | GRAYED + { + $$ = MENUITEM_GRAYED; + } + | HELP + { + $$ = MENUITEM_HELP; + } + | INACTIVE + { + $$ = MENUITEM_INACTIVE; + } + | MENUBARBREAK + { + $$ = MENUITEM_MENUBARBREAK; + } + | MENUBREAK + { + $$ = MENUITEM_MENUBREAK; + } + ; + +/* Menuex resources. */ + +menuex: + id MENUEX suboptions BEG menuexitems END + { + define_menu ($1, &$3, $5); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + ; + +menuexitems: + /* empty */ + { + $$ = NULL; + } + | menuexitems menuexitem + { + if ($1 == NULL) + $$ = $2; + else + { + rc_menuitem **pp; + + for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next) + ; + *pp = $2; + $$ = $1; + } + } + ; + +menuexitem: + MENUITEM res_unicode_string_concat + { + $$ = define_menuitem ($2, 0, 0, 0, 0, NULL); + } + | MENUITEM res_unicode_string_concat cnumexpr + { + $$ = define_menuitem ($2, $3, 0, 0, 0, NULL); + } + | MENUITEM res_unicode_string_concat cnumexpr cnumexpr optcnumexpr + { + $$ = define_menuitem ($2, $3, $4, $5, 0, NULL); + } + | MENUITEM SEPARATOR + { + $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL); + } + | POPUP res_unicode_string_concat BEG menuexitems END + { + $$ = define_menuitem ($2, 0, 0, 0, 0, $4); + } + | POPUP res_unicode_string_concat cnumexpr BEG menuexitems END + { + $$ = define_menuitem ($2, $3, 0, 0, 0, $5); + } + | POPUP res_unicode_string_concat cnumexpr cnumexpr BEG menuexitems END + { + $$ = define_menuitem ($2, $3, $4, 0, 0, $6); + } + | POPUP res_unicode_string_concat cnumexpr cnumexpr cnumexpr optcnumexpr + BEG menuexitems END + { + $$ = define_menuitem ($2, $3, $4, $5, $6, $8); + } + ; + +/* Messagetable resources. */ + +messagetable: + id MESSAGETABLE memflags_move file_name + { + define_messagetable ($1, &$3, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + ; + +/* We use a different lexing algorithm, because rcdata strings may + contain embedded null bytes, and we need to know the length to use. */ + +optrcdata_data: + { + rcparse_rcdata (); + } + optrcdata_data_int + { + rcparse_normal (); + $$ = $2; + } + ; + +optrcdata_data_int: + /* empty */ + { + $$.first = NULL; + $$.last = NULL; + } + | rcdata_data + { + $$ = $1; + } + ; + +rcdata_data: + sizedstring + { + rc_rcdata_item *ri; + + ri = define_rcdata_string ($1.s, $1.length); + $$.first = ri; + $$.last = ri; + } + | sizedunistring + { + rc_rcdata_item *ri; + + ri = define_rcdata_unistring ($1.s, $1.length); + $$.first = ri; + $$.last = ri; + } + | sizednumexpr + { + rc_rcdata_item *ri; + + ri = define_rcdata_number ($1.val, $1.dword); + $$.first = ri; + $$.last = ri; + } + | rcdata_data ',' sizedstring + { + rc_rcdata_item *ri; + + ri = define_rcdata_string ($3.s, $3.length); + $$.first = $1.first; + $1.last->next = ri; + $$.last = ri; + } + | rcdata_data ',' sizedunistring + { + rc_rcdata_item *ri; + + ri = define_rcdata_unistring ($3.s, $3.length); + $$.first = $1.first; + $1.last->next = ri; + $$.last = ri; + } + | rcdata_data ',' sizednumexpr + { + rc_rcdata_item *ri; + + ri = define_rcdata_number ($3.val, $3.dword); + $$.first = $1.first; + $1.last->next = ri; + $$.last = ri; + } + | rcdata_data ',' + { + $$=$1; + } + ; + +/* Stringtable resources. */ + +stringtable: + STRINGTABLE suboptions BEG + { sub_res_info = $2; rcparse_rcdata (); } + string_data END { rcparse_normal (); } + ; + +string_data: + /* empty */ + | string_data numexpr res_unicode_sizedstring_concat + { + define_stringtable (&sub_res_info, $2, $3.s, $3.length); + rcparse_discard_strings (); + } + | string_data numexpr ',' res_unicode_sizedstring_concat + { + define_stringtable (&sub_res_info, $2, $4.s, $4.length); + rcparse_discard_strings (); + } + | string_data error + { + rcparse_warning (_("invalid stringtable resource.")); + abort (); + } + ; + +rcdata_id: + id + { + $$=$1; + } + | HTML + { + $$.named = 0; + $$.u.id = 23; + } + | RCDATA + { + $$.named = 0; + $$.u.id = RT_RCDATA; + } + | MANIFEST + { + $$.named = 0; + $$.u.id = RT_MANIFEST; + } + | PLUGPLAY + { + $$.named = 0; + $$.u.id = RT_PLUGPLAY; + } + | VXD + { + $$.named = 0; + $$.u.id = RT_VXD; + } + | DLGINCLUDE + { + $$.named = 0; + $$.u.id = RT_DLGINCLUDE; + } + | DLGINIT + { + $$.named = 0; + $$.u.id = RT_DLGINIT; + } + | ANICURSOR + { + $$.named = 0; + $$.u.id = RT_ANICURSOR; + } + | ANIICON + { + $$.named = 0; + $$.u.id = RT_ANIICON; + } + ; + +/* User defined resources. We accept general suboptions in the + file_name case to keep the parser happy. */ + +user: + id rcdata_id suboptions BEG optrcdata_data END + { + define_user_data ($1, $2, &$3, $5.first); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + | id rcdata_id suboptions file_name + { + define_user_file ($1, $2, &$3, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + ; + +toolbar: + id TOOLBAR suboptions numexpr cnumexpr BEG toolbar_data END + { + define_toolbar ($1, &$3, $4, $5, $7); + } + ; + +toolbar_data: /* empty */ { $$= NULL; } + | toolbar_data BUTTON id + { + rc_toolbar_item *c,*n; + c = $1; + n= (rc_toolbar_item *) + res_alloc (sizeof (rc_toolbar_item)); + if (c != NULL) + while (c->next != NULL) + c = c->next; + n->prev = c; + n->next = NULL; + if (c != NULL) + c->next = n; + n->id = $3; + if ($1 == NULL) + $$ = n; + else + $$ = $1; + } + | toolbar_data SEPARATOR + { + rc_toolbar_item *c,*n; + c = $1; + n= (rc_toolbar_item *) + res_alloc (sizeof (rc_toolbar_item)); + if (c != NULL) + while (c->next != NULL) + c = c->next; + n->prev = c; + n->next = NULL; + if (c != NULL) + c->next = n; + n->id.named = 0; + n->id.u.id = 0; + if ($1 == NULL) + $$ = n; + else + $$ = $1; + } + ; + +/* Versioninfo resources. */ + +versioninfo: + id VERSIONINFO fixedverinfo BEG verblocks END + { + define_versioninfo ($1, language, $3, $5); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); + } + ; + +fixedverinfo: + /* empty */ + { + $$ = ((rc_fixed_versioninfo *) + res_alloc (sizeof (rc_fixed_versioninfo))); + memset ($$, 0, sizeof (rc_fixed_versioninfo)); + } + | fixedverinfo FILEVERSION numexpr optcnumexpr optcnumexpr + optcnumexpr + { + $1->file_version_ms = ($3 << 16) | ($4 & 0xffff); + $1->file_version_ls = ($5 << 16) | ($6 & 0xffff); + $$ = $1; + } + | fixedverinfo PRODUCTVERSION numexpr optcnumexpr optcnumexpr + optcnumexpr + { + $1->product_version_ms = ($3 << 16) | ($4 & 0xffff); + $1->product_version_ls = ($5 << 16) | ($6 & 0xffff); + $$ = $1; + } + | fixedverinfo FILEFLAGSMASK numexpr + { + $1->file_flags_mask = $3; + $$ = $1; + } + | fixedverinfo FILEFLAGS numexpr + { + $1->file_flags = $3; + $$ = $1; + } + | fixedverinfo FILEOS numexpr + { + $1->file_os = $3; + $$ = $1; + } + | fixedverinfo FILETYPE numexpr + { + $1->file_type = $3; + $$ = $1; + } + | fixedverinfo FILESUBTYPE numexpr + { + $1->file_subtype = $3; + $$ = $1; + } + ; + +/* To handle verblocks successfully, the lexer handles BLOCK + specially. A BLOCK "StringFileInfo" is returned as + BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as + BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK + with the string as the value. */ + +verblocks: + /* empty */ + { + $$ = NULL; + } + | verblocks BLOCKSTRINGFILEINFO BEG verstringtables END + { + $$ = append_ver_stringfileinfo ($1, $4); + } + | verblocks BLOCKVARFILEINFO BEG VALUE res_unicode_string_concat vertrans END + { + $$ = append_ver_varfileinfo ($1, $5, $6); + } + ; + +verstringtables: + /* empty */ + { + $$ = NULL; + } + | verstringtables BLOCK BEG vervals END + { + $$ = append_ver_stringtable ($1, $2, $4); + } + ; + +vervals: + /* empty */ + { + $$ = NULL; + } + | vervals VALUE res_unicode_string_concat ',' res_unicode_string_concat + { + $$ = append_verval ($1, $3, $5); + } + ; + +vertrans: + /* empty */ + { + $$ = NULL; + } + | vertrans cnumexpr cnumexpr + { + $$ = append_vertrans ($1, $2, $3); + } + ; + +/* A resource ID. */ + +id: + posnumexpr + { + $$.named = 0; + $$.u.id = $1; + } + | resname + { + res_unistring_to_id (&$$, $1); + } + ; + +/* A resource reference. */ + +resname: + res_unicode_string + { + $$ = $1; + } + | STRING + { + unichar *h = NULL; + unicode_from_ascii ((rc_uint_type *) NULL, &h, $1); + $$ = h; + } + ; + + +resref: + posnumexpr ',' + { + $$.named = 0; + $$.u.id = $1; + } + | resname + { + res_unistring_to_id (&$$, $1); + } + | resname ',' + { + res_unistring_to_id (&$$, $1); + } + ; + +/* Generic suboptions. These may appear before the BEGIN in any + multiline statement. */ + +suboptions: + /* empty */ + { + memset (&$$, 0, sizeof (rc_res_res_info)); + $$.language = language; + /* FIXME: Is this the right default? */ + $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE; + } + | suboptions memflag + { + $$ = $1; + $$.memflags |= $2.on; + $$.memflags &=~ $2.off; + } + | suboptions CHARACTERISTICS numexpr + { + $$ = $1; + $$.characteristics = $3; + } + | suboptions LANGUAGE numexpr cnumexpr + { + $$ = $1; + $$.language = $3 | ($4 << SUBLANG_SHIFT); + } + | suboptions VERSIONK numexpr + { + $$ = $1; + $$.version = $3; + } + ; + +/* Memory flags which default to MOVEABLE and DISCARDABLE. */ + +memflags_move_discard: + /* empty */ + { + memset (&$$, 0, sizeof (rc_res_res_info)); + $$.language = language; + $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE; + } + | memflags_move_discard memflag + { + $$ = $1; + $$.memflags |= $2.on; + $$.memflags &=~ $2.off; + } + ; + +/* Memory flags which default to MOVEABLE. */ + +memflags_move: + /* empty */ + { + memset (&$$, 0, sizeof (rc_res_res_info)); + $$.language = language; + $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE; + } + | memflags_move memflag + { + $$ = $1; + $$.memflags |= $2.on; + $$.memflags &=~ $2.off; + } + ; + +/* Memory flags. This returns a struct with two integers, because we + sometimes want to set bits and we sometimes want to clear them. */ + +memflag: + MOVEABLE + { + $$.on = MEMFLAG_MOVEABLE; + $$.off = 0; + } + | FIXED + { + $$.on = 0; + $$.off = MEMFLAG_MOVEABLE; + } + | PURE + { + $$.on = MEMFLAG_PURE; + $$.off = 0; + } + | IMPURE + { + $$.on = 0; + $$.off = MEMFLAG_PURE; + } + | PRELOAD + { + $$.on = MEMFLAG_PRELOAD; + $$.off = 0; + } + | LOADONCALL + { + $$.on = 0; + $$.off = MEMFLAG_PRELOAD; + } + | DISCARDABLE + { + $$.on = MEMFLAG_DISCARDABLE; + $$.off = 0; + } + ; + +/* A file name. */ + +file_name: + QUOTEDSTRING + { + $$ = $1; + } + | STRING + { + $$ = $1; + } + ; + +/* Concat string */ +res_unicode_string_concat: + res_unicode_string + { + $$ = $1; + } + | + res_unicode_string_concat res_unicode_string + { + rc_uint_type l1 = unichar_len ($1); + rc_uint_type l2 = unichar_len ($2); + unichar *h = (unichar *) res_alloc ((l1 + l2 + 1) * sizeof (unichar)); + if (l1 != 0) + memcpy (h, $1, l1 * sizeof (unichar)); + if (l2 != 0) + memcpy (h + l1, $2, l2 * sizeof (unichar)); + h[l1 + l2] = 0; + $$ = h; + } + ; + +res_unicode_string: + QUOTEDUNISTRING + { + $$ = unichar_dup ($1); + } + | QUOTEDSTRING + { + unichar *h = NULL; + unicode_from_ascii ((rc_uint_type *) NULL, &h, $1); + $$ = h; + } + ; + +res_unicode_sizedstring: + sizedunistring + { + $$ = $1; + } + | sizedstring + { + unichar *h = NULL; + rc_uint_type l = 0; + unicode_from_ascii_len (&l, &h, $1.s, $1.length); + $$.s = h; + $$.length = l; + } + ; + +/* Concat string */ +res_unicode_sizedstring_concat: + res_unicode_sizedstring + { + $$ = $1; + } + | + res_unicode_sizedstring_concat res_unicode_sizedstring + { + rc_uint_type l1 = $1.length; + rc_uint_type l2 = $2.length; + unichar *h = (unichar *) res_alloc ((l1 + l2 + 1) * sizeof (unichar)); + if (l1 != 0) + memcpy (h, $1.s, l1 * sizeof (unichar)); + if (l2 != 0) + memcpy (h + l1, $2.s, l2 * sizeof (unichar)); + h[l1 + l2] = 0; + $$.length = l1 + l2; + $$.s = h; + } + ; + +sizedstring: + SIZEDSTRING + { + $$ = $1; + } + | sizedstring SIZEDSTRING + { + rc_uint_type l = $1.length + $2.length; + char *h = (char *) res_alloc (l); + memcpy (h, $1.s, $1.length); + memcpy (h + $1.length, $2.s, $2.length); + $$.s = h; + $$.length = l; + } + ; + +sizedunistring: + SIZEDUNISTRING + { + $$ = $1; + } + | sizedunistring SIZEDUNISTRING + { + rc_uint_type l = $1.length + $2.length; + unichar *h = (unichar *) res_alloc (l * sizeof (unichar)); + memcpy (h, $1.s, $1.length * sizeof (unichar)); + memcpy (h + $1.length, $2.s, $2.length * sizeof (unichar)); + $$.s = h; + $$.length = l; + } + ; + +/* A style expression. This changes the static variable STYLE. We do + it this way because rc appears to permit a style to be set to + something like + WS_GROUP | NOT WS_TABSTOP + to mean that a default of WS_TABSTOP should be removed. Anything + which wants to accept a style must first set STYLE to the default + value. The styleexpr nonterminal will change STYLE as specified by + the user. Note that we do not accept arbitrary expressions here, + just numbers separated by '|'. */ + +styleexpr: + parennumber + { + style |= $1; + } + | NOT parennumber + { + style &=~ $2; + } + | styleexpr '|' parennumber + { + style |= $3; + } + | styleexpr '|' NOT parennumber + { + style &=~ $4; + } + ; + +parennumber: + NUMBER + { + $$ = $1.val; + } + | '(' numexpr ')' + { + $$ = $2; + } + ; + +/* An optional expression with a leading comma. */ + +optcnumexpr: + /* empty */ + { + $$ = 0; + } + | cnumexpr + { + $$ = $1; + } + ; + +/* An expression with a leading comma. */ + +cnumexpr: + ',' numexpr + { + $$ = $2; + } + ; + +/* A possibly negated numeric expression. */ + +numexpr: + sizednumexpr + { + $$ = $1.val; + } + ; + +/* A possibly negated expression with a size. */ + +sizednumexpr: + NUMBER + { + $$ = $1; + } + | '(' sizednumexpr ')' + { + $$ = $2; + } + | '~' sizednumexpr %prec '~' + { + $$.val = ~ $2.val; + $$.dword = $2.dword; + } + | '-' sizednumexpr %prec NEG + { + $$.val = - $2.val; + $$.dword = $2.dword; + } + | sizednumexpr '*' sizednumexpr + { + $$.val = $1.val * $3.val; + $$.dword = $1.dword || $3.dword; + } + | sizednumexpr '/' sizednumexpr + { + $$.val = $1.val / ($3.val ? $3.val : 1); + $$.dword = $1.dword || $3.dword; + } + | sizednumexpr '%' sizednumexpr + { + $$.val = $1.val % ($3.val ? $3.val : 1); + $$.dword = $1.dword || $3.dword; + } + | sizednumexpr '+' sizednumexpr + { + $$.val = $1.val + $3.val; + $$.dword = $1.dword || $3.dword; + } + | sizednumexpr '-' sizednumexpr + { + $$.val = $1.val - $3.val; + $$.dword = $1.dword || $3.dword; + } + | sizednumexpr '&' sizednumexpr + { + $$.val = $1.val & $3.val; + $$.dword = $1.dword || $3.dword; + } + | sizednumexpr '^' sizednumexpr + { + $$.val = $1.val ^ $3.val; + $$.dword = $1.dword || $3.dword; + } + | sizednumexpr '|' sizednumexpr + { + $$.val = $1.val | $3.val; + $$.dword = $1.dword || $3.dword; + } + ; + +/* An expression with a leading comma which does not use unary + negation. */ + +cposnumexpr: + ',' posnumexpr + { + $$ = $2; + } + ; + +/* An expression which does not use unary negation. */ + +posnumexpr: + sizedposnumexpr + { + $$ = $1.val; + } + ; + +/* An expression which does not use unary negation. We separate unary + negation to avoid parsing conflicts when two numeric expressions + appear consecutively. */ + +sizedposnumexpr: + NUMBER + { + $$ = $1; + } + | '(' sizednumexpr ')' + { + $$ = $2; + } + | '~' sizednumexpr %prec '~' + { + $$.val = ~ $2.val; + $$.dword = $2.dword; + } + | sizedposnumexpr '*' sizednumexpr + { + $$.val = $1.val * $3.val; + $$.dword = $1.dword || $3.dword; + } + | sizedposnumexpr '/' sizednumexpr + { + $$.val = $1.val / ($3.val ? $3.val : 1); + $$.dword = $1.dword || $3.dword; + } + | sizedposnumexpr '%' sizednumexpr + { + /* PR 17512: file: 89105a25. */ + $$.val = $1.val % ($3.val ? $3.val : 1); + $$.dword = $1.dword || $3.dword; + } + | sizedposnumexpr '+' sizednumexpr + { + $$.val = $1.val + $3.val; + $$.dword = $1.dword || $3.dword; + } + | sizedposnumexpr '-' sizednumexpr + { + $$.val = $1.val - $3.val; + $$.dword = $1.dword || $3.dword; + } + | sizedposnumexpr '&' sizednumexpr + { + $$.val = $1.val & $3.val; + $$.dword = $1.dword || $3.dword; + } + | sizedposnumexpr '^' sizednumexpr + { + $$.val = $1.val ^ $3.val; + $$.dword = $1.dword || $3.dword; + } + | sizedposnumexpr '|' sizednumexpr + { + $$.val = $1.val | $3.val; + $$.dword = $1.dword || $3.dword; + } + ; + +%% + +/* Set the language from the command line. */ + +void +rcparse_set_language (int lang) +{ + language = lang; +} diff --git a/support/sdbinutils/binutils/rdcoff.c b/support/sdbinutils/binutils/rdcoff.c new file mode 100644 index 0000000..cc6fec5 --- /dev/null +++ b/support/sdbinutils/binutils/rdcoff.c @@ -0,0 +1,880 @@ +/* stabs.c -- Parse COFF debugging information + Copyright (C) 1996-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor . + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* This file contains code which parses COFF debugging information. */ + +#include "sysdep.h" +#include "bfd.h" +#include "coff/internal.h" +#include "libiberty.h" +#include "bucomm.h" +#include "debug.h" +#include "budbg.h" + +/* FIXME: We should not need this BFD internal file. We need it for + the N_BTMASK, etc., values. */ +#include "libcoff.h" + +/* These macros extract the right mask and shifts for this BFD. They + assume that there is a local variable named ABFD. This is so that + macros like ISFCN and DECREF, from coff/internal.h, will work + without modification. */ +#define N_BTMASK (coff_data (abfd)->local_n_btmask) +#define N_BTSHFT (coff_data (abfd)->local_n_btshft) +#define N_TMASK (coff_data (abfd)->local_n_tmask) +#define N_TSHIFT (coff_data (abfd)->local_n_tshift) + +/* This structure is used to hold the symbols, as well as the current + location within the symbols. */ + +struct coff_symbols +{ + /* The symbols. */ + asymbol **syms; + /* The number of symbols. */ + long symcount; + /* The index of the current symbol. */ + long symno; + /* The index of the current symbol in the COFF symbol table (where + each auxent counts as a symbol). */ + long coff_symno; +}; + +/* The largest basic type we are prepared to handle. */ + +#define T_MAX (T_LNGDBL) + +/* This structure is used to hold slots. */ + +struct coff_slots +{ + /* Next set of slots. */ + struct coff_slots *next; + /* Slots. */ +#define COFF_SLOTS (16) + debug_type slots[COFF_SLOTS]; +}; + +/* This structure is used to map symbol indices to types. */ + +struct coff_types +{ + /* Slots. */ + struct coff_slots *slots; + /* Basic types. */ + debug_type basic[T_MAX + 1]; +}; + +static debug_type *coff_get_slot (struct coff_types *, long); +static debug_type parse_coff_type + (bfd *, struct coff_symbols *, struct coff_types *, long, int, + union internal_auxent *, bfd_boolean, void *); +static debug_type parse_coff_base_type + (bfd *, struct coff_symbols *, struct coff_types *, long, int, + union internal_auxent *, void *); +static debug_type parse_coff_struct_type + (bfd *, struct coff_symbols *, struct coff_types *, int, + union internal_auxent *, void *); +static debug_type parse_coff_enum_type + (bfd *, struct coff_symbols *, struct coff_types *, + union internal_auxent *, void *); +static bfd_boolean parse_coff_symbol + (bfd *, struct coff_types *, asymbol *, long, struct internal_syment *, + void *, debug_type, bfd_boolean); +static bfd_boolean external_coff_symbol_p (int sym_class); + +/* Return the slot for a type. */ + +static debug_type * +coff_get_slot (struct coff_types *types, long indx) +{ + struct coff_slots **pps; + + pps = &types->slots; + + /* PR 17512: file: 078-18333-0.001:0.1. + FIXME: The value of 1000 is a guess. Maybe a better heuristic is needed. */ + if (indx / COFF_SLOTS > 1000) + fatal (_("Excessively large slot index: %lx"), indx); + + while (indx >= COFF_SLOTS) + { + if (*pps == NULL) + { + *pps = (struct coff_slots *) xmalloc (sizeof **pps); + memset (*pps, 0, sizeof **pps); + } + pps = &(*pps)->next; + indx -= COFF_SLOTS; + } + + if (*pps == NULL) + { + *pps = (struct coff_slots *) xmalloc (sizeof **pps); + memset (*pps, 0, sizeof **pps); + } + + return (*pps)->slots + indx; +} + +/* Parse a COFF type code in NTYPE. */ + +static debug_type +parse_coff_type (bfd *abfd, struct coff_symbols *symbols, + struct coff_types *types, long coff_symno, int ntype, + union internal_auxent *pauxent, bfd_boolean useaux, + void *dhandle) +{ + debug_type type; + + if ((ntype & ~N_BTMASK) != 0) + { + int newtype; + + newtype = DECREF (ntype); + + if (ISPTR (ntype)) + { + type = parse_coff_type (abfd, symbols, types, coff_symno, newtype, + pauxent, useaux, dhandle); + type = debug_make_pointer_type (dhandle, type); + } + else if (ISFCN (ntype)) + { + type = parse_coff_type (abfd, symbols, types, coff_symno, newtype, + pauxent, useaux, dhandle); + type = debug_make_function_type (dhandle, type, (debug_type *) NULL, + FALSE); + } + else if (ISARY (ntype)) + { + int n; + + if (pauxent == NULL) + n = 0; + else + { + unsigned short *dim; + int i; + + /* FIXME: If pauxent->x_sym.x_tagndx.l == 0, gdb sets + the c_naux field of the syment to 0. */ + + /* Move the dimensions down, so that the next array + picks up the next one. */ + dim = pauxent->x_sym.x_fcnary.x_ary.x_dimen; + n = dim[0]; + for (i = 0; *dim != 0 && i < DIMNUM - 1; i++, dim++) + *dim = *(dim + 1); + *dim = 0; + } + + type = parse_coff_type (abfd, symbols, types, coff_symno, newtype, + pauxent, FALSE, dhandle); + type = debug_make_array_type (dhandle, type, + parse_coff_base_type (abfd, symbols, + types, + coff_symno, + T_INT, + NULL, dhandle), + 0, n - 1, FALSE); + } + else + { + non_fatal (_("parse_coff_type: Bad type code 0x%x"), ntype); + return DEBUG_TYPE_NULL; + } + + return type; + } + + if (pauxent != NULL && pauxent->x_sym.x_tagndx.l > 0) + { + debug_type *slot; + + /* This is a reference to an existing type. FIXME: gdb checks + that the class is not C_STRTAG, nor C_UNTAG, nor C_ENTAG. */ + slot = coff_get_slot (types, pauxent->x_sym.x_tagndx.l); + if (*slot != DEBUG_TYPE_NULL) + return *slot; + else + return debug_make_indirect_type (dhandle, slot, (const char *) NULL); + } + + /* If the aux entry has already been used for something, useaux will + have been set to false, indicating that parse_coff_base_type + should not use it. We need to do it this way, rather than simply + passing pauxent as NULL, because we need to be able handle + multiple array dimensions while still discarding pauxent after + having handled all of them. */ + if (! useaux) + pauxent = NULL; + + return parse_coff_base_type (abfd, symbols, types, coff_symno, ntype, + pauxent, dhandle); +} + +/* Parse a basic COFF type in NTYPE. */ + +static debug_type +parse_coff_base_type (bfd *abfd, struct coff_symbols *symbols, + struct coff_types *types, long coff_symno, int ntype, + union internal_auxent *pauxent, void *dhandle) +{ + debug_type ret; + bfd_boolean set_basic; + const char *name; + debug_type *slot; + + if (ntype >= 0 + && ntype <= T_MAX + && types->basic[ntype] != DEBUG_TYPE_NULL) + return types->basic[ntype]; + + set_basic = TRUE; + name = NULL; + + switch (ntype) + { + default: + ret = debug_make_void_type (dhandle); + break; + + case T_NULL: + case T_VOID: + ret = debug_make_void_type (dhandle); + name = "void"; + break; + + case T_CHAR: + ret = debug_make_int_type (dhandle, 1, FALSE); + name = "char"; + break; + + case T_SHORT: + ret = debug_make_int_type (dhandle, 2, FALSE); + name = "short"; + break; + + case T_INT: + /* FIXME: Perhaps the size should depend upon the architecture. */ + ret = debug_make_int_type (dhandle, 4, FALSE); + name = "int"; + break; + + case T_LONG: + ret = debug_make_int_type (dhandle, 4, FALSE); + name = "long"; + break; + + case T_FLOAT: + ret = debug_make_float_type (dhandle, 4); + name = "float"; + break; + + case T_DOUBLE: + ret = debug_make_float_type (dhandle, 8); + name = "double"; + break; + + case T_LNGDBL: + ret = debug_make_float_type (dhandle, 12); + name = "long double"; + break; + + case T_UCHAR: + ret = debug_make_int_type (dhandle, 1, TRUE); + name = "unsigned char"; + break; + + case T_USHORT: + ret = debug_make_int_type (dhandle, 2, TRUE); + name = "unsigned short"; + break; + + case T_UINT: + ret = debug_make_int_type (dhandle, 4, TRUE); + name = "unsigned int"; + break; + + case T_ULONG: + ret = debug_make_int_type (dhandle, 4, TRUE); + name = "unsigned long"; + break; + + case T_STRUCT: + if (pauxent == NULL) + ret = debug_make_struct_type (dhandle, TRUE, 0, + (debug_field *) NULL); + else + ret = parse_coff_struct_type (abfd, symbols, types, ntype, pauxent, + dhandle); + + slot = coff_get_slot (types, coff_symno); + *slot = ret; + + set_basic = FALSE; + break; + + case T_UNION: + if (pauxent == NULL) + ret = debug_make_struct_type (dhandle, FALSE, 0, (debug_field *) NULL); + else + ret = parse_coff_struct_type (abfd, symbols, types, ntype, pauxent, + dhandle); + + slot = coff_get_slot (types, coff_symno); + *slot = ret; + + set_basic = FALSE; + break; + + case T_ENUM: + if (pauxent == NULL) + ret = debug_make_enum_type (dhandle, (const char **) NULL, + (bfd_signed_vma *) NULL); + else + ret = parse_coff_enum_type (abfd, symbols, types, pauxent, dhandle); + + slot = coff_get_slot (types, coff_symno); + *slot = ret; + + set_basic = FALSE; + break; + } + + if (name != NULL) + ret = debug_name_type (dhandle, name, ret); + + if (set_basic + && ntype >= 0 + && ntype <= T_MAX) + types->basic[ntype] = ret; + + return ret; +} + +/* Parse a struct type. */ + +static debug_type +parse_coff_struct_type (bfd *abfd, struct coff_symbols *symbols, + struct coff_types *types, int ntype, + union internal_auxent *pauxent, void *dhandle) +{ + long symend; + int alloc; + debug_field *fields; + int count; + bfd_boolean done; + + symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l; + + alloc = 10; + fields = (debug_field *) xmalloc (alloc * sizeof *fields); + count = 0; + + done = FALSE; + while (! done + && symbols->coff_symno < symend + && symbols->symno < symbols->symcount) + { + asymbol *sym; + long this_coff_symno; + struct internal_syment syment; + union internal_auxent auxent; + union internal_auxent *psubaux; + bfd_vma bitpos = 0, bitsize = 0; + + sym = symbols->syms[symbols->symno]; + + if (! bfd_coff_get_syment (abfd, sym, &syment)) + { + non_fatal (_("bfd_coff_get_syment failed: %s"), + bfd_errmsg (bfd_get_error ())); + return DEBUG_TYPE_NULL; + } + + this_coff_symno = symbols->coff_symno; + + ++symbols->symno; + symbols->coff_symno += 1 + syment.n_numaux; + + if (syment.n_numaux == 0) + psubaux = NULL; + else + { + if (! bfd_coff_get_auxent (abfd, sym, 0, &auxent)) + { + non_fatal (_("bfd_coff_get_auxent failed: %s"), + bfd_errmsg (bfd_get_error ())); + return DEBUG_TYPE_NULL; + } + psubaux = &auxent; + } + + switch (syment.n_sclass) + { + case C_MOS: + case C_MOU: + bitpos = 8 * bfd_asymbol_value (sym); + bitsize = 0; + break; + + case C_FIELD: + bitpos = bfd_asymbol_value (sym); + bitsize = auxent.x_sym.x_misc.x_lnsz.x_size; + break; + + case C_EOS: + done = TRUE; + break; + } + + if (! done) + { + debug_type ftype; + debug_field f; + + ftype = parse_coff_type (abfd, symbols, types, this_coff_symno, + syment.n_type, psubaux, TRUE, dhandle); + f = debug_make_field (dhandle, bfd_asymbol_name (sym), ftype, + bitpos, bitsize, DEBUG_VISIBILITY_PUBLIC); + if (f == DEBUG_FIELD_NULL) + return DEBUG_TYPE_NULL; + + if (count + 1 >= alloc) + { + alloc += 10; + fields = ((debug_field *) + xrealloc (fields, alloc * sizeof *fields)); + } + + fields[count] = f; + ++count; + } + } + + fields[count] = DEBUG_FIELD_NULL; + + return debug_make_struct_type (dhandle, ntype == T_STRUCT, + pauxent->x_sym.x_misc.x_lnsz.x_size, + fields); +} + +/* Parse an enum type. */ + +static debug_type +parse_coff_enum_type (bfd *abfd, struct coff_symbols *symbols, + struct coff_types *types ATTRIBUTE_UNUSED, + union internal_auxent *pauxent, void *dhandle) +{ + long symend; + int alloc; + const char **names; + bfd_signed_vma *vals; + int count; + bfd_boolean done; + + symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l; + + alloc = 10; + names = (const char **) xmalloc (alloc * sizeof *names); + vals = (bfd_signed_vma *) xmalloc (alloc * sizeof *vals); + count = 0; + + done = FALSE; + while (! done + && symbols->coff_symno < symend + && symbols->symno < symbols->symcount) + { + asymbol *sym; + struct internal_syment syment; + + sym = symbols->syms[symbols->symno]; + + if (! bfd_coff_get_syment (abfd, sym, &syment)) + { + non_fatal (_("bfd_coff_get_syment failed: %s"), + bfd_errmsg (bfd_get_error ())); + return DEBUG_TYPE_NULL; + } + + ++symbols->symno; + symbols->coff_symno += 1 + syment.n_numaux; + + switch (syment.n_sclass) + { + case C_MOE: + if (count + 1 >= alloc) + { + alloc += 10; + names = ((const char **) + xrealloc (names, alloc * sizeof *names)); + vals = ((bfd_signed_vma *) + xrealloc (vals, alloc * sizeof *vals)); + } + + names[count] = bfd_asymbol_name (sym); + vals[count] = bfd_asymbol_value (sym); + ++count; + break; + + case C_EOS: + done = TRUE; + break; + } + } + + names[count] = NULL; + + return debug_make_enum_type (dhandle, names, vals); +} + +/* Handle a single COFF symbol. */ + +static bfd_boolean +parse_coff_symbol (bfd *abfd ATTRIBUTE_UNUSED, struct coff_types *types, + asymbol *sym, long coff_symno, + struct internal_syment *psyment, void *dhandle, + debug_type type, bfd_boolean within_function) +{ + switch (psyment->n_sclass) + { + case C_NULL: + break; + + case C_AUTO: + if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type, + DEBUG_LOCAL, bfd_asymbol_value (sym))) + return FALSE; + break; + + case C_WEAKEXT: + case C_EXT: + if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type, + DEBUG_GLOBAL, bfd_asymbol_value (sym))) + return FALSE; + break; + + case C_STAT: + if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type, + (within_function + ? DEBUG_LOCAL_STATIC + : DEBUG_STATIC), + bfd_asymbol_value (sym))) + return FALSE; + break; + + case C_REG: + /* FIXME: We may need to convert the register number. */ + if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type, + DEBUG_REGISTER, bfd_asymbol_value (sym))) + return FALSE; + break; + + case C_LABEL: + break; + + case C_ARG: + if (! debug_record_parameter (dhandle, bfd_asymbol_name (sym), type, + DEBUG_PARM_STACK, bfd_asymbol_value (sym))) + return FALSE; + break; + + case C_REGPARM: + /* FIXME: We may need to convert the register number. */ + if (! debug_record_parameter (dhandle, bfd_asymbol_name (sym), type, + DEBUG_PARM_REG, bfd_asymbol_value (sym))) + return FALSE; + break; + + case C_TPDEF: + type = debug_name_type (dhandle, bfd_asymbol_name (sym), type); + if (type == DEBUG_TYPE_NULL) + return FALSE; + break; + + case C_STRTAG: + case C_UNTAG: + case C_ENTAG: + { + debug_type *slot; + + type = debug_tag_type (dhandle, bfd_asymbol_name (sym), type); + if (type == DEBUG_TYPE_NULL) + return FALSE; + + /* Store the named type into the slot, so that references get + the name. */ + slot = coff_get_slot (types, coff_symno); + *slot = type; + } + break; + + default: + break; + } + + return TRUE; +} + +/* Determine if a symbol has external visibility. */ + +static bfd_boolean +external_coff_symbol_p (int sym_class) +{ + switch (sym_class) + { + case C_EXT: + case C_WEAKEXT: + return TRUE; + default: + break; + } + return FALSE; +} + +/* This is the main routine. It looks through all the symbols and + handles them. */ + +bfd_boolean +parse_coff (bfd *abfd, asymbol **syms, long symcount, void *dhandle) +{ + struct coff_symbols symbols; + struct coff_types types; + int i; + long next_c_file; + const char *fnname; + int fnclass; + int fntype; + bfd_vma fnend; + alent *linenos; + bfd_boolean within_function; + long this_coff_symno; + + symbols.syms = syms; + symbols.symcount = symcount; + symbols.symno = 0; + symbols.coff_symno = 0; + + types.slots = NULL; + for (i = 0; i <= T_MAX; i++) + types.basic[i] = DEBUG_TYPE_NULL; + + next_c_file = -1; + fnname = NULL; + fnclass = 0; + fntype = 0; + fnend = 0; + linenos = NULL; + within_function = FALSE; + + while (symbols.symno < symcount) + { + asymbol *sym; + const char *name; + struct internal_syment syment; + union internal_auxent auxent; + union internal_auxent *paux; + debug_type type; + + sym = syms[symbols.symno]; + + if (! bfd_coff_get_syment (abfd, sym, &syment)) + { + non_fatal (_("bfd_coff_get_syment failed: %s"), + bfd_errmsg (bfd_get_error ())); + return FALSE; + } + + name = bfd_asymbol_name (sym); + + this_coff_symno = symbols.coff_symno; + + ++symbols.symno; + symbols.coff_symno += 1 + syment.n_numaux; + + /* We only worry about the first auxent, because that is the + only one which is relevant for debugging information. */ + if (syment.n_numaux == 0) + paux = NULL; + else + { + if (! bfd_coff_get_auxent (abfd, sym, 0, &auxent)) + { + non_fatal (_("bfd_coff_get_auxent failed: %s"), + bfd_errmsg (bfd_get_error ())); + return FALSE; + } + paux = &auxent; + } + + if (this_coff_symno == next_c_file && syment.n_sclass != C_FILE) + { + /* The last C_FILE symbol points to the first external + symbol. */ + if (! debug_set_filename (dhandle, "*globals*")) + return FALSE; + } + + switch (syment.n_sclass) + { + case C_EFCN: + case C_EXTDEF: + case C_ULABEL: + case C_USTATIC: + case C_LINE: + case C_ALIAS: + case C_HIDDEN: + /* Just ignore these classes. */ + break; + + case C_FILE: + next_c_file = syment.n_value; + if (! debug_set_filename (dhandle, name)) + return FALSE; + break; + + case C_STAT: + /* Ignore static symbols with a type of T_NULL. These + represent section entries. */ + if (syment.n_type == T_NULL) + break; + /* Fall through. */ + case C_WEAKEXT: + case C_EXT: + if (ISFCN (syment.n_type)) + { + fnname = name; + fnclass = syment.n_sclass; + fntype = syment.n_type; + if (syment.n_numaux > 0) + fnend = bfd_asymbol_value (sym) + auxent.x_sym.x_misc.x_fsize; + else + fnend = 0; + linenos = BFD_SEND (abfd, _get_lineno, (abfd, sym)); + break; + } + type = parse_coff_type (abfd, &symbols, &types, this_coff_symno, + syment.n_type, paux, TRUE, dhandle); + if (type == DEBUG_TYPE_NULL) + return FALSE; + if (! parse_coff_symbol (abfd, &types, sym, this_coff_symno, &syment, + dhandle, type, within_function)) + return FALSE; + break; + + case C_FCN: + if (strcmp (name, ".bf") == 0) + { + if (fnname == NULL) + { + non_fatal (_("%ld: .bf without preceding function"), + this_coff_symno); + return FALSE; + } + + type = parse_coff_type (abfd, &symbols, &types, this_coff_symno, + DECREF (fntype), paux, FALSE, dhandle); + if (type == DEBUG_TYPE_NULL) + return FALSE; + + if (! debug_record_function (dhandle, fnname, type, + external_coff_symbol_p (fnclass), + bfd_asymbol_value (sym))) + return FALSE; + + if (linenos != NULL) + { + int base; + bfd_vma addr; + + if (syment.n_numaux == 0) + base = 0; + else + base = auxent.x_sym.x_misc.x_lnsz.x_lnno - 1; + + addr = bfd_get_section_vma (abfd, bfd_get_section (sym)); + + ++linenos; + + while (linenos->line_number != 0) + { + if (! debug_record_line (dhandle, + linenos->line_number + base, + linenos->u.offset + addr)) + return FALSE; + ++linenos; + } + } + + fnname = NULL; + linenos = NULL; + fnclass = 0; + fntype = 0; + + within_function = TRUE; + } + else if (strcmp (name, ".ef") == 0) + { + if (! within_function) + { + non_fatal (_("%ld: unexpected .ef\n"), this_coff_symno); + return FALSE; + } + + if (bfd_asymbol_value (sym) > fnend) + fnend = bfd_asymbol_value (sym); + if (! debug_end_function (dhandle, fnend)) + return FALSE; + + fnend = 0; + within_function = FALSE; + } + break; + + case C_BLOCK: + if (strcmp (name, ".bb") == 0) + { + if (! debug_start_block (dhandle, bfd_asymbol_value (sym))) + return FALSE; + } + else if (strcmp (name, ".eb") == 0) + { + if (! debug_end_block (dhandle, bfd_asymbol_value (sym))) + return FALSE; + } + break; + + default: + type = parse_coff_type (abfd, &symbols, &types, this_coff_symno, + syment.n_type, paux, TRUE, dhandle); + if (type == DEBUG_TYPE_NULL) + return FALSE; + if (! parse_coff_symbol (abfd, &types, sym, this_coff_symno, &syment, + dhandle, type, within_function)) + return FALSE; + break; + } + } + + return TRUE; +} diff --git a/support/sdbinutils/binutils/rddbg.c b/support/sdbinutils/binutils/rddbg.c new file mode 100644 index 0000000..49972e6 --- /dev/null +++ b/support/sdbinutils/binutils/rddbg.c @@ -0,0 +1,465 @@ +/* rddbg.c -- Read debugging information into a generic form. + Copyright (C) 1995-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor . + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + + +/* This file reads debugging information into a generic form. This + file knows how to dig the debugging information out of an object + file. */ + +#include "sysdep.h" +#include "bfd.h" +#include "libiberty.h" +#include "bucomm.h" +#include "debug.h" +#include "budbg.h" + +static bfd_boolean read_section_stabs_debugging_info + (bfd *, asymbol **, long, void *, bfd_boolean *); +static bfd_boolean read_symbol_stabs_debugging_info + (bfd *, asymbol **, long, void *, bfd_boolean *); +static bfd_boolean read_ieee_debugging_info (bfd *, void *, bfd_boolean *); +static void save_stab (int, int, bfd_vma, const char *); +static void stab_context (void); +static void free_saved_stabs (void); + +/* Read debugging information from a BFD. Returns a generic debugging + pointer. */ + +void * +read_debugging_info (bfd *abfd, asymbol **syms, long symcount, bfd_boolean no_messages) +{ + void *dhandle; + bfd_boolean found; + + dhandle = debug_init (); + if (dhandle == NULL) + return NULL; + + if (! read_section_stabs_debugging_info (abfd, syms, symcount, dhandle, + &found)) + return NULL; + + if (bfd_get_flavour (abfd) == bfd_target_aout_flavour) + { + if (! read_symbol_stabs_debugging_info (abfd, syms, symcount, dhandle, + &found)) + return NULL; + } + + if (bfd_get_flavour (abfd) == bfd_target_ieee_flavour) + { + if (! read_ieee_debugging_info (abfd, dhandle, &found)) + return NULL; + } + + /* Try reading the COFF symbols if we didn't find any stabs in COFF + sections. */ + if (! found + && bfd_get_flavour (abfd) == bfd_target_coff_flavour + && symcount > 0) + { + if (! parse_coff (abfd, syms, symcount, dhandle)) + return NULL; + found = TRUE; + } + + if (! found) + { + if (! no_messages) + non_fatal (_("%s: no recognized debugging information"), + bfd_get_filename (abfd)); + return NULL; + } + + return dhandle; +} + +/* Read stabs in sections debugging information from a BFD. */ + +static bfd_boolean +read_section_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount, + void *dhandle, bfd_boolean *pfound) +{ + static struct + { + const char *secname; + const char *strsecname; + } + names[] = + { + { ".stab", ".stabstr" }, + { "LC_SYMTAB.stabs", "LC_SYMTAB.stabstr" }, + { "$GDB_SYMBOLS$", "$GDB_STRINGS$" } + }; + unsigned int i; + void *shandle; + + *pfound = FALSE; + shandle = NULL; + + for (i = 0; i < sizeof names / sizeof names[0]; i++) + { + asection *sec, *strsec; + + sec = bfd_get_section_by_name (abfd, names[i].secname); + strsec = bfd_get_section_by_name (abfd, names[i].strsecname); + if (sec != NULL && strsec != NULL) + { + bfd_size_type stabsize, strsize; + bfd_byte *stabs, *strings; + bfd_byte *stab; + bfd_size_type stroff, next_stroff; + + stabsize = bfd_section_size (abfd, sec); + stabs = (bfd_byte *) xmalloc (stabsize); + if (! bfd_get_section_contents (abfd, sec, stabs, 0, stabsize)) + { + fprintf (stderr, "%s: %s: %s\n", + bfd_get_filename (abfd), names[i].secname, + bfd_errmsg (bfd_get_error ())); + return FALSE; + } + + strsize = bfd_section_size (abfd, strsec); + strings = (bfd_byte *) xmalloc (strsize + 1); + if (! bfd_get_section_contents (abfd, strsec, strings, 0, strsize)) + { + fprintf (stderr, "%s: %s: %s\n", + bfd_get_filename (abfd), names[i].strsecname, + bfd_errmsg (bfd_get_error ())); + return FALSE; + } + /* Zero terminate the strings table, just in case. */ + strings [strsize] = 0; + if (shandle == NULL) + { + shandle = start_stab (dhandle, abfd, TRUE, syms, symcount); + if (shandle == NULL) + return FALSE; + } + + *pfound = TRUE; + + stroff = 0; + next_stroff = 0; + /* PR 17512: file: 078-60391-0.001:0.1. */ + for (stab = stabs; stab <= (stabs + stabsize) - 12; stab += 12) + { + unsigned int strx; + int type; + int other ATTRIBUTE_UNUSED; + int desc; + bfd_vma value; + + /* This code presumes 32 bit values. */ + + strx = bfd_get_32 (abfd, stab); + type = bfd_get_8 (abfd, stab + 4); + other = bfd_get_8 (abfd, stab + 5); + desc = bfd_get_16 (abfd, stab + 6); + value = bfd_get_32 (abfd, stab + 8); + + if (type == 0) + { + /* Special type 0 stabs indicate the offset to the + next string table. */ + stroff = next_stroff; + next_stroff += value; + } + else + { + size_t len; + char *f, *s; + + if (stroff + strx >= strsize) + { + fprintf (stderr, _("%s: %s: stab entry %ld is corrupt, strx = 0x%x, type = %d\n"), + bfd_get_filename (abfd), names[i].secname, + (long) (stab - stabs) / 12, strx, type); + continue; + } + + s = (char *) strings + stroff + strx; + f = NULL; + + /* PR 17512: file: 002-87578-0.001:0.1. + It is possible to craft a file where, without the 'strlen (s) > 0', + an attempt to read the byte before 'strings' would occur. */ + while ((len = strlen (s)) > 0 + && s[len - 1] == '\\' + && stab + 12 < stabs + stabsize) + { + char *p; + + stab += 12; + p = s + len - 1; + *p = '\0'; + strx = stroff + bfd_get_32 (abfd, stab); + if (strx >= strsize) + { + fprintf (stderr, _("%s: %s: stab entry %ld is corrupt\n"), + bfd_get_filename (abfd), names[i].secname, + (long) (stab - stabs) / 12); + break; + } + else + s = concat (s, (char *) strings + strx, + (const char *) NULL); + + /* We have to restore the backslash, because, if + the linker is hashing stabs strings, we may + see the same string more than once. */ + *p = '\\'; + + if (f != NULL) + free (f); + f = s; + } + + save_stab (type, desc, value, s); + + if (! parse_stab (dhandle, shandle, type, desc, value, s)) + { + stab_context (); + free_saved_stabs (); + return FALSE; + } + + /* Don't free f, since I think the stabs code + expects strings to hang around. This should be + straightened out. FIXME. */ + } + } + + free_saved_stabs (); + free (stabs); + + /* Don't free strings, since I think the stabs code expects + the strings to hang around. This should be straightened + out. FIXME. */ + } + } + + if (shandle != NULL) + { + if (! finish_stab (dhandle, shandle)) + return FALSE; + } + + return TRUE; +} + +/* Read stabs in the symbol table. */ + +static bfd_boolean +read_symbol_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount, + void *dhandle, bfd_boolean *pfound) +{ + void *shandle; + asymbol **ps, **symend; + + shandle = NULL; + symend = syms + symcount; + for (ps = syms; ps < symend; ps++) + { + symbol_info i; + + bfd_get_symbol_info (abfd, *ps, &i); + + if (i.type == '-') + { + const char *s; + char *f; + + if (shandle == NULL) + { + shandle = start_stab (dhandle, abfd, FALSE, syms, symcount); + if (shandle == NULL) + return FALSE; + } + + *pfound = TRUE; + + s = i.name; + if (s == NULL || strlen (s) < 1) + return FALSE; + f = NULL; + + while (strlen (s) > 0 + && s[strlen (s) - 1] == '\\' + && ps + 1 < symend) + { + char *sc, *n; + + ++ps; + sc = xstrdup (s); + sc[strlen (sc) - 1] = '\0'; + n = concat (sc, bfd_asymbol_name (*ps), (const char *) NULL); + free (sc); + if (f != NULL) + free (f); + f = n; + s = n; + } + + save_stab (i.stab_type, i.stab_desc, i.value, s); + + if (! parse_stab (dhandle, shandle, i.stab_type, i.stab_desc, + i.value, s)) + { + stab_context (); + free_saved_stabs (); + return FALSE; + } + + /* Don't free f, since I think the stabs code expects + strings to hang around. This should be straightened out. + FIXME. */ + } + } + + free_saved_stabs (); + + if (shandle != NULL) + { + if (! finish_stab (dhandle, shandle)) + return FALSE; + } + + return TRUE; +} + +/* Read IEEE debugging information. */ + +static bfd_boolean +read_ieee_debugging_info (bfd *abfd, void *dhandle, bfd_boolean *pfound) +{ + asection *dsec; + bfd_size_type size; + bfd_byte *contents; + + /* The BFD backend puts the debugging information into a section + named .debug. */ + + dsec = bfd_get_section_by_name (abfd, ".debug"); + if (dsec == NULL) + return TRUE; + + size = bfd_section_size (abfd, dsec); + contents = (bfd_byte *) xmalloc (size); + if (! bfd_get_section_contents (abfd, dsec, contents, 0, size)) + return FALSE; + + if (! parse_ieee (dhandle, abfd, contents, size)) + return FALSE; + + free (contents); + + *pfound = TRUE; + + return TRUE; +} + +/* Record stabs strings, so that we can give some context for errors. */ + +#define SAVE_STABS_COUNT (16) + +struct saved_stab +{ + int type; + int desc; + bfd_vma value; + char *string; +}; + +static struct saved_stab saved_stabs[SAVE_STABS_COUNT]; +static int saved_stabs_index; + +/* Save a stabs string. */ + +static void +save_stab (int type, int desc, bfd_vma value, const char *string) +{ + if (saved_stabs[saved_stabs_index].string != NULL) + free (saved_stabs[saved_stabs_index].string); + saved_stabs[saved_stabs_index].type = type; + saved_stabs[saved_stabs_index].desc = desc; + saved_stabs[saved_stabs_index].value = value; + saved_stabs[saved_stabs_index].string = xstrdup (string); + saved_stabs_index = (saved_stabs_index + 1) % SAVE_STABS_COUNT; +} + +/* Provide context for an error. */ + +static void +stab_context (void) +{ + int i; + + fprintf (stderr, _("Last stabs entries before error:\n")); + fprintf (stderr, "n_type n_desc n_value string\n"); + + i = saved_stabs_index; + do + { + struct saved_stab *stabp; + + stabp = saved_stabs + i; + if (stabp->string != NULL) + { + const char *s; + + s = bfd_get_stab_name (stabp->type); + if (s != NULL) + fprintf (stderr, "%-6s", s); + else if (stabp->type == 0) + fprintf (stderr, "HdrSym"); + else + fprintf (stderr, "%-6d", stabp->type); + fprintf (stderr, " %-6d ", stabp->desc); + fprintf_vma (stderr, stabp->value); + if (stabp->type != 0) + fprintf (stderr, " %s", stabp->string); + fprintf (stderr, "\n"); + } + i = (i + 1) % SAVE_STABS_COUNT; + } + while (i != saved_stabs_index); +} + +/* Free the saved stab strings. */ + +static void +free_saved_stabs (void) +{ + int i; + + for (i = 0; i < SAVE_STABS_COUNT; i++) + { + if (saved_stabs[i].string != NULL) + { + free (saved_stabs[i].string); + saved_stabs[i].string = NULL; + } + } + + saved_stabs_index = 0; +} diff --git a/support/sdbinutils/binutils/readelf.c b/support/sdbinutils/binutils/readelf.c new file mode 100644 index 0000000..ae1cda9 --- /dev/null +++ b/support/sdbinutils/binutils/readelf.c @@ -0,0 +1,19150 @@ +/* readelf.c -- display contents of an ELF format file + Copyright (C) 1998-2018 Free Software Foundation, Inc. + + Originally developed by Eric Youngdale + Modifications by Nick Clifton + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* The difference between readelf and objdump: + + Both programs are capable of displaying the contents of ELF format files, + so why does the binutils project have two file dumpers ? + + The reason is that objdump sees an ELF file through a BFD filter of the + world; if BFD has a bug where, say, it disagrees about a machine constant + in e_flags, then the odds are good that it will remain internally + consistent. The linker sees it the BFD way, objdump sees it the BFD way, + GAS sees it the BFD way. There was need for a tool to go find out what + the file actually says. + + This is why the readelf program does not link against the BFD library - it + exists as an independent program to help verify the correct working of BFD. + + There is also the case that readelf can provide more information about an + ELF file than is provided by objdump. In particular it can display DWARF + debugging information which (at the moment) objdump cannot. */ + +#include "sysdep.h" +#include +#include +#include +#ifdef HAVE_WCHAR_H +#include +#endif + +#if __GNUC__ >= 2 +/* Define BFD64 here, even if our default architecture is 32 bit ELF + as this will allow us to read in and parse 64bit and 32bit ELF files. + Only do this if we believe that the compiler can support a 64 bit + data type. For now we only rely on GCC being able to do this. */ +#define BFD64 +#endif + +#include "bfd.h" +#include "bucomm.h" +#include "elfcomm.h" +#include "dwarf.h" + +#include "elf/common.h" +#include "elf/external.h" +#include "elf/internal.h" + + +/* Included here, before RELOC_MACROS_GEN_FUNC is defined, so that + we can obtain the H8 reloc numbers. We need these for the + get_reloc_size() function. We include h8.h again after defining + RELOC_MACROS_GEN_FUNC so that we get the naming function as well. */ + +#include "elf/h8.h" +#undef _ELF_H8_H + +/* Undo the effects of #including reloc-macros.h. */ + +#undef START_RELOC_NUMBERS +#undef RELOC_NUMBER +#undef FAKE_RELOC +#undef EMPTY_RELOC +#undef END_RELOC_NUMBERS +#undef _RELOC_MACROS_H + +/* The following headers use the elf/reloc-macros.h file to + automatically generate relocation recognition functions + such as elf_mips_reloc_type() */ + +#define RELOC_MACROS_GEN_FUNC + +#include "elf/aarch64.h" +#include "elf/alpha.h" +#include "elf/arc.h" +#include "elf/arm.h" +#include "elf/avr.h" +#include "elf/bfin.h" +#include "elf/cr16.h" +#include "elf/cris.h" +#include "elf/crx.h" +#include "elf/d10v.h" +#include "elf/d30v.h" +#include "elf/dlx.h" +#include "elf/epiphany.h" +#include "elf/fr30.h" +#include "elf/frv.h" +#include "elf/ft32.h" +#include "elf/h8.h" +#include "elf/hppa.h" +#include "elf/i386.h" +#include "elf/i370.h" +#include "elf/i860.h" +#include "elf/i960.h" +#include "elf/ia64.h" +#include "elf/ip2k.h" +#include "elf/lm32.h" +#include "elf/iq2000.h" +#include "elf/m32c.h" +#include "elf/m32r.h" +#include "elf/m68k.h" +#include "elf/m68hc11.h" +#include "elf/mcore.h" +#include "elf/mep.h" +#include "elf/metag.h" +#include "elf/microblaze.h" +#include "elf/mips.h" +#include "elf/mmix.h" +#include "elf/mn10200.h" +#include "elf/mn10300.h" +#include "elf/moxie.h" +#include "elf/mt.h" +#include "elf/msp430.h" +#include "elf/nds32.h" +#include "elf/nios2.h" +#include "elf/or1k.h" +#include "elf/pj.h" +#include "elf/ppc.h" +#include "elf/ppc64.h" +#include "elf/pru.h" +#include "elf/riscv.h" +#include "elf/rl78.h" +#include "elf/rx.h" +#include "elf/s390.h" +#include "elf/score.h" +#include "elf/sh.h" +#include "elf/sparc.h" +#include "elf/spu.h" +#include "elf/tic6x.h" +#include "elf/tilegx.h" +#include "elf/tilepro.h" +#include "elf/v850.h" +#include "elf/vax.h" +#include "elf/visium.h" +#include "elf/wasm32.h" +#include "elf/x86-64.h" +#include "elf/xc16x.h" +#include "elf/xgate.h" +#include "elf/xstormy16.h" +#include "elf/xtensa.h" + +#include "getopt.h" +#include "libiberty.h" +#include "safe-ctype.h" +#include "filenames.h" + +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &(((TYPE *) 0)->MEMBER)) +#endif + +typedef struct elf_section_list +{ + Elf_Internal_Shdr * hdr; + struct elf_section_list * next; +} elf_section_list; + +/* Flag bits indicating particular types of dump. */ +#define HEX_DUMP (1 << 0) /* The -x command line switch. */ +#define DISASS_DUMP (1 << 1) /* The -i command line switch. */ +#define DEBUG_DUMP (1 << 2) /* The -w command line switch. */ +#define STRING_DUMP (1 << 3) /* The -p command line switch. */ +#define RELOC_DUMP (1 << 4) /* The -R command line switch. */ + +typedef unsigned char dump_type; + +/* A linked list of the section names for which dumps were requested. */ +struct dump_list_entry +{ + char * name; + dump_type type; + struct dump_list_entry * next; +}; + +typedef struct filedata +{ + const char * file_name; + FILE * handle; + bfd_size_type file_size; + Elf_Internal_Ehdr file_header; + Elf_Internal_Shdr * section_headers; + Elf_Internal_Phdr * program_headers; + char * string_table; + unsigned long string_table_length; + /* A dynamic array of flags indicating for which sections a dump of + some kind has been requested. It is reset on a per-object file + basis and then initialised from the cmdline_dump_sects array, + the results of interpreting the -w switch, and the + dump_sects_byname list. */ + dump_type * dump_sects; + unsigned int num_dump_sects; +} Filedata; + +char * program_name = "readelf"; + +static unsigned long archive_file_offset; +static unsigned long archive_file_size; +static unsigned long dynamic_addr; +static bfd_size_type dynamic_size; +static size_t dynamic_nent; +static char * dynamic_strings; +static unsigned long dynamic_strings_length; +static unsigned long num_dynamic_syms; +static Elf_Internal_Sym * dynamic_symbols; +static Elf_Internal_Syminfo * dynamic_syminfo; +static unsigned long dynamic_syminfo_offset; +static unsigned int dynamic_syminfo_nent; +static char program_interpreter[PATH_MAX]; +static bfd_vma dynamic_info[DT_ENCODING]; +static bfd_vma dynamic_info_DT_GNU_HASH; +static bfd_vma version_info[16]; +static Elf_Internal_Dyn * dynamic_section; +static elf_section_list * symtab_shndx_list; +static bfd_boolean show_name = FALSE; +static bfd_boolean do_dynamic = FALSE; +static bfd_boolean do_syms = FALSE; +static bfd_boolean do_dyn_syms = FALSE; +static bfd_boolean do_reloc = FALSE; +static bfd_boolean do_sections = FALSE; +static bfd_boolean do_section_groups = FALSE; +static bfd_boolean do_section_details = FALSE; +static bfd_boolean do_segments = FALSE; +static bfd_boolean do_unwind = FALSE; +static bfd_boolean do_using_dynamic = FALSE; +static bfd_boolean do_header = FALSE; +static bfd_boolean do_dump = FALSE; +static bfd_boolean do_version = FALSE; +static bfd_boolean do_histogram = FALSE; +static bfd_boolean do_debugging = FALSE; +static bfd_boolean do_arch = FALSE; +static bfd_boolean do_notes = FALSE; +static bfd_boolean do_archive_index = FALSE; +static bfd_boolean is_32bit_elf = FALSE; +static bfd_boolean decompress_dumps = FALSE; + +struct group_list +{ + struct group_list * next; + unsigned int section_index; +}; + +struct group +{ + struct group_list * root; + unsigned int group_index; +}; + +static size_t group_count; +static struct group * section_groups; +static struct group ** section_headers_groups; + +/* A dynamic array of flags indicating for which sections a dump + has been requested via command line switches. */ +static Filedata cmdline; + +static struct dump_list_entry * dump_sects_byname; + +/* How to print a vma value. */ +typedef enum print_mode +{ + HEX, + DEC, + DEC_5, + UNSIGNED, + PREFIX_HEX, + FULL_HEX, + LONG_HEX +} +print_mode; + +/* Versioned symbol info. */ +enum versioned_symbol_info +{ + symbol_undefined, + symbol_hidden, + symbol_public +}; + +static const char * get_symbol_version_string + (Filedata *, bfd_boolean, const char *, unsigned long, unsigned, + Elf_Internal_Sym *, enum versioned_symbol_info *, unsigned short *); + +#define UNKNOWN -1 + +#define SECTION_NAME(X) \ + ((X) == NULL ? _("") \ + : filedata->string_table == NULL ? _("") \ + : ((X)->sh_name >= filedata->string_table_length ? _("") \ + : filedata->string_table + (X)->sh_name)) + +#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ + +#define GET_ELF_SYMBOLS(file, section, sym_count) \ + (is_32bit_elf ? get_32bit_elf_symbols (file, section, sym_count) \ + : get_64bit_elf_symbols (file, section, sym_count)) + +#define VALID_DYNAMIC_NAME(offset) ((dynamic_strings != NULL) && (offset < dynamic_strings_length)) +/* GET_DYNAMIC_NAME asssumes that VALID_DYNAMIC_NAME has + already been called and verified that the string exists. */ +#define GET_DYNAMIC_NAME(offset) (dynamic_strings + offset) + +#define REMOVE_ARCH_BITS(ADDR) \ + do \ + { \ + if (filedata->file_header.e_machine == EM_ARM) \ + (ADDR) &= ~1; \ + } \ + while (0) + +/* Print a BFD_VMA to an internal buffer, for use in error messages. + BFD_FMA_FMT can't be used in translated strings. */ + +static const char * +bfd_vmatoa (char *fmtch, bfd_vma value) +{ + /* bfd_vmatoa is used more then once in a printf call for output. + Cycle through an array of buffers. */ + static int buf_pos = 0; + static struct bfd_vmatoa_buf + { + char place[64]; + } buf[4]; + char *ret; + char fmt[32]; + + ret = buf[buf_pos++].place; + buf_pos %= ARRAY_SIZE (buf); + + sprintf (fmt, "%%%s%s", BFD_VMA_FMT, fmtch); + snprintf (ret, sizeof (buf[0].place), fmt, value); + return ret; +} + +/* Retrieve NMEMB structures, each SIZE bytes long from FILEDATA starting at + OFFSET + the offset of the current archive member, if we are examining an + archive. Put the retrieved data into VAR, if it is not NULL. Otherwise + allocate a buffer using malloc and fill that. In either case return the + pointer to the start of the retrieved data or NULL if something went wrong. + If something does go wrong and REASON is not NULL then emit an error + message using REASON as part of the context. */ + +static void * +get_data (void * var, + Filedata * filedata, + unsigned long offset, + bfd_size_type size, + bfd_size_type nmemb, + const char * reason) +{ + void * mvar; + bfd_size_type amt = size * nmemb; + + if (size == 0 || nmemb == 0) + return NULL; + + /* If the size_t type is smaller than the bfd_size_type, eg because + you are building a 32-bit tool on a 64-bit host, then make sure + that when the sizes are cast to (size_t) no information is lost. */ + if (sizeof (size_t) < sizeof (bfd_size_type) + && ( (bfd_size_type) ((size_t) size) != size + || (bfd_size_type) ((size_t) nmemb) != nmemb)) + { + if (reason) + error (_("Size truncation prevents reading %s" + " elements of size %s for %s\n"), + bfd_vmatoa ("u", nmemb), bfd_vmatoa ("u", size), reason); + return NULL; + } + + /* Check for size overflow. */ + if (amt < nmemb) + { + if (reason) + error (_("Size overflow prevents reading %s" + " elements of size %s for %s\n"), + bfd_vmatoa ("u", nmemb), bfd_vmatoa ("u", size), reason); + return NULL; + } + + /* Be kind to memory chekers (eg valgrind, address sanitizer) by not + attempting to allocate memory when the read is bound to fail. */ + if (amt > filedata->file_size + || offset + archive_file_offset + amt > filedata->file_size) + { + if (reason) + error (_("Reading %s bytes extends past end of file for %s\n"), + bfd_vmatoa ("u", amt), reason); + return NULL; + } + + if (fseek (filedata->handle, archive_file_offset + offset, SEEK_SET)) + { + if (reason) + error (_("Unable to seek to 0x%lx for %s\n"), + archive_file_offset + offset, reason); + return NULL; + } + + mvar = var; + if (mvar == NULL) + { + /* Check for overflow. */ + if (nmemb < (~(bfd_size_type) 0 - 1) / size) + /* + 1 so that we can '\0' terminate invalid string table sections. */ + mvar = malloc ((size_t) amt + 1); + + if (mvar == NULL) + { + if (reason) + error (_("Out of memory allocating %s bytes for %s\n"), + bfd_vmatoa ("u", amt), reason); + return NULL; + } + + ((char *) mvar)[amt] = '\0'; + } + + if (fread (mvar, (size_t) size, (size_t) nmemb, filedata->handle) != nmemb) + { + if (reason) + error (_("Unable to read in %s bytes of %s\n"), + bfd_vmatoa ("u", amt), reason); + if (mvar != var) + free (mvar); + return NULL; + } + + return mvar; +} + +/* Print a VMA value in the MODE specified. + Returns the number of characters displayed. */ + +static unsigned int +print_vma (bfd_vma vma, print_mode mode) +{ + unsigned int nc = 0; + + switch (mode) + { + case FULL_HEX: + nc = printf ("0x"); + /* Fall through. */ + case LONG_HEX: +#ifdef BFD64 + if (is_32bit_elf) + return nc + printf ("%8.8" BFD_VMA_FMT "x", vma); +#endif + printf_vma (vma); + return nc + 16; + + case DEC_5: + if (vma <= 99999) + return printf ("%5" BFD_VMA_FMT "d", vma); + /* Fall through. */ + case PREFIX_HEX: + nc = printf ("0x"); + /* Fall through. */ + case HEX: + return nc + printf ("%" BFD_VMA_FMT "x", vma); + + case DEC: + return printf ("%" BFD_VMA_FMT "d", vma); + + case UNSIGNED: + return printf ("%" BFD_VMA_FMT "u", vma); + + default: + /* FIXME: Report unrecognised mode ? */ + return 0; + } +} + +/* Display a symbol on stdout. Handles the display of control characters and + multibye characters (assuming the host environment supports them). + + Display at most abs(WIDTH) characters, truncating as necessary, unless do_wide is true. + + If WIDTH is negative then ensure that the output is at least (- WIDTH) characters, + padding as necessary. + + Returns the number of emitted characters. */ + +static unsigned int +print_symbol (signed int width, const char *symbol) +{ + bfd_boolean extra_padding = FALSE; + signed int num_printed = 0; +#ifdef HAVE_MBSTATE_T + mbstate_t state; +#endif + unsigned int width_remaining; + + if (width < 0) + { + /* Keep the width positive. This helps the code below. */ + width = - width; + extra_padding = TRUE; + } + assert (width != 0); + + if (do_wide) + /* Set the remaining width to a very large value. + This simplifies the code below. */ + width_remaining = INT_MAX; + else + width_remaining = width; + +#ifdef HAVE_MBSTATE_T + /* Initialise the multibyte conversion state. */ + memset (& state, 0, sizeof (state)); +#endif + + while (width_remaining) + { + size_t n; + const char c = *symbol++; + + if (c == 0) + break; + + /* Do not print control characters directly as they can affect terminal + settings. Such characters usually appear in the names generated + by the assembler for local labels. */ + if (ISCNTRL (c)) + { + if (width_remaining < 2) + break; + + printf ("^%c", c + 0x40); + width_remaining -= 2; + num_printed += 2; + } + else if (ISPRINT (c)) + { + putchar (c); + width_remaining --; + num_printed ++; + } + else + { +#ifdef HAVE_MBSTATE_T + wchar_t w; +#endif + /* Let printf do the hard work of displaying multibyte characters. */ + printf ("%.1s", symbol - 1); + width_remaining --; + num_printed ++; + +#ifdef HAVE_MBSTATE_T + /* Try to find out how many bytes made up the character that was + just printed. Advance the symbol pointer past the bytes that + were displayed. */ + n = mbrtowc (& w, symbol - 1, MB_CUR_MAX, & state); +#else + n = 1; +#endif + if (n != (size_t) -1 && n != (size_t) -2 && n > 0) + symbol += (n - 1); + } + } + + if (extra_padding && num_printed < width) + { + /* Fill in the remaining spaces. */ + printf ("%-*s", width - num_printed, " "); + num_printed = width; + } + + return num_printed; +} + +/* Returns a pointer to a static buffer containing a printable version of + the given section's name. Like print_symbol, except that it does not try + to print multibyte characters, it just interprets them as hex values. */ + +static const char * +printable_section_name (Filedata * filedata, const Elf_Internal_Shdr * sec) +{ +#define MAX_PRINT_SEC_NAME_LEN 128 + static char sec_name_buf [MAX_PRINT_SEC_NAME_LEN + 1]; + const char * name = SECTION_NAME (sec); + char * buf = sec_name_buf; + char c; + unsigned int remaining = MAX_PRINT_SEC_NAME_LEN; + + while ((c = * name ++) != 0) + { + if (ISCNTRL (c)) + { + if (remaining < 2) + break; + + * buf ++ = '^'; + * buf ++ = c + 0x40; + remaining -= 2; + } + else if (ISPRINT (c)) + { + * buf ++ = c; + remaining -= 1; + } + else + { + static char hex[17] = "0123456789ABCDEF"; + + if (remaining < 4) + break; + * buf ++ = '<'; + * buf ++ = hex[(c & 0xf0) >> 4]; + * buf ++ = hex[c & 0x0f]; + * buf ++ = '>'; + remaining -= 4; + } + + if (remaining == 0) + break; + } + + * buf = 0; + return sec_name_buf; +} + +static const char * +printable_section_name_from_index (Filedata * filedata, unsigned long ndx) +{ + if (ndx >= filedata->file_header.e_shnum) + return _(""); + + return printable_section_name (filedata, filedata->section_headers + ndx); +} + +/* Return a pointer to section NAME, or NULL if no such section exists. */ + +static Elf_Internal_Shdr * +find_section (Filedata * filedata, const char * name) +{ + unsigned int i; + + assert (filedata->section_headers != NULL); + + for (i = 0; i < filedata->file_header.e_shnum; i++) + if (streq (SECTION_NAME (filedata->section_headers + i), name)) + return filedata->section_headers + i; + + return NULL; +} + +/* Return a pointer to a section containing ADDR, or NULL if no such + section exists. */ + +static Elf_Internal_Shdr * +find_section_by_address (Filedata * filedata, bfd_vma addr) +{ + unsigned int i; + + for (i = 0; i < filedata->file_header.e_shnum; i++) + { + Elf_Internal_Shdr *sec = filedata->section_headers + i; + + if (addr >= sec->sh_addr && addr < sec->sh_addr + sec->sh_size) + return sec; + } + + return NULL; +} + +static Elf_Internal_Shdr * +find_section_by_type (Filedata * filedata, unsigned int type) +{ + unsigned int i; + + for (i = 0; i < filedata->file_header.e_shnum; i++) + { + Elf_Internal_Shdr *sec = filedata->section_headers + i; + + if (sec->sh_type == type) + return sec; + } + + return NULL; +} + +/* Return a pointer to section NAME, or NULL if no such section exists, + restricted to the list of sections given in SET. */ + +static Elf_Internal_Shdr * +find_section_in_set (Filedata * filedata, const char * name, unsigned int * set) +{ + unsigned int i; + + if (set != NULL) + { + while ((i = *set++) > 0) + { + /* See PR 21156 for a reproducer. */ + if (i >= filedata->file_header.e_shnum) + continue; /* FIXME: Should we issue an error message ? */ + + if (streq (SECTION_NAME (filedata->section_headers + i), name)) + return filedata->section_headers + i; + } + } + + return find_section (filedata, name); +} + +/* Read an unsigned LEB128 encoded value from DATA. + Set *LENGTH_RETURN to the number of bytes read. */ + +static inline unsigned long +read_uleb128 (unsigned char * data, + unsigned int * length_return, + const unsigned char * const end) +{ + return read_leb128 (data, length_return, FALSE, end); +} + +/* Return TRUE if the current file is for IA-64 machine and OpenVMS ABI. + This OS has so many departures from the ELF standard that we test it at + many places. */ + +static inline bfd_boolean +is_ia64_vms (Filedata * filedata) +{ + return filedata->file_header.e_machine == EM_IA_64 + && filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_OPENVMS; +} + +/* Guess the relocation size commonly used by the specific machines. */ + +static bfd_boolean +guess_is_rela (unsigned int e_machine) +{ + switch (e_machine) + { + /* Targets that use REL relocations. */ + case EM_386: + case EM_IAMCU: + case EM_960: + case EM_ARM: + case EM_D10V: + case EM_CYGNUS_D10V: + case EM_DLX: + case EM_MIPS: + case EM_MIPS_RS3_LE: + case EM_CYGNUS_M32R: + case EM_SCORE: + case EM_XGATE: + return FALSE; + + /* Targets that use RELA relocations. */ + case EM_68K: + case EM_860: + case EM_AARCH64: + case EM_ADAPTEVA_EPIPHANY: + case EM_ALPHA: + case EM_ALTERA_NIOS2: + case EM_ARC: + case EM_ARC_COMPACT: + case EM_ARC_COMPACT2: + case EM_AVR: + case EM_AVR_OLD: + case EM_BLACKFIN: + case EM_CR16: + case EM_CRIS: + case EM_CRX: + case EM_D30V: + case EM_CYGNUS_D30V: + case EM_FR30: + case EM_FT32: + case EM_CYGNUS_FR30: + case EM_CYGNUS_FRV: + case EM_H8S: + case EM_H8_300: + case EM_H8_300H: + case EM_IA_64: + case EM_IP2K: + case EM_IP2K_OLD: + case EM_IQ2000: + case EM_LATTICEMICO32: + case EM_M32C_OLD: + case EM_M32C: + case EM_M32R: + case EM_MCORE: + case EM_CYGNUS_MEP: + case EM_METAG: + case EM_MMIX: + case EM_MN10200: + case EM_CYGNUS_MN10200: + case EM_MN10300: + case EM_CYGNUS_MN10300: + case EM_MOXIE: + case EM_MSP430: + case EM_MSP430_OLD: + case EM_MT: + case EM_NDS32: + case EM_NIOS32: + case EM_OR1K: + case EM_PPC64: + case EM_PPC: + case EM_TI_PRU: + case EM_RISCV: + case EM_RL78: + case EM_RX: + case EM_S390: + case EM_S390_OLD: + case EM_SH: + case EM_SPARC: + case EM_SPARC32PLUS: + case EM_SPARCV9: + case EM_SPU: + case EM_TI_C6000: + case EM_TILEGX: + case EM_TILEPRO: + case EM_V800: + case EM_V850: + case EM_CYGNUS_V850: + case EM_VAX: + case EM_VISIUM: + case EM_X86_64: + case EM_L1OM: + case EM_K1OM: + case EM_XSTORMY16: + case EM_XTENSA: + case EM_XTENSA_OLD: + case EM_MICROBLAZE: + case EM_MICROBLAZE_OLD: + case EM_WEBASSEMBLY: + return TRUE; + + case EM_68HC05: + case EM_68HC08: + case EM_68HC11: + case EM_68HC16: + case EM_FX66: + case EM_ME16: + case EM_MMA: + case EM_NCPU: + case EM_NDR1: + case EM_PCP: + case EM_ST100: + case EM_ST19: + case EM_ST7: + case EM_ST9PLUS: + case EM_STARCORE: + case EM_SVX: + case EM_TINYJ: + default: + warn (_("Don't know about relocations on this machine architecture\n")); + return FALSE; + } +} + +/* Load RELA type relocations from FILEDATA at REL_OFFSET extending for REL_SIZE bytes. + Returns TRUE upon success, FALSE otherwise. If successful then a + pointer to a malloc'ed buffer containing the relocs is placed in *RELASP, + and the number of relocs loaded is placed in *NRELASP. It is the caller's + responsibility to free the allocated buffer. */ + +static bfd_boolean +slurp_rela_relocs (Filedata * filedata, + unsigned long rel_offset, + unsigned long rel_size, + Elf_Internal_Rela ** relasp, + unsigned long * nrelasp) +{ + Elf_Internal_Rela * relas; + size_t nrelas; + unsigned int i; + + if (is_32bit_elf) + { + Elf32_External_Rela * erelas; + + erelas = (Elf32_External_Rela *) get_data (NULL, filedata, rel_offset, 1, + rel_size, _("32-bit relocation data")); + if (!erelas) + return FALSE; + + nrelas = rel_size / sizeof (Elf32_External_Rela); + + relas = (Elf_Internal_Rela *) cmalloc (nrelas, + sizeof (Elf_Internal_Rela)); + + if (relas == NULL) + { + free (erelas); + error (_("out of memory parsing relocs\n")); + return FALSE; + } + + for (i = 0; i < nrelas; i++) + { + relas[i].r_offset = BYTE_GET (erelas[i].r_offset); + relas[i].r_info = BYTE_GET (erelas[i].r_info); + relas[i].r_addend = BYTE_GET_SIGNED (erelas[i].r_addend); + } + + free (erelas); + } + else + { + Elf64_External_Rela * erelas; + + erelas = (Elf64_External_Rela *) get_data (NULL, filedata, rel_offset, 1, + rel_size, _("64-bit relocation data")); + if (!erelas) + return FALSE; + + nrelas = rel_size / sizeof (Elf64_External_Rela); + + relas = (Elf_Internal_Rela *) cmalloc (nrelas, + sizeof (Elf_Internal_Rela)); + + if (relas == NULL) + { + free (erelas); + error (_("out of memory parsing relocs\n")); + return FALSE; + } + + for (i = 0; i < nrelas; i++) + { + relas[i].r_offset = BYTE_GET (erelas[i].r_offset); + relas[i].r_info = BYTE_GET (erelas[i].r_info); + relas[i].r_addend = BYTE_GET_SIGNED (erelas[i].r_addend); + + /* The #ifdef BFD64 below is to prevent a compile time + warning. We know that if we do not have a 64 bit data + type that we will never execute this code anyway. */ +#ifdef BFD64 + if (filedata->file_header.e_machine == EM_MIPS + && filedata->file_header.e_ident[EI_DATA] != ELFDATA2MSB) + { + /* In little-endian objects, r_info isn't really a + 64-bit little-endian value: it has a 32-bit + little-endian symbol index followed by four + individual byte fields. Reorder INFO + accordingly. */ + bfd_vma inf = relas[i].r_info; + inf = (((inf & 0xffffffff) << 32) + | ((inf >> 56) & 0xff) + | ((inf >> 40) & 0xff00) + | ((inf >> 24) & 0xff0000) + | ((inf >> 8) & 0xff000000)); + relas[i].r_info = inf; + } +#endif /* BFD64 */ + } + + free (erelas); + } + + *relasp = relas; + *nrelasp = nrelas; + return TRUE; +} + +/* Load REL type relocations from FILEDATA at REL_OFFSET extending for REL_SIZE bytes. + Returns TRUE upon success, FALSE otherwise. If successful then a + pointer to a malloc'ed buffer containing the relocs is placed in *RELSP, + and the number of relocs loaded is placed in *NRELSP. It is the caller's + responsibility to free the allocated buffer. */ + +static bfd_boolean +slurp_rel_relocs (Filedata * filedata, + unsigned long rel_offset, + unsigned long rel_size, + Elf_Internal_Rela ** relsp, + unsigned long * nrelsp) +{ + Elf_Internal_Rela * rels; + size_t nrels; + unsigned int i; + + if (is_32bit_elf) + { + Elf32_External_Rel * erels; + + erels = (Elf32_External_Rel *) get_data (NULL, filedata, rel_offset, 1, + rel_size, _("32-bit relocation data")); + if (!erels) + return FALSE; + + nrels = rel_size / sizeof (Elf32_External_Rel); + + rels = (Elf_Internal_Rela *) cmalloc (nrels, sizeof (Elf_Internal_Rela)); + + if (rels == NULL) + { + free (erels); + error (_("out of memory parsing relocs\n")); + return FALSE; + } + + for (i = 0; i < nrels; i++) + { + rels[i].r_offset = BYTE_GET (erels[i].r_offset); + rels[i].r_info = BYTE_GET (erels[i].r_info); + rels[i].r_addend = 0; + } + + free (erels); + } + else + { + Elf64_External_Rel * erels; + + erels = (Elf64_External_Rel *) get_data (NULL, filedata, rel_offset, 1, + rel_size, _("64-bit relocation data")); + if (!erels) + return FALSE; + + nrels = rel_size / sizeof (Elf64_External_Rel); + + rels = (Elf_Internal_Rela *) cmalloc (nrels, sizeof (Elf_Internal_Rela)); + + if (rels == NULL) + { + free (erels); + error (_("out of memory parsing relocs\n")); + return FALSE; + } + + for (i = 0; i < nrels; i++) + { + rels[i].r_offset = BYTE_GET (erels[i].r_offset); + rels[i].r_info = BYTE_GET (erels[i].r_info); + rels[i].r_addend = 0; + + /* The #ifdef BFD64 below is to prevent a compile time + warning. We know that if we do not have a 64 bit data + type that we will never execute this code anyway. */ +#ifdef BFD64 + if (filedata->file_header.e_machine == EM_MIPS + && filedata->file_header.e_ident[EI_DATA] != ELFDATA2MSB) + { + /* In little-endian objects, r_info isn't really a + 64-bit little-endian value: it has a 32-bit + little-endian symbol index followed by four + individual byte fields. Reorder INFO + accordingly. */ + bfd_vma inf = rels[i].r_info; + inf = (((inf & 0xffffffff) << 32) + | ((inf >> 56) & 0xff) + | ((inf >> 40) & 0xff00) + | ((inf >> 24) & 0xff0000) + | ((inf >> 8) & 0xff000000)); + rels[i].r_info = inf; + } +#endif /* BFD64 */ + } + + free (erels); + } + + *relsp = rels; + *nrelsp = nrels; + return TRUE; +} + +/* Returns the reloc type extracted from the reloc info field. */ + +static unsigned int +get_reloc_type (Filedata * filedata, bfd_vma reloc_info) +{ + if (is_32bit_elf) + return ELF32_R_TYPE (reloc_info); + + switch (filedata->file_header.e_machine) + { + case EM_MIPS: + /* Note: We assume that reloc_info has already been adjusted for us. */ + return ELF64_MIPS_R_TYPE (reloc_info); + + case EM_SPARCV9: + return ELF64_R_TYPE_ID (reloc_info); + + default: + return ELF64_R_TYPE (reloc_info); + } +} + +/* Return the symbol index extracted from the reloc info field. */ + +static bfd_vma +get_reloc_symindex (bfd_vma reloc_info) +{ + return is_32bit_elf ? ELF32_R_SYM (reloc_info) : ELF64_R_SYM (reloc_info); +} + +static inline bfd_boolean +uses_msp430x_relocs (Filedata * filedata) +{ + return + filedata->file_header.e_machine == EM_MSP430 /* Paranoia. */ + /* GCC uses osabi == ELFOSBI_STANDALONE. */ + && (((filedata->file_header.e_flags & EF_MSP430_MACH) == E_MSP430_MACH_MSP430X) + /* TI compiler uses ELFOSABI_NONE. */ + || (filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_NONE)); +} + +/* Display the contents of the relocation data found at the specified + offset. */ + +static bfd_boolean +dump_relocations (Filedata * filedata, + unsigned long rel_offset, + unsigned long rel_size, + Elf_Internal_Sym * symtab, + unsigned long nsyms, + char * strtab, + unsigned long strtablen, + int is_rela, + bfd_boolean is_dynsym) +{ + unsigned long i; + Elf_Internal_Rela * rels; + bfd_boolean res = TRUE; + + if (is_rela == UNKNOWN) + is_rela = guess_is_rela (filedata->file_header.e_machine); + + if (is_rela) + { + if (!slurp_rela_relocs (filedata, rel_offset, rel_size, &rels, &rel_size)) + return FALSE; + } + else + { + if (!slurp_rel_relocs (filedata, rel_offset, rel_size, &rels, &rel_size)) + return FALSE; + } + + if (is_32bit_elf) + { + if (is_rela) + { + if (do_wide) + printf (_(" Offset Info Type Sym. Value Symbol's Name + Addend\n")); + else + printf (_(" Offset Info Type Sym.Value Sym. Name + Addend\n")); + } + else + { + if (do_wide) + printf (_(" Offset Info Type Sym. Value Symbol's Name\n")); + else + printf (_(" Offset Info Type Sym.Value Sym. Name\n")); + } + } + else + { + if (is_rela) + { + if (do_wide) + printf (_(" Offset Info Type Symbol's Value Symbol's Name + Addend\n")); + else + printf (_(" Offset Info Type Sym. Value Sym. Name + Addend\n")); + } + else + { + if (do_wide) + printf (_(" Offset Info Type Symbol's Value Symbol's Name\n")); + else + printf (_(" Offset Info Type Sym. Value Sym. Name\n")); + } + } + + for (i = 0; i < rel_size; i++) + { + const char * rtype; + bfd_vma offset; + bfd_vma inf; + bfd_vma symtab_index; + bfd_vma type; + + offset = rels[i].r_offset; + inf = rels[i].r_info; + + type = get_reloc_type (filedata, inf); + symtab_index = get_reloc_symindex (inf); + + if (is_32bit_elf) + { + printf ("%8.8lx %8.8lx ", + (unsigned long) offset & 0xffffffff, + (unsigned long) inf & 0xffffffff); + } + else + { +#if BFD_HOST_64BIT_LONG + printf (do_wide + ? "%16.16lx %16.16lx " + : "%12.12lx %12.12lx ", + offset, inf); +#elif BFD_HOST_64BIT_LONG_LONG +#ifndef __MSVCRT__ + printf (do_wide + ? "%16.16llx %16.16llx " + : "%12.12llx %12.12llx ", + offset, inf); +#else + printf (do_wide + ? "%16.16I64x %16.16I64x " + : "%12.12I64x %12.12I64x ", + offset, inf); +#endif +#else + printf (do_wide + ? "%8.8lx%8.8lx %8.8lx%8.8lx " + : "%4.4lx%8.8lx %4.4lx%8.8lx ", + _bfd_int64_high (offset), + _bfd_int64_low (offset), + _bfd_int64_high (inf), + _bfd_int64_low (inf)); +#endif + } + + switch (filedata->file_header.e_machine) + { + default: + rtype = NULL; + break; + + case EM_AARCH64: + rtype = elf_aarch64_reloc_type (type); + break; + + case EM_M32R: + case EM_CYGNUS_M32R: + rtype = elf_m32r_reloc_type (type); + break; + + case EM_386: + case EM_IAMCU: + rtype = elf_i386_reloc_type (type); + break; + + case EM_68HC11: + case EM_68HC12: + rtype = elf_m68hc11_reloc_type (type); + break; + + case EM_68K: + rtype = elf_m68k_reloc_type (type); + break; + + case EM_960: + rtype = elf_i960_reloc_type (type); + break; + + case EM_AVR: + case EM_AVR_OLD: + rtype = elf_avr_reloc_type (type); + break; + + case EM_OLD_SPARCV9: + case EM_SPARC32PLUS: + case EM_SPARCV9: + case EM_SPARC: + rtype = elf_sparc_reloc_type (type); + break; + + case EM_SPU: + rtype = elf_spu_reloc_type (type); + break; + + case EM_V800: + rtype = v800_reloc_type (type); + break; + case EM_V850: + case EM_CYGNUS_V850: + rtype = v850_reloc_type (type); + break; + + case EM_D10V: + case EM_CYGNUS_D10V: + rtype = elf_d10v_reloc_type (type); + break; + + case EM_D30V: + case EM_CYGNUS_D30V: + rtype = elf_d30v_reloc_type (type); + break; + + case EM_DLX: + rtype = elf_dlx_reloc_type (type); + break; + + case EM_SH: + rtype = elf_sh_reloc_type (type); + break; + + case EM_MN10300: + case EM_CYGNUS_MN10300: + rtype = elf_mn10300_reloc_type (type); + break; + + case EM_MN10200: + case EM_CYGNUS_MN10200: + rtype = elf_mn10200_reloc_type (type); + break; + + case EM_FR30: + case EM_CYGNUS_FR30: + rtype = elf_fr30_reloc_type (type); + break; + + case EM_CYGNUS_FRV: + rtype = elf_frv_reloc_type (type); + break; + + case EM_FT32: + rtype = elf_ft32_reloc_type (type); + break; + + case EM_MCORE: + rtype = elf_mcore_reloc_type (type); + break; + + case EM_MMIX: + rtype = elf_mmix_reloc_type (type); + break; + + case EM_MOXIE: + rtype = elf_moxie_reloc_type (type); + break; + + case EM_MSP430: + if (uses_msp430x_relocs (filedata)) + { + rtype = elf_msp430x_reloc_type (type); + break; + } + /* Fall through. */ + case EM_MSP430_OLD: + rtype = elf_msp430_reloc_type (type); + break; + + case EM_NDS32: + rtype = elf_nds32_reloc_type (type); + break; + + case EM_PPC: + rtype = elf_ppc_reloc_type (type); + break; + + case EM_PPC64: + rtype = elf_ppc64_reloc_type (type); + break; + + case EM_MIPS: + case EM_MIPS_RS3_LE: + rtype = elf_mips_reloc_type (type); + break; + + case EM_RISCV: + rtype = elf_riscv_reloc_type (type); + break; + + case EM_ALPHA: + rtype = elf_alpha_reloc_type (type); + break; + + case EM_ARM: + rtype = elf_arm_reloc_type (type); + break; + + case EM_ARC: + case EM_ARC_COMPACT: + case EM_ARC_COMPACT2: + rtype = elf_arc_reloc_type (type); + break; + + case EM_PARISC: + rtype = elf_hppa_reloc_type (type); + break; + + case EM_H8_300: + case EM_H8_300H: + case EM_H8S: + rtype = elf_h8_reloc_type (type); + break; + + case EM_OR1K: + rtype = elf_or1k_reloc_type (type); + break; + + case EM_PJ: + case EM_PJ_OLD: + rtype = elf_pj_reloc_type (type); + break; + case EM_IA_64: + rtype = elf_ia64_reloc_type (type); + break; + + case EM_CRIS: + rtype = elf_cris_reloc_type (type); + break; + + case EM_860: + rtype = elf_i860_reloc_type (type); + break; + + case EM_X86_64: + case EM_L1OM: + case EM_K1OM: + rtype = elf_x86_64_reloc_type (type); + break; + + case EM_S370: + rtype = i370_reloc_type (type); + break; + + case EM_S390_OLD: + case EM_S390: + rtype = elf_s390_reloc_type (type); + break; + + case EM_SCORE: + rtype = elf_score_reloc_type (type); + break; + + case EM_XSTORMY16: + rtype = elf_xstormy16_reloc_type (type); + break; + + case EM_CRX: + rtype = elf_crx_reloc_type (type); + break; + + case EM_VAX: + rtype = elf_vax_reloc_type (type); + break; + + case EM_VISIUM: + rtype = elf_visium_reloc_type (type); + break; + + case EM_ADAPTEVA_EPIPHANY: + rtype = elf_epiphany_reloc_type (type); + break; + + case EM_IP2K: + case EM_IP2K_OLD: + rtype = elf_ip2k_reloc_type (type); + break; + + case EM_IQ2000: + rtype = elf_iq2000_reloc_type (type); + break; + + case EM_XTENSA_OLD: + case EM_XTENSA: + rtype = elf_xtensa_reloc_type (type); + break; + + case EM_LATTICEMICO32: + rtype = elf_lm32_reloc_type (type); + break; + + case EM_M32C_OLD: + case EM_M32C: + rtype = elf_m32c_reloc_type (type); + break; + + case EM_MT: + rtype = elf_mt_reloc_type (type); + break; + + case EM_BLACKFIN: + rtype = elf_bfin_reloc_type (type); + break; + + case EM_CYGNUS_MEP: + rtype = elf_mep_reloc_type (type); + break; + + case EM_CR16: + rtype = elf_cr16_reloc_type (type); + break; + + case EM_MICROBLAZE: + case EM_MICROBLAZE_OLD: + rtype = elf_microblaze_reloc_type (type); + break; + + case EM_RL78: + rtype = elf_rl78_reloc_type (type); + break; + + case EM_RX: + rtype = elf_rx_reloc_type (type); + break; + + case EM_METAG: + rtype = elf_metag_reloc_type (type); + break; + + case EM_XC16X: + case EM_C166: + rtype = elf_xc16x_reloc_type (type); + break; + + case EM_TI_C6000: + rtype = elf_tic6x_reloc_type (type); + break; + + case EM_TILEGX: + rtype = elf_tilegx_reloc_type (type); + break; + + case EM_TILEPRO: + rtype = elf_tilepro_reloc_type (type); + break; + + case EM_WEBASSEMBLY: + rtype = elf_wasm32_reloc_type (type); + break; + + case EM_XGATE: + rtype = elf_xgate_reloc_type (type); + break; + + case EM_ALTERA_NIOS2: + rtype = elf_nios2_reloc_type (type); + break; + + case EM_TI_PRU: + rtype = elf_pru_reloc_type (type); + break; + } + + if (rtype == NULL) + printf (_("unrecognized: %-7lx"), (unsigned long) type & 0xffffffff); + else + printf (do_wide ? "%-22s" : "%-17.17s", rtype); + + if (filedata->file_header.e_machine == EM_ALPHA + && rtype != NULL + && streq (rtype, "R_ALPHA_LITUSE") + && is_rela) + { + switch (rels[i].r_addend) + { + case LITUSE_ALPHA_ADDR: rtype = "ADDR"; break; + case LITUSE_ALPHA_BASE: rtype = "BASE"; break; + case LITUSE_ALPHA_BYTOFF: rtype = "BYTOFF"; break; + case LITUSE_ALPHA_JSR: rtype = "JSR"; break; + case LITUSE_ALPHA_TLSGD: rtype = "TLSGD"; break; + case LITUSE_ALPHA_TLSLDM: rtype = "TLSLDM"; break; + case LITUSE_ALPHA_JSRDIRECT: rtype = "JSRDIRECT"; break; + default: rtype = NULL; + } + + if (rtype) + printf (" (%s)", rtype); + else + { + putchar (' '); + printf (_(""), + (unsigned long) rels[i].r_addend); + res = FALSE; + } + } + else if (symtab_index) + { + if (symtab == NULL || symtab_index >= nsyms) + { + error (_(" bad symbol index: %08lx in reloc"), (unsigned long) symtab_index); + res = FALSE; + } + else + { + Elf_Internal_Sym * psym; + const char * version_string; + enum versioned_symbol_info sym_info; + unsigned short vna_other; + + psym = symtab + symtab_index; + + version_string + = get_symbol_version_string (filedata, is_dynsym, + strtab, strtablen, + symtab_index, + psym, + &sym_info, + &vna_other); + + printf (" "); + + if (ELF_ST_TYPE (psym->st_info) == STT_GNU_IFUNC) + { + const char * name; + unsigned int len; + unsigned int width = is_32bit_elf ? 8 : 14; + + /* Relocations against GNU_IFUNC symbols do not use the value + of the symbol as the address to relocate against. Instead + they invoke the function named by the symbol and use its + result as the address for relocation. + + To indicate this to the user, do not display the value of + the symbol in the "Symbols's Value" field. Instead show + its name followed by () as a hint that the symbol is + invoked. */ + + if (strtab == NULL + || psym->st_name == 0 + || psym->st_name >= strtablen) + name = "??"; + else + name = strtab + psym->st_name; + + len = print_symbol (width, name); + if (version_string) + printf (sym_info == symbol_public ? "@@%s" : "@%s", + version_string); + printf ("()%-*s", len <= width ? (width + 1) - len : 1, " "); + } + else + { + print_vma (psym->st_value, LONG_HEX); + + printf (is_32bit_elf ? " " : " "); + } + + if (psym->st_name == 0) + { + const char * sec_name = ""; + char name_buf[40]; + + if (ELF_ST_TYPE (psym->st_info) == STT_SECTION) + { + if (psym->st_shndx < filedata->file_header.e_shnum) + sec_name = SECTION_NAME (filedata->section_headers + psym->st_shndx); + else if (psym->st_shndx == SHN_ABS) + sec_name = "ABS"; + else if (psym->st_shndx == SHN_COMMON) + sec_name = "COMMON"; + else if ((filedata->file_header.e_machine == EM_MIPS + && psym->st_shndx == SHN_MIPS_SCOMMON) + || (filedata->file_header.e_machine == EM_TI_C6000 + && psym->st_shndx == SHN_TIC6X_SCOMMON)) + sec_name = "SCOMMON"; + else if (filedata->file_header.e_machine == EM_MIPS + && psym->st_shndx == SHN_MIPS_SUNDEFINED) + sec_name = "SUNDEF"; + else if ((filedata->file_header.e_machine == EM_X86_64 + || filedata->file_header.e_machine == EM_L1OM + || filedata->file_header.e_machine == EM_K1OM) + && psym->st_shndx == SHN_X86_64_LCOMMON) + sec_name = "LARGE_COMMON"; + else if (filedata->file_header.e_machine == EM_IA_64 + && filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_HPUX + && psym->st_shndx == SHN_IA_64_ANSI_COMMON) + sec_name = "ANSI_COM"; + else if (is_ia64_vms (filedata) + && psym->st_shndx == SHN_IA_64_VMS_SYMVEC) + sec_name = "VMS_SYMVEC"; + else + { + sprintf (name_buf, "
", + (unsigned int) psym->st_shndx); + sec_name = name_buf; + } + } + print_symbol (22, sec_name); + } + else if (strtab == NULL) + printf (_(""), psym->st_name); + else if (psym->st_name >= strtablen) + { + error (_(""), psym->st_name); + res = FALSE; + } + else + { + print_symbol (22, strtab + psym->st_name); + if (version_string) + printf (sym_info == symbol_public ? "@@%s" : "@%s", + version_string); + } + + if (is_rela) + { + bfd_vma off = rels[i].r_addend; + + if ((bfd_signed_vma) off < 0) + printf (" - %" BFD_VMA_FMT "x", - off); + else + printf (" + %" BFD_VMA_FMT "x", off); + } + } + } + else if (is_rela) + { + bfd_vma off = rels[i].r_addend; + + printf ("%*c", is_32bit_elf ? 12 : 20, ' '); + if ((bfd_signed_vma) off < 0) + printf ("-%" BFD_VMA_FMT "x", - off); + else + printf ("%" BFD_VMA_FMT "x", off); + } + + if (filedata->file_header.e_machine == EM_SPARCV9 + && rtype != NULL + && streq (rtype, "R_SPARC_OLO10")) + printf (" + %lx", (unsigned long) ELF64_R_TYPE_DATA (inf)); + + putchar ('\n'); + +#ifdef BFD64 + if (! is_32bit_elf && filedata->file_header.e_machine == EM_MIPS) + { + bfd_vma type2 = ELF64_MIPS_R_TYPE2 (inf); + bfd_vma type3 = ELF64_MIPS_R_TYPE3 (inf); + const char * rtype2 = elf_mips_reloc_type (type2); + const char * rtype3 = elf_mips_reloc_type (type3); + + printf (" Type2: "); + + if (rtype2 == NULL) + printf (_("unrecognized: %-7lx"), + (unsigned long) type2 & 0xffffffff); + else + printf ("%-17.17s", rtype2); + + printf ("\n Type3: "); + + if (rtype3 == NULL) + printf (_("unrecognized: %-7lx"), + (unsigned long) type3 & 0xffffffff); + else + printf ("%-17.17s", rtype3); + + putchar ('\n'); + } +#endif /* BFD64 */ + } + + free (rels); + + return res; +} + +static const char * +get_mips_dynamic_type (unsigned long type) +{ + switch (type) + { + case DT_MIPS_RLD_VERSION: return "MIPS_RLD_VERSION"; + case DT_MIPS_TIME_STAMP: return "MIPS_TIME_STAMP"; + case DT_MIPS_ICHECKSUM: return "MIPS_ICHECKSUM"; + case DT_MIPS_IVERSION: return "MIPS_IVERSION"; + case DT_MIPS_FLAGS: return "MIPS_FLAGS"; + case DT_MIPS_BASE_ADDRESS: return "MIPS_BASE_ADDRESS"; + case DT_MIPS_MSYM: return "MIPS_MSYM"; + case DT_MIPS_CONFLICT: return "MIPS_CONFLICT"; + case DT_MIPS_LIBLIST: return "MIPS_LIBLIST"; + case DT_MIPS_LOCAL_GOTNO: return "MIPS_LOCAL_GOTNO"; + case DT_MIPS_CONFLICTNO: return "MIPS_CONFLICTNO"; + case DT_MIPS_LIBLISTNO: return "MIPS_LIBLISTNO"; + case DT_MIPS_SYMTABNO: return "MIPS_SYMTABNO"; + case DT_MIPS_UNREFEXTNO: return "MIPS_UNREFEXTNO"; + case DT_MIPS_GOTSYM: return "MIPS_GOTSYM"; + case DT_MIPS_HIPAGENO: return "MIPS_HIPAGENO"; + case DT_MIPS_RLD_MAP: return "MIPS_RLD_MAP"; + case DT_MIPS_RLD_MAP_REL: return "MIPS_RLD_MAP_REL"; + case DT_MIPS_DELTA_CLASS: return "MIPS_DELTA_CLASS"; + case DT_MIPS_DELTA_CLASS_NO: return "MIPS_DELTA_CLASS_NO"; + case DT_MIPS_DELTA_INSTANCE: return "MIPS_DELTA_INSTANCE"; + case DT_MIPS_DELTA_INSTANCE_NO: return "MIPS_DELTA_INSTANCE_NO"; + case DT_MIPS_DELTA_RELOC: return "MIPS_DELTA_RELOC"; + case DT_MIPS_DELTA_RELOC_NO: return "MIPS_DELTA_RELOC_NO"; + case DT_MIPS_DELTA_SYM: return "MIPS_DELTA_SYM"; + case DT_MIPS_DELTA_SYM_NO: return "MIPS_DELTA_SYM_NO"; + case DT_MIPS_DELTA_CLASSSYM: return "MIPS_DELTA_CLASSSYM"; + case DT_MIPS_DELTA_CLASSSYM_NO: return "MIPS_DELTA_CLASSSYM_NO"; + case DT_MIPS_CXX_FLAGS: return "MIPS_CXX_FLAGS"; + case DT_MIPS_PIXIE_INIT: return "MIPS_PIXIE_INIT"; + case DT_MIPS_SYMBOL_LIB: return "MIPS_SYMBOL_LIB"; + case DT_MIPS_LOCALPAGE_GOTIDX: return "MIPS_LOCALPAGE_GOTIDX"; + case DT_MIPS_LOCAL_GOTIDX: return "MIPS_LOCAL_GOTIDX"; + case DT_MIPS_HIDDEN_GOTIDX: return "MIPS_HIDDEN_GOTIDX"; + case DT_MIPS_PROTECTED_GOTIDX: return "MIPS_PROTECTED_GOTIDX"; + case DT_MIPS_OPTIONS: return "MIPS_OPTIONS"; + case DT_MIPS_INTERFACE: return "MIPS_INTERFACE"; + case DT_MIPS_DYNSTR_ALIGN: return "MIPS_DYNSTR_ALIGN"; + case DT_MIPS_INTERFACE_SIZE: return "MIPS_INTERFACE_SIZE"; + case DT_MIPS_RLD_TEXT_RESOLVE_ADDR: return "MIPS_RLD_TEXT_RESOLVE_ADDR"; + case DT_MIPS_PERF_SUFFIX: return "MIPS_PERF_SUFFIX"; + case DT_MIPS_COMPACT_SIZE: return "MIPS_COMPACT_SIZE"; + case DT_MIPS_GP_VALUE: return "MIPS_GP_VALUE"; + case DT_MIPS_AUX_DYNAMIC: return "MIPS_AUX_DYNAMIC"; + case DT_MIPS_PLTGOT: return "MIPS_PLTGOT"; + case DT_MIPS_RWPLT: return "MIPS_RWPLT"; + default: + return NULL; + } +} + +static const char * +get_sparc64_dynamic_type (unsigned long type) +{ + switch (type) + { + case DT_SPARC_REGISTER: return "SPARC_REGISTER"; + default: + return NULL; + } +} + +static const char * +get_ppc_dynamic_type (unsigned long type) +{ + switch (type) + { + case DT_PPC_GOT: return "PPC_GOT"; + case DT_PPC_OPT: return "PPC_OPT"; + default: + return NULL; + } +} + +static const char * +get_ppc64_dynamic_type (unsigned long type) +{ + switch (type) + { + case DT_PPC64_GLINK: return "PPC64_GLINK"; + case DT_PPC64_OPD: return "PPC64_OPD"; + case DT_PPC64_OPDSZ: return "PPC64_OPDSZ"; + case DT_PPC64_OPT: return "PPC64_OPT"; + default: + return NULL; + } +} + +static const char * +get_parisc_dynamic_type (unsigned long type) +{ + switch (type) + { + case DT_HP_LOAD_MAP: return "HP_LOAD_MAP"; + case DT_HP_DLD_FLAGS: return "HP_DLD_FLAGS"; + case DT_HP_DLD_HOOK: return "HP_DLD_HOOK"; + case DT_HP_UX10_INIT: return "HP_UX10_INIT"; + case DT_HP_UX10_INITSZ: return "HP_UX10_INITSZ"; + case DT_HP_PREINIT: return "HP_PREINIT"; + case DT_HP_PREINITSZ: return "HP_PREINITSZ"; + case DT_HP_NEEDED: return "HP_NEEDED"; + case DT_HP_TIME_STAMP: return "HP_TIME_STAMP"; + case DT_HP_CHECKSUM: return "HP_CHECKSUM"; + case DT_HP_GST_SIZE: return "HP_GST_SIZE"; + case DT_HP_GST_VERSION: return "HP_GST_VERSION"; + case DT_HP_GST_HASHVAL: return "HP_GST_HASHVAL"; + case DT_HP_EPLTREL: return "HP_GST_EPLTREL"; + case DT_HP_EPLTRELSZ: return "HP_GST_EPLTRELSZ"; + case DT_HP_FILTERED: return "HP_FILTERED"; + case DT_HP_FILTER_TLS: return "HP_FILTER_TLS"; + case DT_HP_COMPAT_FILTERED: return "HP_COMPAT_FILTERED"; + case DT_HP_LAZYLOAD: return "HP_LAZYLOAD"; + case DT_HP_BIND_NOW_COUNT: return "HP_BIND_NOW_COUNT"; + case DT_PLT: return "PLT"; + case DT_PLT_SIZE: return "PLT_SIZE"; + case DT_DLT: return "DLT"; + case DT_DLT_SIZE: return "DLT_SIZE"; + default: + return NULL; + } +} + +static const char * +get_ia64_dynamic_type (unsigned long type) +{ + switch (type) + { + case DT_IA_64_PLT_RESERVE: return "IA_64_PLT_RESERVE"; + case DT_IA_64_VMS_SUBTYPE: return "VMS_SUBTYPE"; + case DT_IA_64_VMS_IMGIOCNT: return "VMS_IMGIOCNT"; + case DT_IA_64_VMS_LNKFLAGS: return "VMS_LNKFLAGS"; + case DT_IA_64_VMS_VIR_MEM_BLK_SIZ: return "VMS_VIR_MEM_BLK_SIZ"; + case DT_IA_64_VMS_IDENT: return "VMS_IDENT"; + case DT_IA_64_VMS_NEEDED_IDENT: return "VMS_NEEDED_IDENT"; + case DT_IA_64_VMS_IMG_RELA_CNT: return "VMS_IMG_RELA_CNT"; + case DT_IA_64_VMS_SEG_RELA_CNT: return "VMS_SEG_RELA_CNT"; + case DT_IA_64_VMS_FIXUP_RELA_CNT: return "VMS_FIXUP_RELA_CNT"; + case DT_IA_64_VMS_FIXUP_NEEDED: return "VMS_FIXUP_NEEDED"; + case DT_IA_64_VMS_SYMVEC_CNT: return "VMS_SYMVEC_CNT"; + case DT_IA_64_VMS_XLATED: return "VMS_XLATED"; + case DT_IA_64_VMS_STACKSIZE: return "VMS_STACKSIZE"; + case DT_IA_64_VMS_UNWINDSZ: return "VMS_UNWINDSZ"; + case DT_IA_64_VMS_UNWIND_CODSEG: return "VMS_UNWIND_CODSEG"; + case DT_IA_64_VMS_UNWIND_INFOSEG: return "VMS_UNWIND_INFOSEG"; + case DT_IA_64_VMS_LINKTIME: return "VMS_LINKTIME"; + case DT_IA_64_VMS_SEG_NO: return "VMS_SEG_NO"; + case DT_IA_64_VMS_SYMVEC_OFFSET: return "VMS_SYMVEC_OFFSET"; + case DT_IA_64_VMS_SYMVEC_SEG: return "VMS_SYMVEC_SEG"; + case DT_IA_64_VMS_UNWIND_OFFSET: return "VMS_UNWIND_OFFSET"; + case DT_IA_64_VMS_UNWIND_SEG: return "VMS_UNWIND_SEG"; + case DT_IA_64_VMS_STRTAB_OFFSET: return "VMS_STRTAB_OFFSET"; + case DT_IA_64_VMS_SYSVER_OFFSET: return "VMS_SYSVER_OFFSET"; + case DT_IA_64_VMS_IMG_RELA_OFF: return "VMS_IMG_RELA_OFF"; + case DT_IA_64_VMS_SEG_RELA_OFF: return "VMS_SEG_RELA_OFF"; + case DT_IA_64_VMS_FIXUP_RELA_OFF: return "VMS_FIXUP_RELA_OFF"; + case DT_IA_64_VMS_PLTGOT_OFFSET: return "VMS_PLTGOT_OFFSET"; + case DT_IA_64_VMS_PLTGOT_SEG: return "VMS_PLTGOT_SEG"; + case DT_IA_64_VMS_FPMODE: return "VMS_FPMODE"; + default: + return NULL; + } +} + +static const char * +get_solaris_section_type (unsigned long type) +{ + switch (type) + { + case 0x6fffffee: return "SUNW_ancillary"; + case 0x6fffffef: return "SUNW_capchain"; + case 0x6ffffff0: return "SUNW_capinfo"; + case 0x6ffffff1: return "SUNW_symsort"; + case 0x6ffffff2: return "SUNW_tlssort"; + case 0x6ffffff3: return "SUNW_LDYNSYM"; + case 0x6ffffff4: return "SUNW_dof"; + case 0x6ffffff5: return "SUNW_cap"; + case 0x6ffffff6: return "SUNW_SIGNATURE"; + case 0x6ffffff7: return "SUNW_ANNOTATE"; + case 0x6ffffff8: return "SUNW_DEBUGSTR"; + case 0x6ffffff9: return "SUNW_DEBUG"; + case 0x6ffffffa: return "SUNW_move"; + case 0x6ffffffb: return "SUNW_COMDAT"; + case 0x6ffffffc: return "SUNW_syminfo"; + case 0x6ffffffd: return "SUNW_verdef"; + case 0x6ffffffe: return "SUNW_verneed"; + case 0x6fffffff: return "SUNW_versym"; + case 0x70000000: return "SPARC_GOTDATA"; + default: return NULL; + } +} + +static const char * +get_alpha_dynamic_type (unsigned long type) +{ + switch (type) + { + case DT_ALPHA_PLTRO: return "ALPHA_PLTRO"; + default: return NULL; + } +} + +static const char * +get_score_dynamic_type (unsigned long type) +{ + switch (type) + { + case DT_SCORE_BASE_ADDRESS: return "SCORE_BASE_ADDRESS"; + case DT_SCORE_LOCAL_GOTNO: return "SCORE_LOCAL_GOTNO"; + case DT_SCORE_SYMTABNO: return "SCORE_SYMTABNO"; + case DT_SCORE_GOTSYM: return "SCORE_GOTSYM"; + case DT_SCORE_UNREFEXTNO: return "SCORE_UNREFEXTNO"; + case DT_SCORE_HIPAGENO: return "SCORE_HIPAGENO"; + default: return NULL; + } +} + +static const char * +get_tic6x_dynamic_type (unsigned long type) +{ + switch (type) + { + case DT_C6000_GSYM_OFFSET: return "C6000_GSYM_OFFSET"; + case DT_C6000_GSTR_OFFSET: return "C6000_GSTR_OFFSET"; + case DT_C6000_DSBT_BASE: return "C6000_DSBT_BASE"; + case DT_C6000_DSBT_SIZE: return "C6000_DSBT_SIZE"; + case DT_C6000_PREEMPTMAP: return "C6000_PREEMPTMAP"; + case DT_C6000_DSBT_INDEX: return "C6000_DSBT_INDEX"; + default: return NULL; + } +} + +static const char * +get_nios2_dynamic_type (unsigned long type) +{ + switch (type) + { + case DT_NIOS2_GP: return "NIOS2_GP"; + default: return NULL; + } +} + +static const char * +get_solaris_dynamic_type (unsigned long type) +{ + switch (type) + { + case 0x6000000d: return "SUNW_AUXILIARY"; + case 0x6000000e: return "SUNW_RTLDINF"; + case 0x6000000f: return "SUNW_FILTER"; + case 0x60000010: return "SUNW_CAP"; + case 0x60000011: return "SUNW_SYMTAB"; + case 0x60000012: return "SUNW_SYMSZ"; + case 0x60000013: return "SUNW_SORTENT"; + case 0x60000014: return "SUNW_SYMSORT"; + case 0x60000015: return "SUNW_SYMSORTSZ"; + case 0x60000016: return "SUNW_TLSSORT"; + case 0x60000017: return "SUNW_TLSSORTSZ"; + case 0x60000018: return "SUNW_CAPINFO"; + case 0x60000019: return "SUNW_STRPAD"; + case 0x6000001a: return "SUNW_CAPCHAIN"; + case 0x6000001b: return "SUNW_LDMACH"; + case 0x6000001d: return "SUNW_CAPCHAINENT"; + case 0x6000001f: return "SUNW_CAPCHAINSZ"; + case 0x60000021: return "SUNW_PARENT"; + case 0x60000023: return "SUNW_ASLR"; + case 0x60000025: return "SUNW_RELAX"; + case 0x60000029: return "SUNW_NXHEAP"; + case 0x6000002b: return "SUNW_NXSTACK"; + + case 0x70000001: return "SPARC_REGISTER"; + case 0x7ffffffd: return "AUXILIARY"; + case 0x7ffffffe: return "USED"; + case 0x7fffffff: return "FILTER"; + + default: return NULL; + } +} + +static const char * +get_dynamic_type (Filedata * filedata, unsigned long type) +{ + static char buff[64]; + + switch (type) + { + case DT_NULL: return "NULL"; + case DT_NEEDED: return "NEEDED"; + case DT_PLTRELSZ: return "PLTRELSZ"; + case DT_PLTGOT: return "PLTGOT"; + case DT_HASH: return "HASH"; + case DT_STRTAB: return "STRTAB"; + case DT_SYMTAB: return "SYMTAB"; + case DT_RELA: return "RELA"; + case DT_RELASZ: return "RELASZ"; + case DT_RELAENT: return "RELAENT"; + case DT_STRSZ: return "STRSZ"; + case DT_SYMENT: return "SYMENT"; + case DT_INIT: return "INIT"; + case DT_FINI: return "FINI"; + case DT_SONAME: return "SONAME"; + case DT_RPATH: return "RPATH"; + case DT_SYMBOLIC: return "SYMBOLIC"; + case DT_REL: return "REL"; + case DT_RELSZ: return "RELSZ"; + case DT_RELENT: return "RELENT"; + case DT_PLTREL: return "PLTREL"; + case DT_DEBUG: return "DEBUG"; + case DT_TEXTREL: return "TEXTREL"; + case DT_JMPREL: return "JMPREL"; + case DT_BIND_NOW: return "BIND_NOW"; + case DT_INIT_ARRAY: return "INIT_ARRAY"; + case DT_FINI_ARRAY: return "FINI_ARRAY"; + case DT_INIT_ARRAYSZ: return "INIT_ARRAYSZ"; + case DT_FINI_ARRAYSZ: return "FINI_ARRAYSZ"; + case DT_RUNPATH: return "RUNPATH"; + case DT_FLAGS: return "FLAGS"; + + case DT_PREINIT_ARRAY: return "PREINIT_ARRAY"; + case DT_PREINIT_ARRAYSZ: return "PREINIT_ARRAYSZ"; + case DT_SYMTAB_SHNDX: return "SYMTAB_SHNDX"; + + case DT_CHECKSUM: return "CHECKSUM"; + case DT_PLTPADSZ: return "PLTPADSZ"; + case DT_MOVEENT: return "MOVEENT"; + case DT_MOVESZ: return "MOVESZ"; + case DT_FEATURE: return "FEATURE"; + case DT_POSFLAG_1: return "POSFLAG_1"; + case DT_SYMINSZ: return "SYMINSZ"; + case DT_SYMINENT: return "SYMINENT"; /* aka VALRNGHI */ + + case DT_ADDRRNGLO: return "ADDRRNGLO"; + case DT_CONFIG: return "CONFIG"; + case DT_DEPAUDIT: return "DEPAUDIT"; + case DT_AUDIT: return "AUDIT"; + case DT_PLTPAD: return "PLTPAD"; + case DT_MOVETAB: return "MOVETAB"; + case DT_SYMINFO: return "SYMINFO"; /* aka ADDRRNGHI */ + + case DT_VERSYM: return "VERSYM"; + + case DT_TLSDESC_GOT: return "TLSDESC_GOT"; + case DT_TLSDESC_PLT: return "TLSDESC_PLT"; + case DT_RELACOUNT: return "RELACOUNT"; + case DT_RELCOUNT: return "RELCOUNT"; + case DT_FLAGS_1: return "FLAGS_1"; + case DT_VERDEF: return "VERDEF"; + case DT_VERDEFNUM: return "VERDEFNUM"; + case DT_VERNEED: return "VERNEED"; + case DT_VERNEEDNUM: return "VERNEEDNUM"; + + case DT_AUXILIARY: return "AUXILIARY"; + case DT_USED: return "USED"; + case DT_FILTER: return "FILTER"; + + case DT_GNU_PRELINKED: return "GNU_PRELINKED"; + case DT_GNU_CONFLICT: return "GNU_CONFLICT"; + case DT_GNU_CONFLICTSZ: return "GNU_CONFLICTSZ"; + case DT_GNU_LIBLIST: return "GNU_LIBLIST"; + case DT_GNU_LIBLISTSZ: return "GNU_LIBLISTSZ"; + case DT_GNU_HASH: return "GNU_HASH"; + + default: + if ((type >= DT_LOPROC) && (type <= DT_HIPROC)) + { + const char * result; + + switch (filedata->file_header.e_machine) + { + case EM_MIPS: + case EM_MIPS_RS3_LE: + result = get_mips_dynamic_type (type); + break; + case EM_SPARCV9: + result = get_sparc64_dynamic_type (type); + break; + case EM_PPC: + result = get_ppc_dynamic_type (type); + break; + case EM_PPC64: + result = get_ppc64_dynamic_type (type); + break; + case EM_IA_64: + result = get_ia64_dynamic_type (type); + break; + case EM_ALPHA: + result = get_alpha_dynamic_type (type); + break; + case EM_SCORE: + result = get_score_dynamic_type (type); + break; + case EM_TI_C6000: + result = get_tic6x_dynamic_type (type); + break; + case EM_ALTERA_NIOS2: + result = get_nios2_dynamic_type (type); + break; + default: + if (filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_SOLARIS) + result = get_solaris_dynamic_type (type); + else + result = NULL; + break; + } + + if (result != NULL) + return result; + + snprintf (buff, sizeof (buff), _("Processor Specific: %lx"), type); + } + else if (((type >= DT_LOOS) && (type <= DT_HIOS)) + || (filedata->file_header.e_machine == EM_PARISC + && (type >= OLD_DT_LOOS) && (type <= OLD_DT_HIOS))) + { + const char * result; + + switch (filedata->file_header.e_machine) + { + case EM_PARISC: + result = get_parisc_dynamic_type (type); + break; + case EM_IA_64: + result = get_ia64_dynamic_type (type); + break; + default: + if (filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_SOLARIS) + result = get_solaris_dynamic_type (type); + else + result = NULL; + break; + } + + if (result != NULL) + return result; + + snprintf (buff, sizeof (buff), _("Operating System specific: %lx"), + type); + } + else + snprintf (buff, sizeof (buff), _(": %lx"), type); + + return buff; + } +} + +static char * +get_file_type (unsigned e_type) +{ + static char buff[32]; + + switch (e_type) + { + case ET_NONE: return _("NONE (None)"); + case ET_REL: return _("REL (Relocatable file)"); + case ET_EXEC: return _("EXEC (Executable file)"); + case ET_DYN: return _("DYN (Shared object file)"); + case ET_CORE: return _("CORE (Core file)"); + + default: + if ((e_type >= ET_LOPROC) && (e_type <= ET_HIPROC)) + snprintf (buff, sizeof (buff), _("Processor Specific: (%x)"), e_type); + else if ((e_type >= ET_LOOS) && (e_type <= ET_HIOS)) + snprintf (buff, sizeof (buff), _("OS Specific: (%x)"), e_type); + else + snprintf (buff, sizeof (buff), _(": %x"), e_type); + return buff; + } +} + +static char * +get_machine_name (unsigned e_machine) +{ + static char buff[64]; /* XXX */ + + switch (e_machine) + { + /* Please keep this switch table sorted by increasing EM_ value. */ + /* 0 */ + case EM_NONE: return _("None"); + case EM_M32: return "WE32100"; + case EM_SPARC: return "Sparc"; + case EM_386: return "Intel 80386"; + case EM_68K: return "MC68000"; + case EM_88K: return "MC88000"; + case EM_IAMCU: return "Intel MCU"; + case EM_860: return "Intel 80860"; + case EM_MIPS: return "MIPS R3000"; + case EM_S370: return "IBM System/370"; + /* 10 */ + case EM_MIPS_RS3_LE: return "MIPS R4000 big-endian"; + case EM_OLD_SPARCV9: return "Sparc v9 (old)"; + case EM_PARISC: return "HPPA"; + case EM_VPP550: return "Fujitsu VPP500"; + case EM_SPARC32PLUS: return "Sparc v8+" ; + case EM_960: return "Intel 90860"; + case EM_PPC: return "PowerPC"; + /* 20 */ + case EM_PPC64: return "PowerPC64"; + case EM_S390_OLD: + case EM_S390: return "IBM S/390"; + case EM_SPU: return "SPU"; + /* 30 */ + case EM_V800: return "Renesas V850 (using RH850 ABI)"; + case EM_FR20: return "Fujitsu FR20"; + case EM_RH32: return "TRW RH32"; + case EM_MCORE: return "MCORE"; + /* 40 */ + case EM_ARM: return "ARM"; + case EM_OLD_ALPHA: return "Digital Alpha (old)"; + case EM_SH: return "Renesas / SuperH SH"; + case EM_SPARCV9: return "Sparc v9"; + case EM_TRICORE: return "Siemens Tricore"; + case EM_ARC: return "ARC"; + case EM_H8_300: return "Renesas H8/300"; + case EM_H8_300H: return "Renesas H8/300H"; + case EM_H8S: return "Renesas H8S"; + case EM_H8_500: return "Renesas H8/500"; + /* 50 */ + case EM_IA_64: return "Intel IA-64"; + case EM_MIPS_X: return "Stanford MIPS-X"; + case EM_COLDFIRE: return "Motorola Coldfire"; + case EM_68HC12: return "Motorola MC68HC12 Microcontroller"; + case EM_MMA: return "Fujitsu Multimedia Accelerator"; + case EM_PCP: return "Siemens PCP"; + case EM_NCPU: return "Sony nCPU embedded RISC processor"; + case EM_NDR1: return "Denso NDR1 microprocesspr"; + case EM_STARCORE: return "Motorola Star*Core processor"; + case EM_ME16: return "Toyota ME16 processor"; + /* 60 */ + case EM_ST100: return "STMicroelectronics ST100 processor"; + case EM_TINYJ: return "Advanced Logic Corp. TinyJ embedded processor"; + case EM_X86_64: return "Advanced Micro Devices X86-64"; + case EM_PDSP: return "Sony DSP processor"; + case EM_PDP10: return "Digital Equipment Corp. PDP-10"; + case EM_PDP11: return "Digital Equipment Corp. PDP-11"; + case EM_FX66: return "Siemens FX66 microcontroller"; + case EM_ST9PLUS: return "STMicroelectronics ST9+ 8/16 bit microcontroller"; + case EM_ST7: return "STMicroelectronics ST7 8-bit microcontroller"; + case EM_68HC16: return "Motorola MC68HC16 Microcontroller"; + /* 70 */ + case EM_68HC11: return "Motorola MC68HC11 Microcontroller"; + case EM_68HC08: return "Motorola MC68HC08 Microcontroller"; + case EM_68HC05: return "Motorola MC68HC05 Microcontroller"; + case EM_SVX: return "Silicon Graphics SVx"; + case EM_ST19: return "STMicroelectronics ST19 8-bit microcontroller"; + case EM_VAX: return "Digital VAX"; + case EM_CRIS: return "Axis Communications 32-bit embedded processor"; + case EM_JAVELIN: return "Infineon Technologies 32-bit embedded cpu"; + case EM_FIREPATH: return "Element 14 64-bit DSP processor"; + case EM_ZSP: return "LSI Logic's 16-bit DSP processor"; + /* 80 */ + case EM_MMIX: return "Donald Knuth's educational 64-bit processor"; + case EM_HUANY: return "Harvard Universitys's machine-independent object format"; + case EM_PRISM: return "Vitesse Prism"; + case EM_AVR_OLD: + case EM_AVR: return "Atmel AVR 8-bit microcontroller"; + case EM_CYGNUS_FR30: + case EM_FR30: return "Fujitsu FR30"; + case EM_CYGNUS_D10V: + case EM_D10V: return "d10v"; + case EM_CYGNUS_D30V: + case EM_D30V: return "d30v"; + case EM_CYGNUS_V850: + case EM_V850: return "Renesas V850"; + case EM_CYGNUS_M32R: + case EM_M32R: return "Renesas M32R (formerly Mitsubishi M32r)"; + case EM_CYGNUS_MN10300: + case EM_MN10300: return "mn10300"; + /* 90 */ + case EM_CYGNUS_MN10200: + case EM_MN10200: return "mn10200"; + case EM_PJ: return "picoJava"; + case EM_OR1K: return "OpenRISC 1000"; + case EM_ARC_COMPACT: return "ARCompact"; + case EM_XTENSA_OLD: + case EM_XTENSA: return "Tensilica Xtensa Processor"; + case EM_VIDEOCORE: return "Alphamosaic VideoCore processor"; + case EM_TMM_GPP: return "Thompson Multimedia General Purpose Processor"; + case EM_NS32K: return "National Semiconductor 32000 series"; + case EM_TPC: return "Tenor Network TPC processor"; + case EM_SNP1K: return "Trebia SNP 1000 processor"; + /* 100 */ + case EM_ST200: return "STMicroelectronics ST200 microcontroller"; + case EM_IP2K_OLD: + case EM_IP2K: return "Ubicom IP2xxx 8-bit microcontrollers"; + case EM_MAX: return "MAX Processor"; + case EM_CR: return "National Semiconductor CompactRISC"; + case EM_F2MC16: return "Fujitsu F2MC16"; + case EM_MSP430: return "Texas Instruments msp430 microcontroller"; + case EM_BLACKFIN: return "Analog Devices Blackfin"; + case EM_SE_C33: return "S1C33 Family of Seiko Epson processors"; + case EM_SEP: return "Sharp embedded microprocessor"; + case EM_ARCA: return "Arca RISC microprocessor"; + /* 110 */ + case EM_UNICORE: return "Unicore"; + case EM_EXCESS: return "eXcess 16/32/64-bit configurable embedded CPU"; + case EM_DXP: return "Icera Semiconductor Inc. Deep Execution Processor"; + case EM_ALTERA_NIOS2: return "Altera Nios II"; + case EM_CRX: return "National Semiconductor CRX microprocessor"; + case EM_XGATE: return "Motorola XGATE embedded processor"; + case EM_C166: + case EM_XC16X: return "Infineon Technologies xc16x"; + case EM_M16C: return "Renesas M16C series microprocessors"; + case EM_DSPIC30F: return "Microchip Technology dsPIC30F Digital Signal Controller"; + case EM_CE: return "Freescale Communication Engine RISC core"; + /* 120 */ + case EM_M32C: return "Renesas M32c"; + /* 130 */ + case EM_TSK3000: return "Altium TSK3000 core"; + case EM_RS08: return "Freescale RS08 embedded processor"; + case EM_ECOG2: return "Cyan Technology eCOG2 microprocessor"; + case EM_SCORE: return "SUNPLUS S+Core"; + case EM_DSP24: return "New Japan Radio (NJR) 24-bit DSP Processor"; + case EM_VIDEOCORE3: return "Broadcom VideoCore III processor"; + case EM_LATTICEMICO32: return "Lattice Mico32"; + case EM_SE_C17: return "Seiko Epson C17 family"; + /* 140 */ + case EM_TI_C6000: return "Texas Instruments TMS320C6000 DSP family"; + case EM_TI_C2000: return "Texas Instruments TMS320C2000 DSP family"; + case EM_TI_C5500: return "Texas Instruments TMS320C55x DSP family"; + case EM_TI_PRU: return "TI PRU I/O processor"; + /* 160 */ + case EM_MMDSP_PLUS: return "STMicroelectronics 64bit VLIW Data Signal Processor"; + case EM_CYPRESS_M8C: return "Cypress M8C microprocessor"; + case EM_R32C: return "Renesas R32C series microprocessors"; + case EM_TRIMEDIA: return "NXP Semiconductors TriMedia architecture family"; + case EM_QDSP6: return "QUALCOMM DSP6 Processor"; + case EM_8051: return "Intel 8051 and variants"; + case EM_STXP7X: return "STMicroelectronics STxP7x family"; + case EM_NDS32: return "Andes Technology compact code size embedded RISC processor family"; + case EM_ECOG1X: return "Cyan Technology eCOG1X family"; + case EM_MAXQ30: return "Dallas Semiconductor MAXQ30 Core microcontrollers"; + /* 170 */ + case EM_XIMO16: return "New Japan Radio (NJR) 16-bit DSP Processor"; + case EM_MANIK: return "M2000 Reconfigurable RISC Microprocessor"; + case EM_CRAYNV2: return "Cray Inc. NV2 vector architecture"; + case EM_RX: return "Renesas RX"; + case EM_METAG: return "Imagination Technologies Meta processor architecture"; + case EM_MCST_ELBRUS: return "MCST Elbrus general purpose hardware architecture"; + case EM_ECOG16: return "Cyan Technology eCOG16 family"; + case EM_CR16: + case EM_MICROBLAZE: + case EM_MICROBLAZE_OLD: return "Xilinx MicroBlaze"; + case EM_ETPU: return "Freescale Extended Time Processing Unit"; + case EM_SLE9X: return "Infineon Technologies SLE9X core"; + /* 180 */ + case EM_L1OM: return "Intel L1OM"; + case EM_K1OM: return "Intel K1OM"; + case EM_INTEL182: return "Intel (reserved)"; + case EM_AARCH64: return "AArch64"; + case EM_ARM184: return "ARM (reserved)"; + case EM_AVR32: return "Atmel Corporation 32-bit microprocessor"; + case EM_STM8: return "STMicroeletronics STM8 8-bit microcontroller"; + case EM_TILE64: return "Tilera TILE64 multicore architecture family"; + case EM_TILEPRO: return "Tilera TILEPro multicore architecture family"; + /* 190 */ + case EM_CUDA: return "NVIDIA CUDA architecture"; + case EM_TILEGX: return "Tilera TILE-Gx multicore architecture family"; + case EM_CLOUDSHIELD: return "CloudShield architecture family"; + case EM_COREA_1ST: return "KIPO-KAIST Core-A 1st generation processor family"; + case EM_COREA_2ND: return "KIPO-KAIST Core-A 2nd generation processor family"; + case EM_ARC_COMPACT2: return "ARCv2"; + case EM_OPEN8: return "Open8 8-bit RISC soft processor core"; + case EM_RL78: return "Renesas RL78"; + case EM_VIDEOCORE5: return "Broadcom VideoCore V processor"; + case EM_78K0R: return "Renesas 78K0R"; + /* 200 */ + case EM_56800EX: return "Freescale 56800EX Digital Signal Controller (DSC)"; + case EM_BA1: return "Beyond BA1 CPU architecture"; + case EM_BA2: return "Beyond BA2 CPU architecture"; + case EM_XCORE: return "XMOS xCORE processor family"; + case EM_MCHP_PIC: return "Microchip 8-bit PIC(r) family"; + /* 210 */ + case EM_KM32: return "KM211 KM32 32-bit processor"; + case EM_KMX32: return "KM211 KMX32 32-bit processor"; + case EM_KMX16: return "KM211 KMX16 16-bit processor"; + case EM_KMX8: return "KM211 KMX8 8-bit processor"; + case EM_KVARC: return "KM211 KVARC processor"; + case EM_CDP: return "Paneve CDP architecture family"; + case EM_COGE: return "Cognitive Smart Memory Processor"; + case EM_COOL: return "Bluechip Systems CoolEngine"; + case EM_NORC: return "Nanoradio Optimized RISC"; + case EM_CSR_KALIMBA: return "CSR Kalimba architecture family"; + /* 220 */ + case EM_Z80: return "Zilog Z80"; + case EM_VISIUM: return "CDS VISIUMcore processor"; + case EM_FT32: return "FTDI Chip FT32"; + case EM_MOXIE: return "Moxie"; + case EM_AMDGPU: return "AMD GPU"; + case EM_RISCV: return "RISC-V"; + case EM_LANAI: return "Lanai 32-bit processor"; + case EM_BPF: return "Linux BPF"; + + /* Large numbers... */ + case EM_MT: return "Morpho Techologies MT processor"; + case EM_ALPHA: return "Alpha"; + case EM_WEBASSEMBLY: return "Web Assembly"; + case EM_DLX: return "OpenDLX"; + case EM_XSTORMY16: return "Sanyo XStormy16 CPU core"; + case EM_IQ2000: return "Vitesse IQ2000"; + case EM_M32C_OLD: + case EM_NIOS32: return "Altera Nios"; + case EM_CYGNUS_MEP: return "Toshiba MeP Media Engine"; + case EM_ADAPTEVA_EPIPHANY: return "Adapteva EPIPHANY"; + case EM_CYGNUS_FRV: return "Fujitsu FR-V"; + + default: + snprintf (buff, sizeof (buff), _(": 0x%x"), e_machine); + return buff; + } +} + +static void +decode_ARC_machine_flags (unsigned e_flags, unsigned e_machine, char buf[]) +{ + /* ARC has two machine types EM_ARC_COMPACT and EM_ARC_COMPACT2. Some + other compilers don't a specific architecture type in the e_flags, and + instead use EM_ARC_COMPACT for old ARC600, ARC601, and ARC700 + architectures, and switch to EM_ARC_COMPACT2 for newer ARCEM and ARCHS + architectures. + + Th GNU tools follows this use of EM_ARC_COMPACT and EM_ARC_COMPACT2, + but also sets a specific architecture type in the e_flags field. + + However, when decoding the flags we don't worry if we see an + unexpected pairing, for example EM_ARC_COMPACT machine type, with + ARCEM architecture type. */ + + switch (e_flags & EF_ARC_MACH_MSK) + { + /* We only expect these to occur for EM_ARC_COMPACT2. */ + case EF_ARC_CPU_ARCV2EM: + strcat (buf, ", ARC EM"); + break; + case EF_ARC_CPU_ARCV2HS: + strcat (buf, ", ARC HS"); + break; + + /* We only expect these to occur for EM_ARC_COMPACT. */ + case E_ARC_MACH_ARC600: + strcat (buf, ", ARC600"); + break; + case E_ARC_MACH_ARC601: + strcat (buf, ", ARC601"); + break; + case E_ARC_MACH_ARC700: + strcat (buf, ", ARC700"); + break; + + /* The only times we should end up here are (a) A corrupt ELF, (b) A + new ELF with new architecture being read by an old version of + readelf, or (c) An ELF built with non-GNU compiler that does not + set the architecture in the e_flags. */ + default: + if (e_machine == EM_ARC_COMPACT) + strcat (buf, ", Unknown ARCompact"); + else + strcat (buf, ", Unknown ARC"); + break; + } + + switch (e_flags & EF_ARC_OSABI_MSK) + { + case E_ARC_OSABI_ORIG: + strcat (buf, ", (ABI:legacy)"); + break; + case E_ARC_OSABI_V2: + strcat (buf, ", (ABI:v2)"); + break; + /* Only upstream 3.9+ kernels will support ARCv2 ISA. */ + case E_ARC_OSABI_V3: + strcat (buf, ", v3 no-legacy-syscalls ABI"); + break; + case E_ARC_OSABI_V4: + strcat (buf, ", v4 ABI"); + break; + default: + strcat (buf, ", unrecognised ARC OSABI flag"); + break; + } +} + +static void +decode_ARM_machine_flags (unsigned e_flags, char buf[]) +{ + unsigned eabi; + bfd_boolean unknown = FALSE; + + eabi = EF_ARM_EABI_VERSION (e_flags); + e_flags &= ~ EF_ARM_EABIMASK; + + /* Handle "generic" ARM flags. */ + if (e_flags & EF_ARM_RELEXEC) + { + strcat (buf, ", relocatable executable"); + e_flags &= ~ EF_ARM_RELEXEC; + } + + /* Now handle EABI specific flags. */ + switch (eabi) + { + default: + strcat (buf, ", "); + if (e_flags) + unknown = TRUE; + break; + + case EF_ARM_EABI_VER1: + strcat (buf, ", Version1 EABI"); + while (e_flags) + { + unsigned flag; + + /* Process flags one bit at a time. */ + flag = e_flags & - e_flags; + e_flags &= ~ flag; + + switch (flag) + { + case EF_ARM_SYMSARESORTED: /* Conflicts with EF_ARM_INTERWORK. */ + strcat (buf, ", sorted symbol tables"); + break; + + default: + unknown = TRUE; + break; + } + } + break; + + case EF_ARM_EABI_VER2: + strcat (buf, ", Version2 EABI"); + while (e_flags) + { + unsigned flag; + + /* Process flags one bit at a time. */ + flag = e_flags & - e_flags; + e_flags &= ~ flag; + + switch (flag) + { + case EF_ARM_SYMSARESORTED: /* Conflicts with EF_ARM_INTERWORK. */ + strcat (buf, ", sorted symbol tables"); + break; + + case EF_ARM_DYNSYMSUSESEGIDX: + strcat (buf, ", dynamic symbols use segment index"); + break; + + case EF_ARM_MAPSYMSFIRST: + strcat (buf, ", mapping symbols precede others"); + break; + + default: + unknown = TRUE; + break; + } + } + break; + + case EF_ARM_EABI_VER3: + strcat (buf, ", Version3 EABI"); + break; + + case EF_ARM_EABI_VER4: + strcat (buf, ", Version4 EABI"); + while (e_flags) + { + unsigned flag; + + /* Process flags one bit at a time. */ + flag = e_flags & - e_flags; + e_flags &= ~ flag; + + switch (flag) + { + case EF_ARM_BE8: + strcat (buf, ", BE8"); + break; + + case EF_ARM_LE8: + strcat (buf, ", LE8"); + break; + + default: + unknown = TRUE; + break; + } + } + break; + + case EF_ARM_EABI_VER5: + strcat (buf, ", Version5 EABI"); + while (e_flags) + { + unsigned flag; + + /* Process flags one bit at a time. */ + flag = e_flags & - e_flags; + e_flags &= ~ flag; + + switch (flag) + { + case EF_ARM_BE8: + strcat (buf, ", BE8"); + break; + + case EF_ARM_LE8: + strcat (buf, ", LE8"); + break; + + case EF_ARM_ABI_FLOAT_SOFT: /* Conflicts with EF_ARM_SOFT_FLOAT. */ + strcat (buf, ", soft-float ABI"); + break; + + case EF_ARM_ABI_FLOAT_HARD: /* Conflicts with EF_ARM_VFP_FLOAT. */ + strcat (buf, ", hard-float ABI"); + break; + + default: + unknown = TRUE; + break; + } + } + break; + + case EF_ARM_EABI_UNKNOWN: + strcat (buf, ", GNU EABI"); + while (e_flags) + { + unsigned flag; + + /* Process flags one bit at a time. */ + flag = e_flags & - e_flags; + e_flags &= ~ flag; + + switch (flag) + { + case EF_ARM_INTERWORK: + strcat (buf, ", interworking enabled"); + break; + + case EF_ARM_APCS_26: + strcat (buf, ", uses APCS/26"); + break; + + case EF_ARM_APCS_FLOAT: + strcat (buf, ", uses APCS/float"); + break; + + case EF_ARM_PIC: + strcat (buf, ", position independent"); + break; + + case EF_ARM_ALIGN8: + strcat (buf, ", 8 bit structure alignment"); + break; + + case EF_ARM_NEW_ABI: + strcat (buf, ", uses new ABI"); + break; + + case EF_ARM_OLD_ABI: + strcat (buf, ", uses old ABI"); + break; + + case EF_ARM_SOFT_FLOAT: + strcat (buf, ", software FP"); + break; + + case EF_ARM_VFP_FLOAT: + strcat (buf, ", VFP"); + break; + + case EF_ARM_MAVERICK_FLOAT: + strcat (buf, ", Maverick FP"); + break; + + default: + unknown = TRUE; + break; + } + } + } + + if (unknown) + strcat (buf,_(", ")); +} + +static void +decode_AVR_machine_flags (unsigned e_flags, char buf[], size_t size) +{ + --size; /* Leave space for null terminator. */ + + switch (e_flags & EF_AVR_MACH) + { + case E_AVR_MACH_AVR1: + strncat (buf, ", avr:1", size); + break; + case E_AVR_MACH_AVR2: + strncat (buf, ", avr:2", size); + break; + case E_AVR_MACH_AVR25: + strncat (buf, ", avr:25", size); + break; + case E_AVR_MACH_AVR3: + strncat (buf, ", avr:3", size); + break; + case E_AVR_MACH_AVR31: + strncat (buf, ", avr:31", size); + break; + case E_AVR_MACH_AVR35: + strncat (buf, ", avr:35", size); + break; + case E_AVR_MACH_AVR4: + strncat (buf, ", avr:4", size); + break; + case E_AVR_MACH_AVR5: + strncat (buf, ", avr:5", size); + break; + case E_AVR_MACH_AVR51: + strncat (buf, ", avr:51", size); + break; + case E_AVR_MACH_AVR6: + strncat (buf, ", avr:6", size); + break; + case E_AVR_MACH_AVRTINY: + strncat (buf, ", avr:100", size); + break; + case E_AVR_MACH_XMEGA1: + strncat (buf, ", avr:101", size); + break; + case E_AVR_MACH_XMEGA2: + strncat (buf, ", avr:102", size); + break; + case E_AVR_MACH_XMEGA3: + strncat (buf, ", avr:103", size); + break; + case E_AVR_MACH_XMEGA4: + strncat (buf, ", avr:104", size); + break; + case E_AVR_MACH_XMEGA5: + strncat (buf, ", avr:105", size); + break; + case E_AVR_MACH_XMEGA6: + strncat (buf, ", avr:106", size); + break; + case E_AVR_MACH_XMEGA7: + strncat (buf, ", avr:107", size); + break; + default: + strncat (buf, ", avr:", size); + break; + } + + size -= strlen (buf); + if (e_flags & EF_AVR_LINKRELAX_PREPARED) + strncat (buf, ", link-relax", size); +} + +static void +decode_NDS32_machine_flags (unsigned e_flags, char buf[], size_t size) +{ + unsigned abi; + unsigned arch; + unsigned config; + unsigned version; + bfd_boolean has_fpu = FALSE; + unsigned int r = 0; + + static const char *ABI_STRINGS[] = + { + "ABI v0", /* use r5 as return register; only used in N1213HC */ + "ABI v1", /* use r0 as return register */ + "ABI v2", /* use r0 as return register and don't reserve 24 bytes for arguments */ + "ABI v2fp", /* for FPU */ + "AABI", + "ABI2 FP+" + }; + static const char *VER_STRINGS[] = + { + "Andes ELF V1.3 or older", + "Andes ELF V1.3.1", + "Andes ELF V1.4" + }; + static const char *ARCH_STRINGS[] = + { + "", + "Andes Star v1.0", + "Andes Star v2.0", + "Andes Star v3.0", + "Andes Star v3.0m" + }; + + abi = EF_NDS_ABI & e_flags; + arch = EF_NDS_ARCH & e_flags; + config = EF_NDS_INST & e_flags; + version = EF_NDS32_ELF_VERSION & e_flags; + + memset (buf, 0, size); + + switch (abi) + { + case E_NDS_ABI_V0: + case E_NDS_ABI_V1: + case E_NDS_ABI_V2: + case E_NDS_ABI_V2FP: + case E_NDS_ABI_AABI: + case E_NDS_ABI_V2FP_PLUS: + /* In case there are holes in the array. */ + r += snprintf (buf + r, size - r, ", %s", ABI_STRINGS[abi >> EF_NDS_ABI_SHIFT]); + break; + + default: + r += snprintf (buf + r, size - r, ", "); + break; + } + + switch (version) + { + case E_NDS32_ELF_VER_1_2: + case E_NDS32_ELF_VER_1_3: + case E_NDS32_ELF_VER_1_4: + r += snprintf (buf + r, size - r, ", %s", VER_STRINGS[version >> EF_NDS32_ELF_VERSION_SHIFT]); + break; + + default: + r += snprintf (buf + r, size - r, ", "); + break; + } + + if (E_NDS_ABI_V0 == abi) + { + /* OLD ABI; only used in N1213HC, has performance extension 1. */ + r += snprintf (buf + r, size - r, ", Andes Star v1.0, N1213HC, MAC, PERF1"); + if (arch == E_NDS_ARCH_STAR_V1_0) + r += snprintf (buf + r, size -r, ", 16b"); /* has 16-bit instructions */ + return; + } + + switch (arch) + { + case E_NDS_ARCH_STAR_V1_0: + case E_NDS_ARCH_STAR_V2_0: + case E_NDS_ARCH_STAR_V3_0: + case E_NDS_ARCH_STAR_V3_M: + r += snprintf (buf + r, size - r, ", %s", ARCH_STRINGS[arch >> EF_NDS_ARCH_SHIFT]); + break; + + default: + r += snprintf (buf + r, size - r, ", "); + /* ARCH version determines how the e_flags are interpreted. + If it is unknown, we cannot proceed. */ + return; + } + + /* Newer ABI; Now handle architecture specific flags. */ + if (arch == E_NDS_ARCH_STAR_V1_0) + { + if (config & E_NDS32_HAS_MFUSR_PC_INST) + r += snprintf (buf + r, size -r, ", MFUSR_PC"); + + if (!(config & E_NDS32_HAS_NO_MAC_INST)) + r += snprintf (buf + r, size -r, ", MAC"); + + if (config & E_NDS32_HAS_DIV_INST) + r += snprintf (buf + r, size -r, ", DIV"); + + if (config & E_NDS32_HAS_16BIT_INST) + r += snprintf (buf + r, size -r, ", 16b"); + } + else + { + if (config & E_NDS32_HAS_MFUSR_PC_INST) + { + if (version <= E_NDS32_ELF_VER_1_3) + r += snprintf (buf + r, size -r, ", [B8]"); + else + r += snprintf (buf + r, size -r, ", EX9"); + } + + if (config & E_NDS32_HAS_MAC_DX_INST) + r += snprintf (buf + r, size -r, ", MAC_DX"); + + if (config & E_NDS32_HAS_DIV_DX_INST) + r += snprintf (buf + r, size -r, ", DIV_DX"); + + if (config & E_NDS32_HAS_16BIT_INST) + { + if (version <= E_NDS32_ELF_VER_1_3) + r += snprintf (buf + r, size -r, ", 16b"); + else + r += snprintf (buf + r, size -r, ", IFC"); + } + } + + if (config & E_NDS32_HAS_EXT_INST) + r += snprintf (buf + r, size -r, ", PERF1"); + + if (config & E_NDS32_HAS_EXT2_INST) + r += snprintf (buf + r, size -r, ", PERF2"); + + if (config & E_NDS32_HAS_FPU_INST) + { + has_fpu = TRUE; + r += snprintf (buf + r, size -r, ", FPU_SP"); + } + + if (config & E_NDS32_HAS_FPU_DP_INST) + { + has_fpu = TRUE; + r += snprintf (buf + r, size -r, ", FPU_DP"); + } + + if (config & E_NDS32_HAS_FPU_MAC_INST) + { + has_fpu = TRUE; + r += snprintf (buf + r, size -r, ", FPU_MAC"); + } + + if (has_fpu) + { + switch ((config & E_NDS32_FPU_REG_CONF) >> E_NDS32_FPU_REG_CONF_SHIFT) + { + case E_NDS32_FPU_REG_8SP_4DP: + r += snprintf (buf + r, size -r, ", FPU_REG:8/4"); + break; + case E_NDS32_FPU_REG_16SP_8DP: + r += snprintf (buf + r, size -r, ", FPU_REG:16/8"); + break; + case E_NDS32_FPU_REG_32SP_16DP: + r += snprintf (buf + r, size -r, ", FPU_REG:32/16"); + break; + case E_NDS32_FPU_REG_32SP_32DP: + r += snprintf (buf + r, size -r, ", FPU_REG:32/32"); + break; + } + } + + if (config & E_NDS32_HAS_AUDIO_INST) + r += snprintf (buf + r, size -r, ", AUDIO"); + + if (config & E_NDS32_HAS_STRING_INST) + r += snprintf (buf + r, size -r, ", STR"); + + if (config & E_NDS32_HAS_REDUCED_REGS) + r += snprintf (buf + r, size -r, ", 16REG"); + + if (config & E_NDS32_HAS_VIDEO_INST) + { + if (version <= E_NDS32_ELF_VER_1_3) + r += snprintf (buf + r, size -r, ", VIDEO"); + else + r += snprintf (buf + r, size -r, ", SATURATION"); + } + + if (config & E_NDS32_HAS_ENCRIPT_INST) + r += snprintf (buf + r, size -r, ", ENCRP"); + + if (config & E_NDS32_HAS_L2C_INST) + r += snprintf (buf + r, size -r, ", L2C"); +} + +static char * +get_machine_flags (Filedata * filedata, unsigned e_flags, unsigned e_machine) +{ + static char buf[1024]; + + buf[0] = '\0'; + + if (e_flags) + { + switch (e_machine) + { + default: + break; + + case EM_ARC_COMPACT2: + case EM_ARC_COMPACT: + decode_ARC_machine_flags (e_flags, e_machine, buf); + break; + + case EM_ARM: + decode_ARM_machine_flags (e_flags, buf); + break; + + case EM_AVR: + decode_AVR_machine_flags (e_flags, buf, sizeof buf); + break; + + case EM_BLACKFIN: + if (e_flags & EF_BFIN_PIC) + strcat (buf, ", PIC"); + + if (e_flags & EF_BFIN_FDPIC) + strcat (buf, ", FDPIC"); + + if (e_flags & EF_BFIN_CODE_IN_L1) + strcat (buf, ", code in L1"); + + if (e_flags & EF_BFIN_DATA_IN_L1) + strcat (buf, ", data in L1"); + + break; + + case EM_CYGNUS_FRV: + switch (e_flags & EF_FRV_CPU_MASK) + { + case EF_FRV_CPU_GENERIC: + break; + + default: + strcat (buf, ", fr???"); + break; + + case EF_FRV_CPU_FR300: + strcat (buf, ", fr300"); + break; + + case EF_FRV_CPU_FR400: + strcat (buf, ", fr400"); + break; + case EF_FRV_CPU_FR405: + strcat (buf, ", fr405"); + break; + + case EF_FRV_CPU_FR450: + strcat (buf, ", fr450"); + break; + + case EF_FRV_CPU_FR500: + strcat (buf, ", fr500"); + break; + case EF_FRV_CPU_FR550: + strcat (buf, ", fr550"); + break; + + case EF_FRV_CPU_SIMPLE: + strcat (buf, ", simple"); + break; + case EF_FRV_CPU_TOMCAT: + strcat (buf, ", tomcat"); + break; + } + break; + + case EM_68K: + if ((e_flags & EF_M68K_ARCH_MASK) == EF_M68K_M68000) + strcat (buf, ", m68000"); + else if ((e_flags & EF_M68K_ARCH_MASK) == EF_M68K_CPU32) + strcat (buf, ", cpu32"); + else if ((e_flags & EF_M68K_ARCH_MASK) == EF_M68K_FIDO) + strcat (buf, ", fido_a"); + else + { + char const * isa = _("unknown"); + char const * mac = _("unknown mac"); + char const * additional = NULL; + + switch (e_flags & EF_M68K_CF_ISA_MASK) + { + case EF_M68K_CF_ISA_A_NODIV: + isa = "A"; + additional = ", nodiv"; + break; + case EF_M68K_CF_ISA_A: + isa = "A"; + break; + case EF_M68K_CF_ISA_A_PLUS: + isa = "A+"; + break; + case EF_M68K_CF_ISA_B_NOUSP: + isa = "B"; + additional = ", nousp"; + break; + case EF_M68K_CF_ISA_B: + isa = "B"; + break; + case EF_M68K_CF_ISA_C: + isa = "C"; + break; + case EF_M68K_CF_ISA_C_NODIV: + isa = "C"; + additional = ", nodiv"; + break; + } + strcat (buf, ", cf, isa "); + strcat (buf, isa); + if (additional) + strcat (buf, additional); + if (e_flags & EF_M68K_CF_FLOAT) + strcat (buf, ", float"); + switch (e_flags & EF_M68K_CF_MAC_MASK) + { + case 0: + mac = NULL; + break; + case EF_M68K_CF_MAC: + mac = "mac"; + break; + case EF_M68K_CF_EMAC: + mac = "emac"; + break; + case EF_M68K_CF_EMAC_B: + mac = "emac_b"; + break; + } + if (mac) + { + strcat (buf, ", "); + strcat (buf, mac); + } + } + break; + + case EM_CYGNUS_MEP: + switch (e_flags & EF_MEP_CPU_MASK) + { + case EF_MEP_CPU_MEP: strcat (buf, ", generic MeP"); break; + case EF_MEP_CPU_C2: strcat (buf, ", MeP C2"); break; + case EF_MEP_CPU_C3: strcat (buf, ", MeP C3"); break; + case EF_MEP_CPU_C4: strcat (buf, ", MeP C4"); break; + case EF_MEP_CPU_C5: strcat (buf, ", MeP C5"); break; + case EF_MEP_CPU_H1: strcat (buf, ", MeP H1"); break; + default: strcat (buf, _(", ")); break; + } + + switch (e_flags & EF_MEP_COP_MASK) + { + case EF_MEP_COP_NONE: break; + case EF_MEP_COP_AVC: strcat (buf, ", AVC coprocessor"); break; + case EF_MEP_COP_AVC2: strcat (buf, ", AVC2 coprocessor"); break; + case EF_MEP_COP_FMAX: strcat (buf, ", FMAX coprocessor"); break; + case EF_MEP_COP_IVC2: strcat (buf, ", IVC2 coprocessor"); break; + default: strcat (buf, _("")); break; + } + + if (e_flags & EF_MEP_LIBRARY) + strcat (buf, ", Built for Library"); + + if (e_flags & EF_MEP_INDEX_MASK) + sprintf (buf + strlen (buf), ", Configuration Index: %#x", + e_flags & EF_MEP_INDEX_MASK); + + if (e_flags & ~ EF_MEP_ALL_FLAGS) + sprintf (buf + strlen (buf), _(", unknown flags bits: %#x"), + e_flags & ~ EF_MEP_ALL_FLAGS); + break; + + case EM_PPC: + if (e_flags & EF_PPC_EMB) + strcat (buf, ", emb"); + + if (e_flags & EF_PPC_RELOCATABLE) + strcat (buf, _(", relocatable")); + + if (e_flags & EF_PPC_RELOCATABLE_LIB) + strcat (buf, _(", relocatable-lib")); + break; + + case EM_PPC64: + if (e_flags & EF_PPC64_ABI) + { + char abi[] = ", abiv0"; + + abi[6] += e_flags & EF_PPC64_ABI; + strcat (buf, abi); + } + break; + + case EM_V800: + if ((e_flags & EF_RH850_ABI) == EF_RH850_ABI) + strcat (buf, ", RH850 ABI"); + + if (e_flags & EF_V800_850E3) + strcat (buf, ", V3 architecture"); + + if ((e_flags & (EF_RH850_FPU_DOUBLE | EF_RH850_FPU_SINGLE)) == 0) + strcat (buf, ", FPU not used"); + + if ((e_flags & (EF_RH850_REGMODE22 | EF_RH850_REGMODE32)) == 0) + strcat (buf, ", regmode: COMMON"); + + if ((e_flags & (EF_RH850_GP_FIX | EF_RH850_GP_NOFIX)) == 0) + strcat (buf, ", r4 not used"); + + if ((e_flags & (EF_RH850_EP_FIX | EF_RH850_EP_NOFIX)) == 0) + strcat (buf, ", r30 not used"); + + if ((e_flags & (EF_RH850_TP_FIX | EF_RH850_TP_NOFIX)) == 0) + strcat (buf, ", r5 not used"); + + if ((e_flags & (EF_RH850_REG2_RESERVE | EF_RH850_REG2_NORESERVE)) == 0) + strcat (buf, ", r2 not used"); + + for (e_flags &= 0xFFFF; e_flags; e_flags &= ~ (e_flags & - e_flags)) + { + switch (e_flags & - e_flags) + { + case EF_RH850_FPU_DOUBLE: strcat (buf, ", double precision FPU"); break; + case EF_RH850_FPU_SINGLE: strcat (buf, ", single precision FPU"); break; + case EF_RH850_REGMODE22: strcat (buf, ", regmode:22"); break; + case EF_RH850_REGMODE32: strcat (buf, ", regmode:23"); break; + case EF_RH850_GP_FIX: strcat (buf, ", r4 fixed"); break; + case EF_RH850_GP_NOFIX: strcat (buf, ", r4 free"); break; + case EF_RH850_EP_FIX: strcat (buf, ", r30 fixed"); break; + case EF_RH850_EP_NOFIX: strcat (buf, ", r30 free"); break; + case EF_RH850_TP_FIX: strcat (buf, ", r5 fixed"); break; + case EF_RH850_TP_NOFIX: strcat (buf, ", r5 free"); break; + case EF_RH850_REG2_RESERVE: strcat (buf, ", r2 fixed"); break; + case EF_RH850_REG2_NORESERVE: strcat (buf, ", r2 free"); break; + default: break; + } + } + break; + + case EM_V850: + case EM_CYGNUS_V850: + switch (e_flags & EF_V850_ARCH) + { + case E_V850E3V5_ARCH: + strcat (buf, ", v850e3v5"); + break; + case E_V850E2V3_ARCH: + strcat (buf, ", v850e2v3"); + break; + case E_V850E2_ARCH: + strcat (buf, ", v850e2"); + break; + case E_V850E1_ARCH: + strcat (buf, ", v850e1"); + break; + case E_V850E_ARCH: + strcat (buf, ", v850e"); + break; + case E_V850_ARCH: + strcat (buf, ", v850"); + break; + default: + strcat (buf, _(", unknown v850 architecture variant")); + break; + } + break; + + case EM_M32R: + case EM_CYGNUS_M32R: + if ((e_flags & EF_M32R_ARCH) == E_M32R_ARCH) + strcat (buf, ", m32r"); + break; + + case EM_MIPS: + case EM_MIPS_RS3_LE: + if (e_flags & EF_MIPS_NOREORDER) + strcat (buf, ", noreorder"); + + if (e_flags & EF_MIPS_PIC) + strcat (buf, ", pic"); + + if (e_flags & EF_MIPS_CPIC) + strcat (buf, ", cpic"); + + if (e_flags & EF_MIPS_UCODE) + strcat (buf, ", ugen_reserved"); + + if (e_flags & EF_MIPS_ABI2) + strcat (buf, ", abi2"); + + if (e_flags & EF_MIPS_OPTIONS_FIRST) + strcat (buf, ", odk first"); + + if (e_flags & EF_MIPS_32BITMODE) + strcat (buf, ", 32bitmode"); + + if (e_flags & EF_MIPS_NAN2008) + strcat (buf, ", nan2008"); + + if (e_flags & EF_MIPS_FP64) + strcat (buf, ", fp64"); + + switch ((e_flags & EF_MIPS_MACH)) + { + case E_MIPS_MACH_3900: strcat (buf, ", 3900"); break; + case E_MIPS_MACH_4010: strcat (buf, ", 4010"); break; + case E_MIPS_MACH_4100: strcat (buf, ", 4100"); break; + case E_MIPS_MACH_4111: strcat (buf, ", 4111"); break; + case E_MIPS_MACH_4120: strcat (buf, ", 4120"); break; + case E_MIPS_MACH_4650: strcat (buf, ", 4650"); break; + case E_MIPS_MACH_5400: strcat (buf, ", 5400"); break; + case E_MIPS_MACH_5500: strcat (buf, ", 5500"); break; + case E_MIPS_MACH_5900: strcat (buf, ", 5900"); break; + case E_MIPS_MACH_SB1: strcat (buf, ", sb1"); break; + case E_MIPS_MACH_9000: strcat (buf, ", 9000"); break; + case E_MIPS_MACH_LS2E: strcat (buf, ", loongson-2e"); break; + case E_MIPS_MACH_LS2F: strcat (buf, ", loongson-2f"); break; + case E_MIPS_MACH_LS3A: strcat (buf, ", loongson-3a"); break; + case E_MIPS_MACH_OCTEON: strcat (buf, ", octeon"); break; + case E_MIPS_MACH_OCTEON2: strcat (buf, ", octeon2"); break; + case E_MIPS_MACH_OCTEON3: strcat (buf, ", octeon3"); break; + case E_MIPS_MACH_XLR: strcat (buf, ", xlr"); break; + case E_MIPS_MACH_IAMR2: strcat (buf, ", interaptiv-mr2"); break; + case 0: + /* We simply ignore the field in this case to avoid confusion: + MIPS ELF does not specify EF_MIPS_MACH, it is a GNU + extension. */ + break; + default: strcat (buf, _(", unknown CPU")); break; + } + + switch ((e_flags & EF_MIPS_ABI)) + { + case E_MIPS_ABI_O32: strcat (buf, ", o32"); break; + case E_MIPS_ABI_O64: strcat (buf, ", o64"); break; + case E_MIPS_ABI_EABI32: strcat (buf, ", eabi32"); break; + case E_MIPS_ABI_EABI64: strcat (buf, ", eabi64"); break; + case 0: + /* We simply ignore the field in this case to avoid confusion: + MIPS ELF does not specify EF_MIPS_ABI, it is a GNU extension. + This means it is likely to be an o32 file, but not for + sure. */ + break; + default: strcat (buf, _(", unknown ABI")); break; + } + + if (e_flags & EF_MIPS_ARCH_ASE_MDMX) + strcat (buf, ", mdmx"); + + if (e_flags & EF_MIPS_ARCH_ASE_M16) + strcat (buf, ", mips16"); + + if (e_flags & EF_MIPS_ARCH_ASE_MICROMIPS) + strcat (buf, ", micromips"); + + switch ((e_flags & EF_MIPS_ARCH)) + { + case E_MIPS_ARCH_1: strcat (buf, ", mips1"); break; + case E_MIPS_ARCH_2: strcat (buf, ", mips2"); break; + case E_MIPS_ARCH_3: strcat (buf, ", mips3"); break; + case E_MIPS_ARCH_4: strcat (buf, ", mips4"); break; + case E_MIPS_ARCH_5: strcat (buf, ", mips5"); break; + case E_MIPS_ARCH_32: strcat (buf, ", mips32"); break; + case E_MIPS_ARCH_32R2: strcat (buf, ", mips32r2"); break; + case E_MIPS_ARCH_32R6: strcat (buf, ", mips32r6"); break; + case E_MIPS_ARCH_64: strcat (buf, ", mips64"); break; + case E_MIPS_ARCH_64R2: strcat (buf, ", mips64r2"); break; + case E_MIPS_ARCH_64R6: strcat (buf, ", mips64r6"); break; + default: strcat (buf, _(", unknown ISA")); break; + } + break; + + case EM_NDS32: + decode_NDS32_machine_flags (e_flags, buf, sizeof buf); + break; + + case EM_RISCV: + if (e_flags & EF_RISCV_RVC) + strcat (buf, ", RVC"); + + switch (e_flags & EF_RISCV_FLOAT_ABI) + { + case EF_RISCV_FLOAT_ABI_SOFT: + strcat (buf, ", soft-float ABI"); + break; + + case EF_RISCV_FLOAT_ABI_SINGLE: + strcat (buf, ", single-float ABI"); + break; + + case EF_RISCV_FLOAT_ABI_DOUBLE: + strcat (buf, ", double-float ABI"); + break; + + case EF_RISCV_FLOAT_ABI_QUAD: + strcat (buf, ", quad-float ABI"); + break; + } + break; + + case EM_SH: + switch ((e_flags & EF_SH_MACH_MASK)) + { + case EF_SH1: strcat (buf, ", sh1"); break; + case EF_SH2: strcat (buf, ", sh2"); break; + case EF_SH3: strcat (buf, ", sh3"); break; + case EF_SH_DSP: strcat (buf, ", sh-dsp"); break; + case EF_SH3_DSP: strcat (buf, ", sh3-dsp"); break; + case EF_SH4AL_DSP: strcat (buf, ", sh4al-dsp"); break; + case EF_SH3E: strcat (buf, ", sh3e"); break; + case EF_SH4: strcat (buf, ", sh4"); break; + case EF_SH5: strcat (buf, ", sh5"); break; + case EF_SH2E: strcat (buf, ", sh2e"); break; + case EF_SH4A: strcat (buf, ", sh4a"); break; + case EF_SH2A: strcat (buf, ", sh2a"); break; + case EF_SH4_NOFPU: strcat (buf, ", sh4-nofpu"); break; + case EF_SH4A_NOFPU: strcat (buf, ", sh4a-nofpu"); break; + case EF_SH2A_NOFPU: strcat (buf, ", sh2a-nofpu"); break; + case EF_SH3_NOMMU: strcat (buf, ", sh3-nommu"); break; + case EF_SH4_NOMMU_NOFPU: strcat (buf, ", sh4-nommu-nofpu"); break; + case EF_SH2A_SH4_NOFPU: strcat (buf, ", sh2a-nofpu-or-sh4-nommu-nofpu"); break; + case EF_SH2A_SH3_NOFPU: strcat (buf, ", sh2a-nofpu-or-sh3-nommu"); break; + case EF_SH2A_SH4: strcat (buf, ", sh2a-or-sh4"); break; + case EF_SH2A_SH3E: strcat (buf, ", sh2a-or-sh3e"); break; + default: strcat (buf, _(", unknown ISA")); break; + } + + if (e_flags & EF_SH_PIC) + strcat (buf, ", pic"); + + if (e_flags & EF_SH_FDPIC) + strcat (buf, ", fdpic"); + break; + + case EM_OR1K: + if (e_flags & EF_OR1K_NODELAY) + strcat (buf, ", no delay"); + break; + + case EM_SPARCV9: + if (e_flags & EF_SPARC_32PLUS) + strcat (buf, ", v8+"); + + if (e_flags & EF_SPARC_SUN_US1) + strcat (buf, ", ultrasparcI"); + + if (e_flags & EF_SPARC_SUN_US3) + strcat (buf, ", ultrasparcIII"); + + if (e_flags & EF_SPARC_HAL_R1) + strcat (buf, ", halr1"); + + if (e_flags & EF_SPARC_LEDATA) + strcat (buf, ", ledata"); + + if ((e_flags & EF_SPARCV9_MM) == EF_SPARCV9_TSO) + strcat (buf, ", tso"); + + if ((e_flags & EF_SPARCV9_MM) == EF_SPARCV9_PSO) + strcat (buf, ", pso"); + + if ((e_flags & EF_SPARCV9_MM) == EF_SPARCV9_RMO) + strcat (buf, ", rmo"); + break; + + case EM_PARISC: + switch (e_flags & EF_PARISC_ARCH) + { + case EFA_PARISC_1_0: + strcpy (buf, ", PA-RISC 1.0"); + break; + case EFA_PARISC_1_1: + strcpy (buf, ", PA-RISC 1.1"); + break; + case EFA_PARISC_2_0: + strcpy (buf, ", PA-RISC 2.0"); + break; + default: + break; + } + if (e_flags & EF_PARISC_TRAPNIL) + strcat (buf, ", trapnil"); + if (e_flags & EF_PARISC_EXT) + strcat (buf, ", ext"); + if (e_flags & EF_PARISC_LSB) + strcat (buf, ", lsb"); + if (e_flags & EF_PARISC_WIDE) + strcat (buf, ", wide"); + if (e_flags & EF_PARISC_NO_KABP) + strcat (buf, ", no kabp"); + if (e_flags & EF_PARISC_LAZYSWAP) + strcat (buf, ", lazyswap"); + break; + + case EM_PJ: + case EM_PJ_OLD: + if ((e_flags & EF_PICOJAVA_NEWCALLS) == EF_PICOJAVA_NEWCALLS) + strcat (buf, ", new calling convention"); + + if ((e_flags & EF_PICOJAVA_GNUCALLS) == EF_PICOJAVA_GNUCALLS) + strcat (buf, ", gnu calling convention"); + break; + + case EM_IA_64: + if ((e_flags & EF_IA_64_ABI64)) + strcat (buf, ", 64-bit"); + else + strcat (buf, ", 32-bit"); + if ((e_flags & EF_IA_64_REDUCEDFP)) + strcat (buf, ", reduced fp model"); + if ((e_flags & EF_IA_64_NOFUNCDESC_CONS_GP)) + strcat (buf, ", no function descriptors, constant gp"); + else if ((e_flags & EF_IA_64_CONS_GP)) + strcat (buf, ", constant gp"); + if ((e_flags & EF_IA_64_ABSOLUTE)) + strcat (buf, ", absolute"); + if (filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_OPENVMS) + { + if ((e_flags & EF_IA_64_VMS_LINKAGES)) + strcat (buf, ", vms_linkages"); + switch ((e_flags & EF_IA_64_VMS_COMCOD)) + { + case EF_IA_64_VMS_COMCOD_SUCCESS: + break; + case EF_IA_64_VMS_COMCOD_WARNING: + strcat (buf, ", warning"); + break; + case EF_IA_64_VMS_COMCOD_ERROR: + strcat (buf, ", error"); + break; + case EF_IA_64_VMS_COMCOD_ABORT: + strcat (buf, ", abort"); + break; + default: + warn (_("Unrecognised IA64 VMS Command Code: %x\n"), + e_flags & EF_IA_64_VMS_COMCOD); + strcat (buf, ", "); + } + } + break; + + case EM_VAX: + if ((e_flags & EF_VAX_NONPIC)) + strcat (buf, ", non-PIC"); + if ((e_flags & EF_VAX_DFLOAT)) + strcat (buf, ", D-Float"); + if ((e_flags & EF_VAX_GFLOAT)) + strcat (buf, ", G-Float"); + break; + + case EM_VISIUM: + if (e_flags & EF_VISIUM_ARCH_MCM) + strcat (buf, ", mcm"); + else if (e_flags & EF_VISIUM_ARCH_MCM24) + strcat (buf, ", mcm24"); + if (e_flags & EF_VISIUM_ARCH_GR6) + strcat (buf, ", gr6"); + break; + + case EM_RL78: + switch (e_flags & E_FLAG_RL78_CPU_MASK) + { + case E_FLAG_RL78_ANY_CPU: break; + case E_FLAG_RL78_G10: strcat (buf, ", G10"); break; + case E_FLAG_RL78_G13: strcat (buf, ", G13"); break; + case E_FLAG_RL78_G14: strcat (buf, ", G14"); break; + } + if (e_flags & E_FLAG_RL78_64BIT_DOUBLES) + strcat (buf, ", 64-bit doubles"); + break; + + case EM_RX: + if (e_flags & E_FLAG_RX_64BIT_DOUBLES) + strcat (buf, ", 64-bit doubles"); + if (e_flags & E_FLAG_RX_DSP) + strcat (buf, ", dsp"); + if (e_flags & E_FLAG_RX_PID) + strcat (buf, ", pid"); + if (e_flags & E_FLAG_RX_ABI) + strcat (buf, ", RX ABI"); + if (e_flags & E_FLAG_RX_SINSNS_SET) + strcat (buf, e_flags & E_FLAG_RX_SINSNS_YES + ? ", uses String instructions" : ", bans String instructions"); + if (e_flags & E_FLAG_RX_V2) + strcat (buf, ", V2"); + break; + + case EM_S390: + if (e_flags & EF_S390_HIGH_GPRS) + strcat (buf, ", highgprs"); + break; + + case EM_TI_C6000: + if ((e_flags & EF_C6000_REL)) + strcat (buf, ", relocatable module"); + break; + + case EM_MSP430: + strcat (buf, _(": architecture variant: ")); + switch (e_flags & EF_MSP430_MACH) + { + case E_MSP430_MACH_MSP430x11: strcat (buf, "MSP430x11"); break; + case E_MSP430_MACH_MSP430x11x1 : strcat (buf, "MSP430x11x1 "); break; + case E_MSP430_MACH_MSP430x12: strcat (buf, "MSP430x12"); break; + case E_MSP430_MACH_MSP430x13: strcat (buf, "MSP430x13"); break; + case E_MSP430_MACH_MSP430x14: strcat (buf, "MSP430x14"); break; + case E_MSP430_MACH_MSP430x15: strcat (buf, "MSP430x15"); break; + case E_MSP430_MACH_MSP430x16: strcat (buf, "MSP430x16"); break; + case E_MSP430_MACH_MSP430x31: strcat (buf, "MSP430x31"); break; + case E_MSP430_MACH_MSP430x32: strcat (buf, "MSP430x32"); break; + case E_MSP430_MACH_MSP430x33: strcat (buf, "MSP430x33"); break; + case E_MSP430_MACH_MSP430x41: strcat (buf, "MSP430x41"); break; + case E_MSP430_MACH_MSP430x42: strcat (buf, "MSP430x42"); break; + case E_MSP430_MACH_MSP430x43: strcat (buf, "MSP430x43"); break; + case E_MSP430_MACH_MSP430x44: strcat (buf, "MSP430x44"); break; + case E_MSP430_MACH_MSP430X : strcat (buf, "MSP430X"); break; + default: + strcat (buf, _(": unknown")); break; + } + + if (e_flags & ~ EF_MSP430_MACH) + strcat (buf, _(": unknown extra flag bits also present")); + } + } + + return buf; +} + +static const char * +get_osabi_name (Filedata * filedata, unsigned int osabi) +{ + static char buff[32]; + + switch (osabi) + { + case ELFOSABI_NONE: return "UNIX - System V"; + case ELFOSABI_HPUX: return "UNIX - HP-UX"; + case ELFOSABI_NETBSD: return "UNIX - NetBSD"; + case ELFOSABI_GNU: return "UNIX - GNU"; + case ELFOSABI_SOLARIS: return "UNIX - Solaris"; + case ELFOSABI_AIX: return "UNIX - AIX"; + case ELFOSABI_IRIX: return "UNIX - IRIX"; + case ELFOSABI_FREEBSD: return "UNIX - FreeBSD"; + case ELFOSABI_TRU64: return "UNIX - TRU64"; + case ELFOSABI_MODESTO: return "Novell - Modesto"; + case ELFOSABI_OPENBSD: return "UNIX - OpenBSD"; + case ELFOSABI_OPENVMS: return "VMS - OpenVMS"; + case ELFOSABI_NSK: return "HP - Non-Stop Kernel"; + case ELFOSABI_AROS: return "AROS"; + case ELFOSABI_FENIXOS: return "FenixOS"; + case ELFOSABI_CLOUDABI: return "Nuxi CloudABI"; + case ELFOSABI_OPENVOS: return "Stratus Technologies OpenVOS"; + default: + if (osabi >= 64) + switch (filedata->file_header.e_machine) + { + case EM_ARM: + switch (osabi) + { + case ELFOSABI_ARM: return "ARM"; + default: + break; + } + break; + + case EM_MSP430: + case EM_MSP430_OLD: + case EM_VISIUM: + switch (osabi) + { + case ELFOSABI_STANDALONE: return _("Standalone App"); + default: + break; + } + break; + + case EM_TI_C6000: + switch (osabi) + { + case ELFOSABI_C6000_ELFABI: return _("Bare-metal C6000"); + case ELFOSABI_C6000_LINUX: return "Linux C6000"; + default: + break; + } + break; + + default: + break; + } + snprintf (buff, sizeof (buff), _(""), osabi); + return buff; + } +} + +static const char * +get_aarch64_segment_type (unsigned long type) +{ + switch (type) + { + case PT_AARCH64_ARCHEXT: return "AARCH64_ARCHEXT"; + default: return NULL; + } +} + +static const char * +get_arm_segment_type (unsigned long type) +{ + switch (type) + { + case PT_ARM_EXIDX: return "EXIDX"; + default: return NULL; + } +} + +static const char * +get_s390_segment_type (unsigned long type) +{ + switch (type) + { + case PT_S390_PGSTE: return "S390_PGSTE"; + default: return NULL; + } +} + +static const char * +get_mips_segment_type (unsigned long type) +{ + switch (type) + { + case PT_MIPS_REGINFO: return "REGINFO"; + case PT_MIPS_RTPROC: return "RTPROC"; + case PT_MIPS_OPTIONS: return "OPTIONS"; + case PT_MIPS_ABIFLAGS: return "ABIFLAGS"; + default: return NULL; + } +} + +static const char * +get_parisc_segment_type (unsigned long type) +{ + switch (type) + { + case PT_HP_TLS: return "HP_TLS"; + case PT_HP_CORE_NONE: return "HP_CORE_NONE"; + case PT_HP_CORE_VERSION: return "HP_CORE_VERSION"; + case PT_HP_CORE_KERNEL: return "HP_CORE_KERNEL"; + case PT_HP_CORE_COMM: return "HP_CORE_COMM"; + case PT_HP_CORE_PROC: return "HP_CORE_PROC"; + case PT_HP_CORE_LOADABLE: return "HP_CORE_LOADABLE"; + case PT_HP_CORE_STACK: return "HP_CORE_STACK"; + case PT_HP_CORE_SHM: return "HP_CORE_SHM"; + case PT_HP_CORE_MMF: return "HP_CORE_MMF"; + case PT_HP_PARALLEL: return "HP_PARALLEL"; + case PT_HP_FASTBIND: return "HP_FASTBIND"; + case PT_HP_OPT_ANNOT: return "HP_OPT_ANNOT"; + case PT_HP_HSL_ANNOT: return "HP_HSL_ANNOT"; + case PT_HP_STACK: return "HP_STACK"; + case PT_HP_CORE_UTSNAME: return "HP_CORE_UTSNAME"; + case PT_PARISC_ARCHEXT: return "PARISC_ARCHEXT"; + case PT_PARISC_UNWIND: return "PARISC_UNWIND"; + case PT_PARISC_WEAKORDER: return "PARISC_WEAKORDER"; + default: return NULL; + } +} + +static const char * +get_ia64_segment_type (unsigned long type) +{ + switch (type) + { + case PT_IA_64_ARCHEXT: return "IA_64_ARCHEXT"; + case PT_IA_64_UNWIND: return "IA_64_UNWIND"; + case PT_HP_TLS: return "HP_TLS"; + case PT_IA_64_HP_OPT_ANOT: return "HP_OPT_ANNOT"; + case PT_IA_64_HP_HSL_ANOT: return "HP_HSL_ANNOT"; + case PT_IA_64_HP_STACK: return "HP_STACK"; + default: return NULL; + } +} + +static const char * +get_tic6x_segment_type (unsigned long type) +{ + switch (type) + { + case PT_C6000_PHATTR: return "C6000_PHATTR"; + default: return NULL; + } +} + +static const char * +get_solaris_segment_type (unsigned long type) +{ + switch (type) + { + case 0x6464e550: return "PT_SUNW_UNWIND"; + case 0x6474e550: return "PT_SUNW_EH_FRAME"; + case 0x6ffffff7: return "PT_LOSUNW"; + case 0x6ffffffa: return "PT_SUNWBSS"; + case 0x6ffffffb: return "PT_SUNWSTACK"; + case 0x6ffffffc: return "PT_SUNWDTRACE"; + case 0x6ffffffd: return "PT_SUNWCAP"; + case 0x6fffffff: return "PT_HISUNW"; + default: return NULL; + } +} + +static const char * +get_segment_type (Filedata * filedata, unsigned long p_type) +{ + static char buff[32]; + + switch (p_type) + { + case PT_NULL: return "NULL"; + case PT_LOAD: return "LOAD"; + case PT_DYNAMIC: return "DYNAMIC"; + case PT_INTERP: return "INTERP"; + case PT_NOTE: return "NOTE"; + case PT_SHLIB: return "SHLIB"; + case PT_PHDR: return "PHDR"; + case PT_TLS: return "TLS"; + case PT_GNU_EH_FRAME: return "GNU_EH_FRAME"; + case PT_GNU_STACK: return "GNU_STACK"; + case PT_GNU_RELRO: return "GNU_RELRO"; + + default: + if (p_type >= PT_GNU_MBIND_LO && p_type <= PT_GNU_MBIND_HI) + { + sprintf (buff, "GNU_MBIND+%#lx", + p_type - PT_GNU_MBIND_LO); + } + else if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC)) + { + const char * result; + + switch (filedata->file_header.e_machine) + { + case EM_AARCH64: + result = get_aarch64_segment_type (p_type); + break; + case EM_ARM: + result = get_arm_segment_type (p_type); + break; + case EM_MIPS: + case EM_MIPS_RS3_LE: + result = get_mips_segment_type (p_type); + break; + case EM_PARISC: + result = get_parisc_segment_type (p_type); + break; + case EM_IA_64: + result = get_ia64_segment_type (p_type); + break; + case EM_TI_C6000: + result = get_tic6x_segment_type (p_type); + break; + case EM_S390: + case EM_S390_OLD: + result = get_s390_segment_type (p_type); + break; + default: + result = NULL; + break; + } + + if (result != NULL) + return result; + + sprintf (buff, "LOPROC+%#lx", p_type - PT_LOPROC); + } + else if ((p_type >= PT_LOOS) && (p_type <= PT_HIOS)) + { + const char * result; + + switch (filedata->file_header.e_machine) + { + case EM_PARISC: + result = get_parisc_segment_type (p_type); + break; + case EM_IA_64: + result = get_ia64_segment_type (p_type); + break; + default: + if (filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_SOLARIS) + result = get_solaris_segment_type (p_type); + else + result = NULL; + break; + } + + if (result != NULL) + return result; + + sprintf (buff, "LOOS+%#lx", p_type - PT_LOOS); + } + else + snprintf (buff, sizeof (buff), _(": %lx"), p_type); + + return buff; + } +} + +static const char * +get_arc_section_type_name (unsigned int sh_type) +{ + switch (sh_type) + { + case SHT_ARC_ATTRIBUTES: return "ARC_ATTRIBUTES"; + default: + break; + } + return NULL; +} + +static const char * +get_mips_section_type_name (unsigned int sh_type) +{ + switch (sh_type) + { + case SHT_MIPS_LIBLIST: return "MIPS_LIBLIST"; + case SHT_MIPS_MSYM: return "MIPS_MSYM"; + case SHT_MIPS_CONFLICT: return "MIPS_CONFLICT"; + case SHT_MIPS_GPTAB: return "MIPS_GPTAB"; + case SHT_MIPS_UCODE: return "MIPS_UCODE"; + case SHT_MIPS_DEBUG: return "MIPS_DEBUG"; + case SHT_MIPS_REGINFO: return "MIPS_REGINFO"; + case SHT_MIPS_PACKAGE: return "MIPS_PACKAGE"; + case SHT_MIPS_PACKSYM: return "MIPS_PACKSYM"; + case SHT_MIPS_RELD: return "MIPS_RELD"; + case SHT_MIPS_IFACE: return "MIPS_IFACE"; + case SHT_MIPS_CONTENT: return "MIPS_CONTENT"; + case SHT_MIPS_OPTIONS: return "MIPS_OPTIONS"; + case SHT_MIPS_SHDR: return "MIPS_SHDR"; + case SHT_MIPS_FDESC: return "MIPS_FDESC"; + case SHT_MIPS_EXTSYM: return "MIPS_EXTSYM"; + case SHT_MIPS_DENSE: return "MIPS_DENSE"; + case SHT_MIPS_PDESC: return "MIPS_PDESC"; + case SHT_MIPS_LOCSYM: return "MIPS_LOCSYM"; + case SHT_MIPS_AUXSYM: return "MIPS_AUXSYM"; + case SHT_MIPS_OPTSYM: return "MIPS_OPTSYM"; + case SHT_MIPS_LOCSTR: return "MIPS_LOCSTR"; + case SHT_MIPS_LINE: return "MIPS_LINE"; + case SHT_MIPS_RFDESC: return "MIPS_RFDESC"; + case SHT_MIPS_DELTASYM: return "MIPS_DELTASYM"; + case SHT_MIPS_DELTAINST: return "MIPS_DELTAINST"; + case SHT_MIPS_DELTACLASS: return "MIPS_DELTACLASS"; + case SHT_MIPS_DWARF: return "MIPS_DWARF"; + case SHT_MIPS_DELTADECL: return "MIPS_DELTADECL"; + case SHT_MIPS_SYMBOL_LIB: return "MIPS_SYMBOL_LIB"; + case SHT_MIPS_EVENTS: return "MIPS_EVENTS"; + case SHT_MIPS_TRANSLATE: return "MIPS_TRANSLATE"; + case SHT_MIPS_PIXIE: return "MIPS_PIXIE"; + case SHT_MIPS_XLATE: return "MIPS_XLATE"; + case SHT_MIPS_XLATE_DEBUG: return "MIPS_XLATE_DEBUG"; + case SHT_MIPS_WHIRL: return "MIPS_WHIRL"; + case SHT_MIPS_EH_REGION: return "MIPS_EH_REGION"; + case SHT_MIPS_XLATE_OLD: return "MIPS_XLATE_OLD"; + case SHT_MIPS_PDR_EXCEPTION: return "MIPS_PDR_EXCEPTION"; + case SHT_MIPS_ABIFLAGS: return "MIPS_ABIFLAGS"; + default: + break; + } + return NULL; +} + +static const char * +get_parisc_section_type_name (unsigned int sh_type) +{ + switch (sh_type) + { + case SHT_PARISC_EXT: return "PARISC_EXT"; + case SHT_PARISC_UNWIND: return "PARISC_UNWIND"; + case SHT_PARISC_DOC: return "PARISC_DOC"; + case SHT_PARISC_ANNOT: return "PARISC_ANNOT"; + case SHT_PARISC_SYMEXTN: return "PARISC_SYMEXTN"; + case SHT_PARISC_STUBS: return "PARISC_STUBS"; + case SHT_PARISC_DLKM: return "PARISC_DLKM"; + default: return NULL; + } +} + +static const char * +get_ia64_section_type_name (Filedata * filedata, unsigned int sh_type) +{ + /* If the top 8 bits are 0x78 the next 8 are the os/abi ID. */ + if ((sh_type & 0xFF000000) == SHT_IA_64_LOPSREG) + return get_osabi_name (filedata, (sh_type & 0x00FF0000) >> 16); + + switch (sh_type) + { + case SHT_IA_64_EXT: return "IA_64_EXT"; + case SHT_IA_64_UNWIND: return "IA_64_UNWIND"; + case SHT_IA_64_PRIORITY_INIT: return "IA_64_PRIORITY_INIT"; + case SHT_IA_64_VMS_TRACE: return "VMS_TRACE"; + case SHT_IA_64_VMS_TIE_SIGNATURES: return "VMS_TIE_SIGNATURES"; + case SHT_IA_64_VMS_DEBUG: return "VMS_DEBUG"; + case SHT_IA_64_VMS_DEBUG_STR: return "VMS_DEBUG_STR"; + case SHT_IA_64_VMS_LINKAGES: return "VMS_LINKAGES"; + case SHT_IA_64_VMS_SYMBOL_VECTOR: return "VMS_SYMBOL_VECTOR"; + case SHT_IA_64_VMS_FIXUP: return "VMS_FIXUP"; + default: + break; + } + return NULL; +} + +static const char * +get_x86_64_section_type_name (unsigned int sh_type) +{ + switch (sh_type) + { + case SHT_X86_64_UNWIND: return "X86_64_UNWIND"; + default: return NULL; + } +} + +static const char * +get_aarch64_section_type_name (unsigned int sh_type) +{ + switch (sh_type) + { + case SHT_AARCH64_ATTRIBUTES: return "AARCH64_ATTRIBUTES"; + default: return NULL; + } +} + +static const char * +get_arm_section_type_name (unsigned int sh_type) +{ + switch (sh_type) + { + case SHT_ARM_EXIDX: return "ARM_EXIDX"; + case SHT_ARM_PREEMPTMAP: return "ARM_PREEMPTMAP"; + case SHT_ARM_ATTRIBUTES: return "ARM_ATTRIBUTES"; + case SHT_ARM_DEBUGOVERLAY: return "ARM_DEBUGOVERLAY"; + case SHT_ARM_OVERLAYSECTION: return "ARM_OVERLAYSECTION"; + default: return NULL; + } +} + +static const char * +get_tic6x_section_type_name (unsigned int sh_type) +{ + switch (sh_type) + { + case SHT_C6000_UNWIND: return "C6000_UNWIND"; + case SHT_C6000_PREEMPTMAP: return "C6000_PREEMPTMAP"; + case SHT_C6000_ATTRIBUTES: return "C6000_ATTRIBUTES"; + case SHT_TI_ICODE: return "TI_ICODE"; + case SHT_TI_XREF: return "TI_XREF"; + case SHT_TI_HANDLER: return "TI_HANDLER"; + case SHT_TI_INITINFO: return "TI_INITINFO"; + case SHT_TI_PHATTRS: return "TI_PHATTRS"; + default: return NULL; + } +} + +static const char * +get_msp430x_section_type_name (unsigned int sh_type) +{ + switch (sh_type) + { + case SHT_MSP430_SEC_FLAGS: return "MSP430_SEC_FLAGS"; + case SHT_MSP430_SYM_ALIASES: return "MSP430_SYM_ALIASES"; + case SHT_MSP430_ATTRIBUTES: return "MSP430_ATTRIBUTES"; + default: return NULL; + } +} + +static const char * +get_v850_section_type_name (unsigned int sh_type) +{ + switch (sh_type) + { + case SHT_V850_SCOMMON: return "V850 Small Common"; + case SHT_V850_TCOMMON: return "V850 Tiny Common"; + case SHT_V850_ZCOMMON: return "V850 Zero Common"; + case SHT_RENESAS_IOP: return "RENESAS IOP"; + case SHT_RENESAS_INFO: return "RENESAS INFO"; + default: return NULL; + } +} + +static const char * +get_section_type_name (Filedata * filedata, unsigned int sh_type) +{ + static char buff[32]; + const char * result; + + switch (sh_type) + { + case SHT_NULL: return "NULL"; + case SHT_PROGBITS: return "PROGBITS"; + case SHT_SYMTAB: return "SYMTAB"; + case SHT_STRTAB: return "STRTAB"; + case SHT_RELA: return "RELA"; + case SHT_HASH: return "HASH"; + case SHT_DYNAMIC: return "DYNAMIC"; + case SHT_NOTE: return "NOTE"; + case SHT_NOBITS: return "NOBITS"; + case SHT_REL: return "REL"; + case SHT_SHLIB: return "SHLIB"; + case SHT_DYNSYM: return "DYNSYM"; + case SHT_INIT_ARRAY: return "INIT_ARRAY"; + case SHT_FINI_ARRAY: return "FINI_ARRAY"; + case SHT_PREINIT_ARRAY: return "PREINIT_ARRAY"; + case SHT_GNU_HASH: return "GNU_HASH"; + case SHT_GROUP: return "GROUP"; + case SHT_SYMTAB_SHNDX: return "SYMTAB SECTION INDICIES"; + case SHT_GNU_verdef: return "VERDEF"; + case SHT_GNU_verneed: return "VERNEED"; + case SHT_GNU_versym: return "VERSYM"; + case 0x6ffffff0: return "VERSYM"; + case 0x6ffffffc: return "VERDEF"; + case 0x7ffffffd: return "AUXILIARY"; + case 0x7fffffff: return "FILTER"; + case SHT_GNU_LIBLIST: return "GNU_LIBLIST"; + + default: + if ((sh_type >= SHT_LOPROC) && (sh_type <= SHT_HIPROC)) + { + switch (filedata->file_header.e_machine) + { + case EM_ARC: + case EM_ARC_COMPACT: + case EM_ARC_COMPACT2: + result = get_arc_section_type_name (sh_type); + break; + case EM_MIPS: + case EM_MIPS_RS3_LE: + result = get_mips_section_type_name (sh_type); + break; + case EM_PARISC: + result = get_parisc_section_type_name (sh_type); + break; + case EM_IA_64: + result = get_ia64_section_type_name (filedata, sh_type); + break; + case EM_X86_64: + case EM_L1OM: + case EM_K1OM: + result = get_x86_64_section_type_name (sh_type); + break; + case EM_AARCH64: + result = get_aarch64_section_type_name (sh_type); + break; + case EM_ARM: + result = get_arm_section_type_name (sh_type); + break; + case EM_TI_C6000: + result = get_tic6x_section_type_name (sh_type); + break; + case EM_MSP430: + result = get_msp430x_section_type_name (sh_type); + break; + case EM_V800: + case EM_V850: + case EM_CYGNUS_V850: + result = get_v850_section_type_name (sh_type); + break; + default: + result = NULL; + break; + } + + if (result != NULL) + return result; + + sprintf (buff, "LOPROC+%#x", sh_type - SHT_LOPROC); + } + else if ((sh_type >= SHT_LOOS) && (sh_type <= SHT_HIOS)) + { + switch (filedata->file_header.e_machine) + { + case EM_IA_64: + result = get_ia64_section_type_name (filedata, sh_type); + break; + default: + if (filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_SOLARIS) + result = get_solaris_section_type (sh_type); + else + { + switch (sh_type) + { + case SHT_GNU_INCREMENTAL_INPUTS: result = "GNU_INCREMENTAL_INPUTS"; break; + case SHT_GNU_ATTRIBUTES: result = "GNU_ATTRIBUTES"; break; + case SHT_GNU_HASH: result = "GNU_HASH"; break; + case SHT_GNU_LIBLIST: result = "GNU_LIBLIST"; break; + default: + result = NULL; + break; + } + } + break; + } + + if (result != NULL) + return result; + + sprintf (buff, "LOOS+%#x", sh_type - SHT_LOOS); + } + else if ((sh_type >= SHT_LOUSER) && (sh_type <= SHT_HIUSER)) + { + switch (filedata->file_header.e_machine) + { + case EM_V800: + case EM_V850: + case EM_CYGNUS_V850: + result = get_v850_section_type_name (sh_type); + break; + default: + result = NULL; + break; + } + + if (result != NULL) + return result; + + sprintf (buff, "LOUSER+%#x", sh_type - SHT_LOUSER); + } + else + /* This message is probably going to be displayed in a 15 + character wide field, so put the hex value first. */ + snprintf (buff, sizeof (buff), _("%08x: "), sh_type); + + return buff; + } +} + +#define OPTION_DEBUG_DUMP 512 +#define OPTION_DYN_SYMS 513 +#define OPTION_DWARF_DEPTH 514 +#define OPTION_DWARF_START 515 +#define OPTION_DWARF_CHECK 516 + +static struct option options[] = +{ + {"all", no_argument, 0, 'a'}, + {"file-header", no_argument, 0, 'h'}, + {"program-headers", no_argument, 0, 'l'}, + {"headers", no_argument, 0, 'e'}, + {"histogram", no_argument, 0, 'I'}, + {"segments", no_argument, 0, 'l'}, + {"sections", no_argument, 0, 'S'}, + {"section-headers", no_argument, 0, 'S'}, + {"section-groups", no_argument, 0, 'g'}, + {"section-details", no_argument, 0, 't'}, + {"full-section-name",no_argument, 0, 'N'}, + {"symbols", no_argument, 0, 's'}, + {"syms", no_argument, 0, 's'}, + {"dyn-syms", no_argument, 0, OPTION_DYN_SYMS}, + {"relocs", no_argument, 0, 'r'}, + {"notes", no_argument, 0, 'n'}, + {"dynamic", no_argument, 0, 'd'}, + {"arch-specific", no_argument, 0, 'A'}, + {"version-info", no_argument, 0, 'V'}, + {"use-dynamic", no_argument, 0, 'D'}, + {"unwind", no_argument, 0, 'u'}, + {"archive-index", no_argument, 0, 'c'}, + {"hex-dump", required_argument, 0, 'x'}, + {"relocated-dump", required_argument, 0, 'R'}, + {"string-dump", required_argument, 0, 'p'}, + {"decompress", no_argument, 0, 'z'}, +#ifdef SUPPORT_DISASSEMBLY + {"instruction-dump", required_argument, 0, 'i'}, +#endif + {"debug-dump", optional_argument, 0, OPTION_DEBUG_DUMP}, + + {"dwarf-depth", required_argument, 0, OPTION_DWARF_DEPTH}, + {"dwarf-start", required_argument, 0, OPTION_DWARF_START}, + {"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK}, + + {"version", no_argument, 0, 'v'}, + {"wide", no_argument, 0, 'W'}, + {"help", no_argument, 0, 'H'}, + {0, no_argument, 0, 0} +}; + +static void +usage (FILE * stream) +{ + fprintf (stream, _("Usage: readelf elf-file(s)\n")); + fprintf (stream, _(" Display information about the contents of ELF format files\n")); + fprintf (stream, _(" Options are:\n\ + -a --all Equivalent to: -h -l -S -s -r -d -V -A -I\n\ + -h --file-header Display the ELF file header\n\ + -l --program-headers Display the program headers\n\ + --segments An alias for --program-headers\n\ + -S --section-headers Display the sections' header\n\ + --sections An alias for --section-headers\n\ + -g --section-groups Display the section groups\n\ + -t --section-details Display the section details\n\ + -e --headers Equivalent to: -h -l -S\n\ + -s --syms Display the symbol table\n\ + --symbols An alias for --syms\n\ + --dyn-syms Display the dynamic symbol table\n\ + -n --notes Display the core notes (if present)\n\ + -r --relocs Display the relocations (if present)\n\ + -u --unwind Display the unwind info (if present)\n\ + -d --dynamic Display the dynamic section (if present)\n\ + -V --version-info Display the version sections (if present)\n\ + -A --arch-specific Display architecture specific information (if any)\n\ + -c --archive-index Display the symbol/file index in an archive\n\ + -D --use-dynamic Use the dynamic section info when displaying symbols\n\ + -x --hex-dump=\n\ + Dump the contents of section as bytes\n\ + -p --string-dump=\n\ + Dump the contents of section as strings\n\ + -R --relocated-dump=\n\ + Dump the contents of section as relocated bytes\n\ + -z --decompress Decompress section before dumping it\n\ + -w[lLiaprmfFsoRtUuTgAckK] or\n\ + --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,\n\ + =frames-interp,=str,=loc,=Ranges,=pubtypes,\n\ + =gdb_index,=trace_info,=trace_abbrev,=trace_aranges,\n\ + =addr,=cu_index,=links,=follow-links]\n\ + Display the contents of DWARF debug sections\n")); + fprintf (stream, _("\ + --dwarf-depth=N Do not display DIEs at depth N or greater\n\ + --dwarf-start=N Display DIEs starting with N, at the same depth\n\ + or deeper\n")); +#ifdef SUPPORT_DISASSEMBLY + fprintf (stream, _("\ + -i --instruction-dump=\n\ + Disassemble the contents of section \n")); +#endif + fprintf (stream, _("\ + -I --histogram Display histogram of bucket list lengths\n\ + -W --wide Allow output width to exceed 80 characters\n\ + @ Read options from \n\ + -H --help Display this information\n\ + -v --version Display the version number of readelf\n")); + + if (REPORT_BUGS_TO[0] && stream == stdout) + fprintf (stdout, _("Report bugs to %s\n"), REPORT_BUGS_TO); + + exit (stream == stdout ? 0 : 1); +} + +/* Record the fact that the user wants the contents of section number + SECTION to be displayed using the method(s) encoded as flags bits + in TYPE. Note, TYPE can be zero if we are creating the array for + the first time. */ + +static void +request_dump_bynumber (Filedata * filedata, unsigned int section, dump_type type) +{ + if (section >= filedata->num_dump_sects) + { + dump_type * new_dump_sects; + + new_dump_sects = (dump_type *) calloc (section + 1, + sizeof (* new_dump_sects)); + + if (new_dump_sects == NULL) + error (_("Out of memory allocating dump request table.\n")); + else + { + if (filedata->dump_sects) + { + /* Copy current flag settings. */ + memcpy (new_dump_sects, filedata->dump_sects, + filedata->num_dump_sects * sizeof (* new_dump_sects)); + + free (filedata->dump_sects); + } + + filedata->dump_sects = new_dump_sects; + filedata->num_dump_sects = section + 1; + } + } + + if (filedata->dump_sects) + filedata->dump_sects[section] |= type; +} + +/* Request a dump by section name. */ + +static void +request_dump_byname (const char * section, dump_type type) +{ + struct dump_list_entry * new_request; + + new_request = (struct dump_list_entry *) + malloc (sizeof (struct dump_list_entry)); + if (!new_request) + error (_("Out of memory allocating dump request table.\n")); + + new_request->name = strdup (section); + if (!new_request->name) + error (_("Out of memory allocating dump request table.\n")); + + new_request->type = type; + + new_request->next = dump_sects_byname; + dump_sects_byname = new_request; +} + +static inline void +request_dump (Filedata * filedata, dump_type type) +{ + int section; + char * cp; + + do_dump++; + section = strtoul (optarg, & cp, 0); + + if (! *cp && section >= 0) + request_dump_bynumber (filedata, section, type); + else + request_dump_byname (optarg, type); +} + +static void +parse_args (Filedata * filedata, int argc, char ** argv) +{ + int c; + + if (argc < 2) + usage (stderr); + + while ((c = getopt_long + (argc, argv, "ADHINR:SVWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF) + { + switch (c) + { + case 0: + /* Long options. */ + break; + case 'H': + usage (stdout); + break; + + case 'a': + do_syms = TRUE; + do_reloc = TRUE; + do_unwind = TRUE; + do_dynamic = TRUE; + do_header = TRUE; + do_sections = TRUE; + do_section_groups = TRUE; + do_segments = TRUE; + do_version = TRUE; + do_histogram = TRUE; + do_arch = TRUE; + do_notes = TRUE; + break; + case 'g': + do_section_groups = TRUE; + break; + case 't': + case 'N': + do_sections = TRUE; + do_section_details = TRUE; + break; + case 'e': + do_header = TRUE; + do_sections = TRUE; + do_segments = TRUE; + break; + case 'A': + do_arch = TRUE; + break; + case 'D': + do_using_dynamic = TRUE; + break; + case 'r': + do_reloc = TRUE; + break; + case 'u': + do_unwind = TRUE; + break; + case 'h': + do_header = TRUE; + break; + case 'l': + do_segments = TRUE; + break; + case 's': + do_syms = TRUE; + break; + case 'S': + do_sections = TRUE; + break; + case 'd': + do_dynamic = TRUE; + break; + case 'I': + do_histogram = TRUE; + break; + case 'n': + do_notes = TRUE; + break; + case 'c': + do_archive_index = TRUE; + break; + case 'x': + request_dump (filedata, HEX_DUMP); + break; + case 'p': + request_dump (filedata, STRING_DUMP); + break; + case 'R': + request_dump (filedata, RELOC_DUMP); + break; + case 'z': + decompress_dumps = TRUE; + break; + case 'w': + do_dump = TRUE; + if (optarg == 0) + { + do_debugging = TRUE; + dwarf_select_sections_all (); + } + else + { + do_debugging = FALSE; + dwarf_select_sections_by_letters (optarg); + } + break; + case OPTION_DEBUG_DUMP: + do_dump = TRUE; + if (optarg == 0) + do_debugging = TRUE; + else + { + do_debugging = FALSE; + dwarf_select_sections_by_names (optarg); + } + break; + case OPTION_DWARF_DEPTH: + { + char *cp; + + dwarf_cutoff_level = strtoul (optarg, & cp, 0); + } + break; + case OPTION_DWARF_START: + { + char *cp; + + dwarf_start_die = strtoul (optarg, & cp, 0); + } + break; + case OPTION_DWARF_CHECK: + dwarf_check = TRUE; + break; + case OPTION_DYN_SYMS: + do_dyn_syms = TRUE; + break; +#ifdef SUPPORT_DISASSEMBLY + case 'i': + request_dump (filedata, DISASS_DUMP); + break; +#endif + case 'v': + print_version (program_name); + break; + case 'V': + do_version = TRUE; + break; + case 'W': + do_wide = TRUE; + break; + default: + /* xgettext:c-format */ + error (_("Invalid option '-%c'\n"), c); + /* Fall through. */ + case '?': + usage (stderr); + } + } + + if (!do_dynamic && !do_syms && !do_reloc && !do_unwind && !do_sections + && !do_segments && !do_header && !do_dump && !do_version + && !do_histogram && !do_debugging && !do_arch && !do_notes + && !do_section_groups && !do_archive_index + && !do_dyn_syms) + usage (stderr); +} + +static const char * +get_elf_class (unsigned int elf_class) +{ + static char buff[32]; + + switch (elf_class) + { + case ELFCLASSNONE: return _("none"); + case ELFCLASS32: return "ELF32"; + case ELFCLASS64: return "ELF64"; + default: + snprintf (buff, sizeof (buff), _(""), elf_class); + return buff; + } +} + +static const char * +get_data_encoding (unsigned int encoding) +{ + static char buff[32]; + + switch (encoding) + { + case ELFDATANONE: return _("none"); + case ELFDATA2LSB: return _("2's complement, little endian"); + case ELFDATA2MSB: return _("2's complement, big endian"); + default: + snprintf (buff, sizeof (buff), _(""), encoding); + return buff; + } +} + +/* Decode the data held in 'filedata->file_header'. */ + +static bfd_boolean +process_file_header (Filedata * filedata) +{ + Elf_Internal_Ehdr * header = & filedata->file_header; + + if ( header->e_ident[EI_MAG0] != ELFMAG0 + || header->e_ident[EI_MAG1] != ELFMAG1 + || header->e_ident[EI_MAG2] != ELFMAG2 + || header->e_ident[EI_MAG3] != ELFMAG3) + { + error + (_("Not an ELF file - it has the wrong magic bytes at the start\n")); + return FALSE; + } + + init_dwarf_regnames (header->e_machine); + + if (do_header) + { + unsigned i; + + printf (_("ELF Header:\n")); + printf (_(" Magic: ")); + for (i = 0; i < EI_NIDENT; i++) + printf ("%2.2x ", header->e_ident[i]); + printf ("\n"); + printf (_(" Class: %s\n"), + get_elf_class (header->e_ident[EI_CLASS])); + printf (_(" Data: %s\n"), + get_data_encoding (header->e_ident[EI_DATA])); + printf (_(" Version: %d %s\n"), + header->e_ident[EI_VERSION], + (header->e_ident[EI_VERSION] == EV_CURRENT + ? "(current)" + : (header->e_ident[EI_VERSION] != EV_NONE + ? _("") + : ""))); + printf (_(" OS/ABI: %s\n"), + get_osabi_name (filedata, header->e_ident[EI_OSABI])); + printf (_(" ABI Version: %d\n"), + header->e_ident[EI_ABIVERSION]); + printf (_(" Type: %s\n"), + get_file_type (header->e_type)); + printf (_(" Machine: %s\n"), + get_machine_name (header->e_machine)); + printf (_(" Version: 0x%lx\n"), + (unsigned long) header->e_version); + + printf (_(" Entry point address: ")); + print_vma ((bfd_vma) header->e_entry, PREFIX_HEX); + printf (_("\n Start of program headers: ")); + print_vma ((bfd_vma) header->e_phoff, DEC); + printf (_(" (bytes into file)\n Start of section headers: ")); + print_vma ((bfd_vma) header->e_shoff, DEC); + printf (_(" (bytes into file)\n")); + + printf (_(" Flags: 0x%lx%s\n"), + (unsigned long) header->e_flags, + get_machine_flags (filedata, header->e_flags, header->e_machine)); + printf (_(" Size of this header: %ld (bytes)\n"), + (long) header->e_ehsize); + printf (_(" Size of program headers: %ld (bytes)\n"), + (long) header->e_phentsize); + printf (_(" Number of program headers: %ld"), + (long) header->e_phnum); + if (filedata->section_headers != NULL + && header->e_phnum == PN_XNUM + && filedata->section_headers[0].sh_info != 0) + printf (" (%ld)", (long) filedata->section_headers[0].sh_info); + putc ('\n', stdout); + printf (_(" Size of section headers: %ld (bytes)\n"), + (long) header->e_shentsize); + printf (_(" Number of section headers: %ld"), + (long) header->e_shnum); + if (filedata->section_headers != NULL && header->e_shnum == SHN_UNDEF) + printf (" (%ld)", (long) filedata->section_headers[0].sh_size); + putc ('\n', stdout); + printf (_(" Section header string table index: %ld"), + (long) header->e_shstrndx); + if (filedata->section_headers != NULL + && header->e_shstrndx == (SHN_XINDEX & 0xffff)) + printf (" (%u)", filedata->section_headers[0].sh_link); + else if (header->e_shstrndx != SHN_UNDEF + && header->e_shstrndx >= header->e_shnum) + printf (_(" ")); + putc ('\n', stdout); + } + + if (filedata->section_headers != NULL) + { + if (header->e_phnum == PN_XNUM + && filedata->section_headers[0].sh_info != 0) + header->e_phnum = filedata->section_headers[0].sh_info; + if (header->e_shnum == SHN_UNDEF) + header->e_shnum = filedata->section_headers[0].sh_size; + if (header->e_shstrndx == (SHN_XINDEX & 0xffff)) + header->e_shstrndx = filedata->section_headers[0].sh_link; + if (header->e_shstrndx >= header->e_shnum) + header->e_shstrndx = SHN_UNDEF; + free (filedata->section_headers); + filedata->section_headers = NULL; + } + + return TRUE; +} + +/* Read in the program headers from FILEDATA and store them in PHEADERS. + Returns TRUE upon success, FALSE otherwise. Loads 32-bit headers. */ + +static bfd_boolean +get_32bit_program_headers (Filedata * filedata, Elf_Internal_Phdr * pheaders) +{ + Elf32_External_Phdr * phdrs; + Elf32_External_Phdr * external; + Elf_Internal_Phdr * internal; + unsigned int i; + unsigned int size = filedata->file_header.e_phentsize; + unsigned int num = filedata->file_header.e_phnum; + + /* PR binutils/17531: Cope with unexpected section header sizes. */ + if (size == 0 || num == 0) + return FALSE; + if (size < sizeof * phdrs) + { + error (_("The e_phentsize field in the ELF header is less than the size of an ELF program header\n")); + return FALSE; + } + if (size > sizeof * phdrs) + warn (_("The e_phentsize field in the ELF header is larger than the size of an ELF program header\n")); + + phdrs = (Elf32_External_Phdr *) get_data (NULL, filedata, filedata->file_header.e_phoff, + size, num, _("program headers")); + if (phdrs == NULL) + return FALSE; + + for (i = 0, internal = pheaders, external = phdrs; + i < filedata->file_header.e_phnum; + i++, internal++, external++) + { + internal->p_type = BYTE_GET (external->p_type); + internal->p_offset = BYTE_GET (external->p_offset); + internal->p_vaddr = BYTE_GET (external->p_vaddr); + internal->p_paddr = BYTE_GET (external->p_paddr); + internal->p_filesz = BYTE_GET (external->p_filesz); + internal->p_memsz = BYTE_GET (external->p_memsz); + internal->p_flags = BYTE_GET (external->p_flags); + internal->p_align = BYTE_GET (external->p_align); + } + + free (phdrs); + return TRUE; +} + +/* Read in the program headers from FILEDATA and store them in PHEADERS. + Returns TRUE upon success, FALSE otherwise. Loads 64-bit headers. */ + +static bfd_boolean +get_64bit_program_headers (Filedata * filedata, Elf_Internal_Phdr * pheaders) +{ + Elf64_External_Phdr * phdrs; + Elf64_External_Phdr * external; + Elf_Internal_Phdr * internal; + unsigned int i; + unsigned int size = filedata->file_header.e_phentsize; + unsigned int num = filedata->file_header.e_phnum; + + /* PR binutils/17531: Cope with unexpected section header sizes. */ + if (size == 0 || num == 0) + return FALSE; + if (size < sizeof * phdrs) + { + error (_("The e_phentsize field in the ELF header is less than the size of an ELF program header\n")); + return FALSE; + } + if (size > sizeof * phdrs) + warn (_("The e_phentsize field in the ELF header is larger than the size of an ELF program header\n")); + + phdrs = (Elf64_External_Phdr *) get_data (NULL, filedata, filedata->file_header.e_phoff, + size, num, _("program headers")); + if (!phdrs) + return FALSE; + + for (i = 0, internal = pheaders, external = phdrs; + i < filedata->file_header.e_phnum; + i++, internal++, external++) + { + internal->p_type = BYTE_GET (external->p_type); + internal->p_flags = BYTE_GET (external->p_flags); + internal->p_offset = BYTE_GET (external->p_offset); + internal->p_vaddr = BYTE_GET (external->p_vaddr); + internal->p_paddr = BYTE_GET (external->p_paddr); + internal->p_filesz = BYTE_GET (external->p_filesz); + internal->p_memsz = BYTE_GET (external->p_memsz); + internal->p_align = BYTE_GET (external->p_align); + } + + free (phdrs); + return TRUE; +} + +/* Returns TRUE if the program headers were read into `program_headers'. */ + +static bfd_boolean +get_program_headers (Filedata * filedata) +{ + Elf_Internal_Phdr * phdrs; + + /* Check cache of prior read. */ + if (filedata->program_headers != NULL) + return TRUE; + + /* Be kind to memory checkers by looking for + e_phnum values which we know must be invalid. */ + if (filedata->file_header.e_phnum + * (is_32bit_elf ? sizeof (Elf32_External_Phdr) : sizeof (Elf64_External_Phdr)) + >= filedata->file_size) + { + error (_("Too many program headers - %#x - the file is not that big\n"), + filedata->file_header.e_phnum); + return FALSE; + } + + phdrs = (Elf_Internal_Phdr *) cmalloc (filedata->file_header.e_phnum, + sizeof (Elf_Internal_Phdr)); + if (phdrs == NULL) + { + error (_("Out of memory reading %u program headers\n"), + filedata->file_header.e_phnum); + return FALSE; + } + + if (is_32bit_elf + ? get_32bit_program_headers (filedata, phdrs) + : get_64bit_program_headers (filedata, phdrs)) + { + filedata->program_headers = phdrs; + return TRUE; + } + + free (phdrs); + return FALSE; +} + +/* Returns TRUE if the program headers were loaded. */ + +static bfd_boolean +process_program_headers (Filedata * filedata) +{ + Elf_Internal_Phdr * segment; + unsigned int i; + Elf_Internal_Phdr * previous_load = NULL; + + if (filedata->file_header.e_phnum == 0) + { + /* PR binutils/12467. */ + if (filedata->file_header.e_phoff != 0) + { + warn (_("possibly corrupt ELF header - it has a non-zero program" + " header offset, but no program headers\n")); + return FALSE; + } + else if (do_segments) + printf (_("\nThere are no program headers in this file.\n")); + return TRUE; + } + + if (do_segments && !do_header) + { + printf (_("\nElf file type is %s\n"), get_file_type (filedata->file_header.e_type)); + printf (_("Entry point 0x%s\n"), bfd_vmatoa ("x", filedata->file_header.e_entry)); + printf (ngettext ("There is %d program header, starting at offset %s\n", + "There are %d program headers, starting at offset %s\n", + filedata->file_header.e_phnum), + filedata->file_header.e_phnum, + bfd_vmatoa ("u", filedata->file_header.e_phoff)); + } + + if (! get_program_headers (filedata)) + return TRUE; + + if (do_segments) + { + if (filedata->file_header.e_phnum > 1) + printf (_("\nProgram Headers:\n")); + else + printf (_("\nProgram Headers:\n")); + + if (is_32bit_elf) + printf + (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n")); + else if (do_wide) + printf + (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n")); + else + { + printf + (_(" Type Offset VirtAddr PhysAddr\n")); + printf + (_(" FileSiz MemSiz Flags Align\n")); + } + } + + dynamic_addr = 0; + dynamic_size = 0; + + for (i = 0, segment = filedata->program_headers; + i < filedata->file_header.e_phnum; + i++, segment++) + { + if (do_segments) + { + printf (" %-14.14s ", get_segment_type (filedata, segment->p_type)); + + if (is_32bit_elf) + { + printf ("0x%6.6lx ", (unsigned long) segment->p_offset); + printf ("0x%8.8lx ", (unsigned long) segment->p_vaddr); + printf ("0x%8.8lx ", (unsigned long) segment->p_paddr); + printf ("0x%5.5lx ", (unsigned long) segment->p_filesz); + printf ("0x%5.5lx ", (unsigned long) segment->p_memsz); + printf ("%c%c%c ", + (segment->p_flags & PF_R ? 'R' : ' '), + (segment->p_flags & PF_W ? 'W' : ' '), + (segment->p_flags & PF_X ? 'E' : ' ')); + printf ("%#lx", (unsigned long) segment->p_align); + } + else if (do_wide) + { + if ((unsigned long) segment->p_offset == segment->p_offset) + printf ("0x%6.6lx ", (unsigned long) segment->p_offset); + else + { + print_vma (segment->p_offset, FULL_HEX); + putchar (' '); + } + + print_vma (segment->p_vaddr, FULL_HEX); + putchar (' '); + print_vma (segment->p_paddr, FULL_HEX); + putchar (' '); + + if ((unsigned long) segment->p_filesz == segment->p_filesz) + printf ("0x%6.6lx ", (unsigned long) segment->p_filesz); + else + { + print_vma (segment->p_filesz, FULL_HEX); + putchar (' '); + } + + if ((unsigned long) segment->p_memsz == segment->p_memsz) + printf ("0x%6.6lx", (unsigned long) segment->p_memsz); + else + { + print_vma (segment->p_memsz, FULL_HEX); + } + + printf (" %c%c%c ", + (segment->p_flags & PF_R ? 'R' : ' '), + (segment->p_flags & PF_W ? 'W' : ' '), + (segment->p_flags & PF_X ? 'E' : ' ')); + + if ((unsigned long) segment->p_align == segment->p_align) + printf ("%#lx", (unsigned long) segment->p_align); + else + { + print_vma (segment->p_align, PREFIX_HEX); + } + } + else + { + print_vma (segment->p_offset, FULL_HEX); + putchar (' '); + print_vma (segment->p_vaddr, FULL_HEX); + putchar (' '); + print_vma (segment->p_paddr, FULL_HEX); + printf ("\n "); + print_vma (segment->p_filesz, FULL_HEX); + putchar (' '); + print_vma (segment->p_memsz, FULL_HEX); + printf (" %c%c%c ", + (segment->p_flags & PF_R ? 'R' : ' '), + (segment->p_flags & PF_W ? 'W' : ' '), + (segment->p_flags & PF_X ? 'E' : ' ')); + print_vma (segment->p_align, PREFIX_HEX); + } + + putc ('\n', stdout); + } + + switch (segment->p_type) + { + case PT_LOAD: +#if 0 /* Do not warn about out of order PT_LOAD segments. Although officially + required by the ELF standard, several programs, including the Linux + kernel, make use of non-ordered segments. */ + if (previous_load + && previous_load->p_vaddr > segment->p_vaddr) + error (_("LOAD segments must be sorted in order of increasing VirtAddr\n")); +#endif + if (segment->p_memsz < segment->p_filesz) + error (_("the segment's file size is larger than its memory size\n")); + previous_load = segment; + break; + + case PT_PHDR: + /* PR 20815 - Verify that the program header is loaded into memory. */ + if (i > 0 && previous_load != NULL) + error (_("the PHDR segment must occur before any LOAD segment\n")); + if (filedata->file_header.e_machine != EM_PARISC) + { + unsigned int j; + + for (j = 1; j < filedata->file_header.e_phnum; j++) + if (filedata->program_headers[j].p_vaddr <= segment->p_vaddr + && (filedata->program_headers[j].p_vaddr + + filedata->program_headers[j].p_memsz) + >= (segment->p_vaddr + segment->p_filesz)) + break; + if (j == filedata->file_header.e_phnum) + error (_("the PHDR segment is not covered by a LOAD segment\n")); + } + break; + + case PT_DYNAMIC: + if (dynamic_addr) + error (_("more than one dynamic segment\n")); + + /* By default, assume that the .dynamic section is the first + section in the DYNAMIC segment. */ + dynamic_addr = segment->p_offset; + dynamic_size = segment->p_filesz; + + /* Try to locate the .dynamic section. If there is + a section header table, we can easily locate it. */ + if (filedata->section_headers != NULL) + { + Elf_Internal_Shdr * sec; + + sec = find_section (filedata, ".dynamic"); + if (sec == NULL || sec->sh_size == 0) + { + /* A corresponding .dynamic section is expected, but on + IA-64/OpenVMS it is OK for it to be missing. */ + if (!is_ia64_vms (filedata)) + error (_("no .dynamic section in the dynamic segment\n")); + break; + } + + if (sec->sh_type == SHT_NOBITS) + { + dynamic_size = 0; + break; + } + + dynamic_addr = sec->sh_offset; + dynamic_size = sec->sh_size; + + if (dynamic_addr < segment->p_offset + || dynamic_addr > segment->p_offset + segment->p_filesz) + warn (_("the .dynamic section is not contained" + " within the dynamic segment\n")); + else if (dynamic_addr > segment->p_offset) + warn (_("the .dynamic section is not the first section" + " in the dynamic segment.\n")); + } + + /* PR binutils/17512: Avoid corrupt dynamic section info in the + segment. Check this after matching against the section headers + so we don't warn on debuginfo file (which have NOBITS .dynamic + sections). */ + if (dynamic_addr + dynamic_size >= filedata->file_size) + { + error (_("the dynamic segment offset + size exceeds the size of the file\n")); + dynamic_addr = dynamic_size = 0; + } + break; + + case PT_INTERP: + if (fseek (filedata->handle, archive_file_offset + (long) segment->p_offset, + SEEK_SET)) + error (_("Unable to find program interpreter name\n")); + else + { + char fmt [32]; + int ret = snprintf (fmt, sizeof (fmt), "%%%ds", PATH_MAX - 1); + + if (ret >= (int) sizeof (fmt) || ret < 0) + error (_("Internal error: failed to create format string to display program interpreter\n")); + + program_interpreter[0] = 0; + if (fscanf (filedata->handle, fmt, program_interpreter) <= 0) + error (_("Unable to read program interpreter name\n")); + + if (do_segments) + printf (_(" [Requesting program interpreter: %s]\n"), + program_interpreter); + } + break; + } + } + + if (do_segments + && filedata->section_headers != NULL + && filedata->string_table != NULL) + { + printf (_("\n Section to Segment mapping:\n")); + printf (_(" Segment Sections...\n")); + + for (i = 0; i < filedata->file_header.e_phnum; i++) + { + unsigned int j; + Elf_Internal_Shdr * section; + + segment = filedata->program_headers + i; + section = filedata->section_headers + 1; + + printf (" %2.2d ", i); + + for (j = 1; j < filedata->file_header.e_shnum; j++, section++) + { + if (!ELF_TBSS_SPECIAL (section, segment) + && ELF_SECTION_IN_SEGMENT_STRICT (section, segment)) + printf ("%s ", printable_section_name (filedata, section)); + } + + putc ('\n',stdout); + } + } + + return TRUE; +} + + +/* Find the file offset corresponding to VMA by using the program headers. */ + +static long +offset_from_vma (Filedata * filedata, bfd_vma vma, bfd_size_type size) +{ + Elf_Internal_Phdr * seg; + + if (! get_program_headers (filedata)) + { + warn (_("Cannot interpret virtual addresses without program headers.\n")); + return (long) vma; + } + + for (seg = filedata->program_headers; + seg < filedata->program_headers + filedata->file_header.e_phnum; + ++seg) + { + if (seg->p_type != PT_LOAD) + continue; + + if (vma >= (seg->p_vaddr & -seg->p_align) + && vma + size <= seg->p_vaddr + seg->p_filesz) + return vma - seg->p_vaddr + seg->p_offset; + } + + warn (_("Virtual address 0x%lx not located in any PT_LOAD segment.\n"), + (unsigned long) vma); + return (long) vma; +} + + +/* Allocate memory and load the sections headers into FILEDATA->filedata->section_headers. + If PROBE is true, this is just a probe and we do not generate any error + messages if the load fails. */ + +static bfd_boolean +get_32bit_section_headers (Filedata * filedata, bfd_boolean probe) +{ + Elf32_External_Shdr * shdrs; + Elf_Internal_Shdr * internal; + unsigned int i; + unsigned int size = filedata->file_header.e_shentsize; + unsigned int num = probe ? 1 : filedata->file_header.e_shnum; + + /* PR binutils/17531: Cope with unexpected section header sizes. */ + if (size == 0 || num == 0) + return FALSE; + if (size < sizeof * shdrs) + { + if (! probe) + error (_("The e_shentsize field in the ELF header is less than the size of an ELF section header\n")); + return FALSE; + } + if (!probe && size > sizeof * shdrs) + warn (_("The e_shentsize field in the ELF header is larger than the size of an ELF section header\n")); + + shdrs = (Elf32_External_Shdr *) get_data (NULL, filedata, filedata->file_header.e_shoff, + size, num, + probe ? NULL : _("section headers")); + if (shdrs == NULL) + return FALSE; + + free (filedata->section_headers); + filedata->section_headers = (Elf_Internal_Shdr *) + cmalloc (num, sizeof (Elf_Internal_Shdr)); + if (filedata->section_headers == NULL) + { + if (!probe) + error (_("Out of memory reading %u section headers\n"), num); + return FALSE; + } + + for (i = 0, internal = filedata->section_headers; + i < num; + i++, internal++) + { + internal->sh_name = BYTE_GET (shdrs[i].sh_name); + internal->sh_type = BYTE_GET (shdrs[i].sh_type); + internal->sh_flags = BYTE_GET (shdrs[i].sh_flags); + internal->sh_addr = BYTE_GET (shdrs[i].sh_addr); + internal->sh_offset = BYTE_GET (shdrs[i].sh_offset); + internal->sh_size = BYTE_GET (shdrs[i].sh_size); + internal->sh_link = BYTE_GET (shdrs[i].sh_link); + internal->sh_info = BYTE_GET (shdrs[i].sh_info); + internal->sh_addralign = BYTE_GET (shdrs[i].sh_addralign); + internal->sh_entsize = BYTE_GET (shdrs[i].sh_entsize); + if (!probe && internal->sh_link > num) + warn (_("Section %u has an out of range sh_link value of %u\n"), i, internal->sh_link); + if (!probe && internal->sh_flags & SHF_INFO_LINK && internal->sh_info > num) + warn (_("Section %u has an out of range sh_info value of %u\n"), i, internal->sh_info); + } + + free (shdrs); + return TRUE; +} + +/* Like get_32bit_section_headers, except that it fetches 64-bit headers. */ + +static bfd_boolean +get_64bit_section_headers (Filedata * filedata, bfd_boolean probe) +{ + Elf64_External_Shdr * shdrs; + Elf_Internal_Shdr * internal; + unsigned int i; + unsigned int size = filedata->file_header.e_shentsize; + unsigned int num = probe ? 1 : filedata->file_header.e_shnum; + + /* PR binutils/17531: Cope with unexpected section header sizes. */ + if (size == 0 || num == 0) + return FALSE; + + if (size < sizeof * shdrs) + { + if (! probe) + error (_("The e_shentsize field in the ELF header is less than the size of an ELF section header\n")); + return FALSE; + } + + if (! probe && size > sizeof * shdrs) + warn (_("The e_shentsize field in the ELF header is larger than the size of an ELF section header\n")); + + shdrs = (Elf64_External_Shdr *) get_data (NULL, filedata, + filedata->file_header.e_shoff, + size, num, + probe ? NULL : _("section headers")); + if (shdrs == NULL) + return FALSE; + + free (filedata->section_headers); + filedata->section_headers = (Elf_Internal_Shdr *) + cmalloc (num, sizeof (Elf_Internal_Shdr)); + if (filedata->section_headers == NULL) + { + if (! probe) + error (_("Out of memory reading %u section headers\n"), num); + return FALSE; + } + + for (i = 0, internal = filedata->section_headers; + i < num; + i++, internal++) + { + internal->sh_name = BYTE_GET (shdrs[i].sh_name); + internal->sh_type = BYTE_GET (shdrs[i].sh_type); + internal->sh_flags = BYTE_GET (shdrs[i].sh_flags); + internal->sh_addr = BYTE_GET (shdrs[i].sh_addr); + internal->sh_size = BYTE_GET (shdrs[i].sh_size); + internal->sh_entsize = BYTE_GET (shdrs[i].sh_entsize); + internal->sh_link = BYTE_GET (shdrs[i].sh_link); + internal->sh_info = BYTE_GET (shdrs[i].sh_info); + internal->sh_offset = BYTE_GET (shdrs[i].sh_offset); + internal->sh_addralign = BYTE_GET (shdrs[i].sh_addralign); + if (!probe && internal->sh_link > num) + warn (_("Section %u has an out of range sh_link value of %u\n"), i, internal->sh_link); + if (!probe && internal->sh_flags & SHF_INFO_LINK && internal->sh_info > num) + warn (_("Section %u has an out of range sh_info value of %u\n"), i, internal->sh_info); + } + + free (shdrs); + return TRUE; +} + +static Elf_Internal_Sym * +get_32bit_elf_symbols (Filedata * filedata, + Elf_Internal_Shdr * section, + unsigned long * num_syms_return) +{ + unsigned long number = 0; + Elf32_External_Sym * esyms = NULL; + Elf_External_Sym_Shndx * shndx = NULL; + Elf_Internal_Sym * isyms = NULL; + Elf_Internal_Sym * psym; + unsigned int j; + + if (section->sh_size == 0) + { + if (num_syms_return != NULL) + * num_syms_return = 0; + return NULL; + } + + /* Run some sanity checks first. */ + if (section->sh_entsize == 0 || section->sh_entsize > section->sh_size) + { + error (_("Section %s has an invalid sh_entsize of 0x%lx\n"), + printable_section_name (filedata, section), + (unsigned long) section->sh_entsize); + goto exit_point; + } + + if (section->sh_size > filedata->file_size) + { + error (_("Section %s has an invalid sh_size of 0x%lx\n"), + printable_section_name (filedata, section), + (unsigned long) section->sh_size); + goto exit_point; + } + + number = section->sh_size / section->sh_entsize; + + if (number * sizeof (Elf32_External_Sym) > section->sh_size + 1) + { + error (_("Size (0x%lx) of section %s is not a multiple of its sh_entsize (0x%lx)\n"), + (unsigned long) section->sh_size, + printable_section_name (filedata, section), + (unsigned long) section->sh_entsize); + goto exit_point; + } + + esyms = (Elf32_External_Sym *) get_data (NULL, filedata, section->sh_offset, 1, + section->sh_size, _("symbols")); + if (esyms == NULL) + goto exit_point; + + { + elf_section_list * entry; + + shndx = NULL; + for (entry = symtab_shndx_list; entry != NULL; entry = entry->next) + if (entry->hdr->sh_link == (unsigned long) (section - filedata->section_headers)) + { + shndx = (Elf_External_Sym_Shndx *) get_data (NULL, filedata, + entry->hdr->sh_offset, + 1, entry->hdr->sh_size, + _("symbol table section indicies")); + if (shndx == NULL) + goto exit_point; + /* PR17531: file: heap-buffer-overflow */ + else if (entry->hdr->sh_size / sizeof (Elf_External_Sym_Shndx) < number) + { + error (_("Index section %s has an sh_size of 0x%lx - expected 0x%lx\n"), + printable_section_name (filedata, entry->hdr), + (unsigned long) entry->hdr->sh_size, + (unsigned long) section->sh_size); + goto exit_point; + } + } + } + + isyms = (Elf_Internal_Sym *) cmalloc (number, sizeof (Elf_Internal_Sym)); + + if (isyms == NULL) + { + error (_("Out of memory reading %lu symbols\n"), + (unsigned long) number); + goto exit_point; + } + + for (j = 0, psym = isyms; j < number; j++, psym++) + { + psym->st_name = BYTE_GET (esyms[j].st_name); + psym->st_value = BYTE_GET (esyms[j].st_value); + psym->st_size = BYTE_GET (esyms[j].st_size); + psym->st_shndx = BYTE_GET (esyms[j].st_shndx); + if (psym->st_shndx == (SHN_XINDEX & 0xffff) && shndx != NULL) + psym->st_shndx + = byte_get ((unsigned char *) &shndx[j], sizeof (shndx[j])); + else if (psym->st_shndx >= (SHN_LORESERVE & 0xffff)) + psym->st_shndx += SHN_LORESERVE - (SHN_LORESERVE & 0xffff); + psym->st_info = BYTE_GET (esyms[j].st_info); + psym->st_other = BYTE_GET (esyms[j].st_other); + } + + exit_point: + if (shndx != NULL) + free (shndx); + if (esyms != NULL) + free (esyms); + + if (num_syms_return != NULL) + * num_syms_return = isyms == NULL ? 0 : number; + + return isyms; +} + +static Elf_Internal_Sym * +get_64bit_elf_symbols (Filedata * filedata, + Elf_Internal_Shdr * section, + unsigned long * num_syms_return) +{ + unsigned long number = 0; + Elf64_External_Sym * esyms = NULL; + Elf_External_Sym_Shndx * shndx = NULL; + Elf_Internal_Sym * isyms = NULL; + Elf_Internal_Sym * psym; + unsigned int j; + + if (section->sh_size == 0) + { + if (num_syms_return != NULL) + * num_syms_return = 0; + return NULL; + } + + /* Run some sanity checks first. */ + if (section->sh_entsize == 0 || section->sh_entsize > section->sh_size) + { + error (_("Section %s has an invalid sh_entsize of 0x%lx\n"), + printable_section_name (filedata, section), + (unsigned long) section->sh_entsize); + goto exit_point; + } + + if (section->sh_size > filedata->file_size) + { + error (_("Section %s has an invalid sh_size of 0x%lx\n"), + printable_section_name (filedata, section), + (unsigned long) section->sh_size); + goto exit_point; + } + + number = section->sh_size / section->sh_entsize; + + if (number * sizeof (Elf64_External_Sym) > section->sh_size + 1) + { + error (_("Size (0x%lx) of section %s is not a multiple of its sh_entsize (0x%lx)\n"), + (unsigned long) section->sh_size, + printable_section_name (filedata, section), + (unsigned long) section->sh_entsize); + goto exit_point; + } + + esyms = (Elf64_External_Sym *) get_data (NULL, filedata, section->sh_offset, 1, + section->sh_size, _("symbols")); + if (!esyms) + goto exit_point; + + { + elf_section_list * entry; + + shndx = NULL; + for (entry = symtab_shndx_list; entry != NULL; entry = entry->next) + if (entry->hdr->sh_link == (unsigned long) (section - filedata->section_headers)) + { + shndx = (Elf_External_Sym_Shndx *) get_data (NULL, filedata, + entry->hdr->sh_offset, + 1, entry->hdr->sh_size, + _("symbol table section indicies")); + if (shndx == NULL) + goto exit_point; + /* PR17531: file: heap-buffer-overflow */ + else if (entry->hdr->sh_size / sizeof (Elf_External_Sym_Shndx) < number) + { + error (_("Index section %s has an sh_size of 0x%lx - expected 0x%lx\n"), + printable_section_name (filedata, entry->hdr), + (unsigned long) entry->hdr->sh_size, + (unsigned long) section->sh_size); + goto exit_point; + } + } + } + + isyms = (Elf_Internal_Sym *) cmalloc (number, sizeof (Elf_Internal_Sym)); + + if (isyms == NULL) + { + error (_("Out of memory reading %lu symbols\n"), + (unsigned long) number); + goto exit_point; + } + + for (j = 0, psym = isyms; j < number; j++, psym++) + { + psym->st_name = BYTE_GET (esyms[j].st_name); + psym->st_info = BYTE_GET (esyms[j].st_info); + psym->st_other = BYTE_GET (esyms[j].st_other); + psym->st_shndx = BYTE_GET (esyms[j].st_shndx); + + if (psym->st_shndx == (SHN_XINDEX & 0xffff) && shndx != NULL) + psym->st_shndx + = byte_get ((unsigned char *) &shndx[j], sizeof (shndx[j])); + else if (psym->st_shndx >= (SHN_LORESERVE & 0xffff)) + psym->st_shndx += SHN_LORESERVE - (SHN_LORESERVE & 0xffff); + + psym->st_value = BYTE_GET (esyms[j].st_value); + psym->st_size = BYTE_GET (esyms[j].st_size); + } + + exit_point: + if (shndx != NULL) + free (shndx); + if (esyms != NULL) + free (esyms); + + if (num_syms_return != NULL) + * num_syms_return = isyms == NULL ? 0 : number; + + return isyms; +} + +static const char * +get_elf_section_flags (Filedata * filedata, bfd_vma sh_flags) +{ + static char buff[1024]; + char * p = buff; + unsigned int field_size = is_32bit_elf ? 8 : 16; + signed int sindex; + unsigned int size = sizeof (buff) - (field_size + 4 + 1); + bfd_vma os_flags = 0; + bfd_vma proc_flags = 0; + bfd_vma unknown_flags = 0; + static const struct + { + const char * str; + unsigned int len; + } + flags [] = + { + /* 0 */ { STRING_COMMA_LEN ("WRITE") }, + /* 1 */ { STRING_COMMA_LEN ("ALLOC") }, + /* 2 */ { STRING_COMMA_LEN ("EXEC") }, + /* 3 */ { STRING_COMMA_LEN ("MERGE") }, + /* 4 */ { STRING_COMMA_LEN ("STRINGS") }, + /* 5 */ { STRING_COMMA_LEN ("INFO LINK") }, + /* 6 */ { STRING_COMMA_LEN ("LINK ORDER") }, + /* 7 */ { STRING_COMMA_LEN ("OS NONCONF") }, + /* 8 */ { STRING_COMMA_LEN ("GROUP") }, + /* 9 */ { STRING_COMMA_LEN ("TLS") }, + /* IA-64 specific. */ + /* 10 */ { STRING_COMMA_LEN ("SHORT") }, + /* 11 */ { STRING_COMMA_LEN ("NORECOV") }, + /* IA-64 OpenVMS specific. */ + /* 12 */ { STRING_COMMA_LEN ("VMS_GLOBAL") }, + /* 13 */ { STRING_COMMA_LEN ("VMS_OVERLAID") }, + /* 14 */ { STRING_COMMA_LEN ("VMS_SHARED") }, + /* 15 */ { STRING_COMMA_LEN ("VMS_VECTOR") }, + /* 16 */ { STRING_COMMA_LEN ("VMS_ALLOC_64BIT") }, + /* 17 */ { STRING_COMMA_LEN ("VMS_PROTECTED") }, + /* Generic. */ + /* 18 */ { STRING_COMMA_LEN ("EXCLUDE") }, + /* SPARC specific. */ + /* 19 */ { STRING_COMMA_LEN ("ORDERED") }, + /* 20 */ { STRING_COMMA_LEN ("COMPRESSED") }, + /* ARM specific. */ + /* 21 */ { STRING_COMMA_LEN ("ENTRYSECT") }, + /* 22 */ { STRING_COMMA_LEN ("ARM_PURECODE") }, + /* 23 */ { STRING_COMMA_LEN ("COMDEF") }, + /* GNU specific. */ + /* 24 */ { STRING_COMMA_LEN ("GNU_MBIND") }, + /* VLE specific. */ + /* 25 */ { STRING_COMMA_LEN ("VLE") }, + }; + + if (do_section_details) + { + sprintf (buff, "[%*.*lx]: ", + field_size, field_size, (unsigned long) sh_flags); + p += field_size + 4; + } + + while (sh_flags) + { + bfd_vma flag; + + flag = sh_flags & - sh_flags; + sh_flags &= ~ flag; + + if (do_section_details) + { + switch (flag) + { + case SHF_WRITE: sindex = 0; break; + case SHF_ALLOC: sindex = 1; break; + case SHF_EXECINSTR: sindex = 2; break; + case SHF_MERGE: sindex = 3; break; + case SHF_STRINGS: sindex = 4; break; + case SHF_INFO_LINK: sindex = 5; break; + case SHF_LINK_ORDER: sindex = 6; break; + case SHF_OS_NONCONFORMING: sindex = 7; break; + case SHF_GROUP: sindex = 8; break; + case SHF_TLS: sindex = 9; break; + case SHF_EXCLUDE: sindex = 18; break; + case SHF_COMPRESSED: sindex = 20; break; + case SHF_GNU_MBIND: sindex = 24; break; + + default: + sindex = -1; + switch (filedata->file_header.e_machine) + { + case EM_IA_64: + if (flag == SHF_IA_64_SHORT) + sindex = 10; + else if (flag == SHF_IA_64_NORECOV) + sindex = 11; +#ifdef BFD64 + else if (filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_OPENVMS) + switch (flag) + { + case SHF_IA_64_VMS_GLOBAL: sindex = 12; break; + case SHF_IA_64_VMS_OVERLAID: sindex = 13; break; + case SHF_IA_64_VMS_SHARED: sindex = 14; break; + case SHF_IA_64_VMS_VECTOR: sindex = 15; break; + case SHF_IA_64_VMS_ALLOC_64BIT: sindex = 16; break; + case SHF_IA_64_VMS_PROTECTED: sindex = 17; break; + default: break; + } +#endif + break; + + case EM_386: + case EM_IAMCU: + case EM_X86_64: + case EM_L1OM: + case EM_K1OM: + case EM_OLD_SPARCV9: + case EM_SPARC32PLUS: + case EM_SPARCV9: + case EM_SPARC: + if (flag == SHF_ORDERED) + sindex = 19; + break; + + case EM_ARM: + switch (flag) + { + case SHF_ENTRYSECT: sindex = 21; break; + case SHF_ARM_PURECODE: sindex = 22; break; + case SHF_COMDEF: sindex = 23; break; + default: break; + } + break; + case EM_PPC: + if (flag == SHF_PPC_VLE) + sindex = 25; + break; + + default: + break; + } + } + + if (sindex != -1) + { + if (p != buff + field_size + 4) + { + if (size < (10 + 2)) + { + warn (_("Internal error: not enough buffer room for section flag info")); + return _(""); + } + size -= 2; + *p++ = ','; + *p++ = ' '; + } + + size -= flags [sindex].len; + p = stpcpy (p, flags [sindex].str); + } + else if (flag & SHF_MASKOS) + os_flags |= flag; + else if (flag & SHF_MASKPROC) + proc_flags |= flag; + else + unknown_flags |= flag; + } + else + { + switch (flag) + { + case SHF_WRITE: *p = 'W'; break; + case SHF_ALLOC: *p = 'A'; break; + case SHF_EXECINSTR: *p = 'X'; break; + case SHF_MERGE: *p = 'M'; break; + case SHF_STRINGS: *p = 'S'; break; + case SHF_INFO_LINK: *p = 'I'; break; + case SHF_LINK_ORDER: *p = 'L'; break; + case SHF_OS_NONCONFORMING: *p = 'O'; break; + case SHF_GROUP: *p = 'G'; break; + case SHF_TLS: *p = 'T'; break; + case SHF_EXCLUDE: *p = 'E'; break; + case SHF_COMPRESSED: *p = 'C'; break; + case SHF_GNU_MBIND: *p = 'D'; break; + + default: + if ((filedata->file_header.e_machine == EM_X86_64 + || filedata->file_header.e_machine == EM_L1OM + || filedata->file_header.e_machine == EM_K1OM) + && flag == SHF_X86_64_LARGE) + *p = 'l'; + else if (filedata->file_header.e_machine == EM_ARM + && flag == SHF_ARM_PURECODE) + *p = 'y'; + else if (filedata->file_header.e_machine == EM_PPC + && flag == SHF_PPC_VLE) + *p = 'v'; + else if (flag & SHF_MASKOS) + { + *p = 'o'; + sh_flags &= ~ SHF_MASKOS; + } + else if (flag & SHF_MASKPROC) + { + *p = 'p'; + sh_flags &= ~ SHF_MASKPROC; + } + else + *p = 'x'; + break; + } + p++; + } + } + + if (do_section_details) + { + if (os_flags) + { + size -= 5 + field_size; + if (p != buff + field_size + 4) + { + if (size < (2 + 1)) + { + warn (_("Internal error: not enough buffer room for section flag info")); + return _(""); + } + size -= 2; + *p++ = ','; + *p++ = ' '; + } + sprintf (p, "OS (%*.*lx)", field_size, field_size, + (unsigned long) os_flags); + p += 5 + field_size; + } + if (proc_flags) + { + size -= 7 + field_size; + if (p != buff + field_size + 4) + { + if (size < (2 + 1)) + { + warn (_("Internal error: not enough buffer room for section flag info")); + return _(""); + } + size -= 2; + *p++ = ','; + *p++ = ' '; + } + sprintf (p, "PROC (%*.*lx)", field_size, field_size, + (unsigned long) proc_flags); + p += 7 + field_size; + } + if (unknown_flags) + { + size -= 10 + field_size; + if (p != buff + field_size + 4) + { + if (size < (2 + 1)) + { + warn (_("Internal error: not enough buffer room for section flag info")); + return _(""); + } + size -= 2; + *p++ = ','; + *p++ = ' '; + } + sprintf (p, _("UNKNOWN (%*.*lx)"), field_size, field_size, + (unsigned long) unknown_flags); + p += 10 + field_size; + } + } + + *p = '\0'; + return buff; +} + +static unsigned int +get_compression_header (Elf_Internal_Chdr *chdr, unsigned char *buf, bfd_size_type size) +{ + if (is_32bit_elf) + { + Elf32_External_Chdr *echdr = (Elf32_External_Chdr *) buf; + + if (size < sizeof (* echdr)) + { + error (_("Compressed section is too small even for a compression header\n")); + return 0; + } + + chdr->ch_type = BYTE_GET (echdr->ch_type); + chdr->ch_size = BYTE_GET (echdr->ch_size); + chdr->ch_addralign = BYTE_GET (echdr->ch_addralign); + return sizeof (*echdr); + } + else + { + Elf64_External_Chdr *echdr = (Elf64_External_Chdr *) buf; + + if (size < sizeof (* echdr)) + { + error (_("Compressed section is too small even for a compression header\n")); + return 0; + } + + chdr->ch_type = BYTE_GET (echdr->ch_type); + chdr->ch_size = BYTE_GET (echdr->ch_size); + chdr->ch_addralign = BYTE_GET (echdr->ch_addralign); + return sizeof (*echdr); + } +} + +static bfd_boolean +process_section_headers (Filedata * filedata) +{ + Elf_Internal_Shdr * section; + unsigned int i; + + filedata->section_headers = NULL; + + if (filedata->file_header.e_shnum == 0) + { + /* PR binutils/12467. */ + if (filedata->file_header.e_shoff != 0) + { + warn (_("possibly corrupt ELF file header - it has a non-zero" + " section header offset, but no section headers\n")); + return FALSE; + } + else if (do_sections) + printf (_("\nThere are no sections in this file.\n")); + + return TRUE; + } + + if (do_sections && !do_header) + printf (ngettext ("There is %d section header, " + "starting at offset 0x%lx:\n", + "There are %d section headers, " + "starting at offset 0x%lx:\n", + filedata->file_header.e_shnum), + filedata->file_header.e_shnum, + (unsigned long) filedata->file_header.e_shoff); + + if (is_32bit_elf) + { + if (! get_32bit_section_headers (filedata, FALSE)) + return FALSE; + } + else + { + if (! get_64bit_section_headers (filedata, FALSE)) + return FALSE; + } + + /* Read in the string table, so that we have names to display. */ + if (filedata->file_header.e_shstrndx != SHN_UNDEF + && filedata->file_header.e_shstrndx < filedata->file_header.e_shnum) + { + section = filedata->section_headers + filedata->file_header.e_shstrndx; + + if (section->sh_size != 0) + { + filedata->string_table = (char *) get_data (NULL, filedata, section->sh_offset, + 1, section->sh_size, + _("string table")); + + filedata->string_table_length = filedata->string_table != NULL ? section->sh_size : 0; + } + } + + /* Scan the sections for the dynamic symbol table + and dynamic string table and debug sections. */ + dynamic_symbols = NULL; + dynamic_strings = NULL; + dynamic_syminfo = NULL; + symtab_shndx_list = NULL; + + eh_addr_size = is_32bit_elf ? 4 : 8; + switch (filedata->file_header.e_machine) + { + case EM_MIPS: + case EM_MIPS_RS3_LE: + /* The 64-bit MIPS EABI uses a combination of 32-bit ELF and 64-bit + FDE addresses. However, the ABI also has a semi-official ILP32 + variant for which the normal FDE address size rules apply. + + GCC 4.0 marks EABI64 objects with a dummy .gcc_compiled_longXX + section, where XX is the size of longs in bits. Unfortunately, + earlier compilers provided no way of distinguishing ILP32 objects + from LP64 objects, so if there's any doubt, we should assume that + the official LP64 form is being used. */ + if ((filedata->file_header.e_flags & EF_MIPS_ABI) == E_MIPS_ABI_EABI64 + && find_section (filedata, ".gcc_compiled_long32") == NULL) + eh_addr_size = 8; + break; + + case EM_H8_300: + case EM_H8_300H: + switch (filedata->file_header.e_flags & EF_H8_MACH) + { + case E_H8_MACH_H8300: + case E_H8_MACH_H8300HN: + case E_H8_MACH_H8300SN: + case E_H8_MACH_H8300SXN: + eh_addr_size = 2; + break; + case E_H8_MACH_H8300H: + case E_H8_MACH_H8300S: + case E_H8_MACH_H8300SX: + eh_addr_size = 4; + break; + } + break; + + case EM_M32C_OLD: + case EM_M32C: + switch (filedata->file_header.e_flags & EF_M32C_CPU_MASK) + { + case EF_M32C_CPU_M16C: + eh_addr_size = 2; + break; + } + break; + } + +#define CHECK_ENTSIZE_VALUES(section, i, size32, size64) \ + do \ + { \ + bfd_size_type expected_entsize = is_32bit_elf ? size32 : size64; \ + if (section->sh_entsize != expected_entsize) \ + { \ + char buf[40]; \ + sprintf_vma (buf, section->sh_entsize); \ + /* Note: coded this way so that there is a single string for \ + translation. */ \ + error (_("Section %d has invalid sh_entsize of %s\n"), i, buf); \ + error (_("(Using the expected size of %u for the rest of this dump)\n"), \ + (unsigned) expected_entsize); \ + section->sh_entsize = expected_entsize; \ + } \ + } \ + while (0) + +#define CHECK_ENTSIZE(section, i, type) \ + CHECK_ENTSIZE_VALUES (section, i, sizeof (Elf32_External_##type), \ + sizeof (Elf64_External_##type)) + + for (i = 0, section = filedata->section_headers; + i < filedata->file_header.e_shnum; + i++, section++) + { + char * name = SECTION_NAME (section); + + if (section->sh_type == SHT_DYNSYM) + { + if (dynamic_symbols != NULL) + { + error (_("File contains multiple dynamic symbol tables\n")); + continue; + } + + CHECK_ENTSIZE (section, i, Sym); + dynamic_symbols = GET_ELF_SYMBOLS (filedata, section, & num_dynamic_syms); + } + else if (section->sh_type == SHT_STRTAB + && streq (name, ".dynstr")) + { + if (dynamic_strings != NULL) + { + error (_("File contains multiple dynamic string tables\n")); + continue; + } + + dynamic_strings = (char *) get_data (NULL, filedata, section->sh_offset, + 1, section->sh_size, + _("dynamic strings")); + dynamic_strings_length = dynamic_strings == NULL ? 0 : section->sh_size; + } + else if (section->sh_type == SHT_SYMTAB_SHNDX) + { + elf_section_list * entry = xmalloc (sizeof * entry); + + entry->hdr = section; + entry->next = symtab_shndx_list; + symtab_shndx_list = entry; + } + else if (section->sh_type == SHT_SYMTAB) + CHECK_ENTSIZE (section, i, Sym); + else if (section->sh_type == SHT_GROUP) + CHECK_ENTSIZE_VALUES (section, i, GRP_ENTRY_SIZE, GRP_ENTRY_SIZE); + else if (section->sh_type == SHT_REL) + CHECK_ENTSIZE (section, i, Rel); + else if (section->sh_type == SHT_RELA) + CHECK_ENTSIZE (section, i, Rela); + else if ((do_debugging || do_debug_info || do_debug_abbrevs + || do_debug_lines || do_debug_pubnames || do_debug_pubtypes + || do_debug_aranges || do_debug_frames || do_debug_macinfo + || do_debug_str || do_debug_loc || do_debug_ranges + || do_debug_addr || do_debug_cu_index || do_debug_links) + && (const_strneq (name, ".debug_") + || const_strneq (name, ".zdebug_"))) + { + if (name[1] == 'z') + name += sizeof (".zdebug_") - 1; + else + name += sizeof (".debug_") - 1; + + if (do_debugging + || (do_debug_info && const_strneq (name, "info")) + || (do_debug_info && const_strneq (name, "types")) + || (do_debug_abbrevs && const_strneq (name, "abbrev")) + || (do_debug_lines && strcmp (name, "line") == 0) + || (do_debug_lines && const_strneq (name, "line.")) + || (do_debug_pubnames && const_strneq (name, "pubnames")) + || (do_debug_pubtypes && const_strneq (name, "pubtypes")) + || (do_debug_pubnames && const_strneq (name, "gnu_pubnames")) + || (do_debug_pubtypes && const_strneq (name, "gnu_pubtypes")) + || (do_debug_aranges && const_strneq (name, "aranges")) + || (do_debug_ranges && const_strneq (name, "ranges")) + || (do_debug_ranges && const_strneq (name, "rnglists")) + || (do_debug_frames && const_strneq (name, "frame")) + || (do_debug_macinfo && const_strneq (name, "macinfo")) + || (do_debug_macinfo && const_strneq (name, "macro")) + || (do_debug_str && const_strneq (name, "str")) + || (do_debug_loc && const_strneq (name, "loc")) + || (do_debug_loc && const_strneq (name, "loclists")) + || (do_debug_addr && const_strneq (name, "addr")) + || (do_debug_cu_index && const_strneq (name, "cu_index")) + || (do_debug_cu_index && const_strneq (name, "tu_index")) + ) + request_dump_bynumber (filedata, i, DEBUG_DUMP); + } + /* Linkonce section to be combined with .debug_info at link time. */ + else if ((do_debugging || do_debug_info) + && const_strneq (name, ".gnu.linkonce.wi.")) + request_dump_bynumber (filedata, i, DEBUG_DUMP); + else if (do_debug_frames && streq (name, ".eh_frame")) + request_dump_bynumber (filedata, i, DEBUG_DUMP); + else if (do_gdb_index && (streq (name, ".gdb_index") + || streq (name, ".debug_names"))) + request_dump_bynumber (filedata, i, DEBUG_DUMP); + /* Trace sections for Itanium VMS. */ + else if ((do_debugging || do_trace_info || do_trace_abbrevs + || do_trace_aranges) + && const_strneq (name, ".trace_")) + { + name += sizeof (".trace_") - 1; + + if (do_debugging + || (do_trace_info && streq (name, "info")) + || (do_trace_abbrevs && streq (name, "abbrev")) + || (do_trace_aranges && streq (name, "aranges")) + ) + request_dump_bynumber (filedata, i, DEBUG_DUMP); + } + else if ((do_debugging || do_debug_links) + && (const_strneq (name, ".gnu_debuglink") + || const_strneq (name, ".gnu_debugaltlink"))) + request_dump_bynumber (filedata, i, DEBUG_DUMP); + } + + if (! do_sections) + return TRUE; + + if (filedata->file_header.e_shnum > 1) + printf (_("\nSection Headers:\n")); + else + printf (_("\nSection Header:\n")); + + if (is_32bit_elf) + { + if (do_section_details) + { + printf (_(" [Nr] Name\n")); + printf (_(" Type Addr Off Size ES Lk Inf Al\n")); + } + else + printf + (_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n")); + } + else if (do_wide) + { + if (do_section_details) + { + printf (_(" [Nr] Name\n")); + printf (_(" Type Address Off Size ES Lk Inf Al\n")); + } + else + printf + (_(" [Nr] Name Type Address Off Size ES Flg Lk Inf Al\n")); + } + else + { + if (do_section_details) + { + printf (_(" [Nr] Name\n")); + printf (_(" Type Address Offset Link\n")); + printf (_(" Size EntSize Info Align\n")); + } + else + { + printf (_(" [Nr] Name Type Address Offset\n")); + printf (_(" Size EntSize Flags Link Info Align\n")); + } + } + + if (do_section_details) + printf (_(" Flags\n")); + + for (i = 0, section = filedata->section_headers; + i < filedata->file_header.e_shnum; + i++, section++) + { + /* Run some sanity checks on the section header. */ + + /* Check the sh_link field. */ + switch (section->sh_type) + { + case SHT_SYMTAB_SHNDX: + case SHT_GROUP: + case SHT_HASH: + case SHT_GNU_HASH: + case SHT_GNU_versym: + case SHT_REL: + case SHT_RELA: + if (section->sh_link < 1 + || section->sh_link >= filedata->file_header.e_shnum + || (filedata->section_headers[section->sh_link].sh_type != SHT_SYMTAB + && filedata->section_headers[section->sh_link].sh_type != SHT_DYNSYM)) + warn (_("[%2u]: Link field (%u) should index a symtab section.\n"), + i, section->sh_link); + break; + + case SHT_DYNAMIC: + case SHT_SYMTAB: + case SHT_DYNSYM: + case SHT_GNU_verneed: + case SHT_GNU_verdef: + case SHT_GNU_LIBLIST: + if (section->sh_link < 1 + || section->sh_link >= filedata->file_header.e_shnum + || filedata->section_headers[section->sh_link].sh_type != SHT_STRTAB) + warn (_("[%2u]: Link field (%u) should index a string section.\n"), + i, section->sh_link); + break; + + case SHT_INIT_ARRAY: + case SHT_FINI_ARRAY: + case SHT_PREINIT_ARRAY: + if (section->sh_type < SHT_LOOS && section->sh_link != 0) + warn (_("[%2u]: Unexpected value (%u) in link field.\n"), + i, section->sh_link); + break; + + default: + /* FIXME: Add support for target specific section types. */ +#if 0 /* Currently we do not check other section types as there are too + many special cases. Stab sections for example have a type + of SHT_PROGBITS but an sh_link field that links to the .stabstr + section. */ + if (section->sh_type < SHT_LOOS && section->sh_link != 0) + warn (_("[%2u]: Unexpected value (%u) in link field.\n"), + i, section->sh_link); +#endif + break; + } + + /* Check the sh_info field. */ + switch (section->sh_type) + { + case SHT_REL: + case SHT_RELA: + if (section->sh_info < 1 + || section->sh_info >= filedata->file_header.e_shnum + || (filedata->section_headers[section->sh_info].sh_type != SHT_PROGBITS + && filedata->section_headers[section->sh_info].sh_type != SHT_NOBITS + && filedata->section_headers[section->sh_info].sh_type != SHT_NOTE + && filedata->section_headers[section->sh_info].sh_type != SHT_INIT_ARRAY + /* FIXME: Are other section types valid ? */ + && filedata->section_headers[section->sh_info].sh_type < SHT_LOOS)) + { + if (section->sh_info == 0 + && (filedata->file_header.e_type == ET_EXEC + || filedata->file_header.e_type == ET_DYN + /* These next two tests may be redundant, but + they have been left in for paranoia's sake. */ + || streq (SECTION_NAME (section), ".rel.dyn") + || streq (SECTION_NAME (section), ".rela.dyn"))) + /* Dynamic relocations apply to segments, not sections, so + they do not need an sh_info value. */ + ; + else + warn (_("[%2u]: Info field (%u) should index a relocatable section.\n"), + i, section->sh_info); + } + break; + + case SHT_DYNAMIC: + case SHT_HASH: + case SHT_SYMTAB_SHNDX: + case SHT_INIT_ARRAY: + case SHT_FINI_ARRAY: + case SHT_PREINIT_ARRAY: + if (section->sh_info != 0) + warn (_("[%2u]: Unexpected value (%u) in info field.\n"), + i, section->sh_info); + break; + + case SHT_GROUP: + case SHT_SYMTAB: + case SHT_DYNSYM: + /* A symbol index - we assume that it is valid. */ + break; + + default: + /* FIXME: Add support for target specific section types. */ + if (section->sh_type == SHT_NOBITS) + /* NOBITS section headers with non-zero sh_info fields can be + created when a binary is stripped of everything but its debug + information. The stripped sections have their headers + preserved but their types set to SHT_NOBITS. So do not check + this type of section. */ + ; + else if (section->sh_flags & SHF_INFO_LINK) + { + if (section->sh_info < 1 || section->sh_info >= filedata->file_header.e_shnum) + warn (_("[%2u]: Expected link to another section in info field"), i); + } + else if (section->sh_type < SHT_LOOS + && (section->sh_flags & SHF_GNU_MBIND) == 0 + && section->sh_info != 0) + warn (_("[%2u]: Unexpected value (%u) in info field.\n"), + i, section->sh_info); + break; + } + + /* Check the sh_size field. */ + if (section->sh_size > filedata->file_size + && section->sh_type != SHT_NOBITS + && section->sh_type != SHT_NULL + && section->sh_type < SHT_LOOS) + warn (_("Size of section %u is larger than the entire file!\n"), i); + + printf (" [%2u] ", i); + if (do_section_details) + printf ("%s\n ", printable_section_name (filedata, section)); + else + print_symbol (-17, SECTION_NAME (section)); + + printf (do_wide ? " %-15s " : " %-15.15s ", + get_section_type_name (filedata, section->sh_type)); + + if (is_32bit_elf) + { + const char * link_too_big = NULL; + + print_vma (section->sh_addr, LONG_HEX); + + printf ( " %6.6lx %6.6lx %2.2lx", + (unsigned long) section->sh_offset, + (unsigned long) section->sh_size, + (unsigned long) section->sh_entsize); + + if (do_section_details) + fputs (" ", stdout); + else + printf (" %3s ", get_elf_section_flags (filedata, section->sh_flags)); + + if (section->sh_link >= filedata->file_header.e_shnum) + { + link_too_big = ""; + /* The sh_link value is out of range. Normally this indicates + an error but it can have special values in Solaris binaries. */ + switch (filedata->file_header.e_machine) + { + case EM_386: + case EM_IAMCU: + case EM_X86_64: + case EM_L1OM: + case EM_K1OM: + case EM_OLD_SPARCV9: + case EM_SPARC32PLUS: + case EM_SPARCV9: + case EM_SPARC: + if (section->sh_link == (SHN_BEFORE & 0xffff)) + link_too_big = "BEFORE"; + else if (section->sh_link == (SHN_AFTER & 0xffff)) + link_too_big = "AFTER"; + break; + default: + break; + } + } + + if (do_section_details) + { + if (link_too_big != NULL && * link_too_big) + printf ("<%s> ", link_too_big); + else + printf ("%2u ", section->sh_link); + printf ("%3u %2lu\n", section->sh_info, + (unsigned long) section->sh_addralign); + } + else + printf ("%2u %3u %2lu\n", + section->sh_link, + section->sh_info, + (unsigned long) section->sh_addralign); + + if (link_too_big && ! * link_too_big) + warn (_("section %u: sh_link value of %u is larger than the number of sections\n"), + i, section->sh_link); + } + else if (do_wide) + { + print_vma (section->sh_addr, LONG_HEX); + + if ((long) section->sh_offset == section->sh_offset) + printf (" %6.6lx", (unsigned long) section->sh_offset); + else + { + putchar (' '); + print_vma (section->sh_offset, LONG_HEX); + } + + if ((unsigned long) section->sh_size == section->sh_size) + printf (" %6.6lx", (unsigned long) section->sh_size); + else + { + putchar (' '); + print_vma (section->sh_size, LONG_HEX); + } + + if ((unsigned long) section->sh_entsize == section->sh_entsize) + printf (" %2.2lx", (unsigned long) section->sh_entsize); + else + { + putchar (' '); + print_vma (section->sh_entsize, LONG_HEX); + } + + if (do_section_details) + fputs (" ", stdout); + else + printf (" %3s ", get_elf_section_flags (filedata, section->sh_flags)); + + printf ("%2u %3u ", section->sh_link, section->sh_info); + + if ((unsigned long) section->sh_addralign == section->sh_addralign) + printf ("%2lu\n", (unsigned long) section->sh_addralign); + else + { + print_vma (section->sh_addralign, DEC); + putchar ('\n'); + } + } + else if (do_section_details) + { + printf (" %-15.15s ", + get_section_type_name (filedata, section->sh_type)); + print_vma (section->sh_addr, LONG_HEX); + if ((long) section->sh_offset == section->sh_offset) + printf (" %16.16lx", (unsigned long) section->sh_offset); + else + { + printf (" "); + print_vma (section->sh_offset, LONG_HEX); + } + printf (" %u\n ", section->sh_link); + print_vma (section->sh_size, LONG_HEX); + putchar (' '); + print_vma (section->sh_entsize, LONG_HEX); + + printf (" %-16u %lu\n", + section->sh_info, + (unsigned long) section->sh_addralign); + } + else + { + putchar (' '); + print_vma (section->sh_addr, LONG_HEX); + if ((long) section->sh_offset == section->sh_offset) + printf (" %8.8lx", (unsigned long) section->sh_offset); + else + { + printf (" "); + print_vma (section->sh_offset, LONG_HEX); + } + printf ("\n "); + print_vma (section->sh_size, LONG_HEX); + printf (" "); + print_vma (section->sh_entsize, LONG_HEX); + + printf (" %3s ", get_elf_section_flags (filedata, section->sh_flags)); + + printf (" %2u %3u %lu\n", + section->sh_link, + section->sh_info, + (unsigned long) section->sh_addralign); + } + + if (do_section_details) + { + printf (" %s\n", get_elf_section_flags (filedata, section->sh_flags)); + if ((section->sh_flags & SHF_COMPRESSED) != 0) + { + /* Minimum section size is 12 bytes for 32-bit compression + header + 12 bytes for compressed data header. */ + unsigned char buf[24]; + + assert (sizeof (buf) >= sizeof (Elf64_External_Chdr)); + if (get_data (&buf, filedata, section->sh_offset, 1, + sizeof (buf), _("compression header"))) + { + Elf_Internal_Chdr chdr; + + (void) get_compression_header (&chdr, buf, sizeof (buf)); + + if (chdr.ch_type == ELFCOMPRESS_ZLIB) + printf (" ZLIB, "); + else + printf (_(" [: 0x%x], "), + chdr.ch_type); + print_vma (chdr.ch_size, LONG_HEX); + printf (", %lu\n", (unsigned long) chdr.ch_addralign); + } + } + } + } + + if (!do_section_details) + { + /* The ordering of the letters shown here matches the ordering of the + corresponding SHF_xxx values, and hence the order in which these + letters will be displayed to the user. */ + printf (_("Key to Flags:\n\ + W (write), A (alloc), X (execute), M (merge), S (strings), I (info),\n\ + L (link order), O (extra OS processing required), G (group), T (TLS),\n\ + C (compressed), x (unknown), o (OS specific), E (exclude),\n ")); + if (filedata->file_header.e_machine == EM_X86_64 + || filedata->file_header.e_machine == EM_L1OM + || filedata->file_header.e_machine == EM_K1OM) + printf (_("l (large), ")); + else if (filedata->file_header.e_machine == EM_ARM) + printf (_("y (purecode), ")); + else if (filedata->file_header.e_machine == EM_PPC) + printf (_("v (VLE), ")); + printf ("p (processor specific)\n"); + } + + return TRUE; +} + +static const char * +get_group_flags (unsigned int flags) +{ + static char buff[128]; + + if (flags == 0) + return ""; + else if (flags == GRP_COMDAT) + return "COMDAT "; + + snprintf (buff, 14, _("[0x%x: "), flags); + + flags &= ~ GRP_COMDAT; + if (flags & GRP_MASKOS) + { + strcat (buff, ""); + flags &= ~ GRP_MASKOS; + } + + if (flags & GRP_MASKPROC) + { + strcat (buff, ""); + flags &= ~ GRP_MASKPROC; + } + + if (flags) + strcat (buff, ""); + + strcat (buff, "]"); + return buff; +} + +static bfd_boolean +process_section_groups (Filedata * filedata) +{ + Elf_Internal_Shdr * section; + unsigned int i; + struct group * group; + Elf_Internal_Shdr * symtab_sec; + Elf_Internal_Shdr * strtab_sec; + Elf_Internal_Sym * symtab; + unsigned long num_syms; + char * strtab; + size_t strtab_size; + + /* Don't process section groups unless needed. */ + if (!do_unwind && !do_section_groups) + return TRUE; + + if (filedata->file_header.e_shnum == 0) + { + if (do_section_groups) + printf (_("\nThere are no sections to group in this file.\n")); + + return TRUE; + } + + if (filedata->section_headers == NULL) + { + error (_("Section headers are not available!\n")); + /* PR 13622: This can happen with a corrupt ELF header. */ + return FALSE; + } + + section_headers_groups = (struct group **) calloc (filedata->file_header.e_shnum, + sizeof (struct group *)); + + if (section_headers_groups == NULL) + { + error (_("Out of memory reading %u section group headers\n"), + filedata->file_header.e_shnum); + return FALSE; + } + + /* Scan the sections for the group section. */ + group_count = 0; + for (i = 0, section = filedata->section_headers; + i < filedata->file_header.e_shnum; + i++, section++) + if (section->sh_type == SHT_GROUP) + group_count++; + + if (group_count == 0) + { + if (do_section_groups) + printf (_("\nThere are no section groups in this file.\n")); + + return TRUE; + } + + section_groups = (struct group *) calloc (group_count, sizeof (struct group)); + + if (section_groups == NULL) + { + error (_("Out of memory reading %lu groups\n"), + (unsigned long) group_count); + return FALSE; + } + + symtab_sec = NULL; + strtab_sec = NULL; + symtab = NULL; + num_syms = 0; + strtab = NULL; + strtab_size = 0; + for (i = 0, section = filedata->section_headers, group = section_groups; + i < filedata->file_header.e_shnum; + i++, section++) + { + if (section->sh_type == SHT_GROUP) + { + const char * name = printable_section_name (filedata, section); + const char * group_name; + unsigned char * start; + unsigned char * indices; + unsigned int entry, j, size; + Elf_Internal_Shdr * sec; + Elf_Internal_Sym * sym; + + /* Get the symbol table. */ + if (section->sh_link >= filedata->file_header.e_shnum + || ((sec = filedata->section_headers + section->sh_link)->sh_type + != SHT_SYMTAB)) + { + error (_("Bad sh_link in group section `%s'\n"), name); + continue; + } + + if (symtab_sec != sec) + { + symtab_sec = sec; + if (symtab) + free (symtab); + symtab = GET_ELF_SYMBOLS (filedata, symtab_sec, & num_syms); + } + + if (symtab == NULL) + { + error (_("Corrupt header in group section `%s'\n"), name); + continue; + } + + if (section->sh_info >= num_syms) + { + error (_("Bad sh_info in group section `%s'\n"), name); + continue; + } + + sym = symtab + section->sh_info; + + if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) + { + if (sym->st_shndx == 0 + || sym->st_shndx >= filedata->file_header.e_shnum) + { + error (_("Bad sh_info in group section `%s'\n"), name); + continue; + } + + group_name = SECTION_NAME (filedata->section_headers + sym->st_shndx); + strtab_sec = NULL; + if (strtab) + free (strtab); + strtab = NULL; + strtab_size = 0; + } + else + { + /* Get the string table. */ + if (symtab_sec->sh_link >= filedata->file_header.e_shnum) + { + strtab_sec = NULL; + if (strtab) + free (strtab); + strtab = NULL; + strtab_size = 0; + } + else if (strtab_sec + != (sec = filedata->section_headers + symtab_sec->sh_link)) + { + strtab_sec = sec; + if (strtab) + free (strtab); + + strtab = (char *) get_data (NULL, filedata, strtab_sec->sh_offset, + 1, strtab_sec->sh_size, + _("string table")); + strtab_size = strtab != NULL ? strtab_sec->sh_size : 0; + } + group_name = sym->st_name < strtab_size + ? strtab + sym->st_name : _(""); + } + + /* PR 17531: file: loop. */ + if (section->sh_entsize > section->sh_size) + { + error (_("Section %s has sh_entsize (0x%lx) which is larger than its size (0x%lx)\n"), + printable_section_name (filedata, section), + (unsigned long) section->sh_entsize, + (unsigned long) section->sh_size); + break; + } + + start = (unsigned char *) get_data (NULL, filedata, section->sh_offset, + 1, section->sh_size, + _("section data")); + if (start == NULL) + continue; + + indices = start; + size = (section->sh_size / section->sh_entsize) - 1; + entry = byte_get (indices, 4); + indices += 4; + + if (do_section_groups) + { + printf (_("\n%sgroup section [%5u] `%s' [%s] contains %u sections:\n"), + get_group_flags (entry), i, name, group_name, size); + + printf (_(" [Index] Name\n")); + } + + group->group_index = i; + + for (j = 0; j < size; j++) + { + struct group_list * g; + + entry = byte_get (indices, 4); + indices += 4; + + if (entry >= filedata->file_header.e_shnum) + { + static unsigned num_group_errors = 0; + + if (num_group_errors ++ < 10) + { + error (_("section [%5u] in group section [%5u] > maximum section [%5u]\n"), + entry, i, filedata->file_header.e_shnum - 1); + if (num_group_errors == 10) + warn (_("Further error messages about overlarge group section indicies suppressed\n")); + } + continue; + } + + if (section_headers_groups [entry] != NULL) + { + if (entry) + { + static unsigned num_errs = 0; + + if (num_errs ++ < 10) + { + error (_("section [%5u] in group section [%5u] already in group section [%5u]\n"), + entry, i, + section_headers_groups [entry]->group_index); + if (num_errs == 10) + warn (_("Further error messages about already contained group sections suppressed\n")); + } + continue; + } + else + { + /* Intel C/C++ compiler may put section 0 in a + section group. We just warn it the first time + and ignore it afterwards. */ + static bfd_boolean warned = FALSE; + if (!warned) + { + error (_("section 0 in group section [%5u]\n"), + section_headers_groups [entry]->group_index); + warned = TRUE; + } + } + } + + section_headers_groups [entry] = group; + + if (do_section_groups) + { + sec = filedata->section_headers + entry; + printf (" [%5u] %s\n", entry, printable_section_name (filedata, sec)); + } + + g = (struct group_list *) xmalloc (sizeof (struct group_list)); + g->section_index = entry; + g->next = group->root; + group->root = g; + } + + if (start) + free (start); + + group++; + } + } + + if (symtab) + free (symtab); + if (strtab) + free (strtab); + return TRUE; +} + +/* Data used to display dynamic fixups. */ + +struct ia64_vms_dynfixup +{ + bfd_vma needed_ident; /* Library ident number. */ + bfd_vma needed; /* Index in the dstrtab of the library name. */ + bfd_vma fixup_needed; /* Index of the library. */ + bfd_vma fixup_rela_cnt; /* Number of fixups. */ + bfd_vma fixup_rela_off; /* Fixups offset in the dynamic segment. */ +}; + +/* Data used to display dynamic relocations. */ + +struct ia64_vms_dynimgrela +{ + bfd_vma img_rela_cnt; /* Number of relocations. */ + bfd_vma img_rela_off; /* Reloc offset in the dynamic segment. */ +}; + +/* Display IA-64 OpenVMS dynamic fixups (used to dynamically link a shared + library). */ + +static bfd_boolean +dump_ia64_vms_dynamic_fixups (Filedata * filedata, + struct ia64_vms_dynfixup * fixup, + const char * strtab, + unsigned int strtab_sz) +{ + Elf64_External_VMS_IMAGE_FIXUP * imfs; + long i; + const char * lib_name; + + imfs = get_data (NULL, filedata, dynamic_addr + fixup->fixup_rela_off, + 1, fixup->fixup_rela_cnt * sizeof (*imfs), + _("dynamic section image fixups")); + if (!imfs) + return FALSE; + + if (fixup->needed < strtab_sz) + lib_name = strtab + fixup->needed; + else + { + warn (_("corrupt library name index of 0x%lx found in dynamic entry"), + (unsigned long) fixup->needed); + lib_name = "???"; + } + printf (_("\nImage fixups for needed library #%d: %s - ident: %lx\n"), + (int) fixup->fixup_needed, lib_name, (long) fixup->needed_ident); + printf + (_("Seg Offset Type SymVec DataType\n")); + + for (i = 0; i < (long) fixup->fixup_rela_cnt; i++) + { + unsigned int type; + const char *rtype; + + printf ("%3u ", (unsigned) BYTE_GET (imfs [i].fixup_seg)); + printf_vma ((bfd_vma) BYTE_GET (imfs [i].fixup_offset)); + type = BYTE_GET (imfs [i].type); + rtype = elf_ia64_reloc_type (type); + if (rtype == NULL) + printf (" 0x%08x ", type); + else + printf (" %-32s ", rtype); + printf ("%6u ", (unsigned) BYTE_GET (imfs [i].symvec_index)); + printf ("0x%08x\n", (unsigned) BYTE_GET (imfs [i].data_type)); + } + + free (imfs); + return TRUE; +} + +/* Display IA-64 OpenVMS dynamic relocations (used to relocate an image). */ + +static bfd_boolean +dump_ia64_vms_dynamic_relocs (Filedata * filedata, struct ia64_vms_dynimgrela *imgrela) +{ + Elf64_External_VMS_IMAGE_RELA *imrs; + long i; + + imrs = get_data (NULL, filedata, dynamic_addr + imgrela->img_rela_off, + 1, imgrela->img_rela_cnt * sizeof (*imrs), + _("dynamic section image relocations")); + if (!imrs) + return FALSE; + + printf (_("\nImage relocs\n")); + printf + (_("Seg Offset Type Addend Seg Sym Off\n")); + + for (i = 0; i < (long) imgrela->img_rela_cnt; i++) + { + unsigned int type; + const char *rtype; + + printf ("%3u ", (unsigned) BYTE_GET (imrs [i].rela_seg)); + printf ("%08" BFD_VMA_FMT "x ", + (bfd_vma) BYTE_GET (imrs [i].rela_offset)); + type = BYTE_GET (imrs [i].type); + rtype = elf_ia64_reloc_type (type); + if (rtype == NULL) + printf ("0x%08x ", type); + else + printf ("%-31s ", rtype); + print_vma (BYTE_GET (imrs [i].addend), FULL_HEX); + printf ("%3u ", (unsigned) BYTE_GET (imrs [i].sym_seg)); + printf ("%08" BFD_VMA_FMT "x\n", + (bfd_vma) BYTE_GET (imrs [i].sym_offset)); + } + + free (imrs); + return TRUE; +} + +/* Display IA-64 OpenVMS dynamic relocations and fixups. */ + +static bfd_boolean +process_ia64_vms_dynamic_relocs (Filedata * filedata) +{ + struct ia64_vms_dynfixup fixup; + struct ia64_vms_dynimgrela imgrela; + Elf_Internal_Dyn *entry; + bfd_vma strtab_off = 0; + bfd_vma strtab_sz = 0; + char *strtab = NULL; + bfd_boolean res = TRUE; + + memset (&fixup, 0, sizeof (fixup)); + memset (&imgrela, 0, sizeof (imgrela)); + + /* Note: the order of the entries is specified by the OpenVMS specs. */ + for (entry = dynamic_section; + entry < dynamic_section + dynamic_nent; + entry++) + { + switch (entry->d_tag) + { + case DT_IA_64_VMS_STRTAB_OFFSET: + strtab_off = entry->d_un.d_val; + break; + case DT_STRSZ: + strtab_sz = entry->d_un.d_val; + if (strtab == NULL) + strtab = get_data (NULL, filedata, dynamic_addr + strtab_off, + 1, strtab_sz, _("dynamic string section")); + break; + + case DT_IA_64_VMS_NEEDED_IDENT: + fixup.needed_ident = entry->d_un.d_val; + break; + case DT_NEEDED: + fixup.needed = entry->d_un.d_val; + break; + case DT_IA_64_VMS_FIXUP_NEEDED: + fixup.fixup_needed = entry->d_un.d_val; + break; + case DT_IA_64_VMS_FIXUP_RELA_CNT: + fixup.fixup_rela_cnt = entry->d_un.d_val; + break; + case DT_IA_64_VMS_FIXUP_RELA_OFF: + fixup.fixup_rela_off = entry->d_un.d_val; + if (! dump_ia64_vms_dynamic_fixups (filedata, &fixup, strtab, strtab_sz)) + res = FALSE; + break; + case DT_IA_64_VMS_IMG_RELA_CNT: + imgrela.img_rela_cnt = entry->d_un.d_val; + break; + case DT_IA_64_VMS_IMG_RELA_OFF: + imgrela.img_rela_off = entry->d_un.d_val; + if (! dump_ia64_vms_dynamic_relocs (filedata, &imgrela)) + res = FALSE; + break; + + default: + break; + } + } + + if (strtab != NULL) + free (strtab); + + return res; +} + +static struct +{ + const char * name; + int reloc; + int size; + int rela; +} + dynamic_relocations [] = +{ + { "REL", DT_REL, DT_RELSZ, FALSE }, + { "RELA", DT_RELA, DT_RELASZ, TRUE }, + { "PLT", DT_JMPREL, DT_PLTRELSZ, UNKNOWN } +}; + +/* Process the reloc section. */ + +static bfd_boolean +process_relocs (Filedata * filedata) +{ + unsigned long rel_size; + unsigned long rel_offset; + + if (!do_reloc) + return TRUE; + + if (do_using_dynamic) + { + int is_rela; + const char * name; + bfd_boolean has_dynamic_reloc; + unsigned int i; + + has_dynamic_reloc = FALSE; + + for (i = 0; i < ARRAY_SIZE (dynamic_relocations); i++) + { + is_rela = dynamic_relocations [i].rela; + name = dynamic_relocations [i].name; + rel_size = dynamic_info [dynamic_relocations [i].size]; + rel_offset = dynamic_info [dynamic_relocations [i].reloc]; + + if (rel_size) + has_dynamic_reloc = TRUE; + + if (is_rela == UNKNOWN) + { + if (dynamic_relocations [i].reloc == DT_JMPREL) + switch (dynamic_info[DT_PLTREL]) + { + case DT_REL: + is_rela = FALSE; + break; + case DT_RELA: + is_rela = TRUE; + break; + } + } + + if (rel_size) + { + printf + (_("\n'%s' relocation section at offset 0x%lx contains %ld bytes:\n"), + name, rel_offset, rel_size); + + dump_relocations (filedata, + offset_from_vma (filedata, rel_offset, rel_size), + rel_size, + dynamic_symbols, num_dynamic_syms, + dynamic_strings, dynamic_strings_length, + is_rela, TRUE /* is_dynamic */); + } + } + + if (is_ia64_vms (filedata)) + if (process_ia64_vms_dynamic_relocs (filedata)) + has_dynamic_reloc = TRUE; + + if (! has_dynamic_reloc) + printf (_("\nThere are no dynamic relocations in this file.\n")); + } + else + { + Elf_Internal_Shdr * section; + unsigned long i; + bfd_boolean found = FALSE; + + for (i = 0, section = filedata->section_headers; + i < filedata->file_header.e_shnum; + i++, section++) + { + if ( section->sh_type != SHT_RELA + && section->sh_type != SHT_REL) + continue; + + rel_offset = section->sh_offset; + rel_size = section->sh_size; + + if (rel_size) + { + Elf_Internal_Shdr * strsec; + int is_rela; + unsigned long num_rela; + + printf (_("\nRelocation section ")); + + if (filedata->string_table == NULL) + printf ("%d", section->sh_name); + else + printf ("'%s'", printable_section_name (filedata, section)); + + num_rela = rel_size / section->sh_entsize; + printf (ngettext (" at offset 0x%lx contains %lu entry:\n", + " at offset 0x%lx contains %lu entries:\n", + num_rela), + rel_offset, num_rela); + + is_rela = section->sh_type == SHT_RELA; + + if (section->sh_link != 0 + && section->sh_link < filedata->file_header.e_shnum) + { + Elf_Internal_Shdr * symsec; + Elf_Internal_Sym * symtab; + unsigned long nsyms; + unsigned long strtablen = 0; + char * strtab = NULL; + + symsec = filedata->section_headers + section->sh_link; + if (symsec->sh_type != SHT_SYMTAB + && symsec->sh_type != SHT_DYNSYM) + continue; + + symtab = GET_ELF_SYMBOLS (filedata, symsec, & nsyms); + + if (symtab == NULL) + continue; + + if (symsec->sh_link != 0 + && symsec->sh_link < filedata->file_header.e_shnum) + { + strsec = filedata->section_headers + symsec->sh_link; + + strtab = (char *) get_data (NULL, filedata, strsec->sh_offset, + 1, strsec->sh_size, + _("string table")); + strtablen = strtab == NULL ? 0 : strsec->sh_size; + } + + dump_relocations (filedata, rel_offset, rel_size, + symtab, nsyms, strtab, strtablen, + is_rela, + symsec->sh_type == SHT_DYNSYM); + if (strtab) + free (strtab); + free (symtab); + } + else + dump_relocations (filedata, rel_offset, rel_size, + NULL, 0, NULL, 0, is_rela, + FALSE /* is_dynamic */); + + found = TRUE; + } + } + + if (! found) + { + /* Users sometimes forget the -D option, so try to be helpful. */ + for (i = 0; i < ARRAY_SIZE (dynamic_relocations); i++) + { + if (dynamic_info [dynamic_relocations [i].size]) + { + printf (_("\nThere are no static relocations in this file.")); + printf (_("\nTo see the dynamic relocations add --use-dynamic to the command line.\n")); + + break; + } + } + if (i == ARRAY_SIZE (dynamic_relocations)) + printf (_("\nThere are no relocations in this file.\n")); + } + } + + return TRUE; +} + +/* An absolute address consists of a section and an offset. If the + section is NULL, the offset itself is the address, otherwise, the + address equals to LOAD_ADDRESS(section) + offset. */ + +struct absaddr +{ + unsigned short section; + bfd_vma offset; +}; + +#define ABSADDR(a) \ + ((a).section \ + ? filedata->section_headers [(a).section].sh_addr + (a).offset \ + : (a).offset) + +/* Find the nearest symbol at or below ADDR. Returns the symbol + name, if found, and the offset from the symbol to ADDR. */ + +static void +find_symbol_for_address (Filedata * filedata, + Elf_Internal_Sym * symtab, + unsigned long nsyms, + const char * strtab, + unsigned long strtab_size, + struct absaddr addr, + const char ** symname, + bfd_vma * offset) +{ + bfd_vma dist = 0x100000; + Elf_Internal_Sym * sym; + Elf_Internal_Sym * beg; + Elf_Internal_Sym * end; + Elf_Internal_Sym * best = NULL; + + REMOVE_ARCH_BITS (addr.offset); + beg = symtab; + end = symtab + nsyms; + + while (beg < end) + { + bfd_vma value; + + sym = beg + (end - beg) / 2; + + value = sym->st_value; + REMOVE_ARCH_BITS (value); + + if (sym->st_name != 0 + && (addr.section == SHN_UNDEF || addr.section == sym->st_shndx) + && addr.offset >= value + && addr.offset - value < dist) + { + best = sym; + dist = addr.offset - value; + if (!dist) + break; + } + + if (addr.offset < value) + end = sym; + else + beg = sym + 1; + } + + if (best) + { + *symname = (best->st_name >= strtab_size + ? _("") : strtab + best->st_name); + *offset = dist; + return; + } + + *symname = NULL; + *offset = addr.offset; +} + +static /* signed */ int +symcmp (const void *p, const void *q) +{ + Elf_Internal_Sym *sp = (Elf_Internal_Sym *) p; + Elf_Internal_Sym *sq = (Elf_Internal_Sym *) q; + + return sp->st_value > sq->st_value ? 1 : (sp->st_value < sq->st_value ? -1 : 0); +} + +/* Process the unwind section. */ + +#include "unwind-ia64.h" + +struct ia64_unw_table_entry +{ + struct absaddr start; + struct absaddr end; + struct absaddr info; +}; + +struct ia64_unw_aux_info +{ + struct ia64_unw_table_entry * table; /* Unwind table. */ + unsigned long table_len; /* Length of unwind table. */ + unsigned char * info; /* Unwind info. */ + unsigned long info_size; /* Size of unwind info. */ + bfd_vma info_addr; /* Starting address of unwind info. */ + bfd_vma seg_base; /* Starting address of segment. */ + Elf_Internal_Sym * symtab; /* The symbol table. */ + unsigned long nsyms; /* Number of symbols. */ + Elf_Internal_Sym * funtab; /* Sorted table of STT_FUNC symbols. */ + unsigned long nfuns; /* Number of entries in funtab. */ + char * strtab; /* The string table. */ + unsigned long strtab_size; /* Size of string table. */ +}; + +static bfd_boolean +dump_ia64_unwind (Filedata * filedata, struct ia64_unw_aux_info * aux) +{ + struct ia64_unw_table_entry * tp; + unsigned long j, nfuns; + int in_body; + bfd_boolean res = TRUE; + + aux->funtab = xmalloc (aux->nsyms * sizeof (Elf_Internal_Sym)); + for (nfuns = 0, j = 0; j < aux->nsyms; j++) + if (aux->symtab[j].st_value && ELF_ST_TYPE (aux->symtab[j].st_info) == STT_FUNC) + aux->funtab[nfuns++] = aux->symtab[j]; + aux->nfuns = nfuns; + qsort (aux->funtab, aux->nfuns, sizeof (Elf_Internal_Sym), symcmp); + + for (tp = aux->table; tp < aux->table + aux->table_len; ++tp) + { + bfd_vma stamp; + bfd_vma offset; + const unsigned char * dp; + const unsigned char * head; + const unsigned char * end; + const char * procname; + + find_symbol_for_address (filedata, aux->funtab, aux->nfuns, aux->strtab, + aux->strtab_size, tp->start, &procname, &offset); + + fputs ("\n<", stdout); + + if (procname) + { + fputs (procname, stdout); + + if (offset) + printf ("+%lx", (unsigned long) offset); + } + + fputs (">: [", stdout); + print_vma (tp->start.offset, PREFIX_HEX); + fputc ('-', stdout); + print_vma (tp->end.offset, PREFIX_HEX); + printf ("], info at +0x%lx\n", + (unsigned long) (tp->info.offset - aux->seg_base)); + + /* PR 17531: file: 86232b32. */ + if (aux->info == NULL) + continue; + + /* PR 17531: file: 0997b4d1. */ + if ((ABSADDR (tp->info) - aux->info_addr) >= aux->info_size) + { + warn (_("Invalid offset %lx in table entry %ld\n"), + (long) tp->info.offset, (long) (tp - aux->table)); + res = FALSE; + continue; + } + + head = aux->info + (ABSADDR (tp->info) - aux->info_addr); + stamp = byte_get ((unsigned char *) head, sizeof (stamp)); + + printf (" v%u, flags=0x%lx (%s%s), len=%lu bytes\n", + (unsigned) UNW_VER (stamp), + (unsigned long) ((stamp & UNW_FLAG_MASK) >> 32), + UNW_FLAG_EHANDLER (stamp) ? " ehandler" : "", + UNW_FLAG_UHANDLER (stamp) ? " uhandler" : "", + (unsigned long) (eh_addr_size * UNW_LENGTH (stamp))); + + if (UNW_VER (stamp) != 1) + { + printf (_("\tUnknown version.\n")); + continue; + } + + in_body = 0; + end = head + 8 + eh_addr_size * UNW_LENGTH (stamp); + /* PR 17531: file: 16ceda89. */ + if (end > aux->info + aux->info_size) + end = aux->info + aux->info_size; + for (dp = head + 8; dp < end;) + dp = unw_decode (dp, in_body, & in_body, end); + } + + free (aux->funtab); + + return res; +} + +static bfd_boolean +slurp_ia64_unwind_table (Filedata * filedata, + struct ia64_unw_aux_info * aux, + Elf_Internal_Shdr * sec) +{ + unsigned long size, nrelas, i; + Elf_Internal_Phdr * seg; + struct ia64_unw_table_entry * tep; + Elf_Internal_Shdr * relsec; + Elf_Internal_Rela * rela; + Elf_Internal_Rela * rp; + unsigned char * table; + unsigned char * tp; + Elf_Internal_Sym * sym; + const char * relname; + + aux->table_len = 0; + + /* First, find the starting address of the segment that includes + this section: */ + + if (filedata->file_header.e_phnum) + { + if (! get_program_headers (filedata)) + return FALSE; + + for (seg = filedata->program_headers; + seg < filedata->program_headers + filedata->file_header.e_phnum; + ++seg) + { + if (seg->p_type != PT_LOAD) + continue; + + if (sec->sh_addr >= seg->p_vaddr + && (sec->sh_addr + sec->sh_size <= seg->p_vaddr + seg->p_memsz)) + { + aux->seg_base = seg->p_vaddr; + break; + } + } + } + + /* Second, build the unwind table from the contents of the unwind section: */ + size = sec->sh_size; + table = (unsigned char *) get_data (NULL, filedata, sec->sh_offset, 1, size, + _("unwind table")); + if (!table) + return FALSE; + + aux->table_len = size / (3 * eh_addr_size); + aux->table = (struct ia64_unw_table_entry *) + xcmalloc (aux->table_len, sizeof (aux->table[0])); + tep = aux->table; + + for (tp = table; tp <= table + size - (3 * eh_addr_size); ++tep) + { + tep->start.section = SHN_UNDEF; + tep->end.section = SHN_UNDEF; + tep->info.section = SHN_UNDEF; + tep->start.offset = byte_get (tp, eh_addr_size); tp += eh_addr_size; + tep->end.offset = byte_get (tp, eh_addr_size); tp += eh_addr_size; + tep->info.offset = byte_get (tp, eh_addr_size); tp += eh_addr_size; + tep->start.offset += aux->seg_base; + tep->end.offset += aux->seg_base; + tep->info.offset += aux->seg_base; + } + free (table); + + /* Third, apply any relocations to the unwind table: */ + for (relsec = filedata->section_headers; + relsec < filedata->section_headers + filedata->file_header.e_shnum; + ++relsec) + { + if (relsec->sh_type != SHT_RELA + || relsec->sh_info >= filedata->file_header.e_shnum + || filedata->section_headers + relsec->sh_info != sec) + continue; + + if (!slurp_rela_relocs (filedata, relsec->sh_offset, relsec->sh_size, + & rela, & nrelas)) + { + free (aux->table); + aux->table = NULL; + aux->table_len = 0; + return FALSE; + } + + for (rp = rela; rp < rela + nrelas; ++rp) + { + relname = elf_ia64_reloc_type (get_reloc_type (filedata, rp->r_info)); + sym = aux->symtab + get_reloc_symindex (rp->r_info); + + /* PR 17531: file: 9fa67536. */ + if (relname == NULL) + { + warn (_("Skipping unknown relocation type: %u\n"), + get_reloc_type (filedata, rp->r_info)); + continue; + } + + if (! const_strneq (relname, "R_IA64_SEGREL")) + { + warn (_("Skipping unexpected relocation type: %s\n"), relname); + continue; + } + + i = rp->r_offset / (3 * eh_addr_size); + + /* PR 17531: file: 5bc8d9bf. */ + if (i >= aux->table_len) + { + warn (_("Skipping reloc with overlarge offset: %lx\n"), i); + continue; + } + + switch (rp->r_offset / eh_addr_size % 3) + { + case 0: + aux->table[i].start.section = sym->st_shndx; + aux->table[i].start.offset = rp->r_addend + sym->st_value; + break; + case 1: + aux->table[i].end.section = sym->st_shndx; + aux->table[i].end.offset = rp->r_addend + sym->st_value; + break; + case 2: + aux->table[i].info.section = sym->st_shndx; + aux->table[i].info.offset = rp->r_addend + sym->st_value; + break; + default: + break; + } + } + + free (rela); + } + + return TRUE; +} + +static bfd_boolean +ia64_process_unwind (Filedata * filedata) +{ + Elf_Internal_Shdr * sec; + Elf_Internal_Shdr * unwsec = NULL; + Elf_Internal_Shdr * strsec; + unsigned long i, unwcount = 0, unwstart = 0; + struct ia64_unw_aux_info aux; + bfd_boolean res = TRUE; + + memset (& aux, 0, sizeof (aux)); + + for (i = 0, sec = filedata->section_headers; i < filedata->file_header.e_shnum; ++i, ++sec) + { + if (sec->sh_type == SHT_SYMTAB + && sec->sh_link < filedata->file_header.e_shnum) + { + aux.symtab = GET_ELF_SYMBOLS (filedata, sec, & aux.nsyms); + + strsec = filedata->section_headers + sec->sh_link; + if (aux.strtab != NULL) + { + error (_("Multiple auxillary string tables encountered\n")); + free (aux.strtab); + res = FALSE; + } + aux.strtab = (char *) get_data (NULL, filedata, strsec->sh_offset, + 1, strsec->sh_size, + _("string table")); + aux.strtab_size = aux.strtab != NULL ? strsec->sh_size : 0; + } + else if (sec->sh_type == SHT_IA_64_UNWIND) + unwcount++; + } + + if (!unwcount) + printf (_("\nThere are no unwind sections in this file.\n")); + + while (unwcount-- > 0) + { + char * suffix; + size_t len, len2; + + for (i = unwstart, sec = filedata->section_headers + unwstart, unwsec = NULL; + i < filedata->file_header.e_shnum; ++i, ++sec) + if (sec->sh_type == SHT_IA_64_UNWIND) + { + unwsec = sec; + break; + } + /* We have already counted the number of SHT_IA64_UNWIND + sections so the loop above should never fail. */ + assert (unwsec != NULL); + + unwstart = i + 1; + len = sizeof (ELF_STRING_ia64_unwind_once) - 1; + + if ((unwsec->sh_flags & SHF_GROUP) != 0) + { + /* We need to find which section group it is in. */ + struct group_list * g; + + if (section_headers_groups == NULL + || section_headers_groups [i] == NULL) + i = filedata->file_header.e_shnum; + else + { + g = section_headers_groups [i]->root; + + for (; g != NULL; g = g->next) + { + sec = filedata->section_headers + g->section_index; + + if (streq (SECTION_NAME (sec), ELF_STRING_ia64_unwind_info)) + break; + } + + if (g == NULL) + i = filedata->file_header.e_shnum; + } + } + else if (strneq (SECTION_NAME (unwsec), ELF_STRING_ia64_unwind_once, len)) + { + /* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.ia64unwi.FOO. */ + len2 = sizeof (ELF_STRING_ia64_unwind_info_once) - 1; + suffix = SECTION_NAME (unwsec) + len; + for (i = 0, sec = filedata->section_headers; i < filedata->file_header.e_shnum; + ++i, ++sec) + if (strneq (SECTION_NAME (sec), ELF_STRING_ia64_unwind_info_once, len2) + && streq (SECTION_NAME (sec) + len2, suffix)) + break; + } + else + { + /* .IA_64.unwindFOO -> .IA_64.unwind_infoFOO + .IA_64.unwind or BAR -> .IA_64.unwind_info. */ + len = sizeof (ELF_STRING_ia64_unwind) - 1; + len2 = sizeof (ELF_STRING_ia64_unwind_info) - 1; + suffix = ""; + if (strneq (SECTION_NAME (unwsec), ELF_STRING_ia64_unwind, len)) + suffix = SECTION_NAME (unwsec) + len; + for (i = 0, sec = filedata->section_headers; i < filedata->file_header.e_shnum; + ++i, ++sec) + if (strneq (SECTION_NAME (sec), ELF_STRING_ia64_unwind_info, len2) + && streq (SECTION_NAME (sec) + len2, suffix)) + break; + } + + if (i == filedata->file_header.e_shnum) + { + printf (_("\nCould not find unwind info section for ")); + + if (filedata->string_table == NULL) + printf ("%d", unwsec->sh_name); + else + printf ("'%s'", printable_section_name (filedata, unwsec)); + } + else + { + aux.info_addr = sec->sh_addr; + aux.info = (unsigned char *) get_data (NULL, filedata, sec->sh_offset, 1, + sec->sh_size, + _("unwind info")); + aux.info_size = aux.info == NULL ? 0 : sec->sh_size; + + printf (_("\nUnwind section ")); + + if (filedata->string_table == NULL) + printf ("%d", unwsec->sh_name); + else + printf ("'%s'", printable_section_name (filedata, unwsec)); + + printf (_(" at offset 0x%lx contains %lu entries:\n"), + (unsigned long) unwsec->sh_offset, + (unsigned long) (unwsec->sh_size / (3 * eh_addr_size))); + + if (slurp_ia64_unwind_table (filedata, & aux, unwsec) + && aux.table_len > 0) + dump_ia64_unwind (filedata, & aux); + + if (aux.table) + free ((char *) aux.table); + if (aux.info) + free ((char *) aux.info); + aux.table = NULL; + aux.info = NULL; + } + } + + if (aux.symtab) + free (aux.symtab); + if (aux.strtab) + free ((char *) aux.strtab); + + return res; +} + +struct hppa_unw_table_entry +{ + struct absaddr start; + struct absaddr end; + unsigned int Cannot_unwind:1; /* 0 */ + unsigned int Millicode:1; /* 1 */ + unsigned int Millicode_save_sr0:1; /* 2 */ + unsigned int Region_description:2; /* 3..4 */ + unsigned int reserved1:1; /* 5 */ + unsigned int Entry_SR:1; /* 6 */ + unsigned int Entry_FR:4; /* Number saved 7..10 */ + unsigned int Entry_GR:5; /* Number saved 11..15 */ + unsigned int Args_stored:1; /* 16 */ + unsigned int Variable_Frame:1; /* 17 */ + unsigned int Separate_Package_Body:1; /* 18 */ + unsigned int Frame_Extension_Millicode:1; /* 19 */ + unsigned int Stack_Overflow_Check:1; /* 20 */ + unsigned int Two_Instruction_SP_Increment:1; /* 21 */ + unsigned int Ada_Region:1; /* 22 */ + unsigned int cxx_info:1; /* 23 */ + unsigned int cxx_try_catch:1; /* 24 */ + unsigned int sched_entry_seq:1; /* 25 */ + unsigned int reserved2:1; /* 26 */ + unsigned int Save_SP:1; /* 27 */ + unsigned int Save_RP:1; /* 28 */ + unsigned int Save_MRP_in_frame:1; /* 29 */ + unsigned int extn_ptr_defined:1; /* 30 */ + unsigned int Cleanup_defined:1; /* 31 */ + + unsigned int MPE_XL_interrupt_marker:1; /* 0 */ + unsigned int HP_UX_interrupt_marker:1; /* 1 */ + unsigned int Large_frame:1; /* 2 */ + unsigned int Pseudo_SP_Set:1; /* 3 */ + unsigned int reserved4:1; /* 4 */ + unsigned int Total_frame_size:27; /* 5..31 */ +}; + +struct hppa_unw_aux_info +{ + struct hppa_unw_table_entry * table; /* Unwind table. */ + unsigned long table_len; /* Length of unwind table. */ + bfd_vma seg_base; /* Starting address of segment. */ + Elf_Internal_Sym * symtab; /* The symbol table. */ + unsigned long nsyms; /* Number of symbols. */ + Elf_Internal_Sym * funtab; /* Sorted table of STT_FUNC symbols. */ + unsigned long nfuns; /* Number of entries in funtab. */ + char * strtab; /* The string table. */ + unsigned long strtab_size; /* Size of string table. */ +}; + +static bfd_boolean +dump_hppa_unwind (Filedata * filedata, struct hppa_unw_aux_info * aux) +{ + struct hppa_unw_table_entry * tp; + unsigned long j, nfuns; + bfd_boolean res = TRUE; + + aux->funtab = xmalloc (aux->nsyms * sizeof (Elf_Internal_Sym)); + for (nfuns = 0, j = 0; j < aux->nsyms; j++) + if (aux->symtab[j].st_value && ELF_ST_TYPE (aux->symtab[j].st_info) == STT_FUNC) + aux->funtab[nfuns++] = aux->symtab[j]; + aux->nfuns = nfuns; + qsort (aux->funtab, aux->nfuns, sizeof (Elf_Internal_Sym), symcmp); + + for (tp = aux->table; tp < aux->table + aux->table_len; ++tp) + { + bfd_vma offset; + const char * procname; + + find_symbol_for_address (filedata, aux->funtab, aux->nfuns, aux->strtab, + aux->strtab_size, tp->start, &procname, + &offset); + + fputs ("\n<", stdout); + + if (procname) + { + fputs (procname, stdout); + + if (offset) + printf ("+%lx", (unsigned long) offset); + } + + fputs (">: [", stdout); + print_vma (tp->start.offset, PREFIX_HEX); + fputc ('-', stdout); + print_vma (tp->end.offset, PREFIX_HEX); + printf ("]\n\t"); + +#define PF(_m) if (tp->_m) printf (#_m " "); +#define PV(_m) if (tp->_m) printf (#_m "=%d ", tp->_m); + PF(Cannot_unwind); + PF(Millicode); + PF(Millicode_save_sr0); + /* PV(Region_description); */ + PF(Entry_SR); + PV(Entry_FR); + PV(Entry_GR); + PF(Args_stored); + PF(Variable_Frame); + PF(Separate_Package_Body); + PF(Frame_Extension_Millicode); + PF(Stack_Overflow_Check); + PF(Two_Instruction_SP_Increment); + PF(Ada_Region); + PF(cxx_info); + PF(cxx_try_catch); + PF(sched_entry_seq); + PF(Save_SP); + PF(Save_RP); + PF(Save_MRP_in_frame); + PF(extn_ptr_defined); + PF(Cleanup_defined); + PF(MPE_XL_interrupt_marker); + PF(HP_UX_interrupt_marker); + PF(Large_frame); + PF(Pseudo_SP_Set); + PV(Total_frame_size); +#undef PF +#undef PV + } + + printf ("\n"); + + free (aux->funtab); + + return res; +} + +static bfd_boolean +slurp_hppa_unwind_table (Filedata * filedata, + struct hppa_unw_aux_info * aux, + Elf_Internal_Shdr * sec) +{ + unsigned long size, unw_ent_size, nentries, nrelas, i; + Elf_Internal_Phdr * seg; + struct hppa_unw_table_entry * tep; + Elf_Internal_Shdr * relsec; + Elf_Internal_Rela * rela; + Elf_Internal_Rela * rp; + unsigned char * table; + unsigned char * tp; + Elf_Internal_Sym * sym; + const char * relname; + + /* First, find the starting address of the segment that includes + this section. */ + if (filedata->file_header.e_phnum) + { + if (! get_program_headers (filedata)) + return FALSE; + + for (seg = filedata->program_headers; + seg < filedata->program_headers + filedata->file_header.e_phnum; + ++seg) + { + if (seg->p_type != PT_LOAD) + continue; + + if (sec->sh_addr >= seg->p_vaddr + && (sec->sh_addr + sec->sh_size <= seg->p_vaddr + seg->p_memsz)) + { + aux->seg_base = seg->p_vaddr; + break; + } + } + } + + /* Second, build the unwind table from the contents of the unwind + section. */ + size = sec->sh_size; + table = (unsigned char *) get_data (NULL, filedata, sec->sh_offset, 1, size, + _("unwind table")); + if (!table) + return FALSE; + + unw_ent_size = 16; + nentries = size / unw_ent_size; + size = unw_ent_size * nentries; + + tep = aux->table = (struct hppa_unw_table_entry *) + xcmalloc (nentries, sizeof (aux->table[0])); + + for (tp = table; tp < table + size; tp += unw_ent_size, ++tep) + { + unsigned int tmp1, tmp2; + + tep->start.section = SHN_UNDEF; + tep->end.section = SHN_UNDEF; + + tep->start.offset = byte_get ((unsigned char *) tp + 0, 4); + tep->end.offset = byte_get ((unsigned char *) tp + 4, 4); + tmp1 = byte_get ((unsigned char *) tp + 8, 4); + tmp2 = byte_get ((unsigned char *) tp + 12, 4); + + tep->start.offset += aux->seg_base; + tep->end.offset += aux->seg_base; + + tep->Cannot_unwind = (tmp1 >> 31) & 0x1; + tep->Millicode = (tmp1 >> 30) & 0x1; + tep->Millicode_save_sr0 = (tmp1 >> 29) & 0x1; + tep->Region_description = (tmp1 >> 27) & 0x3; + tep->reserved1 = (tmp1 >> 26) & 0x1; + tep->Entry_SR = (tmp1 >> 25) & 0x1; + tep->Entry_FR = (tmp1 >> 21) & 0xf; + tep->Entry_GR = (tmp1 >> 16) & 0x1f; + tep->Args_stored = (tmp1 >> 15) & 0x1; + tep->Variable_Frame = (tmp1 >> 14) & 0x1; + tep->Separate_Package_Body = (tmp1 >> 13) & 0x1; + tep->Frame_Extension_Millicode = (tmp1 >> 12) & 0x1; + tep->Stack_Overflow_Check = (tmp1 >> 11) & 0x1; + tep->Two_Instruction_SP_Increment = (tmp1 >> 10) & 0x1; + tep->Ada_Region = (tmp1 >> 9) & 0x1; + tep->cxx_info = (tmp1 >> 8) & 0x1; + tep->cxx_try_catch = (tmp1 >> 7) & 0x1; + tep->sched_entry_seq = (tmp1 >> 6) & 0x1; + tep->reserved2 = (tmp1 >> 5) & 0x1; + tep->Save_SP = (tmp1 >> 4) & 0x1; + tep->Save_RP = (tmp1 >> 3) & 0x1; + tep->Save_MRP_in_frame = (tmp1 >> 2) & 0x1; + tep->extn_ptr_defined = (tmp1 >> 1) & 0x1; + tep->Cleanup_defined = tmp1 & 0x1; + + tep->MPE_XL_interrupt_marker = (tmp2 >> 31) & 0x1; + tep->HP_UX_interrupt_marker = (tmp2 >> 30) & 0x1; + tep->Large_frame = (tmp2 >> 29) & 0x1; + tep->Pseudo_SP_Set = (tmp2 >> 28) & 0x1; + tep->reserved4 = (tmp2 >> 27) & 0x1; + tep->Total_frame_size = tmp2 & 0x7ffffff; + } + free (table); + + /* Third, apply any relocations to the unwind table. */ + for (relsec = filedata->section_headers; + relsec < filedata->section_headers + filedata->file_header.e_shnum; + ++relsec) + { + if (relsec->sh_type != SHT_RELA + || relsec->sh_info >= filedata->file_header.e_shnum + || filedata->section_headers + relsec->sh_info != sec) + continue; + + if (!slurp_rela_relocs (filedata, relsec->sh_offset, relsec->sh_size, + & rela, & nrelas)) + return FALSE; + + for (rp = rela; rp < rela + nrelas; ++rp) + { + relname = elf_hppa_reloc_type (get_reloc_type (filedata, rp->r_info)); + sym = aux->symtab + get_reloc_symindex (rp->r_info); + + /* R_PARISC_SEGREL32 or R_PARISC_SEGREL64. */ + if (! const_strneq (relname, "R_PARISC_SEGREL")) + { + warn (_("Skipping unexpected relocation type %s\n"), relname); + continue; + } + + i = rp->r_offset / unw_ent_size; + + switch ((rp->r_offset % unw_ent_size) / eh_addr_size) + { + case 0: + aux->table[i].start.section = sym->st_shndx; + aux->table[i].start.offset = sym->st_value + rp->r_addend; + break; + case 1: + aux->table[i].end.section = sym->st_shndx; + aux->table[i].end.offset = sym->st_value + rp->r_addend; + break; + default: + break; + } + } + + free (rela); + } + + aux->table_len = nentries; + + return TRUE; +} + +static bfd_boolean +hppa_process_unwind (Filedata * filedata) +{ + struct hppa_unw_aux_info aux; + Elf_Internal_Shdr * unwsec = NULL; + Elf_Internal_Shdr * strsec; + Elf_Internal_Shdr * sec; + unsigned long i; + bfd_boolean res = TRUE; + + if (filedata->string_table == NULL) + return FALSE; + + memset (& aux, 0, sizeof (aux)); + + for (i = 0, sec = filedata->section_headers; i < filedata->file_header.e_shnum; ++i, ++sec) + { + if (sec->sh_type == SHT_SYMTAB + && sec->sh_link < filedata->file_header.e_shnum) + { + aux.symtab = GET_ELF_SYMBOLS (filedata, sec, & aux.nsyms); + + strsec = filedata->section_headers + sec->sh_link; + if (aux.strtab != NULL) + { + error (_("Multiple auxillary string tables encountered\n")); + free (aux.strtab); + res = FALSE; + } + aux.strtab = (char *) get_data (NULL, filedata, strsec->sh_offset, + 1, strsec->sh_size, + _("string table")); + aux.strtab_size = aux.strtab != NULL ? strsec->sh_size : 0; + } + else if (streq (SECTION_NAME (sec), ".PARISC.unwind")) + unwsec = sec; + } + + if (!unwsec) + printf (_("\nThere are no unwind sections in this file.\n")); + + for (i = 0, sec = filedata->section_headers; i < filedata->file_header.e_shnum; ++i, ++sec) + { + if (streq (SECTION_NAME (sec), ".PARISC.unwind")) + { + unsigned long num_unwind = sec->sh_size / (2 * eh_addr_size + 8); + + printf (ngettext ("\nUnwind section '%s' at offset 0x%lx " + "contains %lu entry:\n", + "\nUnwind section '%s' at offset 0x%lx " + "contains %lu entries:\n", + num_unwind), + printable_section_name (filedata, sec), + (unsigned long) sec->sh_offset, + num_unwind); + + if (! slurp_hppa_unwind_table (filedata, &aux, sec)) + res = FALSE; + + if (aux.table_len > 0) + { + if (! dump_hppa_unwind (filedata, &aux)) + res = FALSE; + } + + if (aux.table) + free ((char *) aux.table); + aux.table = NULL; + } + } + + if (aux.symtab) + free (aux.symtab); + if (aux.strtab) + free ((char *) aux.strtab); + + return res; +} + +struct arm_section +{ + unsigned char * data; /* The unwind data. */ + Elf_Internal_Shdr * sec; /* The cached unwind section header. */ + Elf_Internal_Rela * rela; /* The cached relocations for this section. */ + unsigned long nrelas; /* The number of relocations. */ + unsigned int rel_type; /* REL or RELA ? */ + Elf_Internal_Rela * next_rela; /* Cyclic pointer to the next reloc to process. */ +}; + +struct arm_unw_aux_info +{ + Filedata * filedata; /* The file containing the unwind sections. */ + Elf_Internal_Sym * symtab; /* The file's symbol table. */ + unsigned long nsyms; /* Number of symbols. */ + Elf_Internal_Sym * funtab; /* Sorted table of STT_FUNC symbols. */ + unsigned long nfuns; /* Number of these symbols. */ + char * strtab; /* The file's string table. */ + unsigned long strtab_size; /* Size of string table. */ +}; + +static const char * +arm_print_vma_and_name (Filedata * filedata, + struct arm_unw_aux_info * aux, + bfd_vma fn, + struct absaddr addr) +{ + const char *procname; + bfd_vma sym_offset; + + if (addr.section == SHN_UNDEF) + addr.offset = fn; + + find_symbol_for_address (filedata, aux->funtab, aux->nfuns, aux->strtab, + aux->strtab_size, addr, &procname, + &sym_offset); + + print_vma (fn, PREFIX_HEX); + + if (procname) + { + fputs (" <", stdout); + fputs (procname, stdout); + + if (sym_offset) + printf ("+0x%lx", (unsigned long) sym_offset); + fputc ('>', stdout); + } + + return procname; +} + +static void +arm_free_section (struct arm_section *arm_sec) +{ + if (arm_sec->data != NULL) + free (arm_sec->data); + + if (arm_sec->rela != NULL) + free (arm_sec->rela); +} + +/* 1) If SEC does not match the one cached in ARM_SEC, then free the current + cached section and install SEC instead. + 2) Locate the 32-bit word at WORD_OFFSET in unwind section SEC + and return its valued in * WORDP, relocating if necessary. + 3) Update the NEXT_RELA field in ARM_SEC and store the section index and + relocation's offset in ADDR. + 4) If SYM_NAME is non-NULL and a relocation was applied, record the offset + into the string table of the symbol associated with the reloc. If no + reloc was applied store -1 there. + 5) Return TRUE upon success, FALSE otherwise. */ + +static bfd_boolean +get_unwind_section_word (Filedata * filedata, + struct arm_unw_aux_info * aux, + struct arm_section * arm_sec, + Elf_Internal_Shdr * sec, + bfd_vma word_offset, + unsigned int * wordp, + struct absaddr * addr, + bfd_vma * sym_name) +{ + Elf_Internal_Rela *rp; + Elf_Internal_Sym *sym; + const char * relname; + unsigned int word; + bfd_boolean wrapped; + + if (sec == NULL || arm_sec == NULL) + return FALSE; + + addr->section = SHN_UNDEF; + addr->offset = 0; + + if (sym_name != NULL) + *sym_name = (bfd_vma) -1; + + /* If necessary, update the section cache. */ + if (sec != arm_sec->sec) + { + Elf_Internal_Shdr *relsec; + + arm_free_section (arm_sec); + + arm_sec->sec = sec; + arm_sec->data = get_data (NULL, aux->filedata, sec->sh_offset, 1, + sec->sh_size, _("unwind data")); + arm_sec->rela = NULL; + arm_sec->nrelas = 0; + + for (relsec = filedata->section_headers; + relsec < filedata->section_headers + filedata->file_header.e_shnum; + ++relsec) + { + if (relsec->sh_info >= filedata->file_header.e_shnum + || filedata->section_headers + relsec->sh_info != sec + /* PR 15745: Check the section type as well. */ + || (relsec->sh_type != SHT_REL + && relsec->sh_type != SHT_RELA)) + continue; + + arm_sec->rel_type = relsec->sh_type; + if (relsec->sh_type == SHT_REL) + { + if (!slurp_rel_relocs (aux->filedata, relsec->sh_offset, + relsec->sh_size, + & arm_sec->rela, & arm_sec->nrelas)) + return FALSE; + } + else /* relsec->sh_type == SHT_RELA */ + { + if (!slurp_rela_relocs (aux->filedata, relsec->sh_offset, + relsec->sh_size, + & arm_sec->rela, & arm_sec->nrelas)) + return FALSE; + } + break; + } + + arm_sec->next_rela = arm_sec->rela; + } + + /* If there is no unwind data we can do nothing. */ + if (arm_sec->data == NULL) + return FALSE; + + /* If the offset is invalid then fail. */ + if (/* PR 21343 *//* PR 18879 */ + sec->sh_size < 4 + || word_offset > (sec->sh_size - 4) + || ((bfd_signed_vma) word_offset) < 0) + return FALSE; + + /* Get the word at the required offset. */ + word = byte_get (arm_sec->data + word_offset, 4); + + /* PR 17531: file: id:000001,src:001266+003044,op:splice,rep:128. */ + if (arm_sec->rela == NULL) + { + * wordp = word; + return TRUE; + } + + /* Look through the relocs to find the one that applies to the provided offset. */ + wrapped = FALSE; + for (rp = arm_sec->next_rela; rp != arm_sec->rela + arm_sec->nrelas; rp++) + { + bfd_vma prelval, offset; + + if (rp->r_offset > word_offset && !wrapped) + { + rp = arm_sec->rela; + wrapped = TRUE; + } + if (rp->r_offset > word_offset) + break; + + if (rp->r_offset & 3) + { + warn (_("Skipping unexpected relocation at offset 0x%lx\n"), + (unsigned long) rp->r_offset); + continue; + } + + if (rp->r_offset < word_offset) + continue; + + /* PR 17531: file: 027-161405-0.004 */ + if (aux->symtab == NULL) + continue; + + if (arm_sec->rel_type == SHT_REL) + { + offset = word & 0x7fffffff; + if (offset & 0x40000000) + offset |= ~ (bfd_vma) 0x7fffffff; + } + else if (arm_sec->rel_type == SHT_RELA) + offset = rp->r_addend; + else + { + error (_("Unknown section relocation type %d encountered\n"), + arm_sec->rel_type); + break; + } + + /* PR 17531 file: 027-1241568-0.004. */ + if (ELF32_R_SYM (rp->r_info) >= aux->nsyms) + { + error (_("Bad symbol index in unwind relocation (%lu > %lu)\n"), + (unsigned long) ELF32_R_SYM (rp->r_info), aux->nsyms); + break; + } + + sym = aux->symtab + ELF32_R_SYM (rp->r_info); + offset += sym->st_value; + prelval = offset - (arm_sec->sec->sh_addr + rp->r_offset); + + /* Check that we are processing the expected reloc type. */ + if (filedata->file_header.e_machine == EM_ARM) + { + relname = elf_arm_reloc_type (ELF32_R_TYPE (rp->r_info)); + if (relname == NULL) + { + warn (_("Skipping unknown ARM relocation type: %d\n"), + (int) ELF32_R_TYPE (rp->r_info)); + continue; + } + + if (streq (relname, "R_ARM_NONE")) + continue; + + if (! streq (relname, "R_ARM_PREL31")) + { + warn (_("Skipping unexpected ARM relocation type %s\n"), relname); + continue; + } + } + else if (filedata->file_header.e_machine == EM_TI_C6000) + { + relname = elf_tic6x_reloc_type (ELF32_R_TYPE (rp->r_info)); + if (relname == NULL) + { + warn (_("Skipping unknown C6000 relocation type: %d\n"), + (int) ELF32_R_TYPE (rp->r_info)); + continue; + } + + if (streq (relname, "R_C6000_NONE")) + continue; + + if (! streq (relname, "R_C6000_PREL31")) + { + warn (_("Skipping unexpected C6000 relocation type %s\n"), relname); + continue; + } + + prelval >>= 1; + } + else + { + /* This function currently only supports ARM and TI unwinders. */ + warn (_("Only TI and ARM unwinders are currently supported\n")); + break; + } + + word = (word & ~ (bfd_vma) 0x7fffffff) | (prelval & 0x7fffffff); + addr->section = sym->st_shndx; + addr->offset = offset; + + if (sym_name) + * sym_name = sym->st_name; + break; + } + + *wordp = word; + arm_sec->next_rela = rp; + + return TRUE; +} + +static const char *tic6x_unwind_regnames[16] = +{ + "A15", "B15", "B14", "B13", "B12", "B11", "B10", "B3", + "A14", "A13", "A12", "A11", "A10", + "[invalid reg 13]", "[invalid reg 14]", "[invalid reg 15]" +}; + +static void +decode_tic6x_unwind_regmask (unsigned int mask) +{ + int i; + + for (i = 12; mask; mask >>= 1, i--) + { + if (mask & 1) + { + fputs (tic6x_unwind_regnames[i], stdout); + if (mask > 1) + fputs (", ", stdout); + } + } +} + +#define ADVANCE \ + if (remaining == 0 && more_words) \ + { \ + data_offset += 4; \ + if (! get_unwind_section_word (filedata, aux, data_arm_sec, data_sec, \ + data_offset, & word, & addr, NULL)) \ + return FALSE; \ + remaining = 4; \ + more_words--; \ + } \ + +#define GET_OP(OP) \ + ADVANCE; \ + if (remaining) \ + { \ + remaining--; \ + (OP) = word >> 24; \ + word <<= 8; \ + } \ + else \ + { \ + printf (_("[Truncated opcode]\n")); \ + return FALSE; \ + } \ + printf ("0x%02x ", OP) + +static bfd_boolean +decode_arm_unwind_bytecode (Filedata * filedata, + struct arm_unw_aux_info * aux, + unsigned int word, + unsigned int remaining, + unsigned int more_words, + bfd_vma data_offset, + Elf_Internal_Shdr * data_sec, + struct arm_section * data_arm_sec) +{ + struct absaddr addr; + bfd_boolean res = TRUE; + + /* Decode the unwinding instructions. */ + while (1) + { + unsigned int op, op2; + + ADVANCE; + if (remaining == 0) + break; + remaining--; + op = word >> 24; + word <<= 8; + + printf (" 0x%02x ", op); + + if ((op & 0xc0) == 0x00) + { + int offset = ((op & 0x3f) << 2) + 4; + + printf (" vsp = vsp + %d", offset); + } + else if ((op & 0xc0) == 0x40) + { + int offset = ((op & 0x3f) << 2) + 4; + + printf (" vsp = vsp - %d", offset); + } + else if ((op & 0xf0) == 0x80) + { + GET_OP (op2); + if (op == 0x80 && op2 == 0) + printf (_("Refuse to unwind")); + else + { + unsigned int mask = ((op & 0x0f) << 8) | op2; + bfd_boolean first = TRUE; + int i; + + printf ("pop {"); + for (i = 0; i < 12; i++) + if (mask & (1 << i)) + { + if (first) + first = FALSE; + else + printf (", "); + printf ("r%d", 4 + i); + } + printf ("}"); + } + } + else if ((op & 0xf0) == 0x90) + { + if (op == 0x9d || op == 0x9f) + printf (_(" [Reserved]")); + else + printf (" vsp = r%d", op & 0x0f); + } + else if ((op & 0xf0) == 0xa0) + { + int end = 4 + (op & 0x07); + bfd_boolean first = TRUE; + int i; + + printf (" pop {"); + for (i = 4; i <= end; i++) + { + if (first) + first = FALSE; + else + printf (", "); + printf ("r%d", i); + } + if (op & 0x08) + { + if (!first) + printf (", "); + printf ("r14"); + } + printf ("}"); + } + else if (op == 0xb0) + printf (_(" finish")); + else if (op == 0xb1) + { + GET_OP (op2); + if (op2 == 0 || (op2 & 0xf0) != 0) + printf (_("[Spare]")); + else + { + unsigned int mask = op2 & 0x0f; + bfd_boolean first = TRUE; + int i; + + printf ("pop {"); + for (i = 0; i < 12; i++) + if (mask & (1 << i)) + { + if (first) + first = FALSE; + else + printf (", "); + printf ("r%d", i); + } + printf ("}"); + } + } + else if (op == 0xb2) + { + unsigned char buf[9]; + unsigned int i, len; + unsigned long offset; + + for (i = 0; i < sizeof (buf); i++) + { + GET_OP (buf[i]); + if ((buf[i] & 0x80) == 0) + break; + } + if (i == sizeof (buf)) + { + error (_("corrupt change to vsp")); + res = FALSE; + } + else + { + offset = read_uleb128 (buf, &len, buf + i + 1); + assert (len == i + 1); + offset = offset * 4 + 0x204; + printf ("vsp = vsp + %ld", offset); + } + } + else if (op == 0xb3 || op == 0xc8 || op == 0xc9) + { + unsigned int first, last; + + GET_OP (op2); + first = op2 >> 4; + last = op2 & 0x0f; + if (op == 0xc8) + first = first + 16; + printf ("pop {D%d", first); + if (last) + printf ("-D%d", first + last); + printf ("}"); + } + else if ((op & 0xf8) == 0xb8 || (op & 0xf8) == 0xd0) + { + unsigned int count = op & 0x07; + + printf ("pop {D8"); + if (count) + printf ("-D%d", 8 + count); + printf ("}"); + } + else if (op >= 0xc0 && op <= 0xc5) + { + unsigned int count = op & 0x07; + + printf (" pop {wR10"); + if (count) + printf ("-wR%d", 10 + count); + printf ("}"); + } + else if (op == 0xc6) + { + unsigned int first, last; + + GET_OP (op2); + first = op2 >> 4; + last = op2 & 0x0f; + printf ("pop {wR%d", first); + if (last) + printf ("-wR%d", first + last); + printf ("}"); + } + else if (op == 0xc7) + { + GET_OP (op2); + if (op2 == 0 || (op2 & 0xf0) != 0) + printf (_("[Spare]")); + else + { + unsigned int mask = op2 & 0x0f; + bfd_boolean first = TRUE; + int i; + + printf ("pop {"); + for (i = 0; i < 4; i++) + if (mask & (1 << i)) + { + if (first) + first = FALSE; + else + printf (", "); + printf ("wCGR%d", i); + } + printf ("}"); + } + } + else + { + printf (_(" [unsupported opcode]")); + res = FALSE; + } + + printf ("\n"); + } + + return res; +} + +static bfd_boolean +decode_tic6x_unwind_bytecode (Filedata * filedata, + struct arm_unw_aux_info * aux, + unsigned int word, + unsigned int remaining, + unsigned int more_words, + bfd_vma data_offset, + Elf_Internal_Shdr * data_sec, + struct arm_section * data_arm_sec) +{ + struct absaddr addr; + + /* Decode the unwinding instructions. */ + while (1) + { + unsigned int op, op2; + + ADVANCE; + if (remaining == 0) + break; + remaining--; + op = word >> 24; + word <<= 8; + + printf (" 0x%02x ", op); + + if ((op & 0xc0) == 0x00) + { + int offset = ((op & 0x3f) << 3) + 8; + printf (" sp = sp + %d", offset); + } + else if ((op & 0xc0) == 0x80) + { + GET_OP (op2); + if (op == 0x80 && op2 == 0) + printf (_("Refuse to unwind")); + else + { + unsigned int mask = ((op & 0x1f) << 8) | op2; + if (op & 0x20) + printf ("pop compact {"); + else + printf ("pop {"); + + decode_tic6x_unwind_regmask (mask); + printf("}"); + } + } + else if ((op & 0xf0) == 0xc0) + { + unsigned int reg; + unsigned int nregs; + unsigned int i; + const char *name; + struct + { + unsigned int offset; + unsigned int reg; + } regpos[16]; + + /* Scan entire instruction first so that GET_OP output is not + interleaved with disassembly. */ + nregs = 0; + for (i = 0; nregs < (op & 0xf); i++) + { + GET_OP (op2); + reg = op2 >> 4; + if (reg != 0xf) + { + regpos[nregs].offset = i * 2; + regpos[nregs].reg = reg; + nregs++; + } + + reg = op2 & 0xf; + if (reg != 0xf) + { + regpos[nregs].offset = i * 2 + 1; + regpos[nregs].reg = reg; + nregs++; + } + } + + printf (_("pop frame {")); + reg = nregs - 1; + for (i = i * 2; i > 0; i--) + { + if (regpos[reg].offset == i - 1) + { + name = tic6x_unwind_regnames[regpos[reg].reg]; + if (reg > 0) + reg--; + } + else + name = _("[pad]"); + + fputs (name, stdout); + if (i > 1) + printf (", "); + } + + printf ("}"); + } + else if (op == 0xd0) + printf (" MOV FP, SP"); + else if (op == 0xd1) + printf (" __c6xabi_pop_rts"); + else if (op == 0xd2) + { + unsigned char buf[9]; + unsigned int i, len; + unsigned long offset; + + for (i = 0; i < sizeof (buf); i++) + { + GET_OP (buf[i]); + if ((buf[i] & 0x80) == 0) + break; + } + /* PR 17531: file: id:000001,src:001906+004739,op:splice,rep:2. */ + if (i == sizeof (buf)) + { + warn (_("Corrupt stack pointer adjustment detected\n")); + return FALSE; + } + + offset = read_uleb128 (buf, &len, buf + i + 1); + assert (len == i + 1); + offset = offset * 8 + 0x408; + printf (_("sp = sp + %ld"), offset); + } + else if ((op & 0xf0) == 0xe0) + { + if ((op & 0x0f) == 7) + printf (" RETURN"); + else + printf (" MV %s, B3", tic6x_unwind_regnames[op & 0x0f]); + } + else + { + printf (_(" [unsupported opcode]")); + } + putchar ('\n'); + } + + return TRUE; +} + +static bfd_vma +arm_expand_prel31 (Filedata * filedata, bfd_vma word, bfd_vma where) +{ + bfd_vma offset; + + offset = word & 0x7fffffff; + if (offset & 0x40000000) + offset |= ~ (bfd_vma) 0x7fffffff; + + if (filedata->file_header.e_machine == EM_TI_C6000) + offset <<= 1; + + return offset + where; +} + +static bfd_boolean +decode_arm_unwind (Filedata * filedata, + struct arm_unw_aux_info * aux, + unsigned int word, + unsigned int remaining, + bfd_vma data_offset, + Elf_Internal_Shdr * data_sec, + struct arm_section * data_arm_sec) +{ + int per_index; + unsigned int more_words = 0; + struct absaddr addr; + bfd_vma sym_name = (bfd_vma) -1; + bfd_boolean res = TRUE; + + if (remaining == 0) + { + /* Fetch the first word. + Note - when decoding an object file the address extracted + here will always be 0. So we also pass in the sym_name + parameter so that we can find the symbol associated with + the personality routine. */ + if (! get_unwind_section_word (filedata, aux, data_arm_sec, data_sec, data_offset, + & word, & addr, & sym_name)) + return FALSE; + + remaining = 4; + } + + if ((word & 0x80000000) == 0) + { + /* Expand prel31 for personality routine. */ + bfd_vma fn; + const char *procname; + + fn = arm_expand_prel31 (filedata, word, data_sec->sh_addr + data_offset); + printf (_(" Personality routine: ")); + if (fn == 0 + && addr.section == SHN_UNDEF && addr.offset == 0 + && sym_name != (bfd_vma) -1 && sym_name < aux->strtab_size) + { + procname = aux->strtab + sym_name; + print_vma (fn, PREFIX_HEX); + if (procname) + { + fputs (" <", stdout); + fputs (procname, stdout); + fputc ('>', stdout); + } + } + else + procname = arm_print_vma_and_name (filedata, aux, fn, addr); + fputc ('\n', stdout); + + /* The GCC personality routines use the standard compact + encoding, starting with one byte giving the number of + words. */ + if (procname != NULL + && (const_strneq (procname, "__gcc_personality_v0") + || const_strneq (procname, "__gxx_personality_v0") + || const_strneq (procname, "__gcj_personality_v0") + || const_strneq (procname, "__gnu_objc_personality_v0"))) + { + remaining = 0; + more_words = 1; + ADVANCE; + if (!remaining) + { + printf (_(" [Truncated data]\n")); + return FALSE; + } + more_words = word >> 24; + word <<= 8; + remaining--; + per_index = -1; + } + else + return TRUE; + } + else + { + /* ARM EHABI Section 6.3: + + An exception-handling table entry for the compact model looks like: + + 31 30-28 27-24 23-0 + -- ----- ----- ---- + 1 0 index Data for personalityRoutine[index] */ + + if (filedata->file_header.e_machine == EM_ARM + && (word & 0x70000000)) + { + warn (_("Corrupt ARM compact model table entry: %x \n"), word); + res = FALSE; + } + + per_index = (word >> 24) & 0x7f; + printf (_(" Compact model index: %d\n"), per_index); + if (per_index == 0) + { + more_words = 0; + word <<= 8; + remaining--; + } + else if (per_index < 3) + { + more_words = (word >> 16) & 0xff; + word <<= 16; + remaining -= 2; + } + } + + switch (filedata->file_header.e_machine) + { + case EM_ARM: + if (per_index < 3) + { + if (! decode_arm_unwind_bytecode (filedata, aux, word, remaining, more_words, + data_offset, data_sec, data_arm_sec)) + res = FALSE; + } + else + { + warn (_("Unknown ARM compact model index encountered\n")); + printf (_(" [reserved]\n")); + res = FALSE; + } + break; + + case EM_TI_C6000: + if (per_index < 3) + { + if (! decode_tic6x_unwind_bytecode (filedata, aux, word, remaining, more_words, + data_offset, data_sec, data_arm_sec)) + res = FALSE; + } + else if (per_index < 5) + { + if (((word >> 17) & 0x7f) == 0x7f) + printf (_(" Restore stack from frame pointer\n")); + else + printf (_(" Stack increment %d\n"), (word >> 14) & 0x1fc); + printf (_(" Registers restored: ")); + if (per_index == 4) + printf (" (compact) "); + decode_tic6x_unwind_regmask ((word >> 4) & 0x1fff); + putchar ('\n'); + printf (_(" Return register: %s\n"), + tic6x_unwind_regnames[word & 0xf]); + } + else + printf (_(" [reserved (%d)]\n"), per_index); + break; + + default: + error (_("Unsupported architecture type %d encountered when decoding unwind table\n"), + filedata->file_header.e_machine); + res = FALSE; + } + + /* Decode the descriptors. Not implemented. */ + + return res; +} + +static bfd_boolean +dump_arm_unwind (Filedata * filedata, + struct arm_unw_aux_info * aux, + Elf_Internal_Shdr * exidx_sec) +{ + struct arm_section exidx_arm_sec, extab_arm_sec; + unsigned int i, exidx_len; + unsigned long j, nfuns; + bfd_boolean res = TRUE; + + memset (&exidx_arm_sec, 0, sizeof (exidx_arm_sec)); + memset (&extab_arm_sec, 0, sizeof (extab_arm_sec)); + exidx_len = exidx_sec->sh_size / 8; + + aux->funtab = xmalloc (aux->nsyms * sizeof (Elf_Internal_Sym)); + for (nfuns = 0, j = 0; j < aux->nsyms; j++) + if (aux->symtab[j].st_value && ELF_ST_TYPE (aux->symtab[j].st_info) == STT_FUNC) + aux->funtab[nfuns++] = aux->symtab[j]; + aux->nfuns = nfuns; + qsort (aux->funtab, aux->nfuns, sizeof (Elf_Internal_Sym), symcmp); + + for (i = 0; i < exidx_len; i++) + { + unsigned int exidx_fn, exidx_entry; + struct absaddr fn_addr, entry_addr; + bfd_vma fn; + + fputc ('\n', stdout); + + if (! get_unwind_section_word (filedata, aux, & exidx_arm_sec, exidx_sec, + 8 * i, & exidx_fn, & fn_addr, NULL) + || ! get_unwind_section_word (filedata, aux, & exidx_arm_sec, exidx_sec, + 8 * i + 4, & exidx_entry, & entry_addr, NULL)) + { + free (aux->funtab); + arm_free_section (& exidx_arm_sec); + arm_free_section (& extab_arm_sec); + return FALSE; + } + + /* ARM EHABI, Section 5: + An index table entry consists of 2 words. + The first word contains a prel31 offset to the start of a function, with bit 31 clear. */ + if (exidx_fn & 0x80000000) + { + warn (_("corrupt index table entry: %x\n"), exidx_fn); + res = FALSE; + } + + fn = arm_expand_prel31 (filedata, exidx_fn, exidx_sec->sh_addr + 8 * i); + + arm_print_vma_and_name (filedata, aux, fn, fn_addr); + fputs (": ", stdout); + + if (exidx_entry == 1) + { + print_vma (exidx_entry, PREFIX_HEX); + fputs (" [cantunwind]\n", stdout); + } + else if (exidx_entry & 0x80000000) + { + print_vma (exidx_entry, PREFIX_HEX); + fputc ('\n', stdout); + decode_arm_unwind (filedata, aux, exidx_entry, 4, 0, NULL, NULL); + } + else + { + bfd_vma table, table_offset = 0; + Elf_Internal_Shdr *table_sec; + + fputs ("@", stdout); + table = arm_expand_prel31 (filedata, exidx_entry, exidx_sec->sh_addr + 8 * i + 4); + print_vma (table, PREFIX_HEX); + printf ("\n"); + + /* Locate the matching .ARM.extab. */ + if (entry_addr.section != SHN_UNDEF + && entry_addr.section < filedata->file_header.e_shnum) + { + table_sec = filedata->section_headers + entry_addr.section; + table_offset = entry_addr.offset; + /* PR 18879 */ + if (table_offset > table_sec->sh_size + || ((bfd_signed_vma) table_offset) < 0) + { + warn (_("Unwind entry contains corrupt offset (0x%lx) into section %s\n"), + (unsigned long) table_offset, + printable_section_name (filedata, table_sec)); + res = FALSE; + continue; + } + } + else + { + table_sec = find_section_by_address (filedata, table); + if (table_sec != NULL) + table_offset = table - table_sec->sh_addr; + } + + if (table_sec == NULL) + { + warn (_("Could not locate .ARM.extab section containing 0x%lx.\n"), + (unsigned long) table); + res = FALSE; + continue; + } + + if (! decode_arm_unwind (filedata, aux, 0, 0, table_offset, table_sec, + &extab_arm_sec)) + res = FALSE; + } + } + + printf ("\n"); + + free (aux->funtab); + arm_free_section (&exidx_arm_sec); + arm_free_section (&extab_arm_sec); + + return res; +} + +/* Used for both ARM and C6X unwinding tables. */ + +static bfd_boolean +arm_process_unwind (Filedata * filedata) +{ + struct arm_unw_aux_info aux; + Elf_Internal_Shdr *unwsec = NULL; + Elf_Internal_Shdr *strsec; + Elf_Internal_Shdr *sec; + unsigned long i; + unsigned int sec_type; + bfd_boolean res = TRUE; + + switch (filedata->file_header.e_machine) + { + case EM_ARM: + sec_type = SHT_ARM_EXIDX; + break; + + case EM_TI_C6000: + sec_type = SHT_C6000_UNWIND; + break; + + default: + error (_("Unsupported architecture type %d encountered when processing unwind table\n"), + filedata->file_header.e_machine); + return FALSE; + } + + if (filedata->string_table == NULL) + return FALSE; + + memset (& aux, 0, sizeof (aux)); + aux.filedata = filedata; + + for (i = 0, sec = filedata->section_headers; i < filedata->file_header.e_shnum; ++i, ++sec) + { + if (sec->sh_type == SHT_SYMTAB && sec->sh_link < filedata->file_header.e_shnum) + { + aux.symtab = GET_ELF_SYMBOLS (filedata, sec, & aux.nsyms); + + strsec = filedata->section_headers + sec->sh_link; + + /* PR binutils/17531 file: 011-12666-0.004. */ + if (aux.strtab != NULL) + { + error (_("Multiple string tables found in file.\n")); + free (aux.strtab); + res = FALSE; + } + aux.strtab = get_data (NULL, filedata, strsec->sh_offset, + 1, strsec->sh_size, _("string table")); + aux.strtab_size = aux.strtab != NULL ? strsec->sh_size : 0; + } + else if (sec->sh_type == sec_type) + unwsec = sec; + } + + if (unwsec == NULL) + printf (_("\nThere are no unwind sections in this file.\n")); + else + for (i = 0, sec = filedata->section_headers; i < filedata->file_header.e_shnum; ++i, ++sec) + { + if (sec->sh_type == sec_type) + { + unsigned long num_unwind = sec->sh_size / (2 * eh_addr_size); + printf (ngettext ("\nUnwind section '%s' at offset 0x%lx " + "contains %lu entry:\n", + "\nUnwind section '%s' at offset 0x%lx " + "contains %lu entries:\n", + num_unwind), + printable_section_name (filedata, sec), + (unsigned long) sec->sh_offset, + num_unwind); + + if (! dump_arm_unwind (filedata, &aux, sec)) + res = FALSE; + } + } + + if (aux.symtab) + free (aux.symtab); + if (aux.strtab) + free ((char *) aux.strtab); + + return res; +} + +static bfd_boolean +process_unwind (Filedata * filedata) +{ + struct unwind_handler + { + unsigned int machtype; + bfd_boolean (* handler)(Filedata *); + } handlers[] = + { + { EM_ARM, arm_process_unwind }, + { EM_IA_64, ia64_process_unwind }, + { EM_PARISC, hppa_process_unwind }, + { EM_TI_C6000, arm_process_unwind }, + { 0, NULL } + }; + int i; + + if (!do_unwind) + return TRUE; + + for (i = 0; handlers[i].handler != NULL; i++) + if (filedata->file_header.e_machine == handlers[i].machtype) + return handlers[i].handler (filedata); + + printf (_("\nThe decoding of unwind sections for machine type %s is not currently supported.\n"), + get_machine_name (filedata->file_header.e_machine)); + return TRUE; +} + +static void +dynamic_section_mips_val (Elf_Internal_Dyn * entry) +{ + switch (entry->d_tag) + { + case DT_MIPS_FLAGS: + if (entry->d_un.d_val == 0) + printf (_("NONE")); + else + { + static const char * opts[] = + { + "QUICKSTART", "NOTPOT", "NO_LIBRARY_REPLACEMENT", + "NO_MOVE", "SGI_ONLY", "GUARANTEE_INIT", "DELTA_C_PLUS_PLUS", + "GUARANTEE_START_INIT", "PIXIE", "DEFAULT_DELAY_LOAD", + "REQUICKSTART", "REQUICKSTARTED", "CORD", "NO_UNRES_UNDEF", + "RLD_ORDER_SAFE" + }; + unsigned int cnt; + bfd_boolean first = TRUE; + + for (cnt = 0; cnt < ARRAY_SIZE (opts); ++cnt) + if (entry->d_un.d_val & (1 << cnt)) + { + printf ("%s%s", first ? "" : " ", opts[cnt]); + first = FALSE; + } + } + break; + + case DT_MIPS_IVERSION: + if (VALID_DYNAMIC_NAME (entry->d_un.d_val)) + printf (_("Interface Version: %s"), GET_DYNAMIC_NAME (entry->d_un.d_val)); + else + { + char buf[40]; + sprintf_vma (buf, entry->d_un.d_ptr); + /* Note: coded this way so that there is a single string for translation. */ + printf (_(""), buf); + } + break; + + case DT_MIPS_TIME_STAMP: + { + char timebuf[128]; + struct tm * tmp; + time_t atime = entry->d_un.d_val; + + tmp = gmtime (&atime); + /* PR 17531: file: 6accc532. */ + if (tmp == NULL) + snprintf (timebuf, sizeof (timebuf), _("")); + else + snprintf (timebuf, sizeof (timebuf), "%04u-%02u-%02uT%02u:%02u:%02u", + tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, + tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + printf (_("Time Stamp: %s"), timebuf); + } + break; + + case DT_MIPS_RLD_VERSION: + case DT_MIPS_LOCAL_GOTNO: + case DT_MIPS_CONFLICTNO: + case DT_MIPS_LIBLISTNO: + case DT_MIPS_SYMTABNO: + case DT_MIPS_UNREFEXTNO: + case DT_MIPS_HIPAGENO: + case DT_MIPS_DELTA_CLASS_NO: + case DT_MIPS_DELTA_INSTANCE_NO: + case DT_MIPS_DELTA_RELOC_NO: + case DT_MIPS_DELTA_SYM_NO: + case DT_MIPS_DELTA_CLASSSYM_NO: + case DT_MIPS_COMPACT_SIZE: + print_vma (entry->d_un.d_val, DEC); + break; + + default: + print_vma (entry->d_un.d_ptr, PREFIX_HEX); + } + putchar ('\n'); +} + +static void +dynamic_section_parisc_val (Elf_Internal_Dyn * entry) +{ + switch (entry->d_tag) + { + case DT_HP_DLD_FLAGS: + { + static struct + { + long int bit; + const char * str; + } + flags[] = + { + { DT_HP_DEBUG_PRIVATE, "HP_DEBUG_PRIVATE" }, + { DT_HP_DEBUG_CALLBACK, "HP_DEBUG_CALLBACK" }, + { DT_HP_DEBUG_CALLBACK_BOR, "HP_DEBUG_CALLBACK_BOR" }, + { DT_HP_NO_ENVVAR, "HP_NO_ENVVAR" }, + { DT_HP_BIND_NOW, "HP_BIND_NOW" }, + { DT_HP_BIND_NONFATAL, "HP_BIND_NONFATAL" }, + { DT_HP_BIND_VERBOSE, "HP_BIND_VERBOSE" }, + { DT_HP_BIND_RESTRICTED, "HP_BIND_RESTRICTED" }, + { DT_HP_BIND_SYMBOLIC, "HP_BIND_SYMBOLIC" }, + { DT_HP_RPATH_FIRST, "HP_RPATH_FIRST" }, + { DT_HP_BIND_DEPTH_FIRST, "HP_BIND_DEPTH_FIRST" }, + { DT_HP_GST, "HP_GST" }, + { DT_HP_SHLIB_FIXED, "HP_SHLIB_FIXED" }, + { DT_HP_MERGE_SHLIB_SEG, "HP_MERGE_SHLIB_SEG" }, + { DT_HP_NODELETE, "HP_NODELETE" }, + { DT_HP_GROUP, "HP_GROUP" }, + { DT_HP_PROTECT_LINKAGE_TABLE, "HP_PROTECT_LINKAGE_TABLE" } + }; + bfd_boolean first = TRUE; + size_t cnt; + bfd_vma val = entry->d_un.d_val; + + for (cnt = 0; cnt < ARRAY_SIZE (flags); ++cnt) + if (val & flags[cnt].bit) + { + if (! first) + putchar (' '); + fputs (flags[cnt].str, stdout); + first = FALSE; + val ^= flags[cnt].bit; + } + + if (val != 0 || first) + { + if (! first) + putchar (' '); + print_vma (val, HEX); + } + } + break; + + default: + print_vma (entry->d_un.d_ptr, PREFIX_HEX); + break; + } + putchar ('\n'); +} + +#ifdef BFD64 + +/* VMS vs Unix time offset and factor. */ + +#define VMS_EPOCH_OFFSET 35067168000000000LL +#define VMS_GRANULARITY_FACTOR 10000000 + +/* Display a VMS time in a human readable format. */ + +static void +print_vms_time (bfd_int64_t vmstime) +{ + struct tm *tm; + time_t unxtime; + + unxtime = (vmstime - VMS_EPOCH_OFFSET) / VMS_GRANULARITY_FACTOR; + tm = gmtime (&unxtime); + printf ("%04u-%02u-%02uT%02u:%02u:%02u", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); +} +#endif /* BFD64 */ + +static void +dynamic_section_ia64_val (Elf_Internal_Dyn * entry) +{ + switch (entry->d_tag) + { + case DT_IA_64_PLT_RESERVE: + /* First 3 slots reserved. */ + print_vma (entry->d_un.d_ptr, PREFIX_HEX); + printf (" -- "); + print_vma (entry->d_un.d_ptr + (3 * 8), PREFIX_HEX); + break; + + case DT_IA_64_VMS_LINKTIME: +#ifdef BFD64 + print_vms_time (entry->d_un.d_val); +#endif + break; + + case DT_IA_64_VMS_LNKFLAGS: + print_vma (entry->d_un.d_ptr, PREFIX_HEX); + if (entry->d_un.d_val & VMS_LF_CALL_DEBUG) + printf (" CALL_DEBUG"); + if (entry->d_un.d_val & VMS_LF_NOP0BUFS) + printf (" NOP0BUFS"); + if (entry->d_un.d_val & VMS_LF_P0IMAGE) + printf (" P0IMAGE"); + if (entry->d_un.d_val & VMS_LF_MKTHREADS) + printf (" MKTHREADS"); + if (entry->d_un.d_val & VMS_LF_UPCALLS) + printf (" UPCALLS"); + if (entry->d_un.d_val & VMS_LF_IMGSTA) + printf (" IMGSTA"); + if (entry->d_un.d_val & VMS_LF_INITIALIZE) + printf (" INITIALIZE"); + if (entry->d_un.d_val & VMS_LF_MAIN) + printf (" MAIN"); + if (entry->d_un.d_val & VMS_LF_EXE_INIT) + printf (" EXE_INIT"); + if (entry->d_un.d_val & VMS_LF_TBK_IN_IMG) + printf (" TBK_IN_IMG"); + if (entry->d_un.d_val & VMS_LF_DBG_IN_IMG) + printf (" DBG_IN_IMG"); + if (entry->d_un.d_val & VMS_LF_TBK_IN_DSF) + printf (" TBK_IN_DSF"); + if (entry->d_un.d_val & VMS_LF_DBG_IN_DSF) + printf (" DBG_IN_DSF"); + if (entry->d_un.d_val & VMS_LF_SIGNATURES) + printf (" SIGNATURES"); + if (entry->d_un.d_val & VMS_LF_REL_SEG_OFF) + printf (" REL_SEG_OFF"); + break; + + default: + print_vma (entry->d_un.d_ptr, PREFIX_HEX); + break; + } + putchar ('\n'); +} + +static bfd_boolean +get_32bit_dynamic_section (Filedata * filedata) +{ + Elf32_External_Dyn * edyn; + Elf32_External_Dyn * ext; + Elf_Internal_Dyn * entry; + + edyn = (Elf32_External_Dyn *) get_data (NULL, filedata, dynamic_addr, 1, + dynamic_size, _("dynamic section")); + if (!edyn) + return FALSE; + + /* SGI's ELF has more than one section in the DYNAMIC segment, and we + might not have the luxury of section headers. Look for the DT_NULL + terminator to determine the number of entries. */ + for (ext = edyn, dynamic_nent = 0; + (char *) (ext + 1) <= (char *) edyn + dynamic_size; + ext++) + { + dynamic_nent++; + if (BYTE_GET (ext->d_tag) == DT_NULL) + break; + } + + dynamic_section = (Elf_Internal_Dyn *) cmalloc (dynamic_nent, + sizeof (* entry)); + if (dynamic_section == NULL) + { + error (_("Out of memory allocating space for %lu dynamic entries\n"), + (unsigned long) dynamic_nent); + free (edyn); + return FALSE; + } + + for (ext = edyn, entry = dynamic_section; + entry < dynamic_section + dynamic_nent; + ext++, entry++) + { + entry->d_tag = BYTE_GET (ext->d_tag); + entry->d_un.d_val = BYTE_GET (ext->d_un.d_val); + } + + free (edyn); + + return TRUE; +} + +static bfd_boolean +get_64bit_dynamic_section (Filedata * filedata) +{ + Elf64_External_Dyn * edyn; + Elf64_External_Dyn * ext; + Elf_Internal_Dyn * entry; + + /* Read in the data. */ + edyn = (Elf64_External_Dyn *) get_data (NULL, filedata, dynamic_addr, 1, + dynamic_size, _("dynamic section")); + if (!edyn) + return FALSE; + + /* SGI's ELF has more than one section in the DYNAMIC segment, and we + might not have the luxury of section headers. Look for the DT_NULL + terminator to determine the number of entries. */ + for (ext = edyn, dynamic_nent = 0; + /* PR 17533 file: 033-67080-0.004 - do not read past end of buffer. */ + (char *) (ext + 1) <= (char *) edyn + dynamic_size; + ext++) + { + dynamic_nent++; + if (BYTE_GET (ext->d_tag) == DT_NULL) + break; + } + + dynamic_section = (Elf_Internal_Dyn *) cmalloc (dynamic_nent, + sizeof (* entry)); + if (dynamic_section == NULL) + { + error (_("Out of memory allocating space for %lu dynamic entries\n"), + (unsigned long) dynamic_nent); + free (edyn); + return FALSE; + } + + /* Convert from external to internal formats. */ + for (ext = edyn, entry = dynamic_section; + entry < dynamic_section + dynamic_nent; + ext++, entry++) + { + entry->d_tag = BYTE_GET (ext->d_tag); + entry->d_un.d_val = BYTE_GET (ext->d_un.d_val); + } + + free (edyn); + + return TRUE; +} + +static void +print_dynamic_flags (bfd_vma flags) +{ + bfd_boolean first = TRUE; + + while (flags) + { + bfd_vma flag; + + flag = flags & - flags; + flags &= ~ flag; + + if (first) + first = FALSE; + else + putc (' ', stdout); + + switch (flag) + { + case DF_ORIGIN: fputs ("ORIGIN", stdout); break; + case DF_SYMBOLIC: fputs ("SYMBOLIC", stdout); break; + case DF_TEXTREL: fputs ("TEXTREL", stdout); break; + case DF_BIND_NOW: fputs ("BIND_NOW", stdout); break; + case DF_STATIC_TLS: fputs ("STATIC_TLS", stdout); break; + default: fputs (_("unknown"), stdout); break; + } + } + puts (""); +} + +/* Parse and display the contents of the dynamic section. */ + +static bfd_boolean +process_dynamic_section (Filedata * filedata) +{ + Elf_Internal_Dyn * entry; + + if (dynamic_size == 0) + { + if (do_dynamic) + printf (_("\nThere is no dynamic section in this file.\n")); + + return TRUE; + } + + if (is_32bit_elf) + { + if (! get_32bit_dynamic_section (filedata)) + return FALSE; + } + else + { + if (! get_64bit_dynamic_section (filedata)) + return FALSE; + } + + /* Find the appropriate symbol table. */ + if (dynamic_symbols == NULL) + { + for (entry = dynamic_section; + entry < dynamic_section + dynamic_nent; + ++entry) + { + Elf_Internal_Shdr section; + + if (entry->d_tag != DT_SYMTAB) + continue; + + dynamic_info[DT_SYMTAB] = entry->d_un.d_val; + + /* Since we do not know how big the symbol table is, + we default to reading in the entire file (!) and + processing that. This is overkill, I know, but it + should work. */ + section.sh_offset = offset_from_vma (filedata, entry->d_un.d_val, 0); + if ((bfd_size_type) section.sh_offset > filedata->file_size) + { + /* See PR 21379 for a reproducer. */ + error (_("Invalid DT_SYMTAB entry: %lx"), (long) section.sh_offset); + return FALSE; + } + + if (archive_file_offset != 0) + section.sh_size = archive_file_size - section.sh_offset; + else + section.sh_size = filedata->file_size - section.sh_offset; + + if (is_32bit_elf) + section.sh_entsize = sizeof (Elf32_External_Sym); + else + section.sh_entsize = sizeof (Elf64_External_Sym); + section.sh_name = filedata->string_table_length; + + dynamic_symbols = GET_ELF_SYMBOLS (filedata, §ion, & num_dynamic_syms); + if (num_dynamic_syms < 1) + { + error (_("Unable to determine the number of symbols to load\n")); + continue; + } + } + } + + /* Similarly find a string table. */ + if (dynamic_strings == NULL) + { + for (entry = dynamic_section; + entry < dynamic_section + dynamic_nent; + ++entry) + { + unsigned long offset; + long str_tab_len; + + if (entry->d_tag != DT_STRTAB) + continue; + + dynamic_info[DT_STRTAB] = entry->d_un.d_val; + + /* Since we do not know how big the string table is, + we default to reading in the entire file (!) and + processing that. This is overkill, I know, but it + should work. */ + + offset = offset_from_vma (filedata, entry->d_un.d_val, 0); + + if (archive_file_offset != 0) + str_tab_len = archive_file_size - offset; + else + str_tab_len = filedata->file_size; + + if (str_tab_len < 1) + { + error + (_("Unable to determine the length of the dynamic string table\n")); + continue; + } + + dynamic_strings = (char *) get_data (NULL, filedata, offset, 1, + str_tab_len, + _("dynamic string table")); + dynamic_strings_length = dynamic_strings == NULL ? 0 : str_tab_len; + break; + } + } + + /* And find the syminfo section if available. */ + if (dynamic_syminfo == NULL) + { + unsigned long syminsz = 0; + + for (entry = dynamic_section; + entry < dynamic_section + dynamic_nent; + ++entry) + { + if (entry->d_tag == DT_SYMINENT) + { + /* Note: these braces are necessary to avoid a syntax + error from the SunOS4 C compiler. */ + /* PR binutils/17531: A corrupt file can trigger this test. + So do not use an assert, instead generate an error message. */ + if (sizeof (Elf_External_Syminfo) != entry->d_un.d_val) + error (_("Bad value (%d) for SYMINENT entry\n"), + (int) entry->d_un.d_val); + } + else if (entry->d_tag == DT_SYMINSZ) + syminsz = entry->d_un.d_val; + else if (entry->d_tag == DT_SYMINFO) + dynamic_syminfo_offset = offset_from_vma (filedata, entry->d_un.d_val, + syminsz); + } + + if (dynamic_syminfo_offset != 0 && syminsz != 0) + { + Elf_External_Syminfo * extsyminfo; + Elf_External_Syminfo * extsym; + Elf_Internal_Syminfo * syminfo; + + /* There is a syminfo section. Read the data. */ + extsyminfo = (Elf_External_Syminfo *) + get_data (NULL, filedata, dynamic_syminfo_offset, 1, syminsz, + _("symbol information")); + if (!extsyminfo) + return FALSE; + + dynamic_syminfo = (Elf_Internal_Syminfo *) malloc (syminsz); + if (dynamic_syminfo == NULL) + { + error (_("Out of memory allocating %lu byte for dynamic symbol info\n"), + (unsigned long) syminsz); + return FALSE; + } + + dynamic_syminfo_nent = syminsz / sizeof (Elf_External_Syminfo); + for (syminfo = dynamic_syminfo, extsym = extsyminfo; + syminfo < dynamic_syminfo + dynamic_syminfo_nent; + ++syminfo, ++extsym) + { + syminfo->si_boundto = BYTE_GET (extsym->si_boundto); + syminfo->si_flags = BYTE_GET (extsym->si_flags); + } + + free (extsyminfo); + } + } + + if (do_dynamic && dynamic_addr) + printf (ngettext ("\nDynamic section at offset 0x%lx " + "contains %lu entry:\n", + "\nDynamic section at offset 0x%lx " + "contains %lu entries:\n", + dynamic_nent), + dynamic_addr, (unsigned long) dynamic_nent); + if (do_dynamic) + printf (_(" Tag Type Name/Value\n")); + + for (entry = dynamic_section; + entry < dynamic_section + dynamic_nent; + entry++) + { + if (do_dynamic) + { + const char * dtype; + + putchar (' '); + print_vma (entry->d_tag, FULL_HEX); + dtype = get_dynamic_type (filedata, entry->d_tag); + printf (" (%s)%*s", dtype, + ((is_32bit_elf ? 27 : 19) - (int) strlen (dtype)), " "); + } + + switch (entry->d_tag) + { + case DT_FLAGS: + if (do_dynamic) + print_dynamic_flags (entry->d_un.d_val); + break; + + case DT_AUXILIARY: + case DT_FILTER: + case DT_CONFIG: + case DT_DEPAUDIT: + case DT_AUDIT: + if (do_dynamic) + { + switch (entry->d_tag) + { + case DT_AUXILIARY: + printf (_("Auxiliary library")); + break; + + case DT_FILTER: + printf (_("Filter library")); + break; + + case DT_CONFIG: + printf (_("Configuration file")); + break; + + case DT_DEPAUDIT: + printf (_("Dependency audit library")); + break; + + case DT_AUDIT: + printf (_("Audit library")); + break; + } + + if (VALID_DYNAMIC_NAME (entry->d_un.d_val)) + printf (": [%s]\n", GET_DYNAMIC_NAME (entry->d_un.d_val)); + else + { + printf (": "); + print_vma (entry->d_un.d_val, PREFIX_HEX); + putchar ('\n'); + } + } + break; + + case DT_FEATURE: + if (do_dynamic) + { + printf (_("Flags:")); + + if (entry->d_un.d_val == 0) + printf (_(" None\n")); + else + { + unsigned long int val = entry->d_un.d_val; + + if (val & DTF_1_PARINIT) + { + printf (" PARINIT"); + val ^= DTF_1_PARINIT; + } + if (val & DTF_1_CONFEXP) + { + printf (" CONFEXP"); + val ^= DTF_1_CONFEXP; + } + if (val != 0) + printf (" %lx", val); + puts (""); + } + } + break; + + case DT_POSFLAG_1: + if (do_dynamic) + { + printf (_("Flags:")); + + if (entry->d_un.d_val == 0) + printf (_(" None\n")); + else + { + unsigned long int val = entry->d_un.d_val; + + if (val & DF_P1_LAZYLOAD) + { + printf (" LAZYLOAD"); + val ^= DF_P1_LAZYLOAD; + } + if (val & DF_P1_GROUPPERM) + { + printf (" GROUPPERM"); + val ^= DF_P1_GROUPPERM; + } + if (val != 0) + printf (" %lx", val); + puts (""); + } + } + break; + + case DT_FLAGS_1: + if (do_dynamic) + { + printf (_("Flags:")); + if (entry->d_un.d_val == 0) + printf (_(" None\n")); + else + { + unsigned long int val = entry->d_un.d_val; + + if (val & DF_1_NOW) + { + printf (" NOW"); + val ^= DF_1_NOW; + } + if (val & DF_1_GLOBAL) + { + printf (" GLOBAL"); + val ^= DF_1_GLOBAL; + } + if (val & DF_1_GROUP) + { + printf (" GROUP"); + val ^= DF_1_GROUP; + } + if (val & DF_1_NODELETE) + { + printf (" NODELETE"); + val ^= DF_1_NODELETE; + } + if (val & DF_1_LOADFLTR) + { + printf (" LOADFLTR"); + val ^= DF_1_LOADFLTR; + } + if (val & DF_1_INITFIRST) + { + printf (" INITFIRST"); + val ^= DF_1_INITFIRST; + } + if (val & DF_1_NOOPEN) + { + printf (" NOOPEN"); + val ^= DF_1_NOOPEN; + } + if (val & DF_1_ORIGIN) + { + printf (" ORIGIN"); + val ^= DF_1_ORIGIN; + } + if (val & DF_1_DIRECT) + { + printf (" DIRECT"); + val ^= DF_1_DIRECT; + } + if (val & DF_1_TRANS) + { + printf (" TRANS"); + val ^= DF_1_TRANS; + } + if (val & DF_1_INTERPOSE) + { + printf (" INTERPOSE"); + val ^= DF_1_INTERPOSE; + } + if (val & DF_1_NODEFLIB) + { + printf (" NODEFLIB"); + val ^= DF_1_NODEFLIB; + } + if (val & DF_1_NODUMP) + { + printf (" NODUMP"); + val ^= DF_1_NODUMP; + } + if (val & DF_1_CONFALT) + { + printf (" CONFALT"); + val ^= DF_1_CONFALT; + } + if (val & DF_1_ENDFILTEE) + { + printf (" ENDFILTEE"); + val ^= DF_1_ENDFILTEE; + } + if (val & DF_1_DISPRELDNE) + { + printf (" DISPRELDNE"); + val ^= DF_1_DISPRELDNE; + } + if (val & DF_1_DISPRELPND) + { + printf (" DISPRELPND"); + val ^= DF_1_DISPRELPND; + } + if (val & DF_1_NODIRECT) + { + printf (" NODIRECT"); + val ^= DF_1_NODIRECT; + } + if (val & DF_1_IGNMULDEF) + { + printf (" IGNMULDEF"); + val ^= DF_1_IGNMULDEF; + } + if (val & DF_1_NOKSYMS) + { + printf (" NOKSYMS"); + val ^= DF_1_NOKSYMS; + } + if (val & DF_1_NOHDR) + { + printf (" NOHDR"); + val ^= DF_1_NOHDR; + } + if (val & DF_1_EDITED) + { + printf (" EDITED"); + val ^= DF_1_EDITED; + } + if (val & DF_1_NORELOC) + { + printf (" NORELOC"); + val ^= DF_1_NORELOC; + } + if (val & DF_1_SYMINTPOSE) + { + printf (" SYMINTPOSE"); + val ^= DF_1_SYMINTPOSE; + } + if (val & DF_1_GLOBAUDIT) + { + printf (" GLOBAUDIT"); + val ^= DF_1_GLOBAUDIT; + } + if (val & DF_1_SINGLETON) + { + printf (" SINGLETON"); + val ^= DF_1_SINGLETON; + } + if (val & DF_1_STUB) + { + printf (" STUB"); + val ^= DF_1_STUB; + } + if (val & DF_1_PIE) + { + printf (" PIE"); + val ^= DF_1_PIE; + } + if (val != 0) + printf (" %lx", val); + puts (""); + } + } + break; + + case DT_PLTREL: + dynamic_info[entry->d_tag] = entry->d_un.d_val; + if (do_dynamic) + puts (get_dynamic_type (filedata, entry->d_un.d_val)); + break; + + case DT_NULL : + case DT_NEEDED : + case DT_PLTGOT : + case DT_HASH : + case DT_STRTAB : + case DT_SYMTAB : + case DT_RELA : + case DT_INIT : + case DT_FINI : + case DT_SONAME : + case DT_RPATH : + case DT_SYMBOLIC: + case DT_REL : + case DT_DEBUG : + case DT_TEXTREL : + case DT_JMPREL : + case DT_RUNPATH : + dynamic_info[entry->d_tag] = entry->d_un.d_val; + + if (do_dynamic) + { + char * name; + + if (VALID_DYNAMIC_NAME (entry->d_un.d_val)) + name = GET_DYNAMIC_NAME (entry->d_un.d_val); + else + name = NULL; + + if (name) + { + switch (entry->d_tag) + { + case DT_NEEDED: + printf (_("Shared library: [%s]"), name); + + if (streq (name, program_interpreter)) + printf (_(" program interpreter")); + break; + + case DT_SONAME: + printf (_("Library soname: [%s]"), name); + break; + + case DT_RPATH: + printf (_("Library rpath: [%s]"), name); + break; + + case DT_RUNPATH: + printf (_("Library runpath: [%s]"), name); + break; + + default: + print_vma (entry->d_un.d_val, PREFIX_HEX); + break; + } + } + else + print_vma (entry->d_un.d_val, PREFIX_HEX); + + putchar ('\n'); + } + break; + + case DT_PLTRELSZ: + case DT_RELASZ : + case DT_STRSZ : + case DT_RELSZ : + case DT_RELAENT : + case DT_SYMENT : + case DT_RELENT : + dynamic_info[entry->d_tag] = entry->d_un.d_val; + /* Fall through. */ + case DT_PLTPADSZ: + case DT_MOVEENT : + case DT_MOVESZ : + case DT_INIT_ARRAYSZ: + case DT_FINI_ARRAYSZ: + case DT_GNU_CONFLICTSZ: + case DT_GNU_LIBLISTSZ: + if (do_dynamic) + { + print_vma (entry->d_un.d_val, UNSIGNED); + printf (_(" (bytes)\n")); + } + break; + + case DT_VERDEFNUM: + case DT_VERNEEDNUM: + case DT_RELACOUNT: + case DT_RELCOUNT: + if (do_dynamic) + { + print_vma (entry->d_un.d_val, UNSIGNED); + putchar ('\n'); + } + break; + + case DT_SYMINSZ: + case DT_SYMINENT: + case DT_SYMINFO: + case DT_USED: + case DT_INIT_ARRAY: + case DT_FINI_ARRAY: + if (do_dynamic) + { + if (entry->d_tag == DT_USED + && VALID_DYNAMIC_NAME (entry->d_un.d_val)) + { + char * name = GET_DYNAMIC_NAME (entry->d_un.d_val); + + if (*name) + { + printf (_("Not needed object: [%s]\n"), name); + break; + } + } + + print_vma (entry->d_un.d_val, PREFIX_HEX); + putchar ('\n'); + } + break; + + case DT_BIND_NOW: + /* The value of this entry is ignored. */ + if (do_dynamic) + putchar ('\n'); + break; + + case DT_GNU_PRELINKED: + if (do_dynamic) + { + struct tm * tmp; + time_t atime = entry->d_un.d_val; + + tmp = gmtime (&atime); + /* PR 17533 file: 041-1244816-0.004. */ + if (tmp == NULL) + printf (_("tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, + tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + + } + break; + + case DT_GNU_HASH: + dynamic_info_DT_GNU_HASH = entry->d_un.d_val; + if (do_dynamic) + { + print_vma (entry->d_un.d_val, PREFIX_HEX); + putchar ('\n'); + } + break; + + default: + if ((entry->d_tag >= DT_VERSYM) && (entry->d_tag <= DT_VERNEEDNUM)) + version_info[DT_VERSIONTAGIDX (entry->d_tag)] = + entry->d_un.d_val; + + if (do_dynamic) + { + switch (filedata->file_header.e_machine) + { + case EM_MIPS: + case EM_MIPS_RS3_LE: + dynamic_section_mips_val (entry); + break; + case EM_PARISC: + dynamic_section_parisc_val (entry); + break; + case EM_IA_64: + dynamic_section_ia64_val (entry); + break; + default: + print_vma (entry->d_un.d_val, PREFIX_HEX); + putchar ('\n'); + } + } + break; + } + } + + return TRUE; +} + +static char * +get_ver_flags (unsigned int flags) +{ + static char buff[32]; + + buff[0] = 0; + + if (flags == 0) + return _("none"); + + if (flags & VER_FLG_BASE) + strcat (buff, "BASE"); + + if (flags & VER_FLG_WEAK) + { + if (flags & VER_FLG_BASE) + strcat (buff, " | "); + + strcat (buff, "WEAK"); + } + + if (flags & VER_FLG_INFO) + { + if (flags & (VER_FLG_BASE|VER_FLG_WEAK)) + strcat (buff, " | "); + + strcat (buff, "INFO"); + } + + if (flags & ~(VER_FLG_BASE | VER_FLG_WEAK | VER_FLG_INFO)) + { + if (flags & (VER_FLG_BASE | VER_FLG_WEAK | VER_FLG_INFO)) + strcat (buff, " | "); + + strcat (buff, _("")); + } + + return buff; +} + +/* Display the contents of the version sections. */ + +static bfd_boolean +process_version_sections (Filedata * filedata) +{ + Elf_Internal_Shdr * section; + unsigned i; + bfd_boolean found = FALSE; + + if (! do_version) + return TRUE; + + for (i = 0, section = filedata->section_headers; + i < filedata->file_header.e_shnum; + i++, section++) + { + switch (section->sh_type) + { + case SHT_GNU_verdef: + { + Elf_External_Verdef * edefs; + unsigned long idx; + unsigned long cnt; + char * endbuf; + + found = TRUE; + + printf (ngettext ("\nVersion definition section '%s' " + "contains %u entry:\n", + "\nVersion definition section '%s' " + "contains %u entries:\n", + section->sh_info), + printable_section_name (filedata, section), + section->sh_info); + + printf (_(" Addr: 0x")); + printf_vma (section->sh_addr); + printf (_(" Offset: %#08lx Link: %u (%s)\n"), + (unsigned long) section->sh_offset, section->sh_link, + printable_section_name_from_index (filedata, section->sh_link)); + + edefs = (Elf_External_Verdef *) + get_data (NULL, filedata, section->sh_offset, 1,section->sh_size, + _("version definition section")); + if (!edefs) + break; + endbuf = (char *) edefs + section->sh_size; + + for (idx = cnt = 0; cnt < section->sh_info; ++cnt) + { + char * vstart; + Elf_External_Verdef * edef; + Elf_Internal_Verdef ent; + Elf_External_Verdaux * eaux; + Elf_Internal_Verdaux aux; + unsigned long isum; + int j; + + vstart = ((char *) edefs) + idx; + if (vstart + sizeof (*edef) > endbuf) + break; + + edef = (Elf_External_Verdef *) vstart; + + ent.vd_version = BYTE_GET (edef->vd_version); + ent.vd_flags = BYTE_GET (edef->vd_flags); + ent.vd_ndx = BYTE_GET (edef->vd_ndx); + ent.vd_cnt = BYTE_GET (edef->vd_cnt); + ent.vd_hash = BYTE_GET (edef->vd_hash); + ent.vd_aux = BYTE_GET (edef->vd_aux); + ent.vd_next = BYTE_GET (edef->vd_next); + + printf (_(" %#06lx: Rev: %d Flags: %s"), + idx, ent.vd_version, get_ver_flags (ent.vd_flags)); + + printf (_(" Index: %d Cnt: %d "), + ent.vd_ndx, ent.vd_cnt); + + /* Check for overflow. */ + if (ent.vd_aux > (size_t) (endbuf - vstart)) + break; + + vstart += ent.vd_aux; + + if (vstart + sizeof (*eaux) > endbuf) + break; + eaux = (Elf_External_Verdaux *) vstart; + + aux.vda_name = BYTE_GET (eaux->vda_name); + aux.vda_next = BYTE_GET (eaux->vda_next); + + if (VALID_DYNAMIC_NAME (aux.vda_name)) + printf (_("Name: %s\n"), GET_DYNAMIC_NAME (aux.vda_name)); + else + printf (_("Name index: %ld\n"), aux.vda_name); + + isum = idx + ent.vd_aux; + + for (j = 1; j < ent.vd_cnt; j++) + { + if (aux.vda_next < sizeof (*eaux) + && !(j == ent.vd_cnt - 1 && aux.vda_next == 0)) + { + warn (_("Invalid vda_next field of %lx\n"), + aux.vda_next); + j = ent.vd_cnt; + break; + } + /* Check for overflow. */ + if (aux.vda_next > (size_t) (endbuf - vstart)) + break; + + isum += aux.vda_next; + vstart += aux.vda_next; + + if (vstart + sizeof (*eaux) > endbuf) + break; + eaux = (Elf_External_Verdaux *) vstart; + + aux.vda_name = BYTE_GET (eaux->vda_name); + aux.vda_next = BYTE_GET (eaux->vda_next); + + if (VALID_DYNAMIC_NAME (aux.vda_name)) + printf (_(" %#06lx: Parent %d: %s\n"), + isum, j, GET_DYNAMIC_NAME (aux.vda_name)); + else + printf (_(" %#06lx: Parent %d, name index: %ld\n"), + isum, j, aux.vda_name); + } + + if (j < ent.vd_cnt) + printf (_(" Version def aux past end of section\n")); + + /* PR 17531: + file: id:000001,src:000172+005151,op:splice,rep:2. */ + if (ent.vd_next < sizeof (*edef) + && !(cnt == section->sh_info - 1 && ent.vd_next == 0)) + { + warn (_("Invalid vd_next field of %lx\n"), ent.vd_next); + cnt = section->sh_info; + break; + } + if (ent.vd_next > (size_t) (endbuf - ((char *) edefs + idx))) + break; + + idx += ent.vd_next; + } + + if (cnt < section->sh_info) + printf (_(" Version definition past end of section\n")); + + free (edefs); + } + break; + + case SHT_GNU_verneed: + { + Elf_External_Verneed * eneed; + unsigned long idx; + unsigned long cnt; + char * endbuf; + + found = TRUE; + + printf (ngettext ("\nVersion needs section '%s' " + "contains %u entry:\n", + "\nVersion needs section '%s' " + "contains %u entries:\n", + section->sh_info), + printable_section_name (filedata, section), section->sh_info); + + printf (_(" Addr: 0x")); + printf_vma (section->sh_addr); + printf (_(" Offset: %#08lx Link: %u (%s)\n"), + (unsigned long) section->sh_offset, section->sh_link, + printable_section_name_from_index (filedata, section->sh_link)); + + eneed = (Elf_External_Verneed *) get_data (NULL, filedata, + section->sh_offset, 1, + section->sh_size, + _("Version Needs section")); + if (!eneed) + break; + endbuf = (char *) eneed + section->sh_size; + + for (idx = cnt = 0; cnt < section->sh_info; ++cnt) + { + Elf_External_Verneed * entry; + Elf_Internal_Verneed ent; + unsigned long isum; + int j; + char * vstart; + + vstart = ((char *) eneed) + idx; + if (vstart + sizeof (*entry) > endbuf) + break; + + entry = (Elf_External_Verneed *) vstart; + + ent.vn_version = BYTE_GET (entry->vn_version); + ent.vn_cnt = BYTE_GET (entry->vn_cnt); + ent.vn_file = BYTE_GET (entry->vn_file); + ent.vn_aux = BYTE_GET (entry->vn_aux); + ent.vn_next = BYTE_GET (entry->vn_next); + + printf (_(" %#06lx: Version: %d"), idx, ent.vn_version); + + if (VALID_DYNAMIC_NAME (ent.vn_file)) + printf (_(" File: %s"), GET_DYNAMIC_NAME (ent.vn_file)); + else + printf (_(" File: %lx"), ent.vn_file); + + printf (_(" Cnt: %d\n"), ent.vn_cnt); + + /* Check for overflow. */ + if (ent.vn_aux > (size_t) (endbuf - vstart)) + break; + vstart += ent.vn_aux; + + for (j = 0, isum = idx + ent.vn_aux; j < ent.vn_cnt; ++j) + { + Elf_External_Vernaux * eaux; + Elf_Internal_Vernaux aux; + + if (vstart + sizeof (*eaux) > endbuf) + break; + eaux = (Elf_External_Vernaux *) vstart; + + aux.vna_hash = BYTE_GET (eaux->vna_hash); + aux.vna_flags = BYTE_GET (eaux->vna_flags); + aux.vna_other = BYTE_GET (eaux->vna_other); + aux.vna_name = BYTE_GET (eaux->vna_name); + aux.vna_next = BYTE_GET (eaux->vna_next); + + if (VALID_DYNAMIC_NAME (aux.vna_name)) + printf (_(" %#06lx: Name: %s"), + isum, GET_DYNAMIC_NAME (aux.vna_name)); + else + printf (_(" %#06lx: Name index: %lx"), + isum, aux.vna_name); + + printf (_(" Flags: %s Version: %d\n"), + get_ver_flags (aux.vna_flags), aux.vna_other); + + if (aux.vna_next < sizeof (*eaux) + && !(j == ent.vn_cnt - 1 && aux.vna_next == 0)) + { + warn (_("Invalid vna_next field of %lx\n"), + aux.vna_next); + j = ent.vn_cnt; + break; + } + /* Check for overflow. */ + if (aux.vna_next > (size_t) (endbuf - vstart)) + break; + isum += aux.vna_next; + vstart += aux.vna_next; + } + + if (j < ent.vn_cnt) + warn (_("Missing Version Needs auxillary information\n")); + + if (ent.vn_next < sizeof (*entry) + && !(cnt == section->sh_info - 1 && ent.vn_next == 0)) + { + warn (_("Invalid vn_next field of %lx\n"), ent.vn_next); + cnt = section->sh_info; + break; + } + if (ent.vn_next > (size_t) (endbuf - ((char *) eneed + idx))) + break; + idx += ent.vn_next; + } + + if (cnt < section->sh_info) + warn (_("Missing Version Needs information\n")); + + free (eneed); + } + break; + + case SHT_GNU_versym: + { + Elf_Internal_Shdr * link_section; + size_t total; + unsigned int cnt; + unsigned char * edata; + unsigned short * data; + char * strtab; + Elf_Internal_Sym * symbols; + Elf_Internal_Shdr * string_sec; + unsigned long num_syms; + long off; + + if (section->sh_link >= filedata->file_header.e_shnum) + break; + + link_section = filedata->section_headers + section->sh_link; + total = section->sh_size / sizeof (Elf_External_Versym); + + if (link_section->sh_link >= filedata->file_header.e_shnum) + break; + + found = TRUE; + + symbols = GET_ELF_SYMBOLS (filedata, link_section, & num_syms); + if (symbols == NULL) + break; + + string_sec = filedata->section_headers + link_section->sh_link; + + strtab = (char *) get_data (NULL, filedata, string_sec->sh_offset, 1, + string_sec->sh_size, + _("version string table")); + if (!strtab) + { + free (symbols); + break; + } + + printf (ngettext ("\nVersion symbols section '%s' " + "contains %lu entry:\n", + "\nVersion symbols section '%s' " + "contains %lu entries:\n", + total), + printable_section_name (filedata, section), (unsigned long) total); + + printf (_(" Addr: ")); + printf_vma (section->sh_addr); + printf (_(" Offset: %#08lx Link: %u (%s)\n"), + (unsigned long) section->sh_offset, section->sh_link, + printable_section_name (filedata, link_section)); + + off = offset_from_vma (filedata, + version_info[DT_VERSIONTAGIDX (DT_VERSYM)], + total * sizeof (short)); + edata = (unsigned char *) get_data (NULL, filedata, off, total, + sizeof (short), + _("version symbol data")); + if (!edata) + { + free (strtab); + free (symbols); + break; + } + + data = (short unsigned int *) cmalloc (total, sizeof (short)); + + for (cnt = total; cnt --;) + data[cnt] = byte_get (edata + cnt * sizeof (short), + sizeof (short)); + + free (edata); + + for (cnt = 0; cnt < total; cnt += 4) + { + int j, nn; + char *name; + char *invalid = _("*invalid*"); + + printf (" %03x:", cnt); + + for (j = 0; (j < 4) && (cnt + j) < total; ++j) + switch (data[cnt + j]) + { + case 0: + fputs (_(" 0 (*local*) "), stdout); + break; + + case 1: + fputs (_(" 1 (*global*) "), stdout); + break; + + default: + nn = printf ("%4x%c", data[cnt + j] & VERSYM_VERSION, + data[cnt + j] & VERSYM_HIDDEN ? 'h' : ' '); + + /* If this index value is greater than the size of the symbols + array, break to avoid an out-of-bounds read. */ + if ((unsigned long)(cnt + j) >= num_syms) + { + warn (_("invalid index into symbol array\n")); + break; + } + + name = NULL; + if (version_info[DT_VERSIONTAGIDX (DT_VERNEED)]) + { + Elf_Internal_Verneed ivn; + unsigned long offset; + + offset = offset_from_vma + (filedata, version_info[DT_VERSIONTAGIDX (DT_VERNEED)], + sizeof (Elf_External_Verneed)); + + do + { + Elf_Internal_Vernaux ivna; + Elf_External_Verneed evn; + Elf_External_Vernaux evna; + unsigned long a_off; + + if (get_data (&evn, filedata, offset, sizeof (evn), 1, + _("version need")) == NULL) + break; + + ivn.vn_aux = BYTE_GET (evn.vn_aux); + ivn.vn_next = BYTE_GET (evn.vn_next); + + a_off = offset + ivn.vn_aux; + + do + { + if (get_data (&evna, filedata, a_off, sizeof (evna), + 1, _("version need aux (2)")) == NULL) + { + ivna.vna_next = 0; + ivna.vna_other = 0; + } + else + { + ivna.vna_next = BYTE_GET (evna.vna_next); + ivna.vna_other = BYTE_GET (evna.vna_other); + } + + a_off += ivna.vna_next; + } + while (ivna.vna_other != data[cnt + j] + && ivna.vna_next != 0); + + if (ivna.vna_other == data[cnt + j]) + { + ivna.vna_name = BYTE_GET (evna.vna_name); + + if (ivna.vna_name >= string_sec->sh_size) + name = invalid; + else + name = strtab + ivna.vna_name; + break; + } + + offset += ivn.vn_next; + } + while (ivn.vn_next); + } + + if (data[cnt + j] != 0x8001 + && version_info[DT_VERSIONTAGIDX (DT_VERDEF)]) + { + Elf_Internal_Verdef ivd; + Elf_External_Verdef evd; + unsigned long offset; + + offset = offset_from_vma + (filedata, version_info[DT_VERSIONTAGIDX (DT_VERDEF)], + sizeof evd); + + do + { + if (get_data (&evd, filedata, offset, sizeof (evd), 1, + _("version def")) == NULL) + { + ivd.vd_next = 0; + /* PR 17531: file: 046-1082287-0.004. */ + ivd.vd_ndx = (data[cnt + j] & VERSYM_VERSION) + 1; + break; + } + else + { + ivd.vd_next = BYTE_GET (evd.vd_next); + ivd.vd_ndx = BYTE_GET (evd.vd_ndx); + } + + offset += ivd.vd_next; + } + while (ivd.vd_ndx != (data[cnt + j] & VERSYM_VERSION) + && ivd.vd_next != 0); + + if (ivd.vd_ndx == (data[cnt + j] & VERSYM_VERSION)) + { + Elf_External_Verdaux evda; + Elf_Internal_Verdaux ivda; + + ivd.vd_aux = BYTE_GET (evd.vd_aux); + + if (get_data (&evda, filedata, + offset - ivd.vd_next + ivd.vd_aux, + sizeof (evda), 1, + _("version def aux")) == NULL) + break; + + ivda.vda_name = BYTE_GET (evda.vda_name); + + if (ivda.vda_name >= string_sec->sh_size) + name = invalid; + else if (name != NULL && name != invalid) + name = _("*both*"); + else + name = strtab + ivda.vda_name; + } + } + if (name != NULL) + nn += printf ("(%s%-*s", + name, + 12 - (int) strlen (name), + ")"); + + if (nn < 18) + printf ("%*c", 18 - nn, ' '); + } + + putchar ('\n'); + } + + free (data); + free (strtab); + free (symbols); + } + break; + + default: + break; + } + } + + if (! found) + printf (_("\nNo version information found in this file.\n")); + + return TRUE; +} + +static const char * +get_symbol_binding (Filedata * filedata, unsigned int binding) +{ + static char buff[32]; + + switch (binding) + { + case STB_LOCAL: return "LOCAL"; + case STB_GLOBAL: return "GLOBAL"; + case STB_WEAK: return "WEAK"; + default: + if (binding >= STB_LOPROC && binding <= STB_HIPROC) + snprintf (buff, sizeof (buff), _(": %d"), + binding); + else if (binding >= STB_LOOS && binding <= STB_HIOS) + { + if (binding == STB_GNU_UNIQUE + && (filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_GNU + /* GNU is still using the default value 0. */ + || filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_NONE)) + return "UNIQUE"; + snprintf (buff, sizeof (buff), _(": %d"), binding); + } + else + snprintf (buff, sizeof (buff), _(": %d"), binding); + return buff; + } +} + +static const char * +get_symbol_type (Filedata * filedata, unsigned int type) +{ + static char buff[32]; + + switch (type) + { + case STT_NOTYPE: return "NOTYPE"; + case STT_OBJECT: return "OBJECT"; + case STT_FUNC: return "FUNC"; + case STT_SECTION: return "SECTION"; + case STT_FILE: return "FILE"; + case STT_COMMON: return "COMMON"; + case STT_TLS: return "TLS"; + case STT_RELC: return "RELC"; + case STT_SRELC: return "SRELC"; + default: + if (type >= STT_LOPROC && type <= STT_HIPROC) + { + if (filedata->file_header.e_machine == EM_ARM && type == STT_ARM_TFUNC) + return "THUMB_FUNC"; + + if (filedata->file_header.e_machine == EM_SPARCV9 && type == STT_REGISTER) + return "REGISTER"; + + if (filedata->file_header.e_machine == EM_PARISC && type == STT_PARISC_MILLI) + return "PARISC_MILLI"; + + snprintf (buff, sizeof (buff), _(": %d"), type); + } + else if (type >= STT_LOOS && type <= STT_HIOS) + { + if (filedata->file_header.e_machine == EM_PARISC) + { + if (type == STT_HP_OPAQUE) + return "HP_OPAQUE"; + if (type == STT_HP_STUB) + return "HP_STUB"; + } + + if (type == STT_GNU_IFUNC + && (filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_GNU + || filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_FREEBSD + /* GNU is still using the default value 0. */ + || filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_NONE)) + return "IFUNC"; + + snprintf (buff, sizeof (buff), _(": %d"), type); + } + else + snprintf (buff, sizeof (buff), _(": %d"), type); + return buff; + } +} + +static const char * +get_symbol_visibility (unsigned int visibility) +{ + switch (visibility) + { + case STV_DEFAULT: return "DEFAULT"; + case STV_INTERNAL: return "INTERNAL"; + case STV_HIDDEN: return "HIDDEN"; + case STV_PROTECTED: return "PROTECTED"; + default: + error (_("Unrecognized visibility value: %u"), visibility); + return _(""); + } +} + +static const char * +get_solaris_symbol_visibility (unsigned int visibility) +{ + switch (visibility) + { + case 4: return "EXPORTED"; + case 5: return "SINGLETON"; + case 6: return "ELIMINATE"; + default: return get_symbol_visibility (visibility); + } +} + +static const char * +get_mips_symbol_other (unsigned int other) +{ + switch (other) + { + case STO_OPTIONAL: return "OPTIONAL"; + case STO_MIPS_PLT: return "MIPS PLT"; + case STO_MIPS_PIC: return "MIPS PIC"; + case STO_MICROMIPS: return "MICROMIPS"; + case STO_MICROMIPS | STO_MIPS_PIC: return "MICROMIPS, MIPS PIC"; + case STO_MIPS16: return "MIPS16"; + default: return NULL; + } +} + +static const char * +get_ia64_symbol_other (Filedata * filedata, unsigned int other) +{ + if (is_ia64_vms (filedata)) + { + static char res[32]; + + res[0] = 0; + + /* Function types is for images and .STB files only. */ + switch (filedata->file_header.e_type) + { + case ET_DYN: + case ET_EXEC: + switch (VMS_ST_FUNC_TYPE (other)) + { + case VMS_SFT_CODE_ADDR: + strcat (res, " CA"); + break; + case VMS_SFT_SYMV_IDX: + strcat (res, " VEC"); + break; + case VMS_SFT_FD: + strcat (res, " FD"); + break; + case VMS_SFT_RESERVE: + strcat (res, " RSV"); + break; + default: + warn (_("Unrecognized IA64 VMS ST Function type: %d\n"), + VMS_ST_FUNC_TYPE (other)); + strcat (res, " "); + break; + } + break; + default: + break; + } + switch (VMS_ST_LINKAGE (other)) + { + case VMS_STL_IGNORE: + strcat (res, " IGN"); + break; + case VMS_STL_RESERVE: + strcat (res, " RSV"); + break; + case VMS_STL_STD: + strcat (res, " STD"); + break; + case VMS_STL_LNK: + strcat (res, " LNK"); + break; + default: + warn (_("Unrecognized IA64 VMS ST Linkage: %d\n"), + VMS_ST_LINKAGE (other)); + strcat (res, " "); + break; + } + + if (res[0] != 0) + return res + 1; + else + return res; + } + return NULL; +} + +static const char * +get_ppc64_symbol_other (unsigned int other) +{ + if (PPC64_LOCAL_ENTRY_OFFSET (other) != 0) + { + static char buf[32]; + snprintf (buf, sizeof buf, _(": %d"), + PPC64_LOCAL_ENTRY_OFFSET (other)); + return buf; + } + return NULL; +} + +static const char * +get_symbol_other (Filedata * filedata, unsigned int other) +{ + const char * result = NULL; + static char buff [32]; + + if (other == 0) + return ""; + + switch (filedata->file_header.e_machine) + { + case EM_MIPS: + result = get_mips_symbol_other (other); + break; + case EM_IA_64: + result = get_ia64_symbol_other (filedata, other); + break; + case EM_PPC64: + result = get_ppc64_symbol_other (other); + break; + default: + result = NULL; + break; + } + + if (result) + return result; + + snprintf (buff, sizeof buff, _(": %x"), other); + return buff; +} + +static const char * +get_symbol_index_type (Filedata * filedata, unsigned int type) +{ + static char buff[32]; + + switch (type) + { + case SHN_UNDEF: return "UND"; + case SHN_ABS: return "ABS"; + case SHN_COMMON: return "COM"; + default: + if (type == SHN_IA_64_ANSI_COMMON + && filedata->file_header.e_machine == EM_IA_64 + && filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_HPUX) + return "ANSI_COM"; + else if ((filedata->file_header.e_machine == EM_X86_64 + || filedata->file_header.e_machine == EM_L1OM + || filedata->file_header.e_machine == EM_K1OM) + && type == SHN_X86_64_LCOMMON) + return "LARGE_COM"; + else if ((type == SHN_MIPS_SCOMMON + && filedata->file_header.e_machine == EM_MIPS) + || (type == SHN_TIC6X_SCOMMON + && filedata->file_header.e_machine == EM_TI_C6000)) + return "SCOM"; + else if (type == SHN_MIPS_SUNDEFINED + && filedata->file_header.e_machine == EM_MIPS) + return "SUND"; + else if (type >= SHN_LOPROC && type <= SHN_HIPROC) + sprintf (buff, "PRC[0x%04x]", type & 0xffff); + else if (type >= SHN_LOOS && type <= SHN_HIOS) + sprintf (buff, "OS [0x%04x]", type & 0xffff); + else if (type >= SHN_LORESERVE) + sprintf (buff, "RSV[0x%04x]", type & 0xffff); + else if (type >= filedata->file_header.e_shnum) + sprintf (buff, _("bad section index[%3d]"), type); + else + sprintf (buff, "%3d", type); + break; + } + + return buff; +} + +static bfd_vma * +get_dynamic_data (Filedata * filedata, bfd_size_type number, unsigned int ent_size) +{ + unsigned char * e_data; + bfd_vma * i_data; + + /* If the size_t type is smaller than the bfd_size_type, eg because + you are building a 32-bit tool on a 64-bit host, then make sure + that when (number) is cast to (size_t) no information is lost. */ + if (sizeof (size_t) < sizeof (bfd_size_type) + && (bfd_size_type) ((size_t) number) != number) + { + error (_("Size truncation prevents reading %s elements of size %u\n"), + bfd_vmatoa ("u", number), ent_size); + return NULL; + } + + /* Be kind to memory chekers (eg valgrind, address sanitizer) by not + attempting to allocate memory when the read is bound to fail. */ + if (ent_size * number > filedata->file_size) + { + error (_("Invalid number of dynamic entries: %s\n"), + bfd_vmatoa ("u", number)); + return NULL; + } + + e_data = (unsigned char *) cmalloc ((size_t) number, ent_size); + if (e_data == NULL) + { + error (_("Out of memory reading %s dynamic entries\n"), + bfd_vmatoa ("u", number)); + return NULL; + } + + if (fread (e_data, ent_size, (size_t) number, filedata->handle) != number) + { + error (_("Unable to read in %s bytes of dynamic data\n"), + bfd_vmatoa ("u", number * ent_size)); + free (e_data); + return NULL; + } + + i_data = (bfd_vma *) cmalloc ((size_t) number, sizeof (*i_data)); + if (i_data == NULL) + { + error (_("Out of memory allocating space for %s dynamic entries\n"), + bfd_vmatoa ("u", number)); + free (e_data); + return NULL; + } + + while (number--) + i_data[number] = byte_get (e_data + number * ent_size, ent_size); + + free (e_data); + + return i_data; +} + +static void +print_dynamic_symbol (Filedata * filedata, bfd_vma si, unsigned long hn) +{ + Elf_Internal_Sym * psym; + int n; + + n = print_vma (si, DEC_5); + if (n < 5) + fputs (&" "[n], stdout); + printf (" %3lu: ", hn); + + if (dynamic_symbols == NULL || si >= num_dynamic_syms) + { + printf (_("\n"), + (unsigned long) si); + return; + } + + psym = dynamic_symbols + si; + print_vma (psym->st_value, LONG_HEX); + putchar (' '); + print_vma (psym->st_size, DEC_5); + + printf (" %-7s", get_symbol_type (filedata, ELF_ST_TYPE (psym->st_info))); + printf (" %-6s", get_symbol_binding (filedata, ELF_ST_BIND (psym->st_info))); + + if (filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_SOLARIS) + printf (" %-7s", get_solaris_symbol_visibility (psym->st_other)); + else + { + unsigned int vis = ELF_ST_VISIBILITY (psym->st_other); + + printf (" %-7s", get_symbol_visibility (vis)); + /* Check to see if any other bits in the st_other field are set. + Note - displaying this information disrupts the layout of the + table being generated, but for the moment this case is very + rare. */ + if (psym->st_other ^ vis) + printf (" [%s] ", get_symbol_other (filedata, psym->st_other ^ vis)); + } + + printf (" %3.3s ", get_symbol_index_type (filedata, psym->st_shndx)); + if (VALID_DYNAMIC_NAME (psym->st_name)) + print_symbol (25, GET_DYNAMIC_NAME (psym->st_name)); + else + printf (_(" "), psym->st_name); + putchar ('\n'); +} + +static const char * +get_symbol_version_string (Filedata * filedata, + bfd_boolean is_dynsym, + const char * strtab, + unsigned long int strtab_size, + unsigned int si, + Elf_Internal_Sym * psym, + enum versioned_symbol_info * sym_info, + unsigned short * vna_other) +{ + unsigned char data[2]; + unsigned short vers_data; + unsigned long offset; + + if (!is_dynsym + || version_info[DT_VERSIONTAGIDX (DT_VERSYM)] == 0) + return NULL; + + offset = offset_from_vma (filedata, version_info[DT_VERSIONTAGIDX (DT_VERSYM)], + sizeof data + si * sizeof (vers_data)); + + if (get_data (&data, filedata, offset + si * sizeof (vers_data), + sizeof (data), 1, _("version data")) == NULL) + return NULL; + + vers_data = byte_get (data, 2); + + if ((vers_data & VERSYM_HIDDEN) == 0 && vers_data <= 1) + return NULL; + + /* Usually we'd only see verdef for defined symbols, and verneed for + undefined symbols. However, symbols defined by the linker in + .dynbss for variables copied from a shared library in order to + avoid text relocations are defined yet have verneed. We could + use a heuristic to detect the special case, for example, check + for verneed first on symbols defined in SHT_NOBITS sections, but + it is simpler and more reliable to just look for both verdef and + verneed. .dynbss might not be mapped to a SHT_NOBITS section. */ + + if (psym->st_shndx != SHN_UNDEF + && vers_data != 0x8001 + && version_info[DT_VERSIONTAGIDX (DT_VERDEF)]) + { + Elf_Internal_Verdef ivd; + Elf_Internal_Verdaux ivda; + Elf_External_Verdaux evda; + unsigned long off; + + off = offset_from_vma (filedata, + version_info[DT_VERSIONTAGIDX (DT_VERDEF)], + sizeof (Elf_External_Verdef)); + + do + { + Elf_External_Verdef evd; + + if (get_data (&evd, filedata, off, sizeof (evd), 1, + _("version def")) == NULL) + { + ivd.vd_ndx = 0; + ivd.vd_aux = 0; + ivd.vd_next = 0; + } + else + { + ivd.vd_ndx = BYTE_GET (evd.vd_ndx); + ivd.vd_aux = BYTE_GET (evd.vd_aux); + ivd.vd_next = BYTE_GET (evd.vd_next); + } + + off += ivd.vd_next; + } + while (ivd.vd_ndx != (vers_data & VERSYM_VERSION) && ivd.vd_next != 0); + + if (ivd.vd_ndx == (vers_data & VERSYM_VERSION)) + { + off -= ivd.vd_next; + off += ivd.vd_aux; + + if (get_data (&evda, filedata, off, sizeof (evda), 1, + _("version def aux")) != NULL) + { + ivda.vda_name = BYTE_GET (evda.vda_name); + + if (psym->st_name != ivda.vda_name) + { + *sym_info = ((vers_data & VERSYM_HIDDEN) != 0 + ? symbol_hidden : symbol_public); + return (ivda.vda_name < strtab_size + ? strtab + ivda.vda_name : _("")); + } + } + } + } + + if (version_info[DT_VERSIONTAGIDX (DT_VERNEED)]) + { + Elf_External_Verneed evn; + Elf_Internal_Verneed ivn; + Elf_Internal_Vernaux ivna; + + offset = offset_from_vma (filedata, + version_info[DT_VERSIONTAGIDX (DT_VERNEED)], + sizeof evn); + do + { + unsigned long vna_off; + + if (get_data (&evn, filedata, offset, sizeof (evn), 1, + _("version need")) == NULL) + { + ivna.vna_next = 0; + ivna.vna_other = 0; + ivna.vna_name = 0; + break; + } + + ivn.vn_aux = BYTE_GET (evn.vn_aux); + ivn.vn_next = BYTE_GET (evn.vn_next); + + vna_off = offset + ivn.vn_aux; + + do + { + Elf_External_Vernaux evna; + + if (get_data (&evna, filedata, vna_off, sizeof (evna), 1, + _("version need aux (3)")) == NULL) + { + ivna.vna_next = 0; + ivna.vna_other = 0; + ivna.vna_name = 0; + } + else + { + ivna.vna_other = BYTE_GET (evna.vna_other); + ivna.vna_next = BYTE_GET (evna.vna_next); + ivna.vna_name = BYTE_GET (evna.vna_name); + } + + vna_off += ivna.vna_next; + } + while (ivna.vna_other != vers_data && ivna.vna_next != 0); + + if (ivna.vna_other == vers_data) + break; + + offset += ivn.vn_next; + } + while (ivn.vn_next != 0); + + if (ivna.vna_other == vers_data) + { + *sym_info = symbol_undefined; + *vna_other = ivna.vna_other; + return (ivna.vna_name < strtab_size + ? strtab + ivna.vna_name : _("")); + } + } + return NULL; +} + +/* Dump the symbol table. */ +static bfd_boolean +process_symbol_table (Filedata * filedata) +{ + Elf_Internal_Shdr * section; + bfd_size_type nbuckets = 0; + bfd_size_type nchains = 0; + bfd_vma * buckets = NULL; + bfd_vma * chains = NULL; + bfd_vma ngnubuckets = 0; + bfd_vma * gnubuckets = NULL; + bfd_vma * gnuchains = NULL; + bfd_vma gnusymidx = 0; + bfd_size_type ngnuchains = 0; + + if (!do_syms && !do_dyn_syms && !do_histogram) + return TRUE; + + if (dynamic_info[DT_HASH] + && (do_histogram + || (do_using_dynamic + && !do_dyn_syms + && dynamic_strings != NULL))) + { + unsigned char nb[8]; + unsigned char nc[8]; + unsigned int hash_ent_size = 4; + + if ((filedata->file_header.e_machine == EM_ALPHA + || filedata->file_header.e_machine == EM_S390 + || filedata->file_header.e_machine == EM_S390_OLD) + && filedata->file_header.e_ident[EI_CLASS] == ELFCLASS64) + hash_ent_size = 8; + + if (fseek (filedata->handle, + (archive_file_offset + + offset_from_vma (filedata, dynamic_info[DT_HASH], + sizeof nb + sizeof nc)), + SEEK_SET)) + { + error (_("Unable to seek to start of dynamic information\n")); + goto no_hash; + } + + if (fread (nb, hash_ent_size, 1, filedata->handle) != 1) + { + error (_("Failed to read in number of buckets\n")); + goto no_hash; + } + + if (fread (nc, hash_ent_size, 1, filedata->handle) != 1) + { + error (_("Failed to read in number of chains\n")); + goto no_hash; + } + + nbuckets = byte_get (nb, hash_ent_size); + nchains = byte_get (nc, hash_ent_size); + + buckets = get_dynamic_data (filedata, nbuckets, hash_ent_size); + chains = get_dynamic_data (filedata, nchains, hash_ent_size); + + no_hash: + if (buckets == NULL || chains == NULL) + { + if (do_using_dynamic) + return FALSE; + free (buckets); + free (chains); + buckets = NULL; + chains = NULL; + nbuckets = 0; + nchains = 0; + } + } + + if (dynamic_info_DT_GNU_HASH + && (do_histogram + || (do_using_dynamic + && !do_dyn_syms + && dynamic_strings != NULL))) + { + unsigned char nb[16]; + bfd_vma i, maxchain = 0xffffffff, bitmaskwords; + bfd_vma buckets_vma; + + if (fseek (filedata->handle, + (archive_file_offset + + offset_from_vma (filedata, dynamic_info_DT_GNU_HASH, + sizeof nb)), + SEEK_SET)) + { + error (_("Unable to seek to start of dynamic information\n")); + goto no_gnu_hash; + } + + if (fread (nb, 16, 1, filedata->handle) != 1) + { + error (_("Failed to read in number of buckets\n")); + goto no_gnu_hash; + } + + ngnubuckets = byte_get (nb, 4); + gnusymidx = byte_get (nb + 4, 4); + bitmaskwords = byte_get (nb + 8, 4); + buckets_vma = dynamic_info_DT_GNU_HASH + 16; + if (is_32bit_elf) + buckets_vma += bitmaskwords * 4; + else + buckets_vma += bitmaskwords * 8; + + if (fseek (filedata->handle, + (archive_file_offset + + offset_from_vma (filedata, buckets_vma, 4)), + SEEK_SET)) + { + error (_("Unable to seek to start of dynamic information\n")); + goto no_gnu_hash; + } + + gnubuckets = get_dynamic_data (filedata, ngnubuckets, 4); + + if (gnubuckets == NULL) + goto no_gnu_hash; + + for (i = 0; i < ngnubuckets; i++) + if (gnubuckets[i] != 0) + { + if (gnubuckets[i] < gnusymidx) + return FALSE; + + if (maxchain == 0xffffffff || gnubuckets[i] > maxchain) + maxchain = gnubuckets[i]; + } + + if (maxchain == 0xffffffff) + goto no_gnu_hash; + + maxchain -= gnusymidx; + + if (fseek (filedata->handle, + (archive_file_offset + + offset_from_vma (filedata, buckets_vma + + 4 * (ngnubuckets + maxchain), 4)), + SEEK_SET)) + { + error (_("Unable to seek to start of dynamic information\n")); + goto no_gnu_hash; + } + + do + { + if (fread (nb, 4, 1, filedata->handle) != 1) + { + error (_("Failed to determine last chain length\n")); + goto no_gnu_hash; + } + + if (maxchain + 1 == 0) + goto no_gnu_hash; + + ++maxchain; + } + while ((byte_get (nb, 4) & 1) == 0); + + if (fseek (filedata->handle, + (archive_file_offset + + offset_from_vma (filedata, buckets_vma + 4 * ngnubuckets, 4)), + SEEK_SET)) + { + error (_("Unable to seek to start of dynamic information\n")); + goto no_gnu_hash; + } + + gnuchains = get_dynamic_data (filedata, maxchain, 4); + ngnuchains = maxchain; + + no_gnu_hash: + if (gnuchains == NULL) + { + free (gnubuckets); + gnubuckets = NULL; + ngnubuckets = 0; + if (do_using_dynamic) + return FALSE; + } + } + + if ((dynamic_info[DT_HASH] || dynamic_info_DT_GNU_HASH) + && do_syms + && do_using_dynamic + && dynamic_strings != NULL + && dynamic_symbols != NULL) + { + unsigned long hn; + + if (dynamic_info[DT_HASH]) + { + bfd_vma si; + char *visited; + + printf (_("\nSymbol table for image:\n")); + if (is_32bit_elf) + printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n")); + else + printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n")); + + visited = xcmalloc (nchains, 1); + memset (visited, 0, nchains); + for (hn = 0; hn < nbuckets; hn++) + { + for (si = buckets[hn]; si > 0; si = chains[si]) + { + print_dynamic_symbol (filedata, si, hn); + if (si >= nchains || visited[si]) + { + error (_("histogram chain is corrupt\n")); + break; + } + visited[si] = 1; + } + } + free (visited); + } + + if (dynamic_info_DT_GNU_HASH) + { + printf (_("\nSymbol table of `.gnu.hash' for image:\n")); + if (is_32bit_elf) + printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n")); + else + printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n")); + + for (hn = 0; hn < ngnubuckets; ++hn) + if (gnubuckets[hn] != 0) + { + bfd_vma si = gnubuckets[hn]; + bfd_vma off = si - gnusymidx; + + do + { + print_dynamic_symbol (filedata, si, hn); + si++; + } + while (off < ngnuchains && (gnuchains[off++] & 1) == 0); + } + } + } + else if ((do_dyn_syms || (do_syms && !do_using_dynamic)) + && filedata->section_headers != NULL) + { + unsigned int i; + + for (i = 0, section = filedata->section_headers; + i < filedata->file_header.e_shnum; + i++, section++) + { + unsigned int si; + char * strtab = NULL; + unsigned long int strtab_size = 0; + Elf_Internal_Sym * symtab; + Elf_Internal_Sym * psym; + unsigned long num_syms; + + if ((section->sh_type != SHT_SYMTAB + && section->sh_type != SHT_DYNSYM) + || (!do_syms + && section->sh_type == SHT_SYMTAB)) + continue; + + if (section->sh_entsize == 0) + { + printf (_("\nSymbol table '%s' has a sh_entsize of zero!\n"), + printable_section_name (filedata, section)); + continue; + } + + num_syms = section->sh_size / section->sh_entsize; + printf (ngettext ("\nSymbol table '%s' contains %lu entry:\n", + "\nSymbol table '%s' contains %lu entries:\n", + num_syms), + printable_section_name (filedata, section), + num_syms); + + if (is_32bit_elf) + printf (_(" Num: Value Size Type Bind Vis Ndx Name\n")); + else + printf (_(" Num: Value Size Type Bind Vis Ndx Name\n")); + + symtab = GET_ELF_SYMBOLS (filedata, section, & num_syms); + if (symtab == NULL) + continue; + + if (section->sh_link == filedata->file_header.e_shstrndx) + { + strtab = filedata->string_table; + strtab_size = filedata->string_table_length; + } + else if (section->sh_link < filedata->file_header.e_shnum) + { + Elf_Internal_Shdr * string_sec; + + string_sec = filedata->section_headers + section->sh_link; + + strtab = (char *) get_data (NULL, filedata, string_sec->sh_offset, + 1, string_sec->sh_size, + _("string table")); + strtab_size = strtab != NULL ? string_sec->sh_size : 0; + } + + for (si = 0, psym = symtab; si < num_syms; si++, psym++) + { + const char *version_string; + enum versioned_symbol_info sym_info; + unsigned short vna_other; + + printf ("%6d: ", si); + print_vma (psym->st_value, LONG_HEX); + putchar (' '); + print_vma (psym->st_size, DEC_5); + printf (" %-7s", get_symbol_type (filedata, ELF_ST_TYPE (psym->st_info))); + printf (" %-6s", get_symbol_binding (filedata, ELF_ST_BIND (psym->st_info))); + if (filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_SOLARIS) + printf (" %-7s", get_solaris_symbol_visibility (psym->st_other)); + else + { + unsigned int vis = ELF_ST_VISIBILITY (psym->st_other); + + printf (" %-7s", get_symbol_visibility (vis)); + /* Check to see if any other bits in the st_other field are set. + Note - displaying this information disrupts the layout of the + table being generated, but for the moment this case is very rare. */ + if (psym->st_other ^ vis) + printf (" [%s] ", get_symbol_other (filedata, psym->st_other ^ vis)); + } + printf (" %4s ", get_symbol_index_type (filedata, psym->st_shndx)); + print_symbol (25, psym->st_name < strtab_size + ? strtab + psym->st_name : _("")); + + version_string + = get_symbol_version_string (filedata, + section->sh_type == SHT_DYNSYM, + strtab, strtab_size, si, + psym, &sym_info, &vna_other); + if (version_string) + { + if (sym_info == symbol_undefined) + printf ("@%s (%d)", version_string, vna_other); + else + printf (sym_info == symbol_hidden ? "@%s" : "@@%s", + version_string); + } + + putchar ('\n'); + + if (ELF_ST_BIND (psym->st_info) == STB_LOCAL + && si >= section->sh_info + /* Irix 5 and 6 MIPS binaries are known to ignore this requirement. */ + && filedata->file_header.e_machine != EM_MIPS + /* Solaris binaries have been found to violate this requirement as + well. Not sure if this is a bug or an ABI requirement. */ + && filedata->file_header.e_ident[EI_OSABI] != ELFOSABI_SOLARIS) + warn (_("local symbol %u found at index >= %s's sh_info value of %u\n"), + si, printable_section_name (filedata, section), section->sh_info); + } + + free (symtab); + if (strtab != filedata->string_table) + free (strtab); + } + } + else if (do_syms) + printf + (_("\nDynamic symbol information is not available for displaying symbols.\n")); + + if (do_histogram && buckets != NULL) + { + unsigned long * lengths; + unsigned long * counts; + unsigned long hn; + bfd_vma si; + unsigned long maxlength = 0; + unsigned long nzero_counts = 0; + unsigned long nsyms = 0; + char *visited; + + printf (ngettext ("\nHistogram for bucket list length " + "(total of %lu bucket):\n", + "\nHistogram for bucket list length " + "(total of %lu buckets):\n", + (unsigned long) nbuckets), + (unsigned long) nbuckets); + + lengths = (unsigned long *) calloc (nbuckets, sizeof (*lengths)); + if (lengths == NULL) + { + error (_("Out of memory allocating space for histogram buckets\n")); + return FALSE; + } + visited = xcmalloc (nchains, 1); + memset (visited, 0, nchains); + + printf (_(" Length Number %% of total Coverage\n")); + for (hn = 0; hn < nbuckets; ++hn) + { + for (si = buckets[hn]; si > 0; si = chains[si]) + { + ++nsyms; + if (maxlength < ++lengths[hn]) + ++maxlength; + if (si >= nchains || visited[si]) + { + error (_("histogram chain is corrupt\n")); + break; + } + visited[si] = 1; + } + } + free (visited); + + counts = (unsigned long *) calloc (maxlength + 1, sizeof (*counts)); + if (counts == NULL) + { + free (lengths); + error (_("Out of memory allocating space for histogram counts\n")); + return FALSE; + } + + for (hn = 0; hn < nbuckets; ++hn) + ++counts[lengths[hn]]; + + if (nbuckets > 0) + { + unsigned long i; + printf (" 0 %-10lu (%5.1f%%)\n", + counts[0], (counts[0] * 100.0) / nbuckets); + for (i = 1; i <= maxlength; ++i) + { + nzero_counts += counts[i] * i; + printf ("%7lu %-10lu (%5.1f%%) %5.1f%%\n", + i, counts[i], (counts[i] * 100.0) / nbuckets, + (nzero_counts * 100.0) / nsyms); + } + } + + free (counts); + free (lengths); + } + + if (buckets != NULL) + { + free (buckets); + free (chains); + } + + if (do_histogram && gnubuckets != NULL) + { + unsigned long * lengths; + unsigned long * counts; + unsigned long hn; + unsigned long maxlength = 0; + unsigned long nzero_counts = 0; + unsigned long nsyms = 0; + + printf (ngettext ("\nHistogram for `.gnu.hash' bucket list length " + "(total of %lu bucket):\n", + "\nHistogram for `.gnu.hash' bucket list length " + "(total of %lu buckets):\n", + (unsigned long) ngnubuckets), + (unsigned long) ngnubuckets); + + lengths = (unsigned long *) calloc (ngnubuckets, sizeof (*lengths)); + if (lengths == NULL) + { + error (_("Out of memory allocating space for gnu histogram buckets\n")); + return FALSE; + } + + printf (_(" Length Number %% of total Coverage\n")); + + for (hn = 0; hn < ngnubuckets; ++hn) + if (gnubuckets[hn] != 0) + { + bfd_vma off, length = 1; + + for (off = gnubuckets[hn] - gnusymidx; + /* PR 17531 file: 010-77222-0.004. */ + off < ngnuchains && (gnuchains[off] & 1) == 0; + ++off) + ++length; + lengths[hn] = length; + if (length > maxlength) + maxlength = length; + nsyms += length; + } + + counts = (unsigned long *) calloc (maxlength + 1, sizeof (*counts)); + if (counts == NULL) + { + free (lengths); + error (_("Out of memory allocating space for gnu histogram counts\n")); + return FALSE; + } + + for (hn = 0; hn < ngnubuckets; ++hn) + ++counts[lengths[hn]]; + + if (ngnubuckets > 0) + { + unsigned long j; + printf (" 0 %-10lu (%5.1f%%)\n", + counts[0], (counts[0] * 100.0) / ngnubuckets); + for (j = 1; j <= maxlength; ++j) + { + nzero_counts += counts[j] * j; + printf ("%7lu %-10lu (%5.1f%%) %5.1f%%\n", + j, counts[j], (counts[j] * 100.0) / ngnubuckets, + (nzero_counts * 100.0) / nsyms); + } + } + + free (counts); + free (lengths); + free (gnubuckets); + free (gnuchains); + } + + return TRUE; +} + +static bfd_boolean +process_syminfo (Filedata * filedata ATTRIBUTE_UNUSED) +{ + unsigned int i; + + if (dynamic_syminfo == NULL + || !do_dynamic) + /* No syminfo, this is ok. */ + return TRUE; + + /* There better should be a dynamic symbol section. */ + if (dynamic_symbols == NULL || dynamic_strings == NULL) + return FALSE; + + if (dynamic_addr) + printf (ngettext ("\nDynamic info segment at offset 0x%lx " + "contains %d entry:\n", + "\nDynamic info segment at offset 0x%lx " + "contains %d entries:\n", + dynamic_syminfo_nent), + dynamic_syminfo_offset, dynamic_syminfo_nent); + + printf (_(" Num: Name BoundTo Flags\n")); + for (i = 0; i < dynamic_syminfo_nent; ++i) + { + unsigned short int flags = dynamic_syminfo[i].si_flags; + + printf ("%4d: ", i); + if (i >= num_dynamic_syms) + printf (_("")); + else if (VALID_DYNAMIC_NAME (dynamic_symbols[i].st_name)) + print_symbol (30, GET_DYNAMIC_NAME (dynamic_symbols[i].st_name)); + else + printf (_(""), dynamic_symbols[i].st_name); + putchar (' '); + + switch (dynamic_syminfo[i].si_boundto) + { + case SYMINFO_BT_SELF: + fputs ("SELF ", stdout); + break; + case SYMINFO_BT_PARENT: + fputs ("PARENT ", stdout); + break; + default: + if (dynamic_syminfo[i].si_boundto > 0 + && dynamic_syminfo[i].si_boundto < dynamic_nent + && VALID_DYNAMIC_NAME (dynamic_section[dynamic_syminfo[i].si_boundto].d_un.d_val)) + { + print_symbol (10, GET_DYNAMIC_NAME (dynamic_section[dynamic_syminfo[i].si_boundto].d_un.d_val)); + putchar (' ' ); + } + else + printf ("%-10d ", dynamic_syminfo[i].si_boundto); + break; + } + + if (flags & SYMINFO_FLG_DIRECT) + printf (" DIRECT"); + if (flags & SYMINFO_FLG_PASSTHRU) + printf (" PASSTHRU"); + if (flags & SYMINFO_FLG_COPY) + printf (" COPY"); + if (flags & SYMINFO_FLG_LAZYLOAD) + printf (" LAZYLOAD"); + + puts (""); + } + + return TRUE; +} + +#define IN_RANGE(START,END,ADDR,OFF) \ + (((ADDR) >= (START)) && ((ADDR) + (OFF) < (END))) + +/* Check to see if the given reloc needs to be handled in a target specific + manner. If so then process the reloc and return TRUE otherwise return + FALSE. + + If called with reloc == NULL, then this is a signal that reloc processing + for the current section has finished, and any saved state should be + discarded. */ + +static bfd_boolean +target_specific_reloc_handling (Filedata * filedata, + Elf_Internal_Rela * reloc, + unsigned char * start, + unsigned char * end, + Elf_Internal_Sym * symtab, + unsigned long num_syms) +{ + unsigned int reloc_type = 0; + unsigned long sym_index = 0; + + if (reloc) + { + reloc_type = get_reloc_type (filedata, reloc->r_info); + sym_index = get_reloc_symindex (reloc->r_info); + } + + switch (filedata->file_header.e_machine) + { + case EM_MSP430: + case EM_MSP430_OLD: + { + static Elf_Internal_Sym * saved_sym = NULL; + + if (reloc == NULL) + { + saved_sym = NULL; + return TRUE; + } + + switch (reloc_type) + { + case 10: /* R_MSP430_SYM_DIFF */ + if (uses_msp430x_relocs (filedata)) + break; + /* Fall through. */ + case 21: /* R_MSP430X_SYM_DIFF */ + /* PR 21139. */ + if (sym_index >= num_syms) + error (_("MSP430 SYM_DIFF reloc contains invalid symbol index %lu\n"), + sym_index); + else + saved_sym = symtab + sym_index; + return TRUE; + + case 1: /* R_MSP430_32 or R_MSP430_ABS32 */ + case 3: /* R_MSP430_16 or R_MSP430_ABS8 */ + goto handle_sym_diff; + + case 5: /* R_MSP430_16_BYTE */ + case 9: /* R_MSP430_8 */ + if (uses_msp430x_relocs (filedata)) + break; + goto handle_sym_diff; + + case 2: /* R_MSP430_ABS16 */ + case 15: /* R_MSP430X_ABS16 */ + if (! uses_msp430x_relocs (filedata)) + break; + goto handle_sym_diff; + + handle_sym_diff: + if (saved_sym != NULL) + { + int reloc_size = reloc_type == 1 ? 4 : 2; + bfd_vma value; + + if (sym_index >= num_syms) + error (_("MSP430 reloc contains invalid symbol index %lu\n"), + sym_index); + else + { + value = reloc->r_addend + (symtab[sym_index].st_value + - saved_sym->st_value); + + if (IN_RANGE (start, end, start + reloc->r_offset, reloc_size)) + byte_put (start + reloc->r_offset, value, reloc_size); + else + /* PR 21137 */ + error (_("MSP430 sym diff reloc contains invalid offset: 0x%lx\n"), + (long) reloc->r_offset); + } + + saved_sym = NULL; + return TRUE; + } + break; + + default: + if (saved_sym != NULL) + error (_("Unhandled MSP430 reloc type found after SYM_DIFF reloc\n")); + break; + } + break; + } + + case EM_MN10300: + case EM_CYGNUS_MN10300: + { + static Elf_Internal_Sym * saved_sym = NULL; + + if (reloc == NULL) + { + saved_sym = NULL; + return TRUE; + } + + switch (reloc_type) + { + case 34: /* R_MN10300_ALIGN */ + return TRUE; + case 33: /* R_MN10300_SYM_DIFF */ + if (sym_index >= num_syms) + error (_("MN10300_SYM_DIFF reloc contains invalid symbol index %lu\n"), + sym_index); + else + saved_sym = symtab + sym_index; + return TRUE; + + case 1: /* R_MN10300_32 */ + case 2: /* R_MN10300_16 */ + if (saved_sym != NULL) + { + int reloc_size = reloc_type == 1 ? 4 : 2; + bfd_vma value; + + if (sym_index >= num_syms) + error (_("MN10300 reloc contains invalid symbol index %lu\n"), + sym_index); + else + { + value = reloc->r_addend + (symtab[sym_index].st_value + - saved_sym->st_value); + + if (IN_RANGE (start, end, start + reloc->r_offset, reloc_size)) + byte_put (start + reloc->r_offset, value, reloc_size); + else + error (_("MN10300 sym diff reloc contains invalid offset: 0x%lx\n"), + (long) reloc->r_offset); + } + + saved_sym = NULL; + return TRUE; + } + break; + default: + if (saved_sym != NULL) + error (_("Unhandled MN10300 reloc type found after SYM_DIFF reloc\n")); + break; + } + break; + } + + case EM_RL78: + { + static bfd_vma saved_sym1 = 0; + static bfd_vma saved_sym2 = 0; + static bfd_vma value; + + if (reloc == NULL) + { + saved_sym1 = saved_sym2 = 0; + return TRUE; + } + + switch (reloc_type) + { + case 0x80: /* R_RL78_SYM. */ + saved_sym1 = saved_sym2; + if (sym_index >= num_syms) + error (_("RL78_SYM reloc contains invalid symbol index %lu\n"), + sym_index); + else + { + saved_sym2 = symtab[sym_index].st_value; + saved_sym2 += reloc->r_addend; + } + return TRUE; + + case 0x83: /* R_RL78_OPsub. */ + value = saved_sym1 - saved_sym2; + saved_sym2 = saved_sym1 = 0; + return TRUE; + break; + + case 0x41: /* R_RL78_ABS32. */ + if (IN_RANGE (start, end, start + reloc->r_offset, 4)) + byte_put (start + reloc->r_offset, value, 4); + else + error (_("RL78 sym diff reloc contains invalid offset: 0x%lx\n"), + (long) reloc->r_offset); + value = 0; + return TRUE; + + case 0x43: /* R_RL78_ABS16. */ + if (IN_RANGE (start, end, start + reloc->r_offset, 2)) + byte_put (start + reloc->r_offset, value, 2); + else + error (_("RL78 sym diff reloc contains invalid offset: 0x%lx\n"), + (long) reloc->r_offset); + value = 0; + return TRUE; + + default: + break; + } + break; + } + } + + return FALSE; +} + +/* Returns TRUE iff RELOC_TYPE is a 32-bit absolute RELA relocation used in + DWARF debug sections. This is a target specific test. Note - we do not + go through the whole including-target-headers-multiple-times route, (as + we have already done with ) because this would become very + messy and even then this function would have to contain target specific + information (the names of the relocs instead of their numeric values). + FIXME: This is not the correct way to solve this problem. The proper way + is to have target specific reloc sizing and typing functions created by + the reloc-macros.h header, in the same way that it already creates the + reloc naming functions. */ + +static bfd_boolean +is_32bit_abs_reloc (Filedata * filedata, unsigned int reloc_type) +{ + /* Please keep this table alpha-sorted for ease of visual lookup. */ + switch (filedata->file_header.e_machine) + { + case EM_386: + case EM_IAMCU: + return reloc_type == 1; /* R_386_32. */ + case EM_68K: + return reloc_type == 1; /* R_68K_32. */ + case EM_860: + return reloc_type == 1; /* R_860_32. */ + case EM_960: + return reloc_type == 2; /* R_960_32. */ + case EM_AARCH64: + return (reloc_type == 258 + || reloc_type == 1); /* R_AARCH64_ABS32 || R_AARCH64_P32_ABS32 */ + case EM_ADAPTEVA_EPIPHANY: + return reloc_type == 3; + case EM_ALPHA: + return reloc_type == 1; /* R_ALPHA_REFLONG. */ + case EM_ARC: + return reloc_type == 1; /* R_ARC_32. */ + case EM_ARC_COMPACT: + case EM_ARC_COMPACT2: + return reloc_type == 4; /* R_ARC_32. */ + case EM_ARM: + return reloc_type == 2; /* R_ARM_ABS32 */ + case EM_AVR_OLD: + case EM_AVR: + return reloc_type == 1; + case EM_BLACKFIN: + return reloc_type == 0x12; /* R_byte4_data. */ + case EM_CRIS: + return reloc_type == 3; /* R_CRIS_32. */ + case EM_CR16: + return reloc_type == 3; /* R_CR16_NUM32. */ + case EM_CRX: + return reloc_type == 15; /* R_CRX_NUM32. */ + case EM_CYGNUS_FRV: + return reloc_type == 1; + case EM_CYGNUS_D10V: + case EM_D10V: + return reloc_type == 6; /* R_D10V_32. */ + case EM_CYGNUS_D30V: + case EM_D30V: + return reloc_type == 12; /* R_D30V_32_NORMAL. */ + case EM_DLX: + return reloc_type == 3; /* R_DLX_RELOC_32. */ + case EM_CYGNUS_FR30: + case EM_FR30: + return reloc_type == 3; /* R_FR30_32. */ + case EM_FT32: + return reloc_type == 1; /* R_FT32_32. */ + case EM_H8S: + case EM_H8_300: + case EM_H8_300H: + return reloc_type == 1; /* R_H8_DIR32. */ + case EM_IA_64: + return (reloc_type == 0x64 /* R_IA64_SECREL32MSB. */ + || reloc_type == 0x65 /* R_IA64_SECREL32LSB. */ + || reloc_type == 0x24 /* R_IA64_DIR32MSB. */ + || reloc_type == 0x25 /* R_IA64_DIR32LSB. */); + case EM_IP2K_OLD: + case EM_IP2K: + return reloc_type == 2; /* R_IP2K_32. */ + case EM_IQ2000: + return reloc_type == 2; /* R_IQ2000_32. */ + case EM_LATTICEMICO32: + return reloc_type == 3; /* R_LM32_32. */ + case EM_M32C_OLD: + case EM_M32C: + return reloc_type == 3; /* R_M32C_32. */ + case EM_M32R: + return reloc_type == 34; /* R_M32R_32_RELA. */ + case EM_68HC11: + case EM_68HC12: + return reloc_type == 6; /* R_M68HC11_32. */ + case EM_MCORE: + return reloc_type == 1; /* R_MCORE_ADDR32. */ + case EM_CYGNUS_MEP: + return reloc_type == 4; /* R_MEP_32. */ + case EM_METAG: + return reloc_type == 2; /* R_METAG_ADDR32. */ + case EM_MICROBLAZE: + return reloc_type == 1; /* R_MICROBLAZE_32. */ + case EM_MIPS: + return reloc_type == 2; /* R_MIPS_32. */ + case EM_MMIX: + return reloc_type == 4; /* R_MMIX_32. */ + case EM_CYGNUS_MN10200: + case EM_MN10200: + return reloc_type == 1; /* R_MN10200_32. */ + case EM_CYGNUS_MN10300: + case EM_MN10300: + return reloc_type == 1; /* R_MN10300_32. */ + case EM_MOXIE: + return reloc_type == 1; /* R_MOXIE_32. */ + case EM_MSP430_OLD: + case EM_MSP430: + return reloc_type == 1; /* R_MSP430_32 or R_MSP320_ABS32. */ + case EM_MT: + return reloc_type == 2; /* R_MT_32. */ + case EM_NDS32: + return reloc_type == 20; /* R_NDS32_RELA. */ + case EM_ALTERA_NIOS2: + return reloc_type == 12; /* R_NIOS2_BFD_RELOC_32. */ + case EM_NIOS32: + return reloc_type == 1; /* R_NIOS_32. */ + case EM_OR1K: + return reloc_type == 1; /* R_OR1K_32. */ + case EM_PARISC: + return (reloc_type == 1 /* R_PARISC_DIR32. */ + || reloc_type == 41); /* R_PARISC_SECREL32. */ + case EM_PJ: + case EM_PJ_OLD: + return reloc_type == 1; /* R_PJ_DATA_DIR32. */ + case EM_PPC64: + return reloc_type == 1; /* R_PPC64_ADDR32. */ + case EM_PPC: + return reloc_type == 1; /* R_PPC_ADDR32. */ + case EM_TI_PRU: + return reloc_type == 11; /* R_PRU_BFD_RELOC_32. */ + case EM_RISCV: + return reloc_type == 1; /* R_RISCV_32. */ + case EM_RL78: + return reloc_type == 1; /* R_RL78_DIR32. */ + case EM_RX: + return reloc_type == 1; /* R_RX_DIR32. */ + case EM_S370: + return reloc_type == 1; /* R_I370_ADDR31. */ + case EM_S390_OLD: + case EM_S390: + return reloc_type == 4; /* R_S390_32. */ + case EM_SCORE: + return reloc_type == 8; /* R_SCORE_ABS32. */ + case EM_SH: + return reloc_type == 1; /* R_SH_DIR32. */ + case EM_SPARC32PLUS: + case EM_SPARCV9: + case EM_SPARC: + return reloc_type == 3 /* R_SPARC_32. */ + || reloc_type == 23; /* R_SPARC_UA32. */ + case EM_SPU: + return reloc_type == 6; /* R_SPU_ADDR32 */ + case EM_TI_C6000: + return reloc_type == 1; /* R_C6000_ABS32. */ + case EM_TILEGX: + return reloc_type == 2; /* R_TILEGX_32. */ + case EM_TILEPRO: + return reloc_type == 1; /* R_TILEPRO_32. */ + case EM_CYGNUS_V850: + case EM_V850: + return reloc_type == 6; /* R_V850_ABS32. */ + case EM_V800: + return reloc_type == 0x33; /* R_V810_WORD. */ + case EM_VAX: + return reloc_type == 1; /* R_VAX_32. */ + case EM_VISIUM: + return reloc_type == 3; /* R_VISIUM_32. */ + case EM_WEBASSEMBLY: + return reloc_type == 1; /* R_WASM32_32. */ + case EM_X86_64: + case EM_L1OM: + case EM_K1OM: + return reloc_type == 10; /* R_X86_64_32. */ + case EM_XC16X: + case EM_C166: + return reloc_type == 3; /* R_XC16C_ABS_32. */ + case EM_XGATE: + return reloc_type == 4; /* R_XGATE_32. */ + case EM_XSTORMY16: + return reloc_type == 1; /* R_XSTROMY16_32. */ + case EM_XTENSA_OLD: + case EM_XTENSA: + return reloc_type == 1; /* R_XTENSA_32. */ + default: + { + static unsigned int prev_warn = 0; + + /* Avoid repeating the same warning multiple times. */ + if (prev_warn != filedata->file_header.e_machine) + error (_("Missing knowledge of 32-bit reloc types used in DWARF sections of machine number %d\n"), + filedata->file_header.e_machine); + prev_warn = filedata->file_header.e_machine; + return FALSE; + } + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 32-bit pc-relative RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_32bit_pcrel_reloc (Filedata * filedata, unsigned int reloc_type) +{ + switch (filedata->file_header.e_machine) + /* Please keep this table alpha-sorted for ease of visual lookup. */ + { + case EM_386: + case EM_IAMCU: + return reloc_type == 2; /* R_386_PC32. */ + case EM_68K: + return reloc_type == 4; /* R_68K_PC32. */ + case EM_AARCH64: + return reloc_type == 261; /* R_AARCH64_PREL32 */ + case EM_ADAPTEVA_EPIPHANY: + return reloc_type == 6; + case EM_ALPHA: + return reloc_type == 10; /* R_ALPHA_SREL32. */ + case EM_ARC_COMPACT: + case EM_ARC_COMPACT2: + return reloc_type == 49; /* R_ARC_32_PCREL. */ + case EM_ARM: + return reloc_type == 3; /* R_ARM_REL32 */ + case EM_AVR_OLD: + case EM_AVR: + return reloc_type == 36; /* R_AVR_32_PCREL. */ + case EM_MICROBLAZE: + return reloc_type == 2; /* R_MICROBLAZE_32_PCREL. */ + case EM_OR1K: + return reloc_type == 9; /* R_OR1K_32_PCREL. */ + case EM_PARISC: + return reloc_type == 9; /* R_PARISC_PCREL32. */ + case EM_PPC: + return reloc_type == 26; /* R_PPC_REL32. */ + case EM_PPC64: + return reloc_type == 26; /* R_PPC64_REL32. */ + case EM_S390_OLD: + case EM_S390: + return reloc_type == 5; /* R_390_PC32. */ + case EM_SH: + return reloc_type == 2; /* R_SH_REL32. */ + case EM_SPARC32PLUS: + case EM_SPARCV9: + case EM_SPARC: + return reloc_type == 6; /* R_SPARC_DISP32. */ + case EM_SPU: + return reloc_type == 13; /* R_SPU_REL32. */ + case EM_TILEGX: + return reloc_type == 6; /* R_TILEGX_32_PCREL. */ + case EM_TILEPRO: + return reloc_type == 4; /* R_TILEPRO_32_PCREL. */ + case EM_VISIUM: + return reloc_type == 6; /* R_VISIUM_32_PCREL */ + case EM_X86_64: + case EM_L1OM: + case EM_K1OM: + return reloc_type == 2; /* R_X86_64_PC32. */ + case EM_XTENSA_OLD: + case EM_XTENSA: + return reloc_type == 14; /* R_XTENSA_32_PCREL. */ + default: + /* Do not abort or issue an error message here. Not all targets use + pc-relative 32-bit relocs in their DWARF debug information and we + have already tested for target coverage in is_32bit_abs_reloc. A + more helpful warning message will be generated by apply_relocations + anyway, so just return. */ + return FALSE; + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 64-bit absolute RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_64bit_abs_reloc (Filedata * filedata, unsigned int reloc_type) +{ + switch (filedata->file_header.e_machine) + { + case EM_AARCH64: + return reloc_type == 257; /* R_AARCH64_ABS64. */ + case EM_ALPHA: + return reloc_type == 2; /* R_ALPHA_REFQUAD. */ + case EM_IA_64: + return (reloc_type == 0x26 /* R_IA64_DIR64MSB. */ + || reloc_type == 0x27 /* R_IA64_DIR64LSB. */); + case EM_PARISC: + return reloc_type == 80; /* R_PARISC_DIR64. */ + case EM_PPC64: + return reloc_type == 38; /* R_PPC64_ADDR64. */ + case EM_RISCV: + return reloc_type == 2; /* R_RISCV_64. */ + case EM_SPARC32PLUS: + case EM_SPARCV9: + case EM_SPARC: + return reloc_type == 32 /* R_SPARC_64. */ + || reloc_type == 54; /* R_SPARC_UA64. */ + case EM_X86_64: + case EM_L1OM: + case EM_K1OM: + return reloc_type == 1; /* R_X86_64_64. */ + case EM_S390_OLD: + case EM_S390: + return reloc_type == 22; /* R_S390_64. */ + case EM_TILEGX: + return reloc_type == 1; /* R_TILEGX_64. */ + case EM_MIPS: + return reloc_type == 18; /* R_MIPS_64. */ + default: + return FALSE; + } +} + +/* Like is_32bit_pcrel_reloc except that it returns TRUE iff RELOC_TYPE is + a 64-bit pc-relative RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_64bit_pcrel_reloc (Filedata * filedata, unsigned int reloc_type) +{ + switch (filedata->file_header.e_machine) + { + case EM_AARCH64: + return reloc_type == 260; /* R_AARCH64_PREL64. */ + case EM_ALPHA: + return reloc_type == 11; /* R_ALPHA_SREL64. */ + case EM_IA_64: + return (reloc_type == 0x4e /* R_IA64_PCREL64MSB. */ + || reloc_type == 0x4f /* R_IA64_PCREL64LSB. */); + case EM_PARISC: + return reloc_type == 72; /* R_PARISC_PCREL64. */ + case EM_PPC64: + return reloc_type == 44; /* R_PPC64_REL64. */ + case EM_SPARC32PLUS: + case EM_SPARCV9: + case EM_SPARC: + return reloc_type == 46; /* R_SPARC_DISP64. */ + case EM_X86_64: + case EM_L1OM: + case EM_K1OM: + return reloc_type == 24; /* R_X86_64_PC64. */ + case EM_S390_OLD: + case EM_S390: + return reloc_type == 23; /* R_S390_PC64. */ + case EM_TILEGX: + return reloc_type == 5; /* R_TILEGX_64_PCREL. */ + default: + return FALSE; + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 24-bit absolute RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_24bit_abs_reloc (Filedata * filedata, unsigned int reloc_type) +{ + switch (filedata->file_header.e_machine) + { + case EM_CYGNUS_MN10200: + case EM_MN10200: + return reloc_type == 4; /* R_MN10200_24. */ + case EM_FT32: + return reloc_type == 5; /* R_FT32_20. */ + default: + return FALSE; + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 16-bit absolute RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_16bit_abs_reloc (Filedata * filedata, unsigned int reloc_type) +{ + /* Please keep this table alpha-sorted for ease of visual lookup. */ + switch (filedata->file_header.e_machine) + { + case EM_ARC: + case EM_ARC_COMPACT: + case EM_ARC_COMPACT2: + return reloc_type == 2; /* R_ARC_16. */ + case EM_ADAPTEVA_EPIPHANY: + return reloc_type == 5; + case EM_AVR_OLD: + case EM_AVR: + return reloc_type == 4; /* R_AVR_16. */ + case EM_CYGNUS_D10V: + case EM_D10V: + return reloc_type == 3; /* R_D10V_16. */ + case EM_FT32: + return reloc_type == 2; /* R_FT32_16. */ + case EM_H8S: + case EM_H8_300: + case EM_H8_300H: + return reloc_type == R_H8_DIR16; + case EM_IP2K_OLD: + case EM_IP2K: + return reloc_type == 1; /* R_IP2K_16. */ + case EM_M32C_OLD: + case EM_M32C: + return reloc_type == 1; /* R_M32C_16 */ + case EM_CYGNUS_MN10200: + case EM_MN10200: + return reloc_type == 2; /* R_MN10200_16. */ + case EM_CYGNUS_MN10300: + case EM_MN10300: + return reloc_type == 2; /* R_MN10300_16. */ + case EM_MSP430: + if (uses_msp430x_relocs (filedata)) + return reloc_type == 2; /* R_MSP430_ABS16. */ + /* Fall through. */ + case EM_MSP430_OLD: + return reloc_type == 5; /* R_MSP430_16_BYTE. */ + case EM_NDS32: + return reloc_type == 19; /* R_NDS32_RELA. */ + case EM_ALTERA_NIOS2: + return reloc_type == 13; /* R_NIOS2_BFD_RELOC_16. */ + case EM_NIOS32: + return reloc_type == 9; /* R_NIOS_16. */ + case EM_OR1K: + return reloc_type == 2; /* R_OR1K_16. */ + case EM_TI_PRU: + return reloc_type == 8; /* R_PRU_BFD_RELOC_16. */ + case EM_TI_C6000: + return reloc_type == 2; /* R_C6000_ABS16. */ + case EM_VISIUM: + return reloc_type == 2; /* R_VISIUM_16. */ + case EM_XC16X: + case EM_C166: + return reloc_type == 2; /* R_XC16C_ABS_16. */ + case EM_XGATE: + return reloc_type == 3; /* R_XGATE_16. */ + default: + return FALSE; + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 32-bit inplace add RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_32bit_inplace_add_reloc (Filedata * filedata, unsigned int reloc_type) +{ + /* Please keep this table alpha-sorted for ease of visual lookup. */ + switch (filedata->file_header.e_machine) + { + case EM_RISCV: + return reloc_type == 35; /* R_RISCV_ADD32. */ + default: + return FALSE; + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 32-bit inplace sub RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_32bit_inplace_sub_reloc (Filedata * filedata, unsigned int reloc_type) +{ + /* Please keep this table alpha-sorted for ease of visual lookup. */ + switch (filedata->file_header.e_machine) + { + case EM_RISCV: + return reloc_type == 39; /* R_RISCV_SUB32. */ + default: + return FALSE; + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 64-bit inplace add RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_64bit_inplace_add_reloc (Filedata * filedata, unsigned int reloc_type) +{ + /* Please keep this table alpha-sorted for ease of visual lookup. */ + switch (filedata->file_header.e_machine) + { + case EM_RISCV: + return reloc_type == 36; /* R_RISCV_ADD64. */ + default: + return FALSE; + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 64-bit inplace sub RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_64bit_inplace_sub_reloc (Filedata * filedata, unsigned int reloc_type) +{ + /* Please keep this table alpha-sorted for ease of visual lookup. */ + switch (filedata->file_header.e_machine) + { + case EM_RISCV: + return reloc_type == 40; /* R_RISCV_SUB64. */ + default: + return FALSE; + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 16-bit inplace add RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_16bit_inplace_add_reloc (Filedata * filedata, unsigned int reloc_type) +{ + /* Please keep this table alpha-sorted for ease of visual lookup. */ + switch (filedata->file_header.e_machine) + { + case EM_RISCV: + return reloc_type == 34; /* R_RISCV_ADD16. */ + default: + return FALSE; + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 16-bit inplace sub RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_16bit_inplace_sub_reloc (Filedata * filedata, unsigned int reloc_type) +{ + /* Please keep this table alpha-sorted for ease of visual lookup. */ + switch (filedata->file_header.e_machine) + { + case EM_RISCV: + return reloc_type == 38; /* R_RISCV_SUB16. */ + default: + return FALSE; + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 8-bit inplace add RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_8bit_inplace_add_reloc (Filedata * filedata, unsigned int reloc_type) +{ + /* Please keep this table alpha-sorted for ease of visual lookup. */ + switch (filedata->file_header.e_machine) + { + case EM_RISCV: + return reloc_type == 33; /* R_RISCV_ADD8. */ + default: + return FALSE; + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 8-bit inplace sub RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_8bit_inplace_sub_reloc (Filedata * filedata, unsigned int reloc_type) +{ + /* Please keep this table alpha-sorted for ease of visual lookup. */ + switch (filedata->file_header.e_machine) + { + case EM_RISCV: + return reloc_type == 37; /* R_RISCV_SUB8. */ + default: + return FALSE; + } +} + +/* Returns TRUE iff RELOC_TYPE is a NONE relocation used for discarded + relocation entries (possibly formerly used for SHT_GROUP sections). */ + +static bfd_boolean +is_none_reloc (Filedata * filedata, unsigned int reloc_type) +{ + switch (filedata->file_header.e_machine) + { + case EM_386: /* R_386_NONE. */ + case EM_68K: /* R_68K_NONE. */ + case EM_ADAPTEVA_EPIPHANY: + case EM_ALPHA: /* R_ALPHA_NONE. */ + case EM_ALTERA_NIOS2: /* R_NIOS2_NONE. */ + case EM_ARC: /* R_ARC_NONE. */ + case EM_ARC_COMPACT2: /* R_ARC_NONE. */ + case EM_ARC_COMPACT: /* R_ARC_NONE. */ + case EM_ARM: /* R_ARM_NONE. */ + case EM_C166: /* R_XC16X_NONE. */ + case EM_CRIS: /* R_CRIS_NONE. */ + case EM_FT32: /* R_FT32_NONE. */ + case EM_IA_64: /* R_IA64_NONE. */ + case EM_K1OM: /* R_X86_64_NONE. */ + case EM_L1OM: /* R_X86_64_NONE. */ + case EM_M32R: /* R_M32R_NONE. */ + case EM_MIPS: /* R_MIPS_NONE. */ + case EM_MN10300: /* R_MN10300_NONE. */ + case EM_MOXIE: /* R_MOXIE_NONE. */ + case EM_NIOS32: /* R_NIOS_NONE. */ + case EM_OR1K: /* R_OR1K_NONE. */ + case EM_PARISC: /* R_PARISC_NONE. */ + case EM_PPC64: /* R_PPC64_NONE. */ + case EM_PPC: /* R_PPC_NONE. */ + case EM_RISCV: /* R_RISCV_NONE. */ + case EM_S390: /* R_390_NONE. */ + case EM_S390_OLD: + case EM_SH: /* R_SH_NONE. */ + case EM_SPARC32PLUS: + case EM_SPARC: /* R_SPARC_NONE. */ + case EM_SPARCV9: + case EM_TILEGX: /* R_TILEGX_NONE. */ + case EM_TILEPRO: /* R_TILEPRO_NONE. */ + case EM_TI_C6000:/* R_C6000_NONE. */ + case EM_X86_64: /* R_X86_64_NONE. */ + case EM_XC16X: + case EM_WEBASSEMBLY: /* R_WASM32_NONE. */ + return reloc_type == 0; + + case EM_AARCH64: + return reloc_type == 0 || reloc_type == 256; + case EM_AVR_OLD: + case EM_AVR: + return (reloc_type == 0 /* R_AVR_NONE. */ + || reloc_type == 30 /* R_AVR_DIFF8. */ + || reloc_type == 31 /* R_AVR_DIFF16. */ + || reloc_type == 32 /* R_AVR_DIFF32. */); + case EM_METAG: + return reloc_type == 3; /* R_METAG_NONE. */ + case EM_NDS32: + return (reloc_type == 0 /* R_XTENSA_NONE. */ + || reloc_type == 204 /* R_NDS32_DIFF8. */ + || reloc_type == 205 /* R_NDS32_DIFF16. */ + || reloc_type == 206 /* R_NDS32_DIFF32. */ + || reloc_type == 207 /* R_NDS32_ULEB128. */); + case EM_TI_PRU: + return (reloc_type == 0 /* R_PRU_NONE. */ + || reloc_type == 65 /* R_PRU_DIFF8. */ + || reloc_type == 66 /* R_PRU_DIFF16. */ + || reloc_type == 67 /* R_PRU_DIFF32. */); + case EM_XTENSA_OLD: + case EM_XTENSA: + return (reloc_type == 0 /* R_XTENSA_NONE. */ + || reloc_type == 17 /* R_XTENSA_DIFF8. */ + || reloc_type == 18 /* R_XTENSA_DIFF16. */ + || reloc_type == 19 /* R_XTENSA_DIFF32. */); + } + return FALSE; +} + +/* Returns TRUE if there is a relocation against + section NAME at OFFSET bytes. */ + +bfd_boolean +reloc_at (struct dwarf_section * dsec, dwarf_vma offset) +{ + Elf_Internal_Rela * relocs; + Elf_Internal_Rela * rp; + + if (dsec == NULL || dsec->reloc_info == NULL) + return FALSE; + + relocs = (Elf_Internal_Rela *) dsec->reloc_info; + + for (rp = relocs; rp < relocs + dsec->num_relocs; ++rp) + if (rp->r_offset == offset) + return TRUE; + + return FALSE; +} + +/* Apply relocations to a section. + Returns TRUE upon success, FALSE otherwise. + If RELOCS_RETURN is non-NULL then it is set to point to the loaded relocs. + It is then the caller's responsibility to free them. NUM_RELOCS_RETURN + will be set to the number of relocs loaded. + + Note: So far support has been added only for those relocations + which can be found in debug sections. FIXME: Add support for + more relocations ? */ + +static bfd_boolean +apply_relocations (Filedata * filedata, + const Elf_Internal_Shdr * section, + unsigned char * start, + bfd_size_type size, + void ** relocs_return, + unsigned long * num_relocs_return) +{ + Elf_Internal_Shdr * relsec; + unsigned char * end = start + size; + bfd_boolean res = TRUE; + + if (relocs_return != NULL) + { + * (Elf_Internal_Rela **) relocs_return = NULL; + * num_relocs_return = 0; + } + + if (filedata->file_header.e_type != ET_REL) + /* No relocs to apply. */ + return TRUE; + + /* Find the reloc section associated with the section. */ + for (relsec = filedata->section_headers; + relsec < filedata->section_headers + filedata->file_header.e_shnum; + ++relsec) + { + bfd_boolean is_rela; + unsigned long num_relocs; + Elf_Internal_Rela * relocs; + Elf_Internal_Rela * rp; + Elf_Internal_Shdr * symsec; + Elf_Internal_Sym * symtab; + unsigned long num_syms; + Elf_Internal_Sym * sym; + + if ((relsec->sh_type != SHT_RELA && relsec->sh_type != SHT_REL) + || relsec->sh_info >= filedata->file_header.e_shnum + || filedata->section_headers + relsec->sh_info != section + || relsec->sh_size == 0 + || relsec->sh_link >= filedata->file_header.e_shnum) + continue; + + is_rela = relsec->sh_type == SHT_RELA; + + if (is_rela) + { + if (!slurp_rela_relocs (filedata, relsec->sh_offset, + relsec->sh_size, & relocs, & num_relocs)) + return FALSE; + } + else + { + if (!slurp_rel_relocs (filedata, relsec->sh_offset, + relsec->sh_size, & relocs, & num_relocs)) + return FALSE; + } + + /* SH uses RELA but uses in place value instead of the addend field. */ + if (filedata->file_header.e_machine == EM_SH) + is_rela = FALSE; + + symsec = filedata->section_headers + relsec->sh_link; + if (symsec->sh_type != SHT_SYMTAB + && symsec->sh_type != SHT_DYNSYM) + return FALSE; + symtab = GET_ELF_SYMBOLS (filedata, symsec, & num_syms); + + for (rp = relocs; rp < relocs + num_relocs; ++rp) + { + bfd_vma addend; + unsigned int reloc_type; + unsigned int reloc_size; + bfd_boolean reloc_inplace = FALSE; + bfd_boolean reloc_subtract = FALSE; + unsigned char * rloc; + unsigned long sym_index; + + reloc_type = get_reloc_type (filedata, rp->r_info); + + if (target_specific_reloc_handling (filedata, rp, start, end, symtab, num_syms)) + continue; + else if (is_none_reloc (filedata, reloc_type)) + continue; + else if (is_32bit_abs_reloc (filedata, reloc_type) + || is_32bit_pcrel_reloc (filedata, reloc_type)) + reloc_size = 4; + else if (is_64bit_abs_reloc (filedata, reloc_type) + || is_64bit_pcrel_reloc (filedata, reloc_type)) + reloc_size = 8; + else if (is_24bit_abs_reloc (filedata, reloc_type)) + reloc_size = 3; + else if (is_16bit_abs_reloc (filedata, reloc_type)) + reloc_size = 2; + else if ((reloc_subtract = is_32bit_inplace_sub_reloc (filedata, + reloc_type)) + || is_32bit_inplace_add_reloc (filedata, reloc_type)) + { + reloc_size = 4; + reloc_inplace = TRUE; + } + else if ((reloc_subtract = is_64bit_inplace_sub_reloc (filedata, + reloc_type)) + || is_64bit_inplace_add_reloc (filedata, reloc_type)) + { + reloc_size = 8; + reloc_inplace = TRUE; + } + else if ((reloc_subtract = is_16bit_inplace_sub_reloc (filedata, + reloc_type)) + || is_16bit_inplace_add_reloc (filedata, reloc_type)) + { + reloc_size = 2; + reloc_inplace = TRUE; + } + else if ((reloc_subtract = is_8bit_inplace_sub_reloc (filedata, + reloc_type)) + || is_8bit_inplace_add_reloc (filedata, reloc_type)) + { + reloc_size = 1; + reloc_inplace = TRUE; + } + else + { + static unsigned int prev_reloc = 0; + + if (reloc_type != prev_reloc) + warn (_("unable to apply unsupported reloc type %d to section %s\n"), + reloc_type, printable_section_name (filedata, section)); + prev_reloc = reloc_type; + res = FALSE; + continue; + } + + rloc = start + rp->r_offset; + if ((rloc + reloc_size) > end || (rloc < start)) + { + warn (_("skipping invalid relocation offset 0x%lx in section %s\n"), + (unsigned long) rp->r_offset, + printable_section_name (filedata, section)); + res = FALSE; + continue; + } + + sym_index = (unsigned long) get_reloc_symindex (rp->r_info); + if (sym_index >= num_syms) + { + warn (_("skipping invalid relocation symbol index 0x%lx in section %s\n"), + sym_index, printable_section_name (filedata, section)); + res = FALSE; + continue; + } + sym = symtab + sym_index; + + /* If the reloc has a symbol associated with it, + make sure that it is of an appropriate type. + + Relocations against symbols without type can happen. + Gcc -feliminate-dwarf2-dups may generate symbols + without type for debug info. + + Icc generates relocations against function symbols + instead of local labels. + + Relocations against object symbols can happen, eg when + referencing a global array. For an example of this see + the _clz.o binary in libgcc.a. */ + if (sym != symtab + && ELF_ST_TYPE (sym->st_info) != STT_COMMON + && ELF_ST_TYPE (sym->st_info) > STT_SECTION) + { + warn (_("skipping unexpected symbol type %s in section %s relocation %ld\n"), + get_symbol_type (filedata, ELF_ST_TYPE (sym->st_info)), + printable_section_name (filedata, relsec), + (long int)(rp - relocs)); + res = FALSE; + continue; + } + + addend = 0; + if (is_rela) + addend += rp->r_addend; + /* R_XTENSA_32, R_PJ_DATA_DIR32 and R_D30V_32_NORMAL are + partial_inplace. */ + if (!is_rela + || (filedata->file_header.e_machine == EM_XTENSA + && reloc_type == 1) + || ((filedata->file_header.e_machine == EM_PJ + || filedata->file_header.e_machine == EM_PJ_OLD) + && reloc_type == 1) + || ((filedata->file_header.e_machine == EM_D30V + || filedata->file_header.e_machine == EM_CYGNUS_D30V) + && reloc_type == 12) + || reloc_inplace) + addend += byte_get (rloc, reloc_size); + + if (is_32bit_pcrel_reloc (filedata, reloc_type) + || is_64bit_pcrel_reloc (filedata, reloc_type)) + { + /* On HPPA, all pc-relative relocations are biased by 8. */ + if (filedata->file_header.e_machine == EM_PARISC) + addend -= 8; + byte_put (rloc, (addend + sym->st_value) - rp->r_offset, + reloc_size); + } + else if (reloc_subtract) + byte_put (rloc, addend - sym->st_value, reloc_size); + else + byte_put (rloc, addend + sym->st_value, reloc_size); + } + + free (symtab); + /* Let the target specific reloc processing code know that + we have finished with these relocs. */ + target_specific_reloc_handling (filedata, NULL, NULL, NULL, NULL, 0); + + if (relocs_return) + { + * (Elf_Internal_Rela **) relocs_return = relocs; + * num_relocs_return = num_relocs; + } + else + free (relocs); + + break; + } + + return res; +} + +#ifdef SUPPORT_DISASSEMBLY +static bfd_boolean +disassemble_section (Elf_Internal_Shdr * section, Filedata * filedata) +{ + printf (_("\nAssembly dump of section %s\n"), printable_section_name (filedata, section)); + + /* FIXME: XXX -- to be done --- XXX */ + + return TRUE; +} +#endif + +/* Reads in the contents of SECTION from FILE, returning a pointer + to a malloc'ed buffer or NULL if something went wrong. */ + +static char * +get_section_contents (Elf_Internal_Shdr * section, Filedata * filedata) +{ + bfd_size_type num_bytes = section->sh_size; + + if (num_bytes == 0 || section->sh_type == SHT_NOBITS) + { + printf (_("Section '%s' has no data to dump.\n"), + printable_section_name (filedata, section)); + return NULL; + } + + return (char *) get_data (NULL, filedata, section->sh_offset, 1, num_bytes, + _("section contents")); +} + +/* Uncompresses a section that was compressed using zlib, in place. */ + +static bfd_boolean +uncompress_section_contents (unsigned char ** buffer, + dwarf_size_type uncompressed_size, + dwarf_size_type * size) +{ + dwarf_size_type compressed_size = *size; + unsigned char * compressed_buffer = *buffer; + unsigned char * uncompressed_buffer; + z_stream strm; + int rc; + + /* It is possible the section consists of several compressed + buffers concatenated together, so we uncompress in a loop. */ + /* PR 18313: The state field in the z_stream structure is supposed + to be invisible to the user (ie us), but some compilers will + still complain about it being used without initialisation. So + we first zero the entire z_stream structure and then set the fields + that we need. */ + memset (& strm, 0, sizeof strm); + strm.avail_in = compressed_size; + strm.next_in = (Bytef *) compressed_buffer; + strm.avail_out = uncompressed_size; + uncompressed_buffer = (unsigned char *) xmalloc (uncompressed_size); + + rc = inflateInit (& strm); + while (strm.avail_in > 0) + { + if (rc != Z_OK) + goto fail; + strm.next_out = ((Bytef *) uncompressed_buffer + + (uncompressed_size - strm.avail_out)); + rc = inflate (&strm, Z_FINISH); + if (rc != Z_STREAM_END) + goto fail; + rc = inflateReset (& strm); + } + rc = inflateEnd (& strm); + if (rc != Z_OK + || strm.avail_out != 0) + goto fail; + + *buffer = uncompressed_buffer; + *size = uncompressed_size; + return TRUE; + + fail: + free (uncompressed_buffer); + /* Indicate decompression failure. */ + *buffer = NULL; + return FALSE; +} + +static bfd_boolean +dump_section_as_strings (Elf_Internal_Shdr * section, Filedata * filedata) +{ + Elf_Internal_Shdr * relsec; + bfd_size_type num_bytes; + unsigned char * data; + unsigned char * end; + unsigned char * real_start; + unsigned char * start; + bfd_boolean some_strings_shown; + + real_start = start = (unsigned char *) get_section_contents (section, filedata); + if (start == NULL) + /* PR 21820: Do not fail if the section was empty. */ + return (section->sh_size == 0 || section->sh_type == SHT_NOBITS) ? TRUE : FALSE; + + num_bytes = section->sh_size; + + printf (_("\nString dump of section '%s':\n"), printable_section_name (filedata, section)); + + if (decompress_dumps) + { + dwarf_size_type new_size = num_bytes; + dwarf_size_type uncompressed_size = 0; + + if ((section->sh_flags & SHF_COMPRESSED) != 0) + { + Elf_Internal_Chdr chdr; + unsigned int compression_header_size + = get_compression_header (& chdr, (unsigned char *) start, + num_bytes); + + if (chdr.ch_type != ELFCOMPRESS_ZLIB) + { + warn (_("section '%s' has unsupported compress type: %d\n"), + printable_section_name (filedata, section), chdr.ch_type); + return FALSE; + } + else if (chdr.ch_addralign != section->sh_addralign) + { + warn (_("compressed section '%s' is corrupted\n"), + printable_section_name (filedata, section)); + return FALSE; + } + uncompressed_size = chdr.ch_size; + start += compression_header_size; + new_size -= compression_header_size; + } + else if (new_size > 12 && streq ((char *) start, "ZLIB")) + { + /* Read the zlib header. In this case, it should be "ZLIB" + followed by the uncompressed section size, 8 bytes in + big-endian order. */ + uncompressed_size = start[4]; uncompressed_size <<= 8; + uncompressed_size += start[5]; uncompressed_size <<= 8; + uncompressed_size += start[6]; uncompressed_size <<= 8; + uncompressed_size += start[7]; uncompressed_size <<= 8; + uncompressed_size += start[8]; uncompressed_size <<= 8; + uncompressed_size += start[9]; uncompressed_size <<= 8; + uncompressed_size += start[10]; uncompressed_size <<= 8; + uncompressed_size += start[11]; + start += 12; + new_size -= 12; + } + + if (uncompressed_size) + { + if (uncompress_section_contents (& start, + uncompressed_size, & new_size)) + num_bytes = new_size; + else + { + error (_("Unable to decompress section %s\n"), + printable_section_name (filedata, section)); + return FALSE; + } + } + else + start = real_start; + } + + /* If the section being dumped has relocations against it the user might + be expecting these relocations to have been applied. Check for this + case and issue a warning message in order to avoid confusion. + FIXME: Maybe we ought to have an option that dumps a section with + relocs applied ? */ + for (relsec = filedata->section_headers; + relsec < filedata->section_headers + filedata->file_header.e_shnum; + ++relsec) + { + if ((relsec->sh_type != SHT_RELA && relsec->sh_type != SHT_REL) + || relsec->sh_info >= filedata->file_header.e_shnum + || filedata->section_headers + relsec->sh_info != section + || relsec->sh_size == 0 + || relsec->sh_link >= filedata->file_header.e_shnum) + continue; + + printf (_(" Note: This section has relocations against it, but these have NOT been applied to this dump.\n")); + break; + } + + data = start; + end = start + num_bytes; + some_strings_shown = FALSE; + + while (data < end) + { + while (!ISPRINT (* data)) + if (++ data >= end) + break; + + if (data < end) + { + size_t maxlen = end - data; + +#ifndef __MSVCRT__ + /* PR 11128: Use two separate invocations in order to work + around bugs in the Solaris 8 implementation of printf. */ + printf (" [%6tx] ", data - start); +#else + printf (" [%6Ix] ", (size_t) (data - start)); +#endif + if (maxlen > 0) + { + print_symbol ((int) maxlen, (const char *) data); + putchar ('\n'); + data += strnlen ((const char *) data, maxlen); + } + else + { + printf (_("\n")); + data = end; + } + some_strings_shown = TRUE; + } + } + + if (! some_strings_shown) + printf (_(" No strings found in this section.")); + + free (real_start); + + putchar ('\n'); + return TRUE; +} + +static bfd_boolean +dump_section_as_bytes (Elf_Internal_Shdr * section, + Filedata * filedata, + bfd_boolean relocate) +{ + Elf_Internal_Shdr * relsec; + bfd_size_type bytes; + bfd_size_type section_size; + bfd_vma addr; + unsigned char * data; + unsigned char * real_start; + unsigned char * start; + + real_start = start = (unsigned char *) get_section_contents (section, filedata); + if (start == NULL) + /* PR 21820: Do not fail if the section was empty. */ + return (section->sh_size == 0 || section->sh_type == SHT_NOBITS) ? TRUE : FALSE; + + section_size = section->sh_size; + + printf (_("\nHex dump of section '%s':\n"), printable_section_name (filedata, section)); + + if (decompress_dumps) + { + dwarf_size_type new_size = section_size; + dwarf_size_type uncompressed_size = 0; + + if ((section->sh_flags & SHF_COMPRESSED) != 0) + { + Elf_Internal_Chdr chdr; + unsigned int compression_header_size + = get_compression_header (& chdr, start, section_size); + + if (chdr.ch_type != ELFCOMPRESS_ZLIB) + { + warn (_("section '%s' has unsupported compress type: %d\n"), + printable_section_name (filedata, section), chdr.ch_type); + return FALSE; + } + else if (chdr.ch_addralign != section->sh_addralign) + { + warn (_("compressed section '%s' is corrupted\n"), + printable_section_name (filedata, section)); + return FALSE; + } + uncompressed_size = chdr.ch_size; + start += compression_header_size; + new_size -= compression_header_size; + } + else if (new_size > 12 && streq ((char *) start, "ZLIB")) + { + /* Read the zlib header. In this case, it should be "ZLIB" + followed by the uncompressed section size, 8 bytes in + big-endian order. */ + uncompressed_size = start[4]; uncompressed_size <<= 8; + uncompressed_size += start[5]; uncompressed_size <<= 8; + uncompressed_size += start[6]; uncompressed_size <<= 8; + uncompressed_size += start[7]; uncompressed_size <<= 8; + uncompressed_size += start[8]; uncompressed_size <<= 8; + uncompressed_size += start[9]; uncompressed_size <<= 8; + uncompressed_size += start[10]; uncompressed_size <<= 8; + uncompressed_size += start[11]; + start += 12; + new_size -= 12; + } + + if (uncompressed_size) + { + if (uncompress_section_contents (& start, uncompressed_size, + & new_size)) + { + section_size = new_size; + } + else + { + error (_("Unable to decompress section %s\n"), + printable_section_name (filedata, section)); + /* FIXME: Print the section anyway ? */ + return FALSE; + } + } + else + start = real_start; + } + + if (relocate) + { + if (! apply_relocations (filedata, section, start, section_size, NULL, NULL)) + return FALSE; + } + else + { + /* If the section being dumped has relocations against it the user might + be expecting these relocations to have been applied. Check for this + case and issue a warning message in order to avoid confusion. + FIXME: Maybe we ought to have an option that dumps a section with + relocs applied ? */ + for (relsec = filedata->section_headers; + relsec < filedata->section_headers + filedata->file_header.e_shnum; + ++relsec) + { + if ((relsec->sh_type != SHT_RELA && relsec->sh_type != SHT_REL) + || relsec->sh_info >= filedata->file_header.e_shnum + || filedata->section_headers + relsec->sh_info != section + || relsec->sh_size == 0 + || relsec->sh_link >= filedata->file_header.e_shnum) + continue; + + printf (_(" NOTE: This section has relocations against it, but these have NOT been applied to this dump.\n")); + break; + } + } + + addr = section->sh_addr; + bytes = section_size; + data = start; + + while (bytes) + { + int j; + int k; + int lbytes; + + lbytes = (bytes > 16 ? 16 : bytes); + + printf (" 0x%8.8lx ", (unsigned long) addr); + + for (j = 0; j < 16; j++) + { + if (j < lbytes) + printf ("%2.2x", data[j]); + else + printf (" "); + + if ((j & 3) == 3) + printf (" "); + } + + for (j = 0; j < lbytes; j++) + { + k = data[j]; + if (k >= ' ' && k < 0x7f) + printf ("%c", k); + else + printf ("."); + } + + putchar ('\n'); + + data += lbytes; + addr += lbytes; + bytes -= lbytes; + } + + free (real_start); + + putchar ('\n'); + return TRUE; +} + +static bfd_boolean +load_specific_debug_section (enum dwarf_section_display_enum debug, + const Elf_Internal_Shdr * sec, + void * data) +{ + struct dwarf_section * section = &debug_displays [debug].section; + char buf [64]; + Filedata * filedata = (Filedata *) data; + + if (section->start != NULL) + { + /* If it is already loaded, do nothing. */ + if (streq (section->filename, filedata->file_name)) + return TRUE; + free (section->start); + } + + snprintf (buf, sizeof (buf), _("%s section data"), section->name); + section->address = sec->sh_addr; + section->user_data = NULL; + section->filename = filedata->file_name; + section->start = (unsigned char *) get_data (NULL, filedata, + sec->sh_offset, 1, + sec->sh_size, buf); + if (section->start == NULL) + section->size = 0; + else + { + unsigned char *start = section->start; + dwarf_size_type size = sec->sh_size; + dwarf_size_type uncompressed_size = 0; + + if ((sec->sh_flags & SHF_COMPRESSED) != 0) + { + Elf_Internal_Chdr chdr; + unsigned int compression_header_size; + + if (size < (is_32bit_elf + ? sizeof (Elf32_External_Chdr) + : sizeof (Elf64_External_Chdr))) + { + warn (_("compressed section %s is too small to contain a compression header"), + section->name); + return FALSE; + } + + compression_header_size = get_compression_header (&chdr, start, size); + + if (chdr.ch_type != ELFCOMPRESS_ZLIB) + { + warn (_("section '%s' has unsupported compress type: %d\n"), + section->name, chdr.ch_type); + return FALSE; + } + else if (chdr.ch_addralign != sec->sh_addralign) + { + warn (_("compressed section '%s' is corrupted\n"), + section->name); + return FALSE; + } + uncompressed_size = chdr.ch_size; + start += compression_header_size; + size -= compression_header_size; + } + else if (size > 12 && streq ((char *) start, "ZLIB")) + { + /* Read the zlib header. In this case, it should be "ZLIB" + followed by the uncompressed section size, 8 bytes in + big-endian order. */ + uncompressed_size = start[4]; uncompressed_size <<= 8; + uncompressed_size += start[5]; uncompressed_size <<= 8; + uncompressed_size += start[6]; uncompressed_size <<= 8; + uncompressed_size += start[7]; uncompressed_size <<= 8; + uncompressed_size += start[8]; uncompressed_size <<= 8; + uncompressed_size += start[9]; uncompressed_size <<= 8; + uncompressed_size += start[10]; uncompressed_size <<= 8; + uncompressed_size += start[11]; + start += 12; + size -= 12; + } + + if (uncompressed_size) + { + if (uncompress_section_contents (&start, uncompressed_size, + &size)) + { + /* Free the compressed buffer, update the section buffer + and the section size if uncompress is successful. */ + free (section->start); + section->start = start; + } + else + { + error (_("Unable to decompress section %s\n"), + printable_section_name (filedata, sec)); + return FALSE; + } + } + + section->size = size; + } + + if (section->start == NULL) + return FALSE; + + if (debug_displays [debug].relocate) + { + if (! apply_relocations (filedata, sec, section->start, section->size, + & section->reloc_info, & section->num_relocs)) + return FALSE; + } + else + { + section->reloc_info = NULL; + section->num_relocs = 0; + } + + return TRUE; +} + +/* If this is not NULL, load_debug_section will only look for sections + within the list of sections given here. */ +static unsigned int * section_subset = NULL; + +bfd_boolean +load_debug_section (enum dwarf_section_display_enum debug, void * data) +{ + struct dwarf_section * section = &debug_displays [debug].section; + Elf_Internal_Shdr * sec; + Filedata * filedata = (Filedata *) data; + + /* Without section headers we cannot find any sections. */ + if (filedata->section_headers == NULL) + return FALSE; + + if (filedata->string_table == NULL + && filedata->file_header.e_shstrndx != SHN_UNDEF + && filedata->file_header.e_shstrndx < filedata->file_header.e_shnum) + { + Elf_Internal_Shdr * strs; + + /* Read in the string table, so that we have section names to scan. */ + strs = filedata->section_headers + filedata->file_header.e_shstrndx; + + if (strs != NULL && strs->sh_size != 0) + { + filedata->string_table + = (char *) get_data (NULL, filedata, strs->sh_offset, + 1, strs->sh_size, _("string table")); + + filedata->string_table_length + = filedata->string_table != NULL ? strs->sh_size : 0; + } + } + + /* Locate the debug section. */ + sec = find_section_in_set (filedata, section->uncompressed_name, section_subset); + if (sec != NULL) + section->name = section->uncompressed_name; + else + { + sec = find_section_in_set (filedata, section->compressed_name, section_subset); + if (sec != NULL) + section->name = section->compressed_name; + } + if (sec == NULL) + return FALSE; + + /* If we're loading from a subset of sections, and we've loaded + a section matching this name before, it's likely that it's a + different one. */ + if (section_subset != NULL) + free_debug_section (debug); + + return load_specific_debug_section (debug, sec, data); +} + +void +free_debug_section (enum dwarf_section_display_enum debug) +{ + struct dwarf_section * section = &debug_displays [debug].section; + + if (section->start == NULL) + return; + + free ((char *) section->start); + section->start = NULL; + section->address = 0; + section->size = 0; +} + +static bfd_boolean +display_debug_section (int shndx, Elf_Internal_Shdr * section, Filedata * filedata) +{ + char * name = SECTION_NAME (section); + const char * print_name = printable_section_name (filedata, section); + bfd_size_type length; + bfd_boolean result = TRUE; + int i; + + length = section->sh_size; + if (length == 0) + { + printf (_("\nSection '%s' has no debugging data.\n"), print_name); + return TRUE; + } + if (section->sh_type == SHT_NOBITS) + { + /* There is no point in dumping the contents of a debugging section + which has the NOBITS type - the bits in the file will be random. + This can happen when a file containing a .eh_frame section is + stripped with the --only-keep-debug command line option. */ + printf (_("section '%s' has the NOBITS type - its contents are unreliable.\n"), + print_name); + return FALSE; + } + + if (const_strneq (name, ".gnu.linkonce.wi.")) + name = ".debug_info"; + + /* See if we know how to display the contents of this section. */ + for (i = 0; i < max; i++) + { + enum dwarf_section_display_enum id = (enum dwarf_section_display_enum) i; + struct dwarf_section_display * display = debug_displays + i; + struct dwarf_section * sec = & display->section; + + if (streq (sec->uncompressed_name, name) + || (id == line && const_strneq (name, ".debug_line.")) + || streq (sec->compressed_name, name)) + { + bfd_boolean secondary = (section != find_section (filedata, name)); + + if (secondary) + free_debug_section (id); + + if (i == line && const_strneq (name, ".debug_line.")) + sec->name = name; + else if (streq (sec->uncompressed_name, name)) + sec->name = sec->uncompressed_name; + else + sec->name = sec->compressed_name; + + if (load_specific_debug_section (id, section, filedata)) + { + /* If this debug section is part of a CU/TU set in a .dwp file, + restrict load_debug_section to the sections in that set. */ + section_subset = find_cu_tu_set (filedata, shndx); + + result &= display->display (sec, filedata); + + section_subset = NULL; + + if (secondary || (id != info && id != abbrev)) + free_debug_section (id); + } + break; + } + } + + if (i == max) + { + printf (_("Unrecognized debug section: %s\n"), print_name); + result = FALSE; + } + + return result; +} + +/* Set DUMP_SECTS for all sections where dumps were requested + based on section name. */ + +static void +initialise_dumps_byname (Filedata * filedata) +{ + struct dump_list_entry * cur; + + for (cur = dump_sects_byname; cur; cur = cur->next) + { + unsigned int i; + bfd_boolean any = FALSE; + + for (i = 0; i < filedata->file_header.e_shnum; i++) + if (streq (SECTION_NAME (filedata->section_headers + i), cur->name)) + { + request_dump_bynumber (filedata, i, cur->type); + any = TRUE; + } + + if (!any) + warn (_("Section '%s' was not dumped because it does not exist!\n"), + cur->name); + } +} + +static bfd_boolean +process_section_contents (Filedata * filedata) +{ + Elf_Internal_Shdr * section; + unsigned int i; + bfd_boolean res = TRUE; + + if (! do_dump) + return TRUE; + + initialise_dumps_byname (filedata); + + for (i = 0, section = filedata->section_headers; + i < filedata->file_header.e_shnum && i < filedata->num_dump_sects; + i++, section++) + { + dump_type dump = filedata->dump_sects[i]; + +#ifdef SUPPORT_DISASSEMBLY + if (dump & DISASS_DUMP) + { + if (! disassemble_section (section, filedata)) + res = FALSE; + } +#endif + if (dump & HEX_DUMP) + { + if (! dump_section_as_bytes (section, filedata, FALSE)) + res = FALSE; + } + + if (dump & RELOC_DUMP) + { + if (! dump_section_as_bytes (section, filedata, TRUE)) + res = FALSE; + } + + if (dump & STRING_DUMP) + { + if (! dump_section_as_strings (section, filedata)) + res = FALSE; + } + + if (dump & DEBUG_DUMP) + { + if (! display_debug_section (i, section, filedata)) + res = FALSE; + } + } + + /* Check to see if the user requested a + dump of a section that does not exist. */ + while (i < filedata->num_dump_sects) + { + if (filedata->dump_sects[i]) + { + warn (_("Section %d was not dumped because it does not exist!\n"), i); + res = FALSE; + } + i++; + } + + return res; +} + +static void +process_mips_fpe_exception (int mask) +{ + if (mask) + { + bfd_boolean first = TRUE; + + if (mask & OEX_FPU_INEX) + fputs ("INEX", stdout), first = FALSE; + if (mask & OEX_FPU_UFLO) + printf ("%sUFLO", first ? "" : "|"), first = FALSE; + if (mask & OEX_FPU_OFLO) + printf ("%sOFLO", first ? "" : "|"), first = FALSE; + if (mask & OEX_FPU_DIV0) + printf ("%sDIV0", first ? "" : "|"), first = FALSE; + if (mask & OEX_FPU_INVAL) + printf ("%sINVAL", first ? "" : "|"); + } + else + fputs ("0", stdout); +} + +/* Display's the value of TAG at location P. If TAG is + greater than 0 it is assumed to be an unknown tag, and + a message is printed to this effect. Otherwise it is + assumed that a message has already been printed. + + If the bottom bit of TAG is set it assumed to have a + string value, otherwise it is assumed to have an integer + value. + + Returns an updated P pointing to the first unread byte + beyond the end of TAG's value. + + Reads at or beyond END will not be made. */ + +static unsigned char * +display_tag_value (signed int tag, + unsigned char * p, + const unsigned char * const end) +{ + unsigned long val; + + if (tag > 0) + printf (" Tag_unknown_%d: ", tag); + + if (p >= end) + { + warn (_("\n")); + } + else if (tag & 1) + { + /* PR 17531 file: 027-19978-0.004. */ + size_t maxlen = (end - p) - 1; + + putchar ('"'); + if (maxlen > 0) + { + print_symbol ((int) maxlen, (const char *) p); + p += strnlen ((char *) p, maxlen) + 1; + } + else + { + printf (_("")); + p = (unsigned char *) end; + } + printf ("\"\n"); + } + else + { + unsigned int len; + + val = read_uleb128 (p, &len, end); + p += len; + printf ("%ld (0x%lx)\n", val, val); + } + + assert (p <= end); + return p; +} + +/* ARC ABI attributes section. */ + +static unsigned char * +display_arc_attribute (unsigned char * p, + const unsigned char * const end) +{ + unsigned int tag; + unsigned int len; + unsigned int val; + + tag = read_uleb128 (p, &len, end); + p += len; + + switch (tag) + { + case Tag_ARC_PCS_config: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ARC_PCS_config: "); + switch (val) + { + case 0: + printf (_("Absent/Non standard\n")); + break; + case 1: + printf (_("Bare metal/mwdt\n")); + break; + case 2: + printf (_("Bare metal/newlib\n")); + break; + case 3: + printf (_("Linux/uclibc\n")); + break; + case 4: + printf (_("Linux/glibc\n")); + break; + default: + printf (_("Unknown\n")); + break; + } + break; + + case Tag_ARC_CPU_base: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ARC_CPU_base: "); + switch (val) + { + default: + case TAG_CPU_NONE: + printf (_("Absent\n")); + break; + case TAG_CPU_ARC6xx: + printf ("ARC6xx\n"); + break; + case TAG_CPU_ARC7xx: + printf ("ARC7xx\n"); + break; + case TAG_CPU_ARCEM: + printf ("ARCEM\n"); + break; + case TAG_CPU_ARCHS: + printf ("ARCHS\n"); + break; + } + break; + + case Tag_ARC_CPU_variation: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ARC_CPU_variation: "); + switch (val) + { + default: + if (val > 0 && val < 16) + printf ("Core%d\n", val); + else + printf ("Unknown\n"); + break; + + case 0: + printf (_("Absent\n")); + break; + } + break; + + case Tag_ARC_CPU_name: + printf (" Tag_ARC_CPU_name: "); + p = display_tag_value (-1, p, end); + break; + + case Tag_ARC_ABI_rf16: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ARC_ABI_rf16: %s\n", val ? _("yes") : _("no")); + break; + + case Tag_ARC_ABI_osver: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ARC_ABI_osver: v%d\n", val); + break; + + case Tag_ARC_ABI_pic: + case Tag_ARC_ABI_sda: + val = read_uleb128 (p, &len, end); + p += len; + printf (tag == Tag_ARC_ABI_sda ? " Tag_ARC_ABI_sda: " + : " Tag_ARC_ABI_pic: "); + switch (val) + { + case 0: + printf (_("Absent\n")); + break; + case 1: + printf ("MWDT\n"); + break; + case 2: + printf ("GNU\n"); + break; + default: + printf (_("Unknown\n")); + break; + } + break; + + case Tag_ARC_ABI_tls: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ARC_ABI_tls: %s\n", val ? "r25": "none"); + break; + + case Tag_ARC_ABI_enumsize: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ARC_ABI_enumsize: %s\n", val ? _("default") : + _("smallest")); + break; + + case Tag_ARC_ABI_exceptions: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ARC_ABI_exceptions: %s\n", val ? _("OPTFP") + : _("default")); + break; + + case Tag_ARC_ABI_double_size: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ARC_ABI_double_size: %d\n", val); + break; + + case Tag_ARC_ISA_config: + printf (" Tag_ARC_ISA_config: "); + p = display_tag_value (-1, p, end); + break; + + case Tag_ARC_ISA_apex: + printf (" Tag_ARC_ISA_apex: "); + p = display_tag_value (-1, p, end); + break; + + case Tag_ARC_ISA_mpy_option: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ARC_ISA_mpy_option: %d\n", val); + break; + + default: + return display_tag_value (tag & 1, p, end); + } + + return p; +} + +/* ARM EABI attributes section. */ +typedef struct +{ + unsigned int tag; + const char * name; + /* 0 = special, 1 = string, 2 = uleb123, > 0x80 == table lookup. */ + unsigned int type; + const char ** table; +} arm_attr_public_tag; + +static const char * arm_attr_tag_CPU_arch[] = + {"Pre-v4", "v4", "v4T", "v5T", "v5TE", "v5TEJ", "v6", "v6KZ", "v6T2", + "v6K", "v7", "v6-M", "v6S-M", "v7E-M", "v8", "v8-R", "v8-M.baseline", + "v8-M.mainline"}; +static const char * arm_attr_tag_ARM_ISA_use[] = {"No", "Yes"}; +static const char * arm_attr_tag_THUMB_ISA_use[] = + {"No", "Thumb-1", "Thumb-2", "Yes"}; +static const char * arm_attr_tag_FP_arch[] = + {"No", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16", "VFPv4", "VFPv4-D16", + "FP for ARMv8", "FPv5/FP-D16 for ARMv8"}; +static const char * arm_attr_tag_WMMX_arch[] = {"No", "WMMXv1", "WMMXv2"}; +static const char * arm_attr_tag_Advanced_SIMD_arch[] = + {"No", "NEONv1", "NEONv1 with Fused-MAC", "NEON for ARMv8", + "NEON for ARMv8.1"}; +static const char * arm_attr_tag_PCS_config[] = + {"None", "Bare platform", "Linux application", "Linux DSO", "PalmOS 2004", + "PalmOS (reserved)", "SymbianOS 2004", "SymbianOS (reserved)"}; +static const char * arm_attr_tag_ABI_PCS_R9_use[] = + {"V6", "SB", "TLS", "Unused"}; +static const char * arm_attr_tag_ABI_PCS_RW_data[] = + {"Absolute", "PC-relative", "SB-relative", "None"}; +static const char * arm_attr_tag_ABI_PCS_RO_data[] = + {"Absolute", "PC-relative", "None"}; +static const char * arm_attr_tag_ABI_PCS_GOT_use[] = + {"None", "direct", "GOT-indirect"}; +static const char * arm_attr_tag_ABI_PCS_wchar_t[] = + {"None", "??? 1", "2", "??? 3", "4"}; +static const char * arm_attr_tag_ABI_FP_rounding[] = {"Unused", "Needed"}; +static const char * arm_attr_tag_ABI_FP_denormal[] = + {"Unused", "Needed", "Sign only"}; +static const char * arm_attr_tag_ABI_FP_exceptions[] = {"Unused", "Needed"}; +static const char * arm_attr_tag_ABI_FP_user_exceptions[] = {"Unused", "Needed"}; +static const char * arm_attr_tag_ABI_FP_number_model[] = + {"Unused", "Finite", "RTABI", "IEEE 754"}; +static const char * arm_attr_tag_ABI_enum_size[] = + {"Unused", "small", "int", "forced to int"}; +static const char * arm_attr_tag_ABI_HardFP_use[] = + {"As Tag_FP_arch", "SP only", "Reserved", "Deprecated"}; +static const char * arm_attr_tag_ABI_VFP_args[] = + {"AAPCS", "VFP registers", "custom", "compatible"}; +static const char * arm_attr_tag_ABI_WMMX_args[] = + {"AAPCS", "WMMX registers", "custom"}; +static const char * arm_attr_tag_ABI_optimization_goals[] = + {"None", "Prefer Speed", "Aggressive Speed", "Prefer Size", + "Aggressive Size", "Prefer Debug", "Aggressive Debug"}; +static const char * arm_attr_tag_ABI_FP_optimization_goals[] = + {"None", "Prefer Speed", "Aggressive Speed", "Prefer Size", + "Aggressive Size", "Prefer Accuracy", "Aggressive Accuracy"}; +static const char * arm_attr_tag_CPU_unaligned_access[] = {"None", "v6"}; +static const char * arm_attr_tag_FP_HP_extension[] = + {"Not Allowed", "Allowed"}; +static const char * arm_attr_tag_ABI_FP_16bit_format[] = + {"None", "IEEE 754", "Alternative Format"}; +static const char * arm_attr_tag_DSP_extension[] = + {"Follow architecture", "Allowed"}; +static const char * arm_attr_tag_MPextension_use[] = + {"Not Allowed", "Allowed"}; +static const char * arm_attr_tag_DIV_use[] = + {"Allowed in Thumb-ISA, v7-R or v7-M", "Not allowed", + "Allowed in v7-A with integer division extension"}; +static const char * arm_attr_tag_T2EE_use[] = {"Not Allowed", "Allowed"}; +static const char * arm_attr_tag_Virtualization_use[] = + {"Not Allowed", "TrustZone", "Virtualization Extensions", + "TrustZone and Virtualization Extensions"}; +static const char * arm_attr_tag_MPextension_use_legacy[] = + {"Not Allowed", "Allowed"}; + +#define LOOKUP(id, name) \ + {id, #name, 0x80 | ARRAY_SIZE(arm_attr_tag_##name), arm_attr_tag_##name} +static arm_attr_public_tag arm_attr_public_tags[] = +{ + {4, "CPU_raw_name", 1, NULL}, + {5, "CPU_name", 1, NULL}, + LOOKUP(6, CPU_arch), + {7, "CPU_arch_profile", 0, NULL}, + LOOKUP(8, ARM_ISA_use), + LOOKUP(9, THUMB_ISA_use), + LOOKUP(10, FP_arch), + LOOKUP(11, WMMX_arch), + LOOKUP(12, Advanced_SIMD_arch), + LOOKUP(13, PCS_config), + LOOKUP(14, ABI_PCS_R9_use), + LOOKUP(15, ABI_PCS_RW_data), + LOOKUP(16, ABI_PCS_RO_data), + LOOKUP(17, ABI_PCS_GOT_use), + LOOKUP(18, ABI_PCS_wchar_t), + LOOKUP(19, ABI_FP_rounding), + LOOKUP(20, ABI_FP_denormal), + LOOKUP(21, ABI_FP_exceptions), + LOOKUP(22, ABI_FP_user_exceptions), + LOOKUP(23, ABI_FP_number_model), + {24, "ABI_align_needed", 0, NULL}, + {25, "ABI_align_preserved", 0, NULL}, + LOOKUP(26, ABI_enum_size), + LOOKUP(27, ABI_HardFP_use), + LOOKUP(28, ABI_VFP_args), + LOOKUP(29, ABI_WMMX_args), + LOOKUP(30, ABI_optimization_goals), + LOOKUP(31, ABI_FP_optimization_goals), + {32, "compatibility", 0, NULL}, + LOOKUP(34, CPU_unaligned_access), + LOOKUP(36, FP_HP_extension), + LOOKUP(38, ABI_FP_16bit_format), + LOOKUP(42, MPextension_use), + LOOKUP(44, DIV_use), + LOOKUP(46, DSP_extension), + {64, "nodefaults", 0, NULL}, + {65, "also_compatible_with", 0, NULL}, + LOOKUP(66, T2EE_use), + {67, "conformance", 1, NULL}, + LOOKUP(68, Virtualization_use), + LOOKUP(70, MPextension_use_legacy) +}; +#undef LOOKUP + +static unsigned char * +display_arm_attribute (unsigned char * p, + const unsigned char * const end) +{ + unsigned int tag; + unsigned int len; + unsigned int val; + arm_attr_public_tag * attr; + unsigned i; + unsigned int type; + + tag = read_uleb128 (p, &len, end); + p += len; + attr = NULL; + for (i = 0; i < ARRAY_SIZE (arm_attr_public_tags); i++) + { + if (arm_attr_public_tags[i].tag == tag) + { + attr = &arm_attr_public_tags[i]; + break; + } + } + + if (attr) + { + printf (" Tag_%s: ", attr->name); + switch (attr->type) + { + case 0: + switch (tag) + { + case 7: /* Tag_CPU_arch_profile. */ + val = read_uleb128 (p, &len, end); + p += len; + switch (val) + { + case 0: printf (_("None\n")); break; + case 'A': printf (_("Application\n")); break; + case 'R': printf (_("Realtime\n")); break; + case 'M': printf (_("Microcontroller\n")); break; + case 'S': printf (_("Application or Realtime\n")); break; + default: printf ("??? (%d)\n", val); break; + } + break; + + case 24: /* Tag_align_needed. */ + val = read_uleb128 (p, &len, end); + p += len; + switch (val) + { + case 0: printf (_("None\n")); break; + case 1: printf (_("8-byte\n")); break; + case 2: printf (_("4-byte\n")); break; + case 3: printf ("??? 3\n"); break; + default: + if (val <= 12) + printf (_("8-byte and up to %d-byte extended\n"), + 1 << val); + else + printf ("??? (%d)\n", val); + break; + } + break; + + case 25: /* Tag_align_preserved. */ + val = read_uleb128 (p, &len, end); + p += len; + switch (val) + { + case 0: printf (_("None\n")); break; + case 1: printf (_("8-byte, except leaf SP\n")); break; + case 2: printf (_("8-byte\n")); break; + case 3: printf ("??? 3\n"); break; + default: + if (val <= 12) + printf (_("8-byte and up to %d-byte extended\n"), + 1 << val); + else + printf ("??? (%d)\n", val); + break; + } + break; + + case 32: /* Tag_compatibility. */ + { + val = read_uleb128 (p, &len, end); + p += len; + printf (_("flag = %d, vendor = "), val); + if (p < end - 1) + { + size_t maxlen = (end - p) - 1; + + print_symbol ((int) maxlen, (const char *) p); + p += strnlen ((char *) p, maxlen) + 1; + } + else + { + printf (_("")); + p = (unsigned char *) end; + } + putchar ('\n'); + } + break; + + case 64: /* Tag_nodefaults. */ + /* PR 17531: file: 001-505008-0.01. */ + if (p < end) + p++; + printf (_("True\n")); + break; + + case 65: /* Tag_also_compatible_with. */ + val = read_uleb128 (p, &len, end); + p += len; + if (val == 6 /* Tag_CPU_arch. */) + { + val = read_uleb128 (p, &len, end); + p += len; + if ((unsigned int) val >= ARRAY_SIZE (arm_attr_tag_CPU_arch)) + printf ("??? (%d)\n", val); + else + printf ("%s\n", arm_attr_tag_CPU_arch[val]); + } + else + printf ("???\n"); + while (p < end && *(p++) != '\0' /* NUL terminator. */) + ; + break; + + default: + printf (_("\n"), tag); + break; + } + return p; + + case 1: + return display_tag_value (-1, p, end); + case 2: + return display_tag_value (0, p, end); + + default: + assert (attr->type & 0x80); + val = read_uleb128 (p, &len, end); + p += len; + type = attr->type & 0x7f; + if (val >= type) + printf ("??? (%d)\n", val); + else + printf ("%s\n", attr->table[val]); + return p; + } + } + + return display_tag_value (tag, p, end); +} + +static unsigned char * +display_gnu_attribute (unsigned char * p, + unsigned char * (* display_proc_gnu_attribute) (unsigned char *, unsigned int, const unsigned char * const), + const unsigned char * const end) +{ + int tag; + unsigned int len; + unsigned int val; + + tag = read_uleb128 (p, &len, end); + p += len; + + /* Tag_compatibility is the only generic GNU attribute defined at + present. */ + if (tag == 32) + { + val = read_uleb128 (p, &len, end); + p += len; + + printf (_("flag = %d, vendor = "), val); + if (p == end) + { + printf (_("\n")); + warn (_("corrupt vendor attribute\n")); + } + else + { + if (p < end - 1) + { + size_t maxlen = (end - p) - 1; + + print_symbol ((int) maxlen, (const char *) p); + p += strnlen ((char *) p, maxlen) + 1; + } + else + { + printf (_("")); + p = (unsigned char *) end; + } + putchar ('\n'); + } + return p; + } + + if ((tag & 2) == 0 && display_proc_gnu_attribute) + return display_proc_gnu_attribute (p, tag, end); + + return display_tag_value (tag, p, end); +} + +static unsigned char * +display_power_gnu_attribute (unsigned char * p, + unsigned int tag, + const unsigned char * const end) +{ + unsigned int len; + unsigned int val; + + if (tag == Tag_GNU_Power_ABI_FP) + { + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_Power_ABI_FP: "); + if (len == 0) + { + printf (_("\n")); + return p; + } + + if (val > 15) + printf ("(%#x), ", val); + + switch (val & 3) + { + case 0: + printf (_("unspecified hard/soft float, ")); + break; + case 1: + printf (_("hard float, ")); + break; + case 2: + printf (_("soft float, ")); + break; + case 3: + printf (_("single-precision hard float, ")); + break; + } + + switch (val & 0xC) + { + case 0: + printf (_("unspecified long double\n")); + break; + case 4: + printf (_("128-bit IBM long double\n")); + break; + case 8: + printf (_("64-bit long double\n")); + break; + case 12: + printf (_("128-bit IEEE long double\n")); + break; + } + return p; + } + + if (tag == Tag_GNU_Power_ABI_Vector) + { + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_Power_ABI_Vector: "); + if (len == 0) + { + printf (_("\n")); + return p; + } + + if (val > 3) + printf ("(%#x), ", val); + + switch (val & 3) + { + case 0: + printf (_("unspecified\n")); + break; + case 1: + printf (_("generic\n")); + break; + case 2: + printf ("AltiVec\n"); + break; + case 3: + printf ("SPE\n"); + break; + } + return p; + } + + if (tag == Tag_GNU_Power_ABI_Struct_Return) + { + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_Power_ABI_Struct_Return: "); + if (len == 0) + { + printf (_("\n")); + return p; + } + + if (val > 2) + printf ("(%#x), ", val); + + switch (val & 3) + { + case 0: + printf (_("unspecified\n")); + break; + case 1: + printf ("r3/r4\n"); + break; + case 2: + printf (_("memory\n")); + break; + case 3: + printf ("???\n"); + break; + } + return p; + } + + return display_tag_value (tag & 1, p, end); +} + +static unsigned char * +display_s390_gnu_attribute (unsigned char * p, + unsigned int tag, + const unsigned char * const end) +{ + unsigned int len; + int val; + + if (tag == Tag_GNU_S390_ABI_Vector) + { + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_S390_ABI_Vector: "); + + switch (val) + { + case 0: + printf (_("any\n")); + break; + case 1: + printf (_("software\n")); + break; + case 2: + printf (_("hardware\n")); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + } + + return display_tag_value (tag & 1, p, end); +} + +static void +display_sparc_hwcaps (unsigned int mask) +{ + if (mask) + { + bfd_boolean first = TRUE; + + if (mask & ELF_SPARC_HWCAP_MUL32) + fputs ("mul32", stdout), first = FALSE; + if (mask & ELF_SPARC_HWCAP_DIV32) + printf ("%sdiv32", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_FSMULD) + printf ("%sfsmuld", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_V8PLUS) + printf ("%sv8plus", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_POPC) + printf ("%spopc", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_VIS) + printf ("%svis", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_VIS2) + printf ("%svis2", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_ASI_BLK_INIT) + printf ("%sASIBlkInit", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_FMAF) + printf ("%sfmaf", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_VIS3) + printf ("%svis3", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_HPC) + printf ("%shpc", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_RANDOM) + printf ("%srandom", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_TRANS) + printf ("%strans", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_FJFMAU) + printf ("%sfjfmau", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_IMA) + printf ("%sima", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP_ASI_CACHE_SPARING) + printf ("%scspare", first ? "" : "|"), first = FALSE; + } + else + fputc ('0', stdout); + fputc ('\n', stdout); +} + +static void +display_sparc_hwcaps2 (unsigned int mask) +{ + if (mask) + { + bfd_boolean first = TRUE; + + if (mask & ELF_SPARC_HWCAP2_FJATHPLUS) + fputs ("fjathplus", stdout), first = FALSE; + if (mask & ELF_SPARC_HWCAP2_VIS3B) + printf ("%svis3b", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP2_ADP) + printf ("%sadp", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP2_SPARC5) + printf ("%ssparc5", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP2_MWAIT) + printf ("%smwait", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP2_XMPMUL) + printf ("%sxmpmul", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP2_XMONT) + printf ("%sxmont2", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP2_NSEC) + printf ("%snsec", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP2_FJATHHPC) + printf ("%sfjathhpc", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP2_FJDES) + printf ("%sfjdes", first ? "" : "|"), first = FALSE; + if (mask & ELF_SPARC_HWCAP2_FJAES) + printf ("%sfjaes", first ? "" : "|"), first = FALSE; + } + else + fputc ('0', stdout); + fputc ('\n', stdout); +} + +static unsigned char * +display_sparc_gnu_attribute (unsigned char * p, + unsigned int tag, + const unsigned char * const end) +{ + unsigned int len; + int val; + + if (tag == Tag_GNU_Sparc_HWCAPS) + { + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_Sparc_HWCAPS: "); + display_sparc_hwcaps (val); + return p; + } + if (tag == Tag_GNU_Sparc_HWCAPS2) + { + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_Sparc_HWCAPS2: "); + display_sparc_hwcaps2 (val); + return p; + } + + return display_tag_value (tag, p, end); +} + +static void +print_mips_fp_abi_value (unsigned int val) +{ + switch (val) + { + case Val_GNU_MIPS_ABI_FP_ANY: + printf (_("Hard or soft float\n")); + break; + case Val_GNU_MIPS_ABI_FP_DOUBLE: + printf (_("Hard float (double precision)\n")); + break; + case Val_GNU_MIPS_ABI_FP_SINGLE: + printf (_("Hard float (single precision)\n")); + break; + case Val_GNU_MIPS_ABI_FP_SOFT: + printf (_("Soft float\n")); + break; + case Val_GNU_MIPS_ABI_FP_OLD_64: + printf (_("Hard float (MIPS32r2 64-bit FPU 12 callee-saved)\n")); + break; + case Val_GNU_MIPS_ABI_FP_XX: + printf (_("Hard float (32-bit CPU, Any FPU)\n")); + break; + case Val_GNU_MIPS_ABI_FP_64: + printf (_("Hard float (32-bit CPU, 64-bit FPU)\n")); + break; + case Val_GNU_MIPS_ABI_FP_64A: + printf (_("Hard float compat (32-bit CPU, 64-bit FPU)\n")); + break; + case Val_GNU_MIPS_ABI_FP_NAN2008: + printf (_("NaN 2008 compatibility\n")); + break; + default: + printf ("??? (%d)\n", val); + break; + } +} + +static unsigned char * +display_mips_gnu_attribute (unsigned char * p, + unsigned int tag, + const unsigned char * const end) +{ + if (tag == Tag_GNU_MIPS_ABI_FP) + { + unsigned int len; + unsigned int val; + + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_MIPS_ABI_FP: "); + + print_mips_fp_abi_value (val); + + return p; + } + + if (tag == Tag_GNU_MIPS_ABI_MSA) + { + unsigned int len; + unsigned int val; + + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_MIPS_ABI_MSA: "); + + switch (val) + { + case Val_GNU_MIPS_ABI_MSA_ANY: + printf (_("Any MSA or not\n")); + break; + case Val_GNU_MIPS_ABI_MSA_128: + printf (_("128-bit MSA\n")); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + } + + return display_tag_value (tag & 1, p, end); +} + +static unsigned char * +display_tic6x_attribute (unsigned char * p, + const unsigned char * const end) +{ + unsigned int tag; + unsigned int len; + int val; + + tag = read_uleb128 (p, &len, end); + p += len; + + switch (tag) + { + case Tag_ISA: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ISA: "); + + switch (val) + { + case C6XABI_Tag_ISA_none: + printf (_("None\n")); + break; + case C6XABI_Tag_ISA_C62X: + printf ("C62x\n"); + break; + case C6XABI_Tag_ISA_C67X: + printf ("C67x\n"); + break; + case C6XABI_Tag_ISA_C67XP: + printf ("C67x+\n"); + break; + case C6XABI_Tag_ISA_C64X: + printf ("C64x\n"); + break; + case C6XABI_Tag_ISA_C64XP: + printf ("C64x+\n"); + break; + case C6XABI_Tag_ISA_C674X: + printf ("C674x\n"); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + + case Tag_ABI_wchar_t: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_wchar_t: "); + switch (val) + { + case 0: + printf (_("Not used\n")); + break; + case 1: + printf (_("2 bytes\n")); + break; + case 2: + printf (_("4 bytes\n")); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + + case Tag_ABI_stack_align_needed: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_stack_align_needed: "); + switch (val) + { + case 0: + printf (_("8-byte\n")); + break; + case 1: + printf (_("16-byte\n")); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + + case Tag_ABI_stack_align_preserved: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_stack_align_preserved: "); + switch (val) + { + case 0: + printf (_("8-byte\n")); + break; + case 1: + printf (_("16-byte\n")); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + + case Tag_ABI_DSBT: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_DSBT: "); + switch (val) + { + case 0: + printf (_("DSBT addressing not used\n")); + break; + case 1: + printf (_("DSBT addressing used\n")); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + + case Tag_ABI_PID: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_PID: "); + switch (val) + { + case 0: + printf (_("Data addressing position-dependent\n")); + break; + case 1: + printf (_("Data addressing position-independent, GOT near DP\n")); + break; + case 2: + printf (_("Data addressing position-independent, GOT far from DP\n")); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + + case Tag_ABI_PIC: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_PIC: "); + switch (val) + { + case 0: + printf (_("Code addressing position-dependent\n")); + break; + case 1: + printf (_("Code addressing position-independent\n")); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + + case Tag_ABI_array_object_alignment: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_array_object_alignment: "); + switch (val) + { + case 0: + printf (_("8-byte\n")); + break; + case 1: + printf (_("4-byte\n")); + break; + case 2: + printf (_("16-byte\n")); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + + case Tag_ABI_array_object_align_expected: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_array_object_align_expected: "); + switch (val) + { + case 0: + printf (_("8-byte\n")); + break; + case 1: + printf (_("4-byte\n")); + break; + case 2: + printf (_("16-byte\n")); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + + case Tag_ABI_compatibility: + { + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_compatibility: "); + printf (_("flag = %d, vendor = "), val); + if (p < end - 1) + { + size_t maxlen = (end - p) - 1; + + print_symbol ((int) maxlen, (const char *) p); + p += strnlen ((char *) p, maxlen) + 1; + } + else + { + printf (_("")); + p = (unsigned char *) end; + } + putchar ('\n'); + return p; + } + + case Tag_ABI_conformance: + { + printf (" Tag_ABI_conformance: \""); + if (p < end - 1) + { + size_t maxlen = (end - p) - 1; + + print_symbol ((int) maxlen, (const char *) p); + p += strnlen ((char *) p, maxlen) + 1; + } + else + { + printf (_("")); + p = (unsigned char *) end; + } + printf ("\"\n"); + return p; + } + } + + return display_tag_value (tag, p, end); +} + +static void +display_raw_attribute (unsigned char * p, unsigned char const * const end) +{ + unsigned long addr = 0; + size_t bytes = end - p; + + assert (end > p); + while (bytes) + { + int j; + int k; + int lbytes = (bytes > 16 ? 16 : bytes); + + printf (" 0x%8.8lx ", addr); + + for (j = 0; j < 16; j++) + { + if (j < lbytes) + printf ("%2.2x", p[j]); + else + printf (" "); + + if ((j & 3) == 3) + printf (" "); + } + + for (j = 0; j < lbytes; j++) + { + k = p[j]; + if (k >= ' ' && k < 0x7f) + printf ("%c", k); + else + printf ("."); + } + + putchar ('\n'); + + p += lbytes; + bytes -= lbytes; + addr += lbytes; + } + + putchar ('\n'); +} + +static unsigned char * +display_msp430x_attribute (unsigned char * p, + const unsigned char * const end) +{ + unsigned int len; + unsigned int val; + unsigned int tag; + + tag = read_uleb128 (p, & len, end); + p += len; + + switch (tag) + { + case OFBA_MSPABI_Tag_ISA: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ISA: "); + switch (val) + { + case 0: printf (_("None\n")); break; + case 1: printf (_("MSP430\n")); break; + case 2: printf (_("MSP430X\n")); break; + default: printf ("??? (%d)\n", val); break; + } + break; + + case OFBA_MSPABI_Tag_Code_Model: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_Code_Model: "); + switch (val) + { + case 0: printf (_("None\n")); break; + case 1: printf (_("Small\n")); break; + case 2: printf (_("Large\n")); break; + default: printf ("??? (%d)\n", val); break; + } + break; + + case OFBA_MSPABI_Tag_Data_Model: + val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_Data_Model: "); + switch (val) + { + case 0: printf (_("None\n")); break; + case 1: printf (_("Small\n")); break; + case 2: printf (_("Large\n")); break; + case 3: printf (_("Restricted Large\n")); break; + default: printf ("??? (%d)\n", val); break; + } + break; + + default: + printf (_(" : "), tag); + + if (tag & 1) + { + putchar ('"'); + if (p < end - 1) + { + size_t maxlen = (end - p) - 1; + + print_symbol ((int) maxlen, (const char *) p); + p += strnlen ((char *) p, maxlen) + 1; + } + else + { + printf (_("")); + p = (unsigned char *) end; + } + printf ("\"\n"); + } + else + { + val = read_uleb128 (p, &len, end); + p += len; + printf ("%d (0x%x)\n", val, val); + } + break; + } + + assert (p <= end); + return p; +} + +static bfd_boolean +process_attributes (Filedata * filedata, + const char * public_name, + unsigned int proc_type, + unsigned char * (* display_pub_attribute) (unsigned char *, const unsigned char * const), + unsigned char * (* display_proc_gnu_attribute) (unsigned char *, unsigned int, const unsigned char * const)) +{ + Elf_Internal_Shdr * sect; + unsigned i; + bfd_boolean res = TRUE; + + /* Find the section header so that we get the size. */ + for (i = 0, sect = filedata->section_headers; + i < filedata->file_header.e_shnum; + i++, sect++) + { + unsigned char * contents; + unsigned char * p; + + if (sect->sh_type != proc_type && sect->sh_type != SHT_GNU_ATTRIBUTES) + continue; + + contents = (unsigned char *) get_data (NULL, filedata, sect->sh_offset, 1, + sect->sh_size, _("attributes")); + if (contents == NULL) + { + res = FALSE; + continue; + } + + p = contents; + /* The first character is the version of the attributes. + Currently only version 1, (aka 'A') is recognised here. */ + if (*p != 'A') + { + printf (_("Unknown attributes version '%c'(%d) - expecting 'A'\n"), *p, *p); + res = FALSE; + } + else + { + bfd_vma section_len; + + section_len = sect->sh_size - 1; + p++; + + while (section_len > 0) + { + bfd_vma attr_len; + unsigned int namelen; + bfd_boolean public_section; + bfd_boolean gnu_section; + + if (section_len <= 4) + { + error (_("Tag section ends prematurely\n")); + res = FALSE; + break; + } + attr_len = byte_get (p, 4); + p += 4; + + if (attr_len > section_len) + { + error (_("Bad attribute length (%u > %u)\n"), + (unsigned) attr_len, (unsigned) section_len); + attr_len = section_len; + res = FALSE; + } + /* PR 17531: file: 001-101425-0.004 */ + else if (attr_len < 5) + { + error (_("Attribute length of %u is too small\n"), (unsigned) attr_len); + res = FALSE; + break; + } + + section_len -= attr_len; + attr_len -= 4; + + namelen = strnlen ((char *) p, attr_len) + 1; + if (namelen == 0 || namelen >= attr_len) + { + error (_("Corrupt attribute section name\n")); + res = FALSE; + break; + } + + printf (_("Attribute Section: ")); + print_symbol (INT_MAX, (const char *) p); + putchar ('\n'); + + if (public_name && streq ((char *) p, public_name)) + public_section = TRUE; + else + public_section = FALSE; + + if (streq ((char *) p, "gnu")) + gnu_section = TRUE; + else + gnu_section = FALSE; + + p += namelen; + attr_len -= namelen; + + while (attr_len > 0 && p < contents + sect->sh_size) + { + int tag; + int val; + bfd_vma size; + unsigned char * end; + + /* PR binutils/17531: Safe handling of corrupt files. */ + if (attr_len < 6) + { + error (_("Unused bytes at end of section\n")); + res = FALSE; + section_len = 0; + break; + } + + tag = *(p++); + size = byte_get (p, 4); + if (size > attr_len) + { + error (_("Bad subsection length (%u > %u)\n"), + (unsigned) size, (unsigned) attr_len); + res = FALSE; + size = attr_len; + } + /* PR binutils/17531: Safe handling of corrupt files. */ + if (size < 6) + { + error (_("Bad subsection length (%u < 6)\n"), + (unsigned) size); + res = FALSE; + section_len = 0; + break; + } + + attr_len -= size; + end = p + size - 1; + assert (end <= contents + sect->sh_size); + p += 4; + + switch (tag) + { + case 1: + printf (_("File Attributes\n")); + break; + case 2: + printf (_("Section Attributes:")); + goto do_numlist; + case 3: + printf (_("Symbol Attributes:")); + /* Fall through. */ + do_numlist: + for (;;) + { + unsigned int j; + + val = read_uleb128 (p, &j, end); + p += j; + if (val == 0) + break; + printf (" %d", val); + } + printf ("\n"); + break; + default: + printf (_("Unknown tag: %d\n"), tag); + public_section = FALSE; + break; + } + + if (public_section && display_pub_attribute != NULL) + { + while (p < end) + p = display_pub_attribute (p, end); + assert (p == end); + } + else if (gnu_section && display_proc_gnu_attribute != NULL) + { + while (p < end) + p = display_gnu_attribute (p, + display_proc_gnu_attribute, + end); + assert (p == end); + } + else if (p < end) + { + printf (_(" Unknown attribute:\n")); + display_raw_attribute (p, end); + p = end; + } + else + attr_len = 0; + } + } + } + + free (contents); + } + + return res; +} + +/* DATA points to the contents of a MIPS GOT that starts at VMA PLTGOT. + Print the Address, Access and Initial fields of an entry at VMA ADDR + and return the VMA of the next entry, or -1 if there was a problem. + Does not read from DATA_END or beyond. */ + +static bfd_vma +print_mips_got_entry (unsigned char * data, bfd_vma pltgot, bfd_vma addr, + unsigned char * data_end) +{ + printf (" "); + print_vma (addr, LONG_HEX); + printf (" "); + if (addr < pltgot + 0xfff0) + printf ("%6d(gp)", (int) (addr - pltgot - 0x7ff0)); + else + printf ("%10s", ""); + printf (" "); + if (data == NULL) + printf ("%*s", is_32bit_elf ? 8 : 16, _("")); + else + { + bfd_vma entry; + unsigned char * from = data + addr - pltgot; + + if (from + (is_32bit_elf ? 4 : 8) > data_end) + { + warn (_("MIPS GOT entry extends beyond the end of available data\n")); + printf ("%*s", is_32bit_elf ? 8 : 16, _("")); + return (bfd_vma) -1; + } + else + { + entry = byte_get (data + addr - pltgot, is_32bit_elf ? 4 : 8); + print_vma (entry, LONG_HEX); + } + } + return addr + (is_32bit_elf ? 4 : 8); +} + +/* DATA points to the contents of a MIPS PLT GOT that starts at VMA + PLTGOT. Print the Address and Initial fields of an entry at VMA + ADDR and return the VMA of the next entry. */ + +static bfd_vma +print_mips_pltgot_entry (unsigned char * data, bfd_vma pltgot, bfd_vma addr) +{ + printf (" "); + print_vma (addr, LONG_HEX); + printf (" "); + if (data == NULL) + printf ("%*s", is_32bit_elf ? 8 : 16, _("")); + else + { + bfd_vma entry; + + entry = byte_get (data + addr - pltgot, is_32bit_elf ? 4 : 8); + print_vma (entry, LONG_HEX); + } + return addr + (is_32bit_elf ? 4 : 8); +} + +static void +print_mips_ases (unsigned int mask) +{ + if (mask & AFL_ASE_DSP) + fputs ("\n\tDSP ASE", stdout); + if (mask & AFL_ASE_DSPR2) + fputs ("\n\tDSP R2 ASE", stdout); + if (mask & AFL_ASE_DSPR3) + fputs ("\n\tDSP R3 ASE", stdout); + if (mask & AFL_ASE_EVA) + fputs ("\n\tEnhanced VA Scheme", stdout); + if (mask & AFL_ASE_MCU) + fputs ("\n\tMCU (MicroController) ASE", stdout); + if (mask & AFL_ASE_MDMX) + fputs ("\n\tMDMX ASE", stdout); + if (mask & AFL_ASE_MIPS3D) + fputs ("\n\tMIPS-3D ASE", stdout); + if (mask & AFL_ASE_MT) + fputs ("\n\tMT ASE", stdout); + if (mask & AFL_ASE_SMARTMIPS) + fputs ("\n\tSmartMIPS ASE", stdout); + if (mask & AFL_ASE_VIRT) + fputs ("\n\tVZ ASE", stdout); + if (mask & AFL_ASE_MSA) + fputs ("\n\tMSA ASE", stdout); + if (mask & AFL_ASE_MIPS16) + fputs ("\n\tMIPS16 ASE", stdout); + if (mask & AFL_ASE_MICROMIPS) + fputs ("\n\tMICROMIPS ASE", stdout); + if (mask & AFL_ASE_XPA) + fputs ("\n\tXPA ASE", stdout); + if (mask & AFL_ASE_MIPS16E2) + fputs ("\n\tMIPS16e2 ASE", stdout); + if (mask == 0) + fprintf (stdout, "\n\t%s", _("None")); + else if ((mask & ~AFL_ASE_MASK) != 0) + fprintf (stdout, "\n\t%s (%x)", _("Unknown"), mask & ~AFL_ASE_MASK); +} + +static void +print_mips_isa_ext (unsigned int isa_ext) +{ + switch (isa_ext) + { + case 0: + fputs (_("None"), stdout); + break; + case AFL_EXT_XLR: + fputs ("RMI XLR", stdout); + break; + case AFL_EXT_OCTEON3: + fputs ("Cavium Networks Octeon3", stdout); + break; + case AFL_EXT_OCTEON2: + fputs ("Cavium Networks Octeon2", stdout); + break; + case AFL_EXT_OCTEONP: + fputs ("Cavium Networks OcteonP", stdout); + break; + case AFL_EXT_LOONGSON_3A: + fputs ("Loongson 3A", stdout); + break; + case AFL_EXT_OCTEON: + fputs ("Cavium Networks Octeon", stdout); + break; + case AFL_EXT_5900: + fputs ("Toshiba R5900", stdout); + break; + case AFL_EXT_4650: + fputs ("MIPS R4650", stdout); + break; + case AFL_EXT_4010: + fputs ("LSI R4010", stdout); + break; + case AFL_EXT_4100: + fputs ("NEC VR4100", stdout); + break; + case AFL_EXT_3900: + fputs ("Toshiba R3900", stdout); + break; + case AFL_EXT_10000: + fputs ("MIPS R10000", stdout); + break; + case AFL_EXT_SB1: + fputs ("Broadcom SB-1", stdout); + break; + case AFL_EXT_4111: + fputs ("NEC VR4111/VR4181", stdout); + break; + case AFL_EXT_4120: + fputs ("NEC VR4120", stdout); + break; + case AFL_EXT_5400: + fputs ("NEC VR5400", stdout); + break; + case AFL_EXT_5500: + fputs ("NEC VR5500", stdout); + break; + case AFL_EXT_LOONGSON_2E: + fputs ("ST Microelectronics Loongson 2E", stdout); + break; + case AFL_EXT_LOONGSON_2F: + fputs ("ST Microelectronics Loongson 2F", stdout); + break; + case AFL_EXT_INTERAPTIV_MR2: + fputs ("Imagination interAptiv MR2", stdout); + break; + default: + fprintf (stdout, "%s (%d)", _("Unknown"), isa_ext); + } +} + +static signed int +get_mips_reg_size (int reg_size) +{ + return (reg_size == AFL_REG_NONE) ? 0 + : (reg_size == AFL_REG_32) ? 32 + : (reg_size == AFL_REG_64) ? 64 + : (reg_size == AFL_REG_128) ? 128 + : -1; +} + +static bfd_boolean +process_mips_specific (Filedata * filedata) +{ + Elf_Internal_Dyn * entry; + Elf_Internal_Shdr *sect = NULL; + size_t liblist_offset = 0; + size_t liblistno = 0; + size_t conflictsno = 0; + size_t options_offset = 0; + size_t conflicts_offset = 0; + size_t pltrelsz = 0; + size_t pltrel = 0; + bfd_vma pltgot = 0; + bfd_vma mips_pltgot = 0; + bfd_vma jmprel = 0; + bfd_vma local_gotno = 0; + bfd_vma gotsym = 0; + bfd_vma symtabno = 0; + bfd_boolean res = TRUE; + + if (! process_attributes (filedata, NULL, SHT_GNU_ATTRIBUTES, NULL, + display_mips_gnu_attribute)) + res = FALSE; + + sect = find_section (filedata, ".MIPS.abiflags"); + + if (sect != NULL) + { + Elf_External_ABIFlags_v0 *abiflags_ext; + Elf_Internal_ABIFlags_v0 abiflags_in; + + if (sizeof (Elf_External_ABIFlags_v0) != sect->sh_size) + { + error (_("Corrupt MIPS ABI Flags section.\n")); + res = FALSE; + } + else + { + abiflags_ext = get_data (NULL, filedata, sect->sh_offset, 1, + sect->sh_size, _("MIPS ABI Flags section")); + if (abiflags_ext) + { + abiflags_in.version = BYTE_GET (abiflags_ext->version); + abiflags_in.isa_level = BYTE_GET (abiflags_ext->isa_level); + abiflags_in.isa_rev = BYTE_GET (abiflags_ext->isa_rev); + abiflags_in.gpr_size = BYTE_GET (abiflags_ext->gpr_size); + abiflags_in.cpr1_size = BYTE_GET (abiflags_ext->cpr1_size); + abiflags_in.cpr2_size = BYTE_GET (abiflags_ext->cpr2_size); + abiflags_in.fp_abi = BYTE_GET (abiflags_ext->fp_abi); + abiflags_in.isa_ext = BYTE_GET (abiflags_ext->isa_ext); + abiflags_in.ases = BYTE_GET (abiflags_ext->ases); + abiflags_in.flags1 = BYTE_GET (abiflags_ext->flags1); + abiflags_in.flags2 = BYTE_GET (abiflags_ext->flags2); + + printf ("\nMIPS ABI Flags Version: %d\n", abiflags_in.version); + printf ("\nISA: MIPS%d", abiflags_in.isa_level); + if (abiflags_in.isa_rev > 1) + printf ("r%d", abiflags_in.isa_rev); + printf ("\nGPR size: %d", + get_mips_reg_size (abiflags_in.gpr_size)); + printf ("\nCPR1 size: %d", + get_mips_reg_size (abiflags_in.cpr1_size)); + printf ("\nCPR2 size: %d", + get_mips_reg_size (abiflags_in.cpr2_size)); + fputs ("\nFP ABI: ", stdout); + print_mips_fp_abi_value (abiflags_in.fp_abi); + fputs ("ISA Extension: ", stdout); + print_mips_isa_ext (abiflags_in.isa_ext); + fputs ("\nASEs:", stdout); + print_mips_ases (abiflags_in.ases); + printf ("\nFLAGS 1: %8.8lx", abiflags_in.flags1); + printf ("\nFLAGS 2: %8.8lx", abiflags_in.flags2); + fputc ('\n', stdout); + free (abiflags_ext); + } + } + } + + /* We have a lot of special sections. Thanks SGI! */ + if (dynamic_section == NULL) + { + /* No dynamic information available. See if there is static GOT. */ + sect = find_section (filedata, ".got"); + if (sect != NULL) + { + unsigned char *data_end; + unsigned char *data; + bfd_vma ent, end; + int addr_size; + + pltgot = sect->sh_addr; + + ent = pltgot; + addr_size = (is_32bit_elf ? 4 : 8); + end = pltgot + sect->sh_size; + + data = (unsigned char *) get_data (NULL, filedata, sect->sh_offset, + end - pltgot, 1, + _("Global Offset Table data")); + /* PR 12855: Null data is handled gracefully throughout. */ + data_end = data + (end - pltgot); + + printf (_("\nStatic GOT:\n")); + printf (_(" Canonical gp value: ")); + print_vma (ent + 0x7ff0, LONG_HEX); + printf ("\n\n"); + + /* In a dynamic binary GOT[0] is reserved for the dynamic + loader to store the lazy resolver pointer, however in + a static binary it may well have been omitted and GOT + reduced to a table of addresses. + PR 21344: Check for the entry being fully available + before fetching it. */ + if (data + && data + ent - pltgot + addr_size <= data_end + && byte_get (data + ent - pltgot, addr_size) == 0) + { + printf (_(" Reserved entries:\n")); + printf (_(" %*s %10s %*s\n"), + addr_size * 2, _("Address"), _("Access"), + addr_size * 2, _("Value")); + ent = print_mips_got_entry (data, pltgot, ent, data_end); + printf ("\n"); + if (ent == (bfd_vma) -1) + goto sgot_print_fail; + + /* Check for the MSB of GOT[1] being set, identifying a + GNU object. This entry will be used by some runtime + loaders, to store the module pointer. Otherwise this + is an ordinary local entry. + PR 21344: Check for the entry being fully available + before fetching it. */ + if (data + && data + ent - pltgot + addr_size <= data_end + && (byte_get (data + ent - pltgot, addr_size) + >> (addr_size * 8 - 1)) != 0) + { + ent = print_mips_got_entry (data, pltgot, ent, data_end); + printf ("\n"); + if (ent == (bfd_vma) -1) + goto sgot_print_fail; + } + printf ("\n"); + } + + if (data != NULL && ent < end) + { + printf (_(" Local entries:\n")); + printf (" %*s %10s %*s\n", + addr_size * 2, _("Address"), _("Access"), + addr_size * 2, _("Value")); + while (ent < end) + { + ent = print_mips_got_entry (data, pltgot, ent, data_end); + printf ("\n"); + if (ent == (bfd_vma) -1) + goto sgot_print_fail; + } + printf ("\n"); + } + + sgot_print_fail: + if (data) + free (data); + } + return res; + } + + for (entry = dynamic_section; + /* PR 17531 file: 012-50589-0.004. */ + entry < dynamic_section + dynamic_nent && entry->d_tag != DT_NULL; + ++entry) + switch (entry->d_tag) + { + case DT_MIPS_LIBLIST: + liblist_offset + = offset_from_vma (filedata, entry->d_un.d_val, + liblistno * sizeof (Elf32_External_Lib)); + break; + case DT_MIPS_LIBLISTNO: + liblistno = entry->d_un.d_val; + break; + case DT_MIPS_OPTIONS: + options_offset = offset_from_vma (filedata, entry->d_un.d_val, 0); + break; + case DT_MIPS_CONFLICT: + conflicts_offset + = offset_from_vma (filedata, entry->d_un.d_val, + conflictsno * sizeof (Elf32_External_Conflict)); + break; + case DT_MIPS_CONFLICTNO: + conflictsno = entry->d_un.d_val; + break; + case DT_PLTGOT: + pltgot = entry->d_un.d_ptr; + break; + case DT_MIPS_LOCAL_GOTNO: + local_gotno = entry->d_un.d_val; + break; + case DT_MIPS_GOTSYM: + gotsym = entry->d_un.d_val; + break; + case DT_MIPS_SYMTABNO: + symtabno = entry->d_un.d_val; + break; + case DT_MIPS_PLTGOT: + mips_pltgot = entry->d_un.d_ptr; + break; + case DT_PLTREL: + pltrel = entry->d_un.d_val; + break; + case DT_PLTRELSZ: + pltrelsz = entry->d_un.d_val; + break; + case DT_JMPREL: + jmprel = entry->d_un.d_ptr; + break; + default: + break; + } + + if (liblist_offset != 0 && liblistno != 0 && do_dynamic) + { + Elf32_External_Lib * elib; + size_t cnt; + + elib = (Elf32_External_Lib *) get_data (NULL, filedata, liblist_offset, + liblistno, + sizeof (Elf32_External_Lib), + _("liblist section data")); + if (elib) + { + printf (ngettext ("\nSection '.liblist' contains %lu entry:\n", + "\nSection '.liblist' contains %lu entries:\n", + (unsigned long) liblistno), + (unsigned long) liblistno); + fputs (_(" Library Time Stamp Checksum Version Flags\n"), + stdout); + + for (cnt = 0; cnt < liblistno; ++cnt) + { + Elf32_Lib liblist; + time_t atime; + char timebuf[128]; + struct tm * tmp; + + liblist.l_name = BYTE_GET (elib[cnt].l_name); + atime = BYTE_GET (elib[cnt].l_time_stamp); + liblist.l_checksum = BYTE_GET (elib[cnt].l_checksum); + liblist.l_version = BYTE_GET (elib[cnt].l_version); + liblist.l_flags = BYTE_GET (elib[cnt].l_flags); + + tmp = gmtime (&atime); + snprintf (timebuf, sizeof (timebuf), + "%04u-%02u-%02uT%02u:%02u:%02u", + tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, + tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + + printf ("%3lu: ", (unsigned long) cnt); + if (VALID_DYNAMIC_NAME (liblist.l_name)) + print_symbol (20, GET_DYNAMIC_NAME (liblist.l_name)); + else + printf (_(""), liblist.l_name); + printf (" %s %#10lx %-7ld", timebuf, liblist.l_checksum, + liblist.l_version); + + if (liblist.l_flags == 0) + puts (_(" NONE")); + else + { + static const struct + { + const char * name; + int bit; + } + l_flags_vals[] = + { + { " EXACT_MATCH", LL_EXACT_MATCH }, + { " IGNORE_INT_VER", LL_IGNORE_INT_VER }, + { " REQUIRE_MINOR", LL_REQUIRE_MINOR }, + { " EXPORTS", LL_EXPORTS }, + { " DELAY_LOAD", LL_DELAY_LOAD }, + { " DELTA", LL_DELTA } + }; + int flags = liblist.l_flags; + size_t fcnt; + + for (fcnt = 0; fcnt < ARRAY_SIZE (l_flags_vals); ++fcnt) + if ((flags & l_flags_vals[fcnt].bit) != 0) + { + fputs (l_flags_vals[fcnt].name, stdout); + flags ^= l_flags_vals[fcnt].bit; + } + if (flags != 0) + printf (" %#x", (unsigned int) flags); + + puts (""); + } + } + + free (elib); + } + else + res = FALSE; + } + + if (options_offset != 0) + { + Elf_External_Options * eopt; + Elf_Internal_Options * iopt; + Elf_Internal_Options * option; + size_t offset; + int cnt; + sect = filedata->section_headers; + + /* Find the section header so that we get the size. */ + sect = find_section_by_type (filedata, SHT_MIPS_OPTIONS); + /* PR 17533 file: 012-277276-0.004. */ + if (sect == NULL) + { + error (_("No MIPS_OPTIONS header found\n")); + return FALSE; + } + + eopt = (Elf_External_Options *) get_data (NULL, filedata, options_offset, 1, + sect->sh_size, _("options")); + if (eopt) + { + iopt = (Elf_Internal_Options *) + cmalloc ((sect->sh_size / sizeof (eopt)), sizeof (* iopt)); + if (iopt == NULL) + { + error (_("Out of memory allocating space for MIPS options\n")); + return FALSE; + } + + offset = cnt = 0; + option = iopt; + + while (offset <= sect->sh_size - sizeof (* eopt)) + { + Elf_External_Options * eoption; + + eoption = (Elf_External_Options *) ((char *) eopt + offset); + + option->kind = BYTE_GET (eoption->kind); + option->size = BYTE_GET (eoption->size); + option->section = BYTE_GET (eoption->section); + option->info = BYTE_GET (eoption->info); + + /* PR 17531: file: ffa0fa3b. */ + if (option->size < sizeof (* eopt) + || offset + option->size > sect->sh_size) + { + error (_("Invalid size (%u) for MIPS option\n"), option->size); + return FALSE; + } + offset += option->size; + + ++option; + ++cnt; + } + + printf (ngettext ("\nSection '%s' contains %d entry:\n", + "\nSection '%s' contains %d entries:\n", + cnt), + printable_section_name (filedata, sect), cnt); + + option = iopt; + offset = 0; + + while (cnt-- > 0) + { + size_t len; + + switch (option->kind) + { + case ODK_NULL: + /* This shouldn't happen. */ + printf (" NULL %d %lx", option->section, option->info); + break; + case ODK_REGINFO: + printf (" REGINFO "); + if (filedata->file_header.e_machine == EM_MIPS) + { + /* 32bit form. */ + Elf32_External_RegInfo * ereg; + Elf32_RegInfo reginfo; + + ereg = (Elf32_External_RegInfo *) (option + 1); + reginfo.ri_gprmask = BYTE_GET (ereg->ri_gprmask); + reginfo.ri_cprmask[0] = BYTE_GET (ereg->ri_cprmask[0]); + reginfo.ri_cprmask[1] = BYTE_GET (ereg->ri_cprmask[1]); + reginfo.ri_cprmask[2] = BYTE_GET (ereg->ri_cprmask[2]); + reginfo.ri_cprmask[3] = BYTE_GET (ereg->ri_cprmask[3]); + reginfo.ri_gp_value = BYTE_GET (ereg->ri_gp_value); + + printf ("GPR %08lx GP 0x%lx\n", + reginfo.ri_gprmask, + (unsigned long) reginfo.ri_gp_value); + printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n", + reginfo.ri_cprmask[0], reginfo.ri_cprmask[1], + reginfo.ri_cprmask[2], reginfo.ri_cprmask[3]); + } + else + { + /* 64 bit form. */ + Elf64_External_RegInfo * ereg; + Elf64_Internal_RegInfo reginfo; + + ereg = (Elf64_External_RegInfo *) (option + 1); + reginfo.ri_gprmask = BYTE_GET (ereg->ri_gprmask); + reginfo.ri_cprmask[0] = BYTE_GET (ereg->ri_cprmask[0]); + reginfo.ri_cprmask[1] = BYTE_GET (ereg->ri_cprmask[1]); + reginfo.ri_cprmask[2] = BYTE_GET (ereg->ri_cprmask[2]); + reginfo.ri_cprmask[3] = BYTE_GET (ereg->ri_cprmask[3]); + reginfo.ri_gp_value = BYTE_GET (ereg->ri_gp_value); + + printf ("GPR %08lx GP 0x", + reginfo.ri_gprmask); + printf_vma (reginfo.ri_gp_value); + printf ("\n"); + + printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n", + reginfo.ri_cprmask[0], reginfo.ri_cprmask[1], + reginfo.ri_cprmask[2], reginfo.ri_cprmask[3]); + } + ++option; + continue; + case ODK_EXCEPTIONS: + fputs (" EXCEPTIONS fpe_min(", stdout); + process_mips_fpe_exception (option->info & OEX_FPU_MIN); + fputs (") fpe_max(", stdout); + process_mips_fpe_exception ((option->info & OEX_FPU_MAX) >> 8); + fputs (")", stdout); + + if (option->info & OEX_PAGE0) + fputs (" PAGE0", stdout); + if (option->info & OEX_SMM) + fputs (" SMM", stdout); + if (option->info & OEX_FPDBUG) + fputs (" FPDBUG", stdout); + if (option->info & OEX_DISMISS) + fputs (" DISMISS", stdout); + break; + case ODK_PAD: + fputs (" PAD ", stdout); + if (option->info & OPAD_PREFIX) + fputs (" PREFIX", stdout); + if (option->info & OPAD_POSTFIX) + fputs (" POSTFIX", stdout); + if (option->info & OPAD_SYMBOL) + fputs (" SYMBOL", stdout); + break; + case ODK_HWPATCH: + fputs (" HWPATCH ", stdout); + if (option->info & OHW_R4KEOP) + fputs (" R4KEOP", stdout); + if (option->info & OHW_R8KPFETCH) + fputs (" R8KPFETCH", stdout); + if (option->info & OHW_R5KEOP) + fputs (" R5KEOP", stdout); + if (option->info & OHW_R5KCVTL) + fputs (" R5KCVTL", stdout); + break; + case ODK_FILL: + fputs (" FILL ", stdout); + /* XXX Print content of info word? */ + break; + case ODK_TAGS: + fputs (" TAGS ", stdout); + /* XXX Print content of info word? */ + break; + case ODK_HWAND: + fputs (" HWAND ", stdout); + if (option->info & OHWA0_R4KEOP_CHECKED) + fputs (" R4KEOP_CHECKED", stdout); + if (option->info & OHWA0_R4KEOP_CLEAN) + fputs (" R4KEOP_CLEAN", stdout); + break; + case ODK_HWOR: + fputs (" HWOR ", stdout); + if (option->info & OHWA0_R4KEOP_CHECKED) + fputs (" R4KEOP_CHECKED", stdout); + if (option->info & OHWA0_R4KEOP_CLEAN) + fputs (" R4KEOP_CLEAN", stdout); + break; + case ODK_GP_GROUP: + printf (" GP_GROUP %#06lx self-contained %#06lx", + option->info & OGP_GROUP, + (option->info & OGP_SELF) >> 16); + break; + case ODK_IDENT: + printf (" IDENT %#06lx self-contained %#06lx", + option->info & OGP_GROUP, + (option->info & OGP_SELF) >> 16); + break; + default: + /* This shouldn't happen. */ + printf (" %3d ??? %d %lx", + option->kind, option->section, option->info); + break; + } + + len = sizeof (* eopt); + while (len < option->size) + { + unsigned char datum = * ((unsigned char *) eopt + offset + len); + + if (ISPRINT (datum)) + printf ("%c", datum); + else + printf ("\\%03o", datum); + len ++; + } + fputs ("\n", stdout); + + offset += option->size; + ++option; + } + + free (eopt); + } + else + res = FALSE; + } + + if (conflicts_offset != 0 && conflictsno != 0) + { + Elf32_Conflict * iconf; + size_t cnt; + + if (dynamic_symbols == NULL) + { + error (_("conflict list found without a dynamic symbol table\n")); + return FALSE; + } + + /* PR 21345 - print a slightly more helpful error message + if we are sure that the cmalloc will fail. */ + if (conflictsno * sizeof (* iconf) > filedata->file_size) + { + error (_("Overlarge number of conflicts detected: %lx\n"), + (long) conflictsno); + return FALSE; + } + + iconf = (Elf32_Conflict *) cmalloc (conflictsno, sizeof (* iconf)); + if (iconf == NULL) + { + error (_("Out of memory allocating space for dynamic conflicts\n")); + return FALSE; + } + + if (is_32bit_elf) + { + Elf32_External_Conflict * econf32; + + econf32 = (Elf32_External_Conflict *) + get_data (NULL, filedata, conflicts_offset, conflictsno, + sizeof (* econf32), _("conflict")); + if (!econf32) + return FALSE; + + for (cnt = 0; cnt < conflictsno; ++cnt) + iconf[cnt] = BYTE_GET (econf32[cnt]); + + free (econf32); + } + else + { + Elf64_External_Conflict * econf64; + + econf64 = (Elf64_External_Conflict *) + get_data (NULL, filedata, conflicts_offset, conflictsno, + sizeof (* econf64), _("conflict")); + if (!econf64) + return FALSE; + + for (cnt = 0; cnt < conflictsno; ++cnt) + iconf[cnt] = BYTE_GET (econf64[cnt]); + + free (econf64); + } + + printf (ngettext ("\nSection '.conflict' contains %lu entry:\n", + "\nSection '.conflict' contains %lu entries:\n", + (unsigned long) conflictsno), + (unsigned long) conflictsno); + puts (_(" Num: Index Value Name")); + + for (cnt = 0; cnt < conflictsno; ++cnt) + { + printf ("%5lu: %8lu ", (unsigned long) cnt, iconf[cnt]); + + if (iconf[cnt] >= num_dynamic_syms) + printf (_("")); + else + { + Elf_Internal_Sym * psym; + + psym = & dynamic_symbols[iconf[cnt]]; + print_vma (psym->st_value, FULL_HEX); + putchar (' '); + if (VALID_DYNAMIC_NAME (psym->st_name)) + print_symbol (25, GET_DYNAMIC_NAME (psym->st_name)); + else + printf (_(""), psym->st_name); + } + putchar ('\n'); + } + + free (iconf); + } + + if (pltgot != 0 && local_gotno != 0) + { + bfd_vma ent, local_end, global_end; + size_t i, offset; + unsigned char * data; + unsigned char * data_end; + int addr_size; + + ent = pltgot; + addr_size = (is_32bit_elf ? 4 : 8); + local_end = pltgot + local_gotno * addr_size; + + /* PR binutils/17533 file: 012-111227-0.004 */ + if (symtabno < gotsym) + { + error (_("The GOT symbol offset (%lu) is greater than the symbol table size (%lu)\n"), + (unsigned long) gotsym, (unsigned long) symtabno); + return FALSE; + } + + global_end = local_end + (symtabno - gotsym) * addr_size; + /* PR 17531: file: 54c91a34. */ + if (global_end < local_end) + { + error (_("Too many GOT symbols: %lu\n"), (unsigned long) symtabno); + return FALSE; + } + + offset = offset_from_vma (filedata, pltgot, global_end - pltgot); + data = (unsigned char *) get_data (NULL, filedata, offset, + global_end - pltgot, 1, + _("Global Offset Table data")); + /* PR 12855: Null data is handled gracefully throughout. */ + data_end = data + (global_end - pltgot); + + printf (_("\nPrimary GOT:\n")); + printf (_(" Canonical gp value: ")); + print_vma (pltgot + 0x7ff0, LONG_HEX); + printf ("\n\n"); + + printf (_(" Reserved entries:\n")); + printf (_(" %*s %10s %*s Purpose\n"), + addr_size * 2, _("Address"), _("Access"), + addr_size * 2, _("Initial")); + ent = print_mips_got_entry (data, pltgot, ent, data_end); + printf (_(" Lazy resolver\n")); + if (ent == (bfd_vma) -1) + goto got_print_fail; + + /* Check for the MSB of GOT[1] being set, denoting a GNU object. + This entry will be used by some runtime loaders, to store the + module pointer. Otherwise this is an ordinary local entry. + PR 21344: Check for the entry being fully available before + fetching it. */ + if (data + && data + ent - pltgot + addr_size <= data_end + && (byte_get (data + ent - pltgot, addr_size) + >> (addr_size * 8 - 1)) != 0) + { + ent = print_mips_got_entry (data, pltgot, ent, data_end); + printf (_(" Module pointer (GNU extension)\n")); + if (ent == (bfd_vma) -1) + goto got_print_fail; + } + printf ("\n"); + + if (data != NULL && ent < local_end) + { + printf (_(" Local entries:\n")); + printf (" %*s %10s %*s\n", + addr_size * 2, _("Address"), _("Access"), + addr_size * 2, _("Initial")); + while (ent < local_end) + { + ent = print_mips_got_entry (data, pltgot, ent, data_end); + printf ("\n"); + if (ent == (bfd_vma) -1) + goto got_print_fail; + } + printf ("\n"); + } + + if (data != NULL && gotsym < symtabno) + { + int sym_width; + + printf (_(" Global entries:\n")); + printf (" %*s %10s %*s %*s %-7s %3s %s\n", + addr_size * 2, _("Address"), + _("Access"), + addr_size * 2, _("Initial"), + addr_size * 2, _("Sym.Val."), + _("Type"), + /* Note for translators: "Ndx" = abbreviated form of "Index". */ + _("Ndx"), _("Name")); + + sym_width = (is_32bit_elf ? 80 : 160) - 28 - addr_size * 6 - 1; + + for (i = gotsym; i < symtabno; i++) + { + ent = print_mips_got_entry (data, pltgot, ent, data_end); + printf (" "); + + if (dynamic_symbols == NULL) + printf (_("")); + else if (i < num_dynamic_syms) + { + Elf_Internal_Sym * psym = dynamic_symbols + i; + + print_vma (psym->st_value, LONG_HEX); + printf (" %-7s %3s ", + get_symbol_type (filedata, ELF_ST_TYPE (psym->st_info)), + get_symbol_index_type (filedata, psym->st_shndx)); + + if (VALID_DYNAMIC_NAME (psym->st_name)) + print_symbol (sym_width, GET_DYNAMIC_NAME (psym->st_name)); + else + printf (_(""), psym->st_name); + } + else + printf (_(""), + (unsigned long) i); + + printf ("\n"); + if (ent == (bfd_vma) -1) + break; + } + printf ("\n"); + } + + got_print_fail: + if (data) + free (data); + } + + if (mips_pltgot != 0 && jmprel != 0 && pltrel != 0 && pltrelsz != 0) + { + bfd_vma ent, end; + size_t offset, rel_offset; + unsigned long count, i; + unsigned char * data; + int addr_size, sym_width; + Elf_Internal_Rela * rels; + + rel_offset = offset_from_vma (filedata, jmprel, pltrelsz); + if (pltrel == DT_RELA) + { + if (!slurp_rela_relocs (filedata, rel_offset, pltrelsz, &rels, &count)) + return FALSE; + } + else + { + if (!slurp_rel_relocs (filedata, rel_offset, pltrelsz, &rels, &count)) + return FALSE; + } + + ent = mips_pltgot; + addr_size = (is_32bit_elf ? 4 : 8); + end = mips_pltgot + (2 + count) * addr_size; + + offset = offset_from_vma (filedata, mips_pltgot, end - mips_pltgot); + data = (unsigned char *) get_data (NULL, filedata, offset, end - mips_pltgot, + 1, _("Procedure Linkage Table data")); + if (data == NULL) + return FALSE; + + printf ("\nPLT GOT:\n\n"); + printf (_(" Reserved entries:\n")); + printf (_(" %*s %*s Purpose\n"), + addr_size * 2, _("Address"), addr_size * 2, _("Initial")); + ent = print_mips_pltgot_entry (data, mips_pltgot, ent); + printf (_(" PLT lazy resolver\n")); + ent = print_mips_pltgot_entry (data, mips_pltgot, ent); + printf (_(" Module pointer\n")); + printf ("\n"); + + printf (_(" Entries:\n")); + printf (" %*s %*s %*s %-7s %3s %s\n", + addr_size * 2, _("Address"), + addr_size * 2, _("Initial"), + addr_size * 2, _("Sym.Val."), _("Type"), _("Ndx"), _("Name")); + sym_width = (is_32bit_elf ? 80 : 160) - 17 - addr_size * 6 - 1; + for (i = 0; i < count; i++) + { + unsigned long idx = get_reloc_symindex (rels[i].r_info); + + ent = print_mips_pltgot_entry (data, mips_pltgot, ent); + printf (" "); + + if (idx >= num_dynamic_syms) + printf (_(""), idx); + else + { + Elf_Internal_Sym * psym = dynamic_symbols + idx; + + print_vma (psym->st_value, LONG_HEX); + printf (" %-7s %3s ", + get_symbol_type (filedata, ELF_ST_TYPE (psym->st_info)), + get_symbol_index_type (filedata, psym->st_shndx)); + if (VALID_DYNAMIC_NAME (psym->st_name)) + print_symbol (sym_width, GET_DYNAMIC_NAME (psym->st_name)); + else + printf (_(""), psym->st_name); + } + printf ("\n"); + } + printf ("\n"); + + if (data) + free (data); + free (rels); + } + + return res; +} + +static bfd_boolean +process_nds32_specific (Filedata * filedata) +{ + Elf_Internal_Shdr *sect = NULL; + + sect = find_section (filedata, ".nds32_e_flags"); + if (sect != NULL) + { + unsigned int *flag; + + printf ("\nNDS32 elf flags section:\n"); + flag = get_data (NULL, filedata, sect->sh_offset, 1, + sect->sh_size, _("NDS32 elf flags section")); + + if (! flag) + return FALSE; + + switch ((*flag) & 0x3) + { + case 0: + printf ("(VEC_SIZE):\tNo entry.\n"); + break; + case 1: + printf ("(VEC_SIZE):\t4 bytes\n"); + break; + case 2: + printf ("(VEC_SIZE):\t16 bytes\n"); + break; + case 3: + printf ("(VEC_SIZE):\treserved\n"); + break; + } + } + + return TRUE; +} + +static bfd_boolean +process_gnu_liblist (Filedata * filedata) +{ + Elf_Internal_Shdr * section; + Elf_Internal_Shdr * string_sec; + Elf32_External_Lib * elib; + char * strtab; + size_t strtab_size; + size_t cnt; + unsigned long num_liblist; + unsigned i; + bfd_boolean res = TRUE; + + if (! do_arch) + return TRUE; + + for (i = 0, section = filedata->section_headers; + i < filedata->file_header.e_shnum; + i++, section++) + { + switch (section->sh_type) + { + case SHT_GNU_LIBLIST: + if (section->sh_link >= filedata->file_header.e_shnum) + break; + + elib = (Elf32_External_Lib *) + get_data (NULL, filedata, section->sh_offset, 1, section->sh_size, + _("liblist section data")); + + if (elib == NULL) + { + res = FALSE; + break; + } + + string_sec = filedata->section_headers + section->sh_link; + strtab = (char *) get_data (NULL, filedata, string_sec->sh_offset, 1, + string_sec->sh_size, + _("liblist string table")); + if (strtab == NULL + || section->sh_entsize != sizeof (Elf32_External_Lib)) + { + free (elib); + free (strtab); + res = FALSE; + break; + } + strtab_size = string_sec->sh_size; + + num_liblist = section->sh_size / sizeof (Elf32_External_Lib); + printf (ngettext ("\nLibrary list section '%s' contains %lu entries:\n", + "\nLibrary list section '%s' contains %lu entries:\n", + num_liblist), + printable_section_name (filedata, section), + num_liblist); + + puts (_(" Library Time Stamp Checksum Version Flags")); + + for (cnt = 0; cnt < section->sh_size / sizeof (Elf32_External_Lib); + ++cnt) + { + Elf32_Lib liblist; + time_t atime; + char timebuf[128]; + struct tm * tmp; + + liblist.l_name = BYTE_GET (elib[cnt].l_name); + atime = BYTE_GET (elib[cnt].l_time_stamp); + liblist.l_checksum = BYTE_GET (elib[cnt].l_checksum); + liblist.l_version = BYTE_GET (elib[cnt].l_version); + liblist.l_flags = BYTE_GET (elib[cnt].l_flags); + + tmp = gmtime (&atime); + snprintf (timebuf, sizeof (timebuf), + "%04u-%02u-%02uT%02u:%02u:%02u", + tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, + tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + + printf ("%3lu: ", (unsigned long) cnt); + if (do_wide) + printf ("%-20s", liblist.l_name < strtab_size + ? strtab + liblist.l_name : _("")); + else + printf ("%-20.20s", liblist.l_name < strtab_size + ? strtab + liblist.l_name : _("")); + printf (" %s %#010lx %-7ld %-7ld\n", timebuf, liblist.l_checksum, + liblist.l_version, liblist.l_flags); + } + + free (elib); + free (strtab); + } + } + + return res; +} + +static const char * +get_note_type (Filedata * filedata, unsigned e_type) +{ + static char buff[64]; + + if (filedata->file_header.e_type == ET_CORE) + switch (e_type) + { + case NT_AUXV: + return _("NT_AUXV (auxiliary vector)"); + case NT_PRSTATUS: + return _("NT_PRSTATUS (prstatus structure)"); + case NT_FPREGSET: + return _("NT_FPREGSET (floating point registers)"); + case NT_PRPSINFO: + return _("NT_PRPSINFO (prpsinfo structure)"); + case NT_TASKSTRUCT: + return _("NT_TASKSTRUCT (task structure)"); + case NT_PRXFPREG: + return _("NT_PRXFPREG (user_xfpregs structure)"); + case NT_PPC_VMX: + return _("NT_PPC_VMX (ppc Altivec registers)"); + case NT_PPC_VSX: + return _("NT_PPC_VSX (ppc VSX registers)"); + case NT_PPC_TAR: + return _("NT_PPC_TAR (ppc TAR register)"); + case NT_PPC_PPR: + return _("NT_PPC_PPR (ppc PPR register)"); + case NT_PPC_DSCR: + return _("NT_PPC_DSCR (ppc DSCR register)"); + case NT_PPC_EBB: + return _("NT_PPC_EBB (ppc EBB registers)"); + case NT_PPC_PMU: + return _("NT_PPC_PMU (ppc PMU registers)"); + case NT_PPC_TM_CGPR: + return _("NT_PPC_TM_CGPR (ppc checkpointed GPR registers)"); + case NT_PPC_TM_CFPR: + return _("NT_PPC_TM_CFPR (ppc checkpointed floating point registers)"); + case NT_PPC_TM_CVMX: + return _("NT_PPC_TM_CVMX (ppc checkpointed Altivec registers)"); + case NT_PPC_TM_CVSX: + return _("NT_PPC_TM_VSX (ppc checkpointed VSX registers)"); + case NT_PPC_TM_SPR: + return _("NT_PPC_TM_SPR (ppc TM special purpose registers)"); + case NT_PPC_TM_CTAR: + return _("NT_PPC_TM_CTAR (ppc checkpointed TAR register)"); + case NT_PPC_TM_CPPR: + return _("NT_PPC_TM_CPPR (ppc checkpointed PPR register)"); + case NT_PPC_TM_CDSCR: + return _("NT_PPC_TM_CDSCR (ppc checkpointed DSCR register)"); + case NT_386_TLS: + return _("NT_386_TLS (x86 TLS information)"); + case NT_386_IOPERM: + return _("NT_386_IOPERM (x86 I/O permissions)"); + case NT_X86_XSTATE: + return _("NT_X86_XSTATE (x86 XSAVE extended state)"); + case NT_S390_HIGH_GPRS: + return _("NT_S390_HIGH_GPRS (s390 upper register halves)"); + case NT_S390_TIMER: + return _("NT_S390_TIMER (s390 timer register)"); + case NT_S390_TODCMP: + return _("NT_S390_TODCMP (s390 TOD comparator register)"); + case NT_S390_TODPREG: + return _("NT_S390_TODPREG (s390 TOD programmable register)"); + case NT_S390_CTRS: + return _("NT_S390_CTRS (s390 control registers)"); + case NT_S390_PREFIX: + return _("NT_S390_PREFIX (s390 prefix register)"); + case NT_S390_LAST_BREAK: + return _("NT_S390_LAST_BREAK (s390 last breaking event address)"); + case NT_S390_SYSTEM_CALL: + return _("NT_S390_SYSTEM_CALL (s390 system call restart data)"); + case NT_S390_TDB: + return _("NT_S390_TDB (s390 transaction diagnostic block)"); + case NT_S390_VXRS_LOW: + return _("NT_S390_VXRS_LOW (s390 vector registers 0-15 upper half)"); + case NT_S390_VXRS_HIGH: + return _("NT_S390_VXRS_HIGH (s390 vector registers 16-31)"); + case NT_S390_GS_CB: + return _("NT_S390_GS_CB (s390 guarded-storage registers)"); + case NT_S390_GS_BC: + return _("NT_S390_GS_BC (s390 guarded-storage broadcast control)"); + case NT_ARM_VFP: + return _("NT_ARM_VFP (arm VFP registers)"); + case NT_ARM_TLS: + return _("NT_ARM_TLS (AArch TLS registers)"); + case NT_ARM_HW_BREAK: + return _("NT_ARM_HW_BREAK (AArch hardware breakpoint registers)"); + case NT_ARM_HW_WATCH: + return _("NT_ARM_HW_WATCH (AArch hardware watchpoint registers)"); + case NT_PSTATUS: + return _("NT_PSTATUS (pstatus structure)"); + case NT_FPREGS: + return _("NT_FPREGS (floating point registers)"); + case NT_PSINFO: + return _("NT_PSINFO (psinfo structure)"); + case NT_LWPSTATUS: + return _("NT_LWPSTATUS (lwpstatus_t structure)"); + case NT_LWPSINFO: + return _("NT_LWPSINFO (lwpsinfo_t structure)"); + case NT_WIN32PSTATUS: + return _("NT_WIN32PSTATUS (win32_pstatus structure)"); + case NT_SIGINFO: + return _("NT_SIGINFO (siginfo_t data)"); + case NT_FILE: + return _("NT_FILE (mapped files)"); + default: + break; + } + else + switch (e_type) + { + case NT_VERSION: + return _("NT_VERSION (version)"); + case NT_ARCH: + return _("NT_ARCH (architecture)"); + case NT_GNU_BUILD_ATTRIBUTE_OPEN: + return _("OPEN"); + case NT_GNU_BUILD_ATTRIBUTE_FUNC: + return _("func"); + default: + break; + } + + snprintf (buff, sizeof (buff), _("Unknown note type: (0x%08x)"), e_type); + return buff; +} + +static bfd_boolean +print_core_note (Elf_Internal_Note *pnote) +{ + unsigned int addr_size = is_32bit_elf ? 4 : 8; + bfd_vma count, page_size; + unsigned char *descdata, *filenames, *descend; + + if (pnote->type != NT_FILE) + { + if (do_wide) + printf ("\n"); + return TRUE; + } + +#ifndef BFD64 + if (!is_32bit_elf) + { + printf (_(" Cannot decode 64-bit note in 32-bit build\n")); + /* Still "successful". */ + return TRUE; + } +#endif + + if (pnote->descsz < 2 * addr_size) + { + error (_(" Malformed note - too short for header\n")); + return FALSE; + } + + descdata = (unsigned char *) pnote->descdata; + descend = descdata + pnote->descsz; + + if (descdata[pnote->descsz - 1] != '\0') + { + error (_(" Malformed note - does not end with \\0\n")); + return FALSE; + } + + count = byte_get (descdata, addr_size); + descdata += addr_size; + + page_size = byte_get (descdata, addr_size); + descdata += addr_size; + + if (count > ((bfd_vma) -1 - 2 * addr_size) / (3 * addr_size) + || pnote->descsz < 2 * addr_size + count * 3 * addr_size) + { + error (_(" Malformed note - too short for supplied file count\n")); + return FALSE; + } + + printf (_(" Page size: ")); + print_vma (page_size, DEC); + printf ("\n"); + + printf (_(" %*s%*s%*s\n"), + (int) (2 + 2 * addr_size), _("Start"), + (int) (4 + 2 * addr_size), _("End"), + (int) (4 + 2 * addr_size), _("Page Offset")); + filenames = descdata + count * 3 * addr_size; + while (count-- > 0) + { + bfd_vma start, end, file_ofs; + + if (filenames == descend) + { + error (_(" Malformed note - filenames end too early\n")); + return FALSE; + } + + start = byte_get (descdata, addr_size); + descdata += addr_size; + end = byte_get (descdata, addr_size); + descdata += addr_size; + file_ofs = byte_get (descdata, addr_size); + descdata += addr_size; + + printf (" "); + print_vma (start, FULL_HEX); + printf (" "); + print_vma (end, FULL_HEX); + printf (" "); + print_vma (file_ofs, FULL_HEX); + printf ("\n %s\n", filenames); + + filenames += 1 + strlen ((char *) filenames); + } + + return TRUE; +} + +static const char * +get_gnu_elf_note_type (unsigned e_type) +{ + /* NB/ Keep this switch statement in sync with print_gnu_note (). */ + switch (e_type) + { + case NT_GNU_ABI_TAG: + return _("NT_GNU_ABI_TAG (ABI version tag)"); + case NT_GNU_HWCAP: + return _("NT_GNU_HWCAP (DSO-supplied software HWCAP info)"); + case NT_GNU_BUILD_ID: + return _("NT_GNU_BUILD_ID (unique build ID bitstring)"); + case NT_GNU_GOLD_VERSION: + return _("NT_GNU_GOLD_VERSION (gold version)"); + case NT_GNU_PROPERTY_TYPE_0: + return _("NT_GNU_PROPERTY_TYPE_0"); + case NT_GNU_BUILD_ATTRIBUTE_OPEN: + return _("NT_GNU_BUILD_ATTRIBUTE_OPEN"); + case NT_GNU_BUILD_ATTRIBUTE_FUNC: + return _("NT_GNU_BUILD_ATTRIBUTE_FUNC"); + default: + { + static char buff[64]; + + snprintf (buff, sizeof (buff), _("Unknown note type: (0x%08x)"), e_type); + return buff; + } + } +} + +static void +decode_x86_isa (unsigned int bitmask) +{ + while (bitmask) + { + unsigned int bit = bitmask & (- bitmask); + + bitmask &= ~ bit; + switch (bit) + { + case GNU_PROPERTY_X86_ISA_1_486: printf ("i486"); break; + case GNU_PROPERTY_X86_ISA_1_586: printf ("586"); break; + case GNU_PROPERTY_X86_ISA_1_686: printf ("686"); break; + case GNU_PROPERTY_X86_ISA_1_SSE: printf ("SSE"); break; + case GNU_PROPERTY_X86_ISA_1_SSE2: printf ("SSE2"); break; + case GNU_PROPERTY_X86_ISA_1_SSE3: printf ("SSE3"); break; + case GNU_PROPERTY_X86_ISA_1_SSSE3: printf ("SSSE3"); break; + case GNU_PROPERTY_X86_ISA_1_SSE4_1: printf ("SSE4_1"); break; + case GNU_PROPERTY_X86_ISA_1_SSE4_2: printf ("SSE4_2"); break; + case GNU_PROPERTY_X86_ISA_1_AVX: printf ("AVX"); break; + case GNU_PROPERTY_X86_ISA_1_AVX2: printf ("AVX2"); break; + case GNU_PROPERTY_X86_ISA_1_AVX512F: printf ("AVX512F"); break; + case GNU_PROPERTY_X86_ISA_1_AVX512CD: printf ("AVX512CD"); break; + case GNU_PROPERTY_X86_ISA_1_AVX512ER: printf ("AVX512ER"); break; + case GNU_PROPERTY_X86_ISA_1_AVX512PF: printf ("AVX512PF"); break; + case GNU_PROPERTY_X86_ISA_1_AVX512VL: printf ("AVX512VL"); break; + case GNU_PROPERTY_X86_ISA_1_AVX512DQ: printf ("AVX512DQ"); break; + case GNU_PROPERTY_X86_ISA_1_AVX512BW: printf ("AVX512BW"); break; + default: printf (_(""), bit); break; + } + if (bitmask) + printf (", "); + } +} + +static void +decode_x86_feature (unsigned int type, unsigned int bitmask) +{ + while (bitmask) + { + unsigned int bit = bitmask & (- bitmask); + + bitmask &= ~ bit; + switch (bit) + { + case GNU_PROPERTY_X86_FEATURE_1_IBT: + switch (type) + { + case GNU_PROPERTY_X86_FEATURE_1_AND: + printf ("IBT"); + break; + default: + /* This should never happen. */ + abort (); + } + break; + case GNU_PROPERTY_X86_FEATURE_1_SHSTK: + switch (type) + { + case GNU_PROPERTY_X86_FEATURE_1_AND: + printf ("SHSTK"); + break; + default: + /* This should never happen. */ + abort (); + } + break; + default: + printf (_(""), bit); + break; + } + if (bitmask) + printf (", "); + } +} + +static void +print_gnu_property_note (Filedata * filedata, Elf_Internal_Note * pnote) +{ + unsigned char * ptr = (unsigned char *) pnote->descdata; + unsigned char * ptr_end = ptr + pnote->descsz; + unsigned int size = is_32bit_elf ? 4 : 8; + + printf (_(" Properties: ")); + + if (pnote->descsz < 8 || (pnote->descsz % size) != 0) + { + printf (_("\n"), pnote->descsz); + return; + } + + while (ptr < ptr_end) + { + unsigned int j; + unsigned int type; + unsigned int datasz; + + if ((size_t) (ptr_end - ptr) < 8) + { + printf (_("\n"), pnote->descsz); + break; + } + + type = byte_get (ptr, 4); + datasz = byte_get (ptr + 4, 4); + + ptr += 8; + + if (datasz > (size_t) (ptr_end - ptr)) + { + printf (_("\n"), + type, datasz); + break; + } + + if (type >= GNU_PROPERTY_LOPROC && type <= GNU_PROPERTY_HIPROC) + { + if (filedata->file_header.e_machine == EM_X86_64 + || filedata->file_header.e_machine == EM_IAMCU + || filedata->file_header.e_machine == EM_386) + { + switch (type) + { + case GNU_PROPERTY_X86_ISA_1_USED: + printf ("x86 ISA used: "); + if (datasz != 4) + printf (_(" "), datasz); + else + decode_x86_isa (byte_get (ptr, 4)); + goto next; + + case GNU_PROPERTY_X86_ISA_1_NEEDED: + printf ("x86 ISA needed: "); + if (datasz != 4) + printf (_(" "), datasz); + else + decode_x86_isa (byte_get (ptr, 4)); + goto next; + + case GNU_PROPERTY_X86_FEATURE_1_AND: + printf ("x86 feature: "); + if (datasz != 4) + printf (_(" "), datasz); + else + decode_x86_feature (type, byte_get (ptr, 4)); + goto next; + + default: + break; + } + } + } + else + { + switch (type) + { + case GNU_PROPERTY_STACK_SIZE: + printf (_("stack size: ")); + if (datasz != size) + printf (_(" "), datasz); + else + printf ("%#lx", (unsigned long) byte_get (ptr, size)); + goto next; + + case GNU_PROPERTY_NO_COPY_ON_PROTECTED: + printf ("no copy on protected "); + if (datasz) + printf (_(" "), datasz); + goto next; + + default: + break; + } + } + + if (type < GNU_PROPERTY_LOPROC) + printf (_(""); + +next: + ptr += ((datasz + (size - 1)) & ~ (size - 1)); + if (ptr == ptr_end) + break; + + if (do_wide) + printf (", "); + else + printf ("\n\t"); + } + + printf ("\n"); +} + +static bfd_boolean +print_gnu_note (Filedata * filedata, Elf_Internal_Note *pnote) +{ + /* NB/ Keep this switch statement in sync with get_gnu_elf_note_type (). */ + switch (pnote->type) + { + case NT_GNU_BUILD_ID: + { + unsigned long i; + + printf (_(" Build ID: ")); + for (i = 0; i < pnote->descsz; ++i) + printf ("%02x", pnote->descdata[i] & 0xff); + printf ("\n"); + } + break; + + case NT_GNU_ABI_TAG: + { + unsigned long os, major, minor, subminor; + const char *osname; + + /* PR 17531: file: 030-599401-0.004. */ + if (pnote->descsz < 16) + { + printf (_(" \n")); + break; + } + + os = byte_get ((unsigned char *) pnote->descdata, 4); + major = byte_get ((unsigned char *) pnote->descdata + 4, 4); + minor = byte_get ((unsigned char *) pnote->descdata + 8, 4); + subminor = byte_get ((unsigned char *) pnote->descdata + 12, 4); + + switch (os) + { + case GNU_ABI_TAG_LINUX: + osname = "Linux"; + break; + case GNU_ABI_TAG_HURD: + osname = "Hurd"; + break; + case GNU_ABI_TAG_SOLARIS: + osname = "Solaris"; + break; + case GNU_ABI_TAG_FREEBSD: + osname = "FreeBSD"; + break; + case GNU_ABI_TAG_NETBSD: + osname = "NetBSD"; + break; + case GNU_ABI_TAG_SYLLABLE: + osname = "Syllable"; + break; + case GNU_ABI_TAG_NACL: + osname = "NaCl"; + break; + default: + osname = "Unknown"; + break; + } + + printf (_(" OS: %s, ABI: %ld.%ld.%ld\n"), osname, + major, minor, subminor); + } + break; + + case NT_GNU_GOLD_VERSION: + { + unsigned long i; + + printf (_(" Version: ")); + for (i = 0; i < pnote->descsz && pnote->descdata[i] != '\0'; ++i) + printf ("%c", pnote->descdata[i]); + printf ("\n"); + } + break; + + case NT_GNU_HWCAP: + { + unsigned long num_entries, mask; + + /* Hardware capabilities information. Word 0 is the number of entries. + Word 1 is a bitmask of enabled entries. The rest of the descriptor + is a series of entries, where each entry is a single byte followed + by a nul terminated string. The byte gives the bit number to test + if enabled in the bitmask. */ + printf (_(" Hardware Capabilities: ")); + if (pnote->descsz < 8) + { + error (_("\n")); + return FALSE; + } + num_entries = byte_get ((unsigned char *) pnote->descdata, 4); + mask = byte_get ((unsigned char *) pnote->descdata + 4, 4); + printf (_("num entries: %ld, enabled mask: %lx\n"), num_entries, mask); + /* FIXME: Add code to display the entries... */ + } + break; + + case NT_GNU_PROPERTY_TYPE_0: + print_gnu_property_note (filedata, pnote); + break; + + default: + /* Handle unrecognised types. An error message should have already been + created by get_gnu_elf_note_type(), so all that we need to do is to + display the data. */ + { + unsigned long i; + + printf (_(" Description data: ")); + for (i = 0; i < pnote->descsz; ++i) + printf ("%02x ", pnote->descdata[i] & 0xff); + printf ("\n"); + } + break; + } + + return TRUE; +} + +static const char * +get_v850_elf_note_type (enum v850_notes n_type) +{ + static char buff[64]; + + switch (n_type) + { + case V850_NOTE_ALIGNMENT: return _("Alignment of 8-byte objects"); + case V850_NOTE_DATA_SIZE: return _("Sizeof double and long double"); + case V850_NOTE_FPU_INFO: return _("Type of FPU support needed"); + case V850_NOTE_SIMD_INFO: return _("Use of SIMD instructions"); + case V850_NOTE_CACHE_INFO: return _("Use of cache"); + case V850_NOTE_MMU_INFO: return _("Use of MMU"); + default: + snprintf (buff, sizeof (buff), _("Unknown note type: (0x%08x)"), n_type); + return buff; + } +} + +static bfd_boolean +print_v850_note (Elf_Internal_Note * pnote) +{ + unsigned int val; + + if (pnote->descsz != 4) + return FALSE; + + val = byte_get ((unsigned char *) pnote->descdata, pnote->descsz); + + if (val == 0) + { + printf (_("not set\n")); + return TRUE; + } + + switch (pnote->type) + { + case V850_NOTE_ALIGNMENT: + switch (val) + { + case EF_RH850_DATA_ALIGN4: printf (_("4-byte\n")); return TRUE; + case EF_RH850_DATA_ALIGN8: printf (_("8-byte\n")); return TRUE; + } + break; + + case V850_NOTE_DATA_SIZE: + switch (val) + { + case EF_RH850_DOUBLE32: printf (_("4-bytes\n")); return TRUE; + case EF_RH850_DOUBLE64: printf (_("8-bytes\n")); return TRUE; + } + break; + + case V850_NOTE_FPU_INFO: + switch (val) + { + case EF_RH850_FPU20: printf (_("FPU-2.0\n")); return TRUE; + case EF_RH850_FPU30: printf (_("FPU-3.0\n")); return TRUE; + } + break; + + case V850_NOTE_MMU_INFO: + case V850_NOTE_CACHE_INFO: + case V850_NOTE_SIMD_INFO: + if (val == EF_RH850_SIMD) + { + printf (_("yes\n")); + return TRUE; + } + break; + + default: + /* An 'unknown note type' message will already have been displayed. */ + break; + } + + printf (_("unknown value: %x\n"), val); + return FALSE; +} + +static bfd_boolean +process_netbsd_elf_note (Elf_Internal_Note * pnote) +{ + unsigned int version; + + switch (pnote->type) + { + case NT_NETBSD_IDENT: + version = byte_get ((unsigned char *) pnote->descdata, sizeof (version)); + if ((version / 10000) % 100) + printf (" NetBSD\t\t0x%08lx\tIDENT %u (%u.%u%s%c)\n", pnote->descsz, + version, version / 100000000, (version / 1000000) % 100, + (version / 10000) % 100 > 26 ? "Z" : "", + 'A' + (version / 10000) % 26); + else + printf (" NetBSD\t\t0x%08lx\tIDENT %u (%u.%u.%u)\n", pnote->descsz, + version, version / 100000000, (version / 1000000) % 100, + (version / 100) % 100); + return TRUE; + + case NT_NETBSD_MARCH: + printf (" NetBSD\t0x%08lx\tMARCH <%s>\n", pnote->descsz, + pnote->descdata); + return TRUE; + + default: + printf (" NetBSD\t0x%08lx\tUnknown note type: (0x%08lx)\n", pnote->descsz, + pnote->type); + return FALSE; + } +} + +static const char * +get_freebsd_elfcore_note_type (Filedata * filedata, unsigned e_type) +{ + switch (e_type) + { + case NT_FREEBSD_THRMISC: + return _("NT_THRMISC (thrmisc structure)"); + case NT_FREEBSD_PROCSTAT_PROC: + return _("NT_PROCSTAT_PROC (proc data)"); + case NT_FREEBSD_PROCSTAT_FILES: + return _("NT_PROCSTAT_FILES (files data)"); + case NT_FREEBSD_PROCSTAT_VMMAP: + return _("NT_PROCSTAT_VMMAP (vmmap data)"); + case NT_FREEBSD_PROCSTAT_GROUPS: + return _("NT_PROCSTAT_GROUPS (groups data)"); + case NT_FREEBSD_PROCSTAT_UMASK: + return _("NT_PROCSTAT_UMASK (umask data)"); + case NT_FREEBSD_PROCSTAT_RLIMIT: + return _("NT_PROCSTAT_RLIMIT (rlimit data)"); + case NT_FREEBSD_PROCSTAT_OSREL: + return _("NT_PROCSTAT_OSREL (osreldate data)"); + case NT_FREEBSD_PROCSTAT_PSSTRINGS: + return _("NT_PROCSTAT_PSSTRINGS (ps_strings data)"); + case NT_FREEBSD_PROCSTAT_AUXV: + return _("NT_PROCSTAT_AUXV (auxv data)"); + case NT_FREEBSD_PTLWPINFO: + return _("NT_PTLWPINFO (ptrace_lwpinfo structure)"); + } + return get_note_type (filedata, e_type); +} + +static const char * +get_netbsd_elfcore_note_type (Filedata * filedata, unsigned e_type) +{ + static char buff[64]; + + if (e_type == NT_NETBSDCORE_PROCINFO) + return _("NetBSD procinfo structure"); + + /* As of Jan 2002 there are no other machine-independent notes + defined for NetBSD core files. If the note type is less + than the start of the machine-dependent note types, we don't + understand it. */ + + if (e_type < NT_NETBSDCORE_FIRSTMACH) + { + snprintf (buff, sizeof (buff), _("Unknown note type: (0x%08x)"), e_type); + return buff; + } + + switch (filedata->file_header.e_machine) + { + /* On the Alpha, SPARC (32-bit and 64-bit), PT_GETREGS == mach+0 + and PT_GETFPREGS == mach+2. */ + + case EM_OLD_ALPHA: + case EM_ALPHA: + case EM_SPARC: + case EM_SPARC32PLUS: + case EM_SPARCV9: + switch (e_type) + { + case NT_NETBSDCORE_FIRSTMACH + 0: + return _("PT_GETREGS (reg structure)"); + case NT_NETBSDCORE_FIRSTMACH + 2: + return _("PT_GETFPREGS (fpreg structure)"); + default: + break; + } + break; + + /* On all other arch's, PT_GETREGS == mach+1 and + PT_GETFPREGS == mach+3. */ + default: + switch (e_type) + { + case NT_NETBSDCORE_FIRSTMACH + 1: + return _("PT_GETREGS (reg structure)"); + case NT_NETBSDCORE_FIRSTMACH + 3: + return _("PT_GETFPREGS (fpreg structure)"); + default: + break; + } + } + + snprintf (buff, sizeof (buff), "PT_FIRSTMACH+%d", + e_type - NT_NETBSDCORE_FIRSTMACH); + return buff; +} + +static const char * +get_stapsdt_note_type (unsigned e_type) +{ + static char buff[64]; + + switch (e_type) + { + case NT_STAPSDT: + return _("NT_STAPSDT (SystemTap probe descriptors)"); + + default: + break; + } + + snprintf (buff, sizeof (buff), _("Unknown note type: (0x%08x)"), e_type); + return buff; +} + +static bfd_boolean +print_stapsdt_note (Elf_Internal_Note *pnote) +{ + int addr_size = is_32bit_elf ? 4 : 8; + char *data = pnote->descdata; + char *data_end = pnote->descdata + pnote->descsz; + bfd_vma pc, base_addr, semaphore; + char *provider, *probe, *arg_fmt; + + pc = byte_get ((unsigned char *) data, addr_size); + data += addr_size; + base_addr = byte_get ((unsigned char *) data, addr_size); + data += addr_size; + semaphore = byte_get ((unsigned char *) data, addr_size); + data += addr_size; + + provider = data; + data += strlen (data) + 1; + probe = data; + data += strlen (data) + 1; + arg_fmt = data; + data += strlen (data) + 1; + + printf (_(" Provider: %s\n"), provider); + printf (_(" Name: %s\n"), probe); + printf (_(" Location: ")); + print_vma (pc, FULL_HEX); + printf (_(", Base: ")); + print_vma (base_addr, FULL_HEX); + printf (_(", Semaphore: ")); + print_vma (semaphore, FULL_HEX); + printf ("\n"); + printf (_(" Arguments: %s\n"), arg_fmt); + + return data == data_end; +} + +static const char * +get_ia64_vms_note_type (unsigned e_type) +{ + static char buff[64]; + + switch (e_type) + { + case NT_VMS_MHD: + return _("NT_VMS_MHD (module header)"); + case NT_VMS_LNM: + return _("NT_VMS_LNM (language name)"); + case NT_VMS_SRC: + return _("NT_VMS_SRC (source files)"); + case NT_VMS_TITLE: + return "NT_VMS_TITLE"; + case NT_VMS_EIDC: + return _("NT_VMS_EIDC (consistency check)"); + case NT_VMS_FPMODE: + return _("NT_VMS_FPMODE (FP mode)"); + case NT_VMS_LINKTIME: + return "NT_VMS_LINKTIME"; + case NT_VMS_IMGNAM: + return _("NT_VMS_IMGNAM (image name)"); + case NT_VMS_IMGID: + return _("NT_VMS_IMGID (image id)"); + case NT_VMS_LINKID: + return _("NT_VMS_LINKID (link id)"); + case NT_VMS_IMGBID: + return _("NT_VMS_IMGBID (build id)"); + case NT_VMS_GSTNAM: + return _("NT_VMS_GSTNAM (sym table name)"); + case NT_VMS_ORIG_DYN: + return "NT_VMS_ORIG_DYN"; + case NT_VMS_PATCHTIME: + return "NT_VMS_PATCHTIME"; + default: + snprintf (buff, sizeof (buff), _("Unknown note type: (0x%08x)"), e_type); + return buff; + } +} + +static bfd_boolean +print_ia64_vms_note (Elf_Internal_Note * pnote) +{ + switch (pnote->type) + { + case NT_VMS_MHD: + if (pnote->descsz > 36) + { + size_t l = strlen (pnote->descdata + 34); + printf (_(" Creation date : %.17s\n"), pnote->descdata); + printf (_(" Last patch date: %.17s\n"), pnote->descdata + 17); + printf (_(" Module name : %s\n"), pnote->descdata + 34); + printf (_(" Module version : %s\n"), pnote->descdata + 34 + l + 1); + } + else + printf (_(" Invalid size\n")); + break; + case NT_VMS_LNM: + printf (_(" Language: %s\n"), pnote->descdata); + break; +#ifdef BFD64 + case NT_VMS_FPMODE: + printf (_(" Floating Point mode: ")); + printf ("0x%016" BFD_VMA_FMT "x\n", + (bfd_vma) byte_get ((unsigned char *)pnote->descdata, 8)); + break; + case NT_VMS_LINKTIME: + printf (_(" Link time: ")); + print_vms_time + ((bfd_int64_t) byte_get ((unsigned char *)pnote->descdata, 8)); + printf ("\n"); + break; + case NT_VMS_PATCHTIME: + printf (_(" Patch time: ")); + print_vms_time + ((bfd_int64_t) byte_get ((unsigned char *)pnote->descdata, 8)); + printf ("\n"); + break; + case NT_VMS_ORIG_DYN: + printf (_(" Major id: %u, minor id: %u\n"), + (unsigned) byte_get ((unsigned char *)pnote->descdata, 4), + (unsigned) byte_get ((unsigned char *)pnote->descdata + 4, 4)); + printf (_(" Last modified : ")); + print_vms_time + ((bfd_int64_t) byte_get ((unsigned char *)pnote->descdata + 8, 8)); + printf (_("\n Link flags : ")); + printf ("0x%016" BFD_VMA_FMT "x\n", + (bfd_vma) byte_get ((unsigned char *)pnote->descdata + 16, 8)); + printf (_(" Header flags: 0x%08x\n"), + (unsigned) byte_get ((unsigned char *)pnote->descdata + 24, 4)); + printf (_(" Image id : %s\n"), pnote->descdata + 32); + break; +#endif + case NT_VMS_IMGNAM: + printf (_(" Image name: %s\n"), pnote->descdata); + break; + case NT_VMS_GSTNAM: + printf (_(" Global symbol table name: %s\n"), pnote->descdata); + break; + case NT_VMS_IMGID: + printf (_(" Image id: %s\n"), pnote->descdata); + break; + case NT_VMS_LINKID: + printf (_(" Linker id: %s\n"), pnote->descdata); + break; + default: + return FALSE; + } + return TRUE; +} + +/* Find the symbol associated with a build attribute that is attached + to address OFFSET. If PNAME is non-NULL then store the name of + the symbol (if found) in the provided pointer, Returns NULL if a + symbol could not be found. */ + +static Elf_Internal_Sym * +get_symbol_for_build_attribute (Filedata * filedata, + unsigned long offset, + bfd_boolean is_open_attr, + const char ** pname) +{ + static Filedata * saved_filedata = NULL; + static char * strtab; + static unsigned long strtablen; + static Elf_Internal_Sym * symtab; + static unsigned long nsyms; + Elf_Internal_Sym * saved_sym = NULL; + Elf_Internal_Sym * sym; + + if (filedata->section_headers != NULL + && (saved_filedata == NULL || filedata != saved_filedata)) + { + Elf_Internal_Shdr * symsec; + + /* Load the symbol and string sections. */ + for (symsec = filedata->section_headers; + symsec < filedata->section_headers + filedata->file_header.e_shnum; + symsec ++) + { + if (symsec->sh_type == SHT_SYMTAB) + { + symtab = GET_ELF_SYMBOLS (filedata, symsec, & nsyms); + + if (symsec->sh_link < filedata->file_header.e_shnum) + { + Elf_Internal_Shdr * strtab_sec = filedata->section_headers + symsec->sh_link; + + strtab = (char *) get_data (NULL, filedata, strtab_sec->sh_offset, + 1, strtab_sec->sh_size, + _("string table")); + strtablen = strtab != NULL ? strtab_sec->sh_size : 0; + } + } + } + saved_filedata = filedata; + } + + if (symtab == NULL || strtab == NULL) + return NULL; + + /* Find a symbol whose value matches offset. */ + for (sym = symtab; sym < symtab + nsyms; sym ++) + if (sym->st_value == offset) + { + if (sym->st_name >= strtablen) + /* Huh ? This should not happen. */ + continue; + + if (strtab[sym->st_name] == 0) + continue; + + if (is_open_attr) + { + /* For OPEN attributes we prefer GLOBAL over LOCAL symbols + and FILE or OBJECT symbols over NOTYPE symbols. We skip + FUNC symbols entirely. */ + switch (ELF_ST_TYPE (sym->st_info)) + { + case STT_OBJECT: + case STT_FILE: + saved_sym = sym; + if (sym->st_size) + { + /* If the symbol has a size associated + with it then we can stop searching. */ + sym = symtab + nsyms; + } + continue; + + case STT_FUNC: + /* Ignore function symbols. */ + continue; + + default: + break; + } + + switch (ELF_ST_BIND (sym->st_info)) + { + case STB_GLOBAL: + if (saved_sym == NULL + || ELF_ST_TYPE (saved_sym->st_info) != STT_OBJECT) + saved_sym = sym; + break; + + case STB_LOCAL: + if (saved_sym == NULL) + saved_sym = sym; + break; + + default: + break; + } + } + else + { + if (ELF_ST_TYPE (sym->st_info) != STT_FUNC) + continue; + + saved_sym = sym; + break; + } + } + + if (saved_sym && pname) + * pname = strtab + saved_sym->st_name; + + return saved_sym; +} + +static bfd_boolean +print_gnu_build_attribute_description (Elf_Internal_Note * pnote, + Filedata * filedata) +{ + static unsigned long global_offset = 0; + static unsigned long global_end = 0; + static unsigned long func_offset = 0; + static unsigned long func_end = 0; + + Elf_Internal_Sym * sym; + const char * name; + unsigned long start; + unsigned long end; + bfd_boolean is_open_attr = pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN; + + switch (pnote->descsz) + { + case 0: + /* A zero-length description means that the range of + the previous note of the same type should be used. */ + if (is_open_attr) + { + if (global_end > global_offset) + printf (_(" Applies to region from %#lx to %#lx\n"), + global_offset, global_end); + else + printf (_(" Applies to region from %#lx\n"), global_offset); + } + else + { + if (func_end > func_offset) + printf (_(" Applies to region from %#lx to %#lx\n"), func_offset, func_end); + else + printf (_(" Applies to region from %#lx\n"), func_offset); + } + return TRUE; + + case 4: + start = byte_get ((unsigned char *) pnote->descdata, 4); + end = 0; + break; + + case 8: + if (is_32bit_elf) + { + /* FIXME: We should check that version 3+ notes are being used here... */ + start = byte_get ((unsigned char *) pnote->descdata, 4); + end = byte_get ((unsigned char *) pnote->descdata + 4, 4); + } + else + { + start = byte_get ((unsigned char *) pnote->descdata, 8); + end = 0; + } + break; + + case 16: + start = byte_get ((unsigned char *) pnote->descdata, 8); + end = byte_get ((unsigned char *) pnote->descdata + 8, 8); + break; + + default: + error (_(" \n"), pnote->descsz); + printf (_(" ")); + return FALSE; + } + + name = NULL; + sym = get_symbol_for_build_attribute (filedata, start, is_open_attr, & name); + + if (end == 0 && sym != NULL && sym->st_size > 0) + end = start + sym->st_size; + + if (is_open_attr) + { + /* FIXME: Need to properly allow for section alignment. 16 is just the alignment used on x86_64. */ + if (global_end > 0 && start > BFD_ALIGN (global_end, 16)) + warn (_("Gap in build notes detected from %#lx to %#lx\n"), + global_end + 1, start - 1); + + printf (_(" Applies to region from %#lx"), start); + global_offset = start; + + if (end) + { + printf (_(" to %#lx"), end); + global_end = end; + } + } + else + { + printf (_(" Applies to region from %#lx"), start); + func_offset = start; + + if (end) + { + printf (_(" to %#lx"), end); + func_end = end; + } + } + + if (sym && name) + printf (_(" (%s)"), name); + + printf ("\n"); + return TRUE; +} + +static bfd_boolean +print_gnu_build_attribute_name (Elf_Internal_Note * pnote) +{ + static const char string_expected [2] = { GNU_BUILD_ATTRIBUTE_TYPE_STRING, 0 }; + static const char number_expected [2] = { GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC, 0 }; + static const char bool_expected [3] = { GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE, GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE, 0 }; + char name_type; + char name_attribute; + const char * expected_types; + const char * name = pnote->namedata; + const char * text; + signed int left; + + if (name == NULL || pnote->namesz < 2) + { + error (_("corrupt name field in GNU build attribute note: size = %ld\n"), pnote->namesz); + print_symbol (-20, _(" ")); + return FALSE; + } + + if (do_wide) + left = 28; + else + left = 20; + + /* Version 2 of the spec adds a "GA" prefix to the name field. */ + if (name[0] == 'G' && name[1] == 'A') + { + if (pnote->namesz < 4) + { + error (_("corrupt name field in GNU build attribute note: size = %ld\n"), pnote->namesz); + print_symbol (-20, _(" ")); + return FALSE; + } + + printf ("GA"); + name += 2; + left -= 2; + } + + switch ((name_type = * name)) + { + case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC: + case GNU_BUILD_ATTRIBUTE_TYPE_STRING: + case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE: + case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE: + printf ("%c", * name); + left --; + break; + default: + error (_("unrecognised attribute type in name field: %d\n"), name_type); + print_symbol (-20, _("")); + return FALSE; + } + + ++ name; + text = NULL; + + switch ((name_attribute = * name)) + { + case GNU_BUILD_ATTRIBUTE_VERSION: + text = _(""); + expected_types = string_expected; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_STACK_PROT: + text = _(""); + expected_types = "!+*"; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_RELRO: + text = _(""); + expected_types = bool_expected; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_STACK_SIZE: + text = _(""); + expected_types = number_expected; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_TOOL: + text = _(""); + expected_types = string_expected; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_ABI: + text = _(""); + expected_types = "$*"; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_PIC: + text = _(""); + expected_types = number_expected; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_SHORT_ENUM: + text = _(""); + expected_types = bool_expected; + ++ name; + break; + default: + if (ISPRINT (* name)) + { + int len = strnlen (name, pnote->namesz - (name - pnote->namedata)) + 1; + + if (len > left && ! do_wide) + len = left; + printf ("%.*s:", len, name); + left -= len; + name += len; + } + else + { + static char tmpbuf [128]; + + error (_("unrecognised byte in name field: %d\n"), * name); + sprintf (tmpbuf, _(""), * name); + text = tmpbuf; + name ++; + } + expected_types = "*$!+"; + break; + } + + if (text) + left -= printf ("%s", text); + + if (strchr (expected_types, name_type) == NULL) + warn (_("attribute does not have an expected type (%c)\n"), name_type); + + if ((unsigned long)(name - pnote->namedata) > pnote->namesz) + { + error (_("corrupt name field: namesz: %lu but parsing gets to %ld\n"), + (unsigned long) pnote->namesz, + (long) (name - pnote->namedata)); + return FALSE; + } + + if (left < 1 && ! do_wide) + return TRUE; + + switch (name_type) + { + case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC: + { + unsigned int bytes; + unsigned long long val = 0; + unsigned int shift = 0; + char * decoded = NULL; + + bytes = pnote->namesz - (name - pnote->namedata); + if (bytes > 0) + /* The -1 is because the name field is always 0 terminated, and we + want to be able to ensure that the shift in the while loop below + will not overflow. */ + -- bytes; + + if (bytes > sizeof (val)) + { + error (_("corrupt numeric name field: too many bytes in the value: %x\n"), + bytes); + bytes = sizeof (val); + } + /* We do not bother to warn if bytes == 0 as this can + happen with some early versions of the gcc plugin. */ + + while (bytes --) + { + unsigned long byte = (* name ++) & 0xff; + + val |= byte << shift; + shift += 8; + } + + switch (name_attribute) + { + case GNU_BUILD_ATTRIBUTE_PIC: + switch (val) + { + case 0: decoded = "static"; break; + case 1: decoded = "pic"; break; + case 2: decoded = "PIC"; break; + case 3: decoded = "pie"; break; + case 4: decoded = "PIE"; break; + default: break; + } + break; + case GNU_BUILD_ATTRIBUTE_STACK_PROT: + switch (val) + { + /* Based upon the SPCT_FLAG_xxx enum values in gcc/cfgexpand.c. */ + case 0: decoded = "off"; break; + case 1: decoded = "on"; break; + case 2: decoded = "all"; break; + case 3: decoded = "strong"; break; + case 4: decoded = "explicit"; break; + default: break; + } + break; + default: + break; + } + + if (decoded != NULL) + { + print_symbol (-left, decoded); + left = 0; + } + else if (val == 0) + { + printf ("0x0"); + left -= 3; + } + else + { + if (do_wide) + left -= printf ("0x%llx", val); + else + left -= printf ("0x%-.*llx", left, val); + } + } + break; + case GNU_BUILD_ATTRIBUTE_TYPE_STRING: + left -= print_symbol (- left, name); + break; + case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE: + left -= print_symbol (- left, "true"); + break; + case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE: + left -= print_symbol (- left, "false"); + break; + } + + if (do_wide && left > 0) + printf ("%-*s", left, " "); + + return TRUE; +} + +/* Note that by the ELF standard, the name field is already null byte + terminated, and namesz includes the terminating null byte. + I.E. the value of namesz for the name "FSF" is 4. + + If the value of namesz is zero, there is no name present. */ + +static bfd_boolean +process_note (Elf_Internal_Note * pnote, + Filedata * filedata) +{ + const char * name = pnote->namesz ? pnote->namedata : "(NONE)"; + const char * nt; + + if (pnote->namesz == 0) + /* If there is no note name, then use the default set of + note type strings. */ + nt = get_note_type (filedata, pnote->type); + + else if (const_strneq (pnote->namedata, "GNU")) + /* GNU-specific object file notes. */ + nt = get_gnu_elf_note_type (pnote->type); + + else if (const_strneq (pnote->namedata, "FreeBSD")) + /* FreeBSD-specific core file notes. */ + nt = get_freebsd_elfcore_note_type (filedata, pnote->type); + + else if (const_strneq (pnote->namedata, "NetBSD-CORE")) + /* NetBSD-specific core file notes. */ + nt = get_netbsd_elfcore_note_type (filedata, pnote->type); + + else if (const_strneq (pnote->namedata, "NetBSD")) + /* NetBSD-specific core file notes. */ + return process_netbsd_elf_note (pnote); + + else if (strneq (pnote->namedata, "SPU/", 4)) + { + /* SPU-specific core file notes. */ + nt = pnote->namedata + 4; + name = "SPU"; + } + + else if (const_strneq (pnote->namedata, "IPF/VMS")) + /* VMS/ia64-specific file notes. */ + nt = get_ia64_vms_note_type (pnote->type); + + else if (const_strneq (pnote->namedata, "stapsdt")) + nt = get_stapsdt_note_type (pnote->type); + + else + /* Don't recognize this note name; just use the default set of + note type strings. */ + nt = get_note_type (filedata, pnote->type); + + printf (" "); + + if (((const_strneq (pnote->namedata, "GA") + && strchr ("*$!+", pnote->namedata[2]) != NULL) + || strchr ("*$!+", pnote->namedata[0]) != NULL) + && (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN + || pnote->type == NT_GNU_BUILD_ATTRIBUTE_FUNC)) + print_gnu_build_attribute_name (pnote); + else + print_symbol (-20, name); + + if (do_wide) + printf (" 0x%08lx\t%s\t", pnote->descsz, nt); + else + printf (" 0x%08lx\t%s\n", pnote->descsz, nt); + + if (const_strneq (pnote->namedata, "IPF/VMS")) + return print_ia64_vms_note (pnote); + else if (const_strneq (pnote->namedata, "GNU")) + return print_gnu_note (filedata, pnote); + else if (const_strneq (pnote->namedata, "stapsdt")) + return print_stapsdt_note (pnote); + else if (const_strneq (pnote->namedata, "CORE")) + return print_core_note (pnote); + else if (((const_strneq (pnote->namedata, "GA") + && strchr ("*$!+", pnote->namedata[2]) != NULL) + || strchr ("*$!+", pnote->namedata[0]) != NULL) + && (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN + || pnote->type == NT_GNU_BUILD_ATTRIBUTE_FUNC)) + return print_gnu_build_attribute_description (pnote, filedata); + + if (pnote->descsz) + { + unsigned long i; + + printf (_(" description data: ")); + for (i = 0; i < pnote->descsz; i++) + printf ("%02x ", pnote->descdata[i]); + if (!do_wide) + printf ("\n"); + } + + if (do_wide) + printf ("\n"); + + return TRUE; +} + +static bfd_boolean +process_notes_at (Filedata * filedata, + Elf_Internal_Shdr * section, + bfd_vma offset, + bfd_vma length, + bfd_vma align) +{ + Elf_External_Note * pnotes; + Elf_External_Note * external; + char * end; + bfd_boolean res = TRUE; + + if (length <= 0) + return FALSE; + + if (section) + { + pnotes = (Elf_External_Note *) get_section_contents (section, filedata); + if (pnotes) + { + if (! apply_relocations (filedata, section, (unsigned char *) pnotes, length, NULL, NULL)) + return FALSE; + } + } + else + pnotes = (Elf_External_Note *) get_data (NULL, filedata, offset, 1, length, + _("notes")); + + if (pnotes == NULL) + return FALSE; + + external = pnotes; + + if (section) + printf (_("\nDisplaying notes found in: %s\n"), printable_section_name (filedata, section)); + else + printf (_("\nDisplaying notes found at file offset 0x%08lx with length 0x%08lx:\n"), + (unsigned long) offset, (unsigned long) length); + + /* NB: Some note sections may have alignment value of 0 or 1. gABI + specifies that notes should be aligned to 4 bytes in 32-bit + objects and to 8 bytes in 64-bit objects. As a Linux extension, + we also support 4 byte alignment in 64-bit objects. If section + alignment is less than 4, we treate alignment as 4 bytes. */ + if (align < 4) + align = 4; + else if (align != 4 && align != 8) + { + warn (_("Corrupt note: alignment %ld, expecting 4 or 8\n"), + (long) align); + return FALSE; + } + + printf (_(" %-20s %10s\tDescription\n"), _("Owner"), _("Data size")); + + end = (char *) pnotes + length; + while ((char *) external < end) + { + Elf_Internal_Note inote; + size_t min_notesz; + char * next; + char * temp = NULL; + size_t data_remaining = end - (char *) external; + + if (!is_ia64_vms (filedata)) + { + /* PR binutils/15191 + Make sure that there is enough data to read. */ + min_notesz = offsetof (Elf_External_Note, name); + if (data_remaining < min_notesz) + { + warn (ngettext ("Corrupt note: only %ld byte remains, " + "not enough for a full note\n", + "Corrupt note: only %ld bytes remain, " + "not enough for a full note\n", + data_remaining), + (long) data_remaining); + break; + } + data_remaining -= min_notesz; + + inote.type = BYTE_GET (external->type); + inote.namesz = BYTE_GET (external->namesz); + inote.namedata = external->name; + inote.descsz = BYTE_GET (external->descsz); + inote.descdata = ((char *) external + + ELF_NOTE_DESC_OFFSET (inote.namesz, align)); + inote.descpos = offset + (inote.descdata - (char *) pnotes); + next = ((char *) external + + ELF_NOTE_NEXT_OFFSET (inote.namesz, inote.descsz, align)); + } + else + { + Elf64_External_VMS_Note *vms_external; + + /* PR binutils/15191 + Make sure that there is enough data to read. */ + min_notesz = offsetof (Elf64_External_VMS_Note, name); + if (data_remaining < min_notesz) + { + warn (ngettext ("Corrupt note: only %ld byte remains, " + "not enough for a full note\n", + "Corrupt note: only %ld bytes remain, " + "not enough for a full note\n", + data_remaining), + (long) data_remaining); + break; + } + data_remaining -= min_notesz; + + vms_external = (Elf64_External_VMS_Note *) external; + inote.type = BYTE_GET (vms_external->type); + inote.namesz = BYTE_GET (vms_external->namesz); + inote.namedata = vms_external->name; + inote.descsz = BYTE_GET (vms_external->descsz); + inote.descdata = inote.namedata + align_power (inote.namesz, 3); + inote.descpos = offset + (inote.descdata - (char *) pnotes); + next = inote.descdata + align_power (inote.descsz, 3); + } + + /* PR 17531: file: 3443835e. */ + /* PR 17531: file: id:000000,sig:11,src:006986,op:havoc,rep:4. */ + if ((size_t) (inote.descdata - inote.namedata) < inote.namesz + || (size_t) (inote.descdata - inote.namedata) > data_remaining + || (size_t) (next - inote.descdata) < inote.descsz + || ((size_t) (next - inote.descdata) + > data_remaining - (size_t) (inote.descdata - inote.namedata))) + { + warn (_("note with invalid namesz and/or descsz found at offset 0x%lx\n"), + (unsigned long) ((char *) external - (char *) pnotes)); + warn (_(" type: 0x%lx, namesize: 0x%08lx, descsize: 0x%08lx, alignment: %u\n"), + inote.type, inote.namesz, inote.descsz, (int) align); + break; + } + + external = (Elf_External_Note *) next; + + /* Verify that name is null terminated. It appears that at least + one version of Linux (RedHat 6.0) generates corefiles that don't + comply with the ELF spec by failing to include the null byte in + namesz. */ + if (inote.namedata[inote.namesz - 1] != '\0') + { + if ((size_t) (inote.descdata - inote.namedata) == inote.namesz) + { + temp = (char *) malloc (inote.namesz + 1); + if (temp == NULL) + { + error (_("Out of memory allocating space for inote name\n")); + res = FALSE; + break; + } + + memcpy (temp, inote.namedata, inote.namesz); + inote.namedata = temp; + } + inote.namedata[inote.namesz] = 0; + } + + if (! process_note (& inote, filedata)) + res = FALSE; + + if (temp != NULL) + { + free (temp); + temp = NULL; + } + } + + free (pnotes); + + return res; +} + +static bfd_boolean +process_corefile_note_segments (Filedata * filedata) +{ + Elf_Internal_Phdr * segment; + unsigned int i; + bfd_boolean res = TRUE; + + if (! get_program_headers (filedata)) + return TRUE; + + for (i = 0, segment = filedata->program_headers; + i < filedata->file_header.e_phnum; + i++, segment++) + { + if (segment->p_type == PT_NOTE) + if (! process_notes_at (filedata, NULL, + (bfd_vma) segment->p_offset, + (bfd_vma) segment->p_filesz, + (bfd_vma) segment->p_align)) + res = FALSE; + } + + return res; +} + +static bfd_boolean +process_v850_notes (Filedata * filedata, bfd_vma offset, bfd_vma length) +{ + Elf_External_Note * pnotes; + Elf_External_Note * external; + char * end; + bfd_boolean res = TRUE; + + if (length <= 0) + return FALSE; + + pnotes = (Elf_External_Note *) get_data (NULL, filedata, offset, 1, length, + _("v850 notes")); + if (pnotes == NULL) + return FALSE; + + external = pnotes; + end = (char*) pnotes + length; + + printf (_("\nDisplaying contents of Renesas V850 notes section at offset 0x%lx with length 0x%lx:\n"), + (unsigned long) offset, (unsigned long) length); + + while ((char *) external + sizeof (Elf_External_Note) < end) + { + Elf_External_Note * next; + Elf_Internal_Note inote; + + inote.type = BYTE_GET (external->type); + inote.namesz = BYTE_GET (external->namesz); + inote.namedata = external->name; + inote.descsz = BYTE_GET (external->descsz); + inote.descdata = inote.namedata + align_power (inote.namesz, 2); + inote.descpos = offset + (inote.descdata - (char *) pnotes); + + if (inote.descdata < (char *) pnotes || inote.descdata >= end) + { + warn (_("Corrupt note: name size is too big: %lx\n"), inote.namesz); + inote.descdata = inote.namedata; + inote.namesz = 0; + } + + next = (Elf_External_Note *) (inote.descdata + align_power (inote.descsz, 2)); + + if ( ((char *) next > end) + || ((char *) next < (char *) pnotes)) + { + warn (_("corrupt descsz found in note at offset 0x%lx\n"), + (unsigned long) ((char *) external - (char *) pnotes)); + warn (_(" type: 0x%lx, namesize: 0x%lx, descsize: 0x%lx\n"), + inote.type, inote.namesz, inote.descsz); + break; + } + + external = next; + + /* Prevent out-of-bounds indexing. */ + if ( inote.namedata + inote.namesz > end + || inote.namedata + inote.namesz < inote.namedata) + { + warn (_("corrupt namesz found in note at offset 0x%lx\n"), + (unsigned long) ((char *) external - (char *) pnotes)); + warn (_(" type: 0x%lx, namesize: 0x%lx, descsize: 0x%lx\n"), + inote.type, inote.namesz, inote.descsz); + break; + } + + printf (" %s: ", get_v850_elf_note_type (inote.type)); + + if (! print_v850_note (& inote)) + { + res = FALSE; + printf ("\n", + inote.namesz, inote.descsz); + } + } + + free (pnotes); + + return res; +} + +static bfd_boolean +process_note_sections (Filedata * filedata) +{ + Elf_Internal_Shdr * section; + unsigned long i; + unsigned int n = 0; + bfd_boolean res = TRUE; + + for (i = 0, section = filedata->section_headers; + i < filedata->file_header.e_shnum && section != NULL; + i++, section++) + { + if (section->sh_type == SHT_NOTE) + { + if (! process_notes_at (filedata, section, + (bfd_vma) section->sh_offset, + (bfd_vma) section->sh_size, + (bfd_vma) section->sh_addralign)) + res = FALSE; + n++; + } + + if (( filedata->file_header.e_machine == EM_V800 + || filedata->file_header.e_machine == EM_V850 + || filedata->file_header.e_machine == EM_CYGNUS_V850) + && section->sh_type == SHT_RENESAS_INFO) + { + if (! process_v850_notes (filedata, + (bfd_vma) section->sh_offset, + (bfd_vma) section->sh_size)) + res = FALSE; + n++; + } + } + + if (n == 0) + /* Try processing NOTE segments instead. */ + return process_corefile_note_segments (filedata); + + return res; +} + +static bfd_boolean +process_notes (Filedata * filedata) +{ + /* If we have not been asked to display the notes then do nothing. */ + if (! do_notes) + return TRUE; + + if (filedata->file_header.e_type != ET_CORE) + return process_note_sections (filedata); + + /* No program headers means no NOTE segment. */ + if (filedata->file_header.e_phnum > 0) + return process_corefile_note_segments (filedata); + + printf (_("No note segments present in the core file.\n")); + return TRUE; +} + +static unsigned char * +display_public_gnu_attributes (unsigned char * start, + const unsigned char * const end) +{ + printf (_(" Unknown GNU attribute: %s\n"), start); + + start += strnlen ((char *) start, end - start); + display_raw_attribute (start, end); + + return (unsigned char *) end; +} + +static unsigned char * +display_generic_attribute (unsigned char * start, + unsigned int tag, + const unsigned char * const end) +{ + if (tag == 0) + return (unsigned char *) end; + + return display_tag_value (tag, start, end); +} + +static bfd_boolean +process_arch_specific (Filedata * filedata) +{ + if (! do_arch) + return TRUE; + + switch (filedata->file_header.e_machine) + { + case EM_ARC: + case EM_ARC_COMPACT: + case EM_ARC_COMPACT2: + return process_attributes (filedata, "ARC", SHT_ARC_ATTRIBUTES, + display_arc_attribute, + display_generic_attribute); + case EM_ARM: + return process_attributes (filedata, "aeabi", SHT_ARM_ATTRIBUTES, + display_arm_attribute, + display_generic_attribute); + + case EM_MIPS: + case EM_MIPS_RS3_LE: + return process_mips_specific (filedata); + + case EM_MSP430: + return process_attributes (filedata, "mspabi", SHT_MSP430_ATTRIBUTES, + display_msp430x_attribute, + display_generic_attribute); + + case EM_NDS32: + return process_nds32_specific (filedata); + + case EM_PPC: + case EM_PPC64: + return process_attributes (filedata, NULL, SHT_GNU_ATTRIBUTES, NULL, + display_power_gnu_attribute); + + case EM_S390: + case EM_S390_OLD: + return process_attributes (filedata, NULL, SHT_GNU_ATTRIBUTES, NULL, + display_s390_gnu_attribute); + + case EM_SPARC: + case EM_SPARC32PLUS: + case EM_SPARCV9: + return process_attributes (filedata, NULL, SHT_GNU_ATTRIBUTES, NULL, + display_sparc_gnu_attribute); + + case EM_TI_C6000: + return process_attributes (filedata, "c6xabi", SHT_C6000_ATTRIBUTES, + display_tic6x_attribute, + display_generic_attribute); + + default: + return process_attributes (filedata, "gnu", SHT_GNU_ATTRIBUTES, + display_public_gnu_attributes, + display_generic_attribute); + } +} + +static bfd_boolean +get_file_header (Filedata * filedata) +{ + /* Read in the identity array. */ + if (fread (filedata->file_header.e_ident, EI_NIDENT, 1, filedata->handle) != 1) + return FALSE; + + /* Determine how to read the rest of the header. */ + switch (filedata->file_header.e_ident[EI_DATA]) + { + default: + case ELFDATANONE: + case ELFDATA2LSB: + byte_get = byte_get_little_endian; + byte_put = byte_put_little_endian; + break; + case ELFDATA2MSB: + byte_get = byte_get_big_endian; + byte_put = byte_put_big_endian; + break; + } + + /* For now we only support 32 bit and 64 bit ELF files. */ + is_32bit_elf = (filedata->file_header.e_ident[EI_CLASS] != ELFCLASS64); + + /* Read in the rest of the header. */ + if (is_32bit_elf) + { + Elf32_External_Ehdr ehdr32; + + if (fread (ehdr32.e_type, sizeof (ehdr32) - EI_NIDENT, 1, filedata->handle) != 1) + return FALSE; + + filedata->file_header.e_type = BYTE_GET (ehdr32.e_type); + filedata->file_header.e_machine = BYTE_GET (ehdr32.e_machine); + filedata->file_header.e_version = BYTE_GET (ehdr32.e_version); + filedata->file_header.e_entry = BYTE_GET (ehdr32.e_entry); + filedata->file_header.e_phoff = BYTE_GET (ehdr32.e_phoff); + filedata->file_header.e_shoff = BYTE_GET (ehdr32.e_shoff); + filedata->file_header.e_flags = BYTE_GET (ehdr32.e_flags); + filedata->file_header.e_ehsize = BYTE_GET (ehdr32.e_ehsize); + filedata->file_header.e_phentsize = BYTE_GET (ehdr32.e_phentsize); + filedata->file_header.e_phnum = BYTE_GET (ehdr32.e_phnum); + filedata->file_header.e_shentsize = BYTE_GET (ehdr32.e_shentsize); + filedata->file_header.e_shnum = BYTE_GET (ehdr32.e_shnum); + filedata->file_header.e_shstrndx = BYTE_GET (ehdr32.e_shstrndx); + } + else + { + Elf64_External_Ehdr ehdr64; + + /* If we have been compiled with sizeof (bfd_vma) == 4, then + we will not be able to cope with the 64bit data found in + 64 ELF files. Detect this now and abort before we start + overwriting things. */ + if (sizeof (bfd_vma) < 8) + { + error (_("This instance of readelf has been built without support for a\n\ +64 bit data type and so it cannot read 64 bit ELF files.\n")); + return FALSE; + } + + if (fread (ehdr64.e_type, sizeof (ehdr64) - EI_NIDENT, 1, filedata->handle) != 1) + return FALSE; + + filedata->file_header.e_type = BYTE_GET (ehdr64.e_type); + filedata->file_header.e_machine = BYTE_GET (ehdr64.e_machine); + filedata->file_header.e_version = BYTE_GET (ehdr64.e_version); + filedata->file_header.e_entry = BYTE_GET (ehdr64.e_entry); + filedata->file_header.e_phoff = BYTE_GET (ehdr64.e_phoff); + filedata->file_header.e_shoff = BYTE_GET (ehdr64.e_shoff); + filedata->file_header.e_flags = BYTE_GET (ehdr64.e_flags); + filedata->file_header.e_ehsize = BYTE_GET (ehdr64.e_ehsize); + filedata->file_header.e_phentsize = BYTE_GET (ehdr64.e_phentsize); + filedata->file_header.e_phnum = BYTE_GET (ehdr64.e_phnum); + filedata->file_header.e_shentsize = BYTE_GET (ehdr64.e_shentsize); + filedata->file_header.e_shnum = BYTE_GET (ehdr64.e_shnum); + filedata->file_header.e_shstrndx = BYTE_GET (ehdr64.e_shstrndx); + } + + if (filedata->file_header.e_shoff) + { + /* There may be some extensions in the first section header. Don't + bomb if we can't read it. */ + if (is_32bit_elf) + get_32bit_section_headers (filedata, TRUE); + else + get_64bit_section_headers (filedata, TRUE); + } + + return TRUE; +} + +static void +close_file (Filedata * filedata) +{ + if (filedata) + { + if (filedata->handle) + fclose (filedata->handle); + free (filedata); + } +} + +void +close_debug_file (void * data) +{ + close_file ((Filedata *) data); +} + +static Filedata * +open_file (const char * pathname) +{ + struct stat statbuf; + Filedata * filedata = NULL; + + if (stat (pathname, & statbuf) < 0 + || ! S_ISREG (statbuf.st_mode)) + goto fail; + + filedata = calloc (1, sizeof * filedata); + if (filedata == NULL) + goto fail; + + filedata->handle = fopen (pathname, "rb"); + if (filedata->handle == NULL) + goto fail; + + filedata->file_size = (bfd_size_type) statbuf.st_size; + filedata->file_name = pathname; + + if (! get_file_header (filedata)) + goto fail; + + if (filedata->file_header.e_shoff) + { + bfd_boolean res; + + /* Read the section headers again, this time for real. */ + if (is_32bit_elf) + res = get_32bit_section_headers (filedata, FALSE); + else + res = get_64bit_section_headers (filedata, FALSE); + + if (!res) + goto fail; + } + + return filedata; + + fail: + if (filedata) + { + if (filedata->handle) + fclose (filedata->handle); + free (filedata); + } + return NULL; +} + +void * +open_debug_file (const char * pathname) +{ + return open_file (pathname); +} + +/* Process one ELF object file according to the command line options. + This file may actually be stored in an archive. The file is + positioned at the start of the ELF object. Returns TRUE if no + problems were encountered, FALSE otherwise. */ + +static bfd_boolean +process_object (Filedata * filedata) +{ + Filedata * separates; + unsigned int i; + bfd_boolean res = TRUE; + + if (! get_file_header (filedata)) + { + error (_("%s: Failed to read file header\n"), filedata->file_name); + return FALSE; + } + + /* Initialise per file variables. */ + for (i = ARRAY_SIZE (version_info); i--;) + version_info[i] = 0; + + for (i = ARRAY_SIZE (dynamic_info); i--;) + dynamic_info[i] = 0; + dynamic_info_DT_GNU_HASH = 0; + + /* Process the file. */ + if (show_name) + printf (_("\nFile: %s\n"), filedata->file_name); + + /* Initialise the dump_sects array from the cmdline_dump_sects array. + Note we do this even if cmdline_dump_sects is empty because we + must make sure that the dump_sets array is zeroed out before each + object file is processed. */ + if (filedata->num_dump_sects > cmdline.num_dump_sects) + memset (filedata->dump_sects, 0, filedata->num_dump_sects * sizeof (* filedata->dump_sects)); + + if (cmdline.num_dump_sects > 0) + { + if (filedata->num_dump_sects == 0) + /* A sneaky way of allocating the dump_sects array. */ + request_dump_bynumber (filedata, cmdline.num_dump_sects, 0); + + assert (filedata->num_dump_sects >= cmdline.num_dump_sects); + memcpy (filedata->dump_sects, cmdline.dump_sects, + cmdline.num_dump_sects * sizeof (* filedata->dump_sects)); + } + + if (! process_file_header (filedata)) + return FALSE; + + if (! process_section_headers (filedata)) + { + /* Without loaded section headers we cannot process lots of things. */ + do_unwind = do_version = do_dump = do_arch = FALSE; + + if (! do_using_dynamic) + do_syms = do_dyn_syms = do_reloc = FALSE; + } + + if (! process_section_groups (filedata)) + /* Without loaded section groups we cannot process unwind. */ + do_unwind = FALSE; + + if (process_program_headers (filedata)) + process_dynamic_section (filedata); + else + res = FALSE; + + if (! process_relocs (filedata)) + res = FALSE; + + if (! process_unwind (filedata)) + res = FALSE; + + if (! process_symbol_table (filedata)) + res = FALSE; + + if (! process_syminfo (filedata)) + res = FALSE; + + if (! process_version_sections (filedata)) + res = FALSE; + + if (filedata->file_header.e_shstrndx != SHN_UNDEF) + separates = load_separate_debug_file (filedata, filedata->file_name); + else + separates = NULL; + + if (! process_section_contents (filedata)) + res = FALSE; + + if (separates) + { + if (! process_section_headers (separates)) + res = FALSE; + else if (! process_section_contents (separates)) + res = FALSE; + } + + if (! process_notes (filedata)) + res = FALSE; + + if (! process_gnu_liblist (filedata)) + res = FALSE; + + if (! process_arch_specific (filedata)) + res = FALSE; + + free (filedata->program_headers); + filedata->program_headers = NULL; + + free (filedata->section_headers); + filedata->section_headers = NULL; + + free (filedata->string_table); + filedata->string_table = NULL; + filedata->string_table_length = 0; + + if (dynamic_strings) + { + free (dynamic_strings); + dynamic_strings = NULL; + dynamic_strings_length = 0; + } + + if (dynamic_symbols) + { + free (dynamic_symbols); + dynamic_symbols = NULL; + num_dynamic_syms = 0; + } + + if (dynamic_syminfo) + { + free (dynamic_syminfo); + dynamic_syminfo = NULL; + } + + if (dynamic_section) + { + free (dynamic_section); + dynamic_section = NULL; + } + + if (section_headers_groups) + { + free (section_headers_groups); + section_headers_groups = NULL; + } + + if (section_groups) + { + struct group_list * g; + struct group_list * next; + + for (i = 0; i < group_count; i++) + { + for (g = section_groups [i].root; g != NULL; g = next) + { + next = g->next; + free (g); + } + } + + free (section_groups); + section_groups = NULL; + } + + free_debug_memory (); + + return res; +} + +/* Process an ELF archive. + On entry the file is positioned just after the ARMAG string. + Returns TRUE upon success, FALSE otherwise. */ + +static bfd_boolean +process_archive (Filedata * filedata, bfd_boolean is_thin_archive) +{ + struct archive_info arch; + struct archive_info nested_arch; + size_t got; + bfd_boolean ret = TRUE; + + show_name = TRUE; + + /* The ARCH structure is used to hold information about this archive. */ + arch.file_name = NULL; + arch.file = NULL; + arch.index_array = NULL; + arch.sym_table = NULL; + arch.longnames = NULL; + + /* The NESTED_ARCH structure is used as a single-item cache of information + about a nested archive (when members of a thin archive reside within + another regular archive file). */ + nested_arch.file_name = NULL; + nested_arch.file = NULL; + nested_arch.index_array = NULL; + nested_arch.sym_table = NULL; + nested_arch.longnames = NULL; + + if (setup_archive (&arch, filedata->file_name, filedata->handle, + is_thin_archive, do_archive_index) != 0) + { + ret = FALSE; + goto out; + } + + if (do_archive_index) + { + if (arch.sym_table == NULL) + error (_("%s: unable to dump the index as none was found\n"), filedata->file_name); + else + { + unsigned long i, l; + unsigned long current_pos; + + printf (_("Index of archive %s: (%lu entries, 0x%lx bytes in the symbol table)\n"), + filedata->file_name, (unsigned long) arch.index_num, arch.sym_size); + + current_pos = ftell (filedata->handle); + + for (i = l = 0; i < arch.index_num; i++) + { + if ((i == 0) || ((i > 0) && (arch.index_array[i] != arch.index_array[i - 1]))) + { + char * member_name; + + member_name = get_archive_member_name_at (&arch, arch.index_array[i], &nested_arch); + + if (member_name != NULL) + { + char * qualified_name = make_qualified_name (&arch, &nested_arch, member_name); + + if (qualified_name != NULL) + { + printf (_("Contents of binary %s at offset "), qualified_name); + (void) print_vma (arch.index_array[i], PREFIX_HEX); + putchar ('\n'); + free (qualified_name); + } + } + } + + if (l >= arch.sym_size) + { + error (_("%s: end of the symbol table reached before the end of the index\n"), + filedata->file_name); + ret = FALSE; + break; + } + /* PR 17531: file: 0b6630b2. */ + printf ("\t%.*s\n", (int) (arch.sym_size - l), arch.sym_table + l); + l += strnlen (arch.sym_table + l, arch.sym_size - l) + 1; + } + + if (arch.uses_64bit_indicies) + l = (l + 7) & ~ 7; + else + l += l & 1; + + if (l < arch.sym_size) + { + error (ngettext ("%s: %ld byte remains in the symbol table, " + "but without corresponding entries in " + "the index table\n", + "%s: %ld bytes remain in the symbol table, " + "but without corresponding entries in " + "the index table\n", + arch.sym_size - l), + filedata->file_name, arch.sym_size - l); + ret = FALSE; + } + + if (fseek (filedata->handle, current_pos, SEEK_SET) != 0) + { + error (_("%s: failed to seek back to start of object files in the archive\n"), + filedata->file_name); + ret = FALSE; + goto out; + } + } + + if (!do_dynamic && !do_syms && !do_reloc && !do_unwind && !do_sections + && !do_segments && !do_header && !do_dump && !do_version + && !do_histogram && !do_debugging && !do_arch && !do_notes + && !do_section_groups && !do_dyn_syms) + { + ret = TRUE; /* Archive index only. */ + goto out; + } + } + + while (1) + { + char * name; + size_t namelen; + char * qualified_name; + + /* Read the next archive header. */ + if (fseek (filedata->handle, arch.next_arhdr_offset, SEEK_SET) != 0) + { + error (_("%s: failed to seek to next archive header\n"), filedata->file_name); + return FALSE; + } + got = fread (&arch.arhdr, 1, sizeof arch.arhdr, filedata->handle); + if (got != sizeof arch.arhdr) + { + if (got == 0) + break; + error (_("%s: failed to read archive header\n"), filedata->file_name); + ret = FALSE; + break; + } + if (memcmp (arch.arhdr.ar_fmag, ARFMAG, 2) != 0) + { + error (_("%s: did not find a valid archive header\n"), arch.file_name); + ret = FALSE; + break; + } + + arch.next_arhdr_offset += sizeof arch.arhdr; + + archive_file_size = strtoul (arch.arhdr.ar_size, NULL, 10); + if (archive_file_size & 01) + ++archive_file_size; + + name = get_archive_member_name (&arch, &nested_arch); + if (name == NULL) + { + error (_("%s: bad archive file name\n"), filedata->file_name); + ret = FALSE; + break; + } + namelen = strlen (name); + + qualified_name = make_qualified_name (&arch, &nested_arch, name); + if (qualified_name == NULL) + { + error (_("%s: bad archive file name\n"), filedata->file_name); + ret = FALSE; + break; + } + + if (is_thin_archive && arch.nested_member_origin == 0) + { + /* This is a proxy for an external member of a thin archive. */ + Filedata * member_filedata; + char * member_file_name = adjust_relative_path + (filedata->file_name, name, namelen); + + if (member_file_name == NULL) + { + ret = FALSE; + break; + } + + member_filedata = open_file (member_file_name); + if (member_filedata == NULL) + { + error (_("Input file '%s' is not readable.\n"), member_file_name); + free (member_file_name); + ret = FALSE; + break; + } + + archive_file_offset = arch.nested_member_origin; + member_filedata->file_name = qualified_name; + + if (! process_object (member_filedata)) + ret = FALSE; + + close_file (member_filedata); + free (member_file_name); + } + else if (is_thin_archive) + { + Filedata thin_filedata; + + memset (&thin_filedata, 0, sizeof (thin_filedata)); + + /* PR 15140: Allow for corrupt thin archives. */ + if (nested_arch.file == NULL) + { + error (_("%s: contains corrupt thin archive: %s\n"), + filedata->file_name, name); + ret = FALSE; + break; + } + + /* This is a proxy for a member of a nested archive. */ + archive_file_offset = arch.nested_member_origin + sizeof arch.arhdr; + + /* The nested archive file will have been opened and setup by + get_archive_member_name. */ + if (fseek (nested_arch.file, archive_file_offset, SEEK_SET) != 0) + { + error (_("%s: failed to seek to archive member.\n"), nested_arch.file_name); + ret = FALSE; + break; + } + + thin_filedata.handle = nested_arch.file; + thin_filedata.file_name = qualified_name; + + if (! process_object (& thin_filedata)) + ret = FALSE; + } + else + { + archive_file_offset = arch.next_arhdr_offset; + arch.next_arhdr_offset += archive_file_size; + + filedata->file_name = qualified_name; + if (! process_object (filedata)) + ret = FALSE; + } + + if (filedata->dump_sects != NULL) + { + free (filedata->dump_sects); + filedata->dump_sects = NULL; + filedata->num_dump_sects = 0; + } + + free (qualified_name); + } + + out: + if (nested_arch.file != NULL) + fclose (nested_arch.file); + release_archive (&nested_arch); + release_archive (&arch); + + return ret; +} + +static bfd_boolean +process_file (char * file_name) +{ + Filedata * filedata = NULL; + struct stat statbuf; + char armag[SARMAG]; + bfd_boolean ret = TRUE; + + if (stat (file_name, &statbuf) < 0) + { + if (errno == ENOENT) + error (_("'%s': No such file\n"), file_name); + else + error (_("Could not locate '%s'. System error message: %s\n"), + file_name, strerror (errno)); + return FALSE; + } + + if (! S_ISREG (statbuf.st_mode)) + { + error (_("'%s' is not an ordinary file\n"), file_name); + return FALSE; + } + + filedata = calloc (1, sizeof * filedata); + if (filedata == NULL) + { + error (_("Out of memory allocating file data structure\n")); + return FALSE; + } + + filedata->file_name = file_name; + filedata->handle = fopen (file_name, "rb"); + if (filedata->handle == NULL) + { + error (_("Input file '%s' is not readable.\n"), file_name); + free (filedata); + return FALSE; + } + + if (fread (armag, SARMAG, 1, filedata->handle) != 1) + { + error (_("%s: Failed to read file's magic number\n"), file_name); + fclose (filedata->handle); + free (filedata); + return FALSE; + } + + filedata->file_size = (bfd_size_type) statbuf.st_size; + + if (memcmp (armag, ARMAG, SARMAG) == 0) + { + if (! process_archive (filedata, FALSE)) + ret = FALSE; + } + else if (memcmp (armag, ARMAGT, SARMAG) == 0) + { + if ( ! process_archive (filedata, TRUE)) + ret = FALSE; + } + else + { + if (do_archive_index) + error (_("File %s is not an archive so its index cannot be displayed.\n"), + file_name); + + rewind (filedata->handle); + archive_file_size = archive_file_offset = 0; + + if (! process_object (filedata)) + ret = FALSE; + } + + fclose (filedata->handle); + free (filedata); + + return ret; +} + +#ifdef SUPPORT_DISASSEMBLY +/* Needed by the i386 disassembler. For extra credit, someone could + fix this so that we insert symbolic addresses here, esp for GOT/PLT + symbols. */ + +void +print_address (unsigned int addr, FILE * outfile) +{ + fprintf (outfile,"0x%8.8x", addr); +} + +/* Needed by the i386 disassembler. */ + +void +db_task_printsym (unsigned int addr) +{ + print_address (addr, stderr); +} +#endif + +int +main (int argc, char ** argv) +{ + int err; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + expandargv (&argc, &argv); + + cmdline.file_name = ""; + parse_args (& cmdline, argc, argv); + + if (optind < (argc - 1)) + show_name = TRUE; + else if (optind >= argc) + { + warn (_("Nothing to do.\n")); + usage (stderr); + } + + err = FALSE; + while (optind < argc) + if (! process_file (argv[optind++])) + err = TRUE; + + if (cmdline.dump_sects != NULL) + free (cmdline.dump_sects); + + return err ? EXIT_FAILURE : EXIT_SUCCESS; +} diff --git a/support/sdbinutils/binutils/rename.c b/support/sdbinutils/binutils/rename.c new file mode 100644 index 0000000..5c3bfee --- /dev/null +++ b/support/sdbinutils/binutils/rename.c @@ -0,0 +1,212 @@ +/* rename.c -- rename a file, preserving symlinks. + Copyright (C) 1999-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" + +#ifdef HAVE_GOOD_UTIME_H +#include +#else /* ! HAVE_GOOD_UTIME_H */ +#ifdef HAVE_UTIMES +#include +#endif /* HAVE_UTIMES */ +#endif /* ! HAVE_GOOD_UTIME_H */ + +#if ! defined (_WIN32) || defined (__CYGWIN32__) +static int simple_copy (const char *, const char *); + +/* The number of bytes to copy at once. */ +#define COPY_BUF 8192 + +/* Copy file FROM to file TO, performing no translations. + Return 0 if ok, -1 if error. */ + +static int +simple_copy (const char *from, const char *to) +{ + int fromfd, tofd, nread; + int saved; + char buf[COPY_BUF]; + + fromfd = open (from, O_RDONLY | O_BINARY); + if (fromfd < 0) + return -1; +#ifdef O_CREAT + tofd = open (to, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0777); +#else + tofd = creat (to, 0777); +#endif + if (tofd < 0) + { + saved = errno; + close (fromfd); + errno = saved; + return -1; + } + while ((nread = read (fromfd, buf, sizeof buf)) > 0) + { + if (write (tofd, buf, nread) != nread) + { + saved = errno; + close (fromfd); + close (tofd); + errno = saved; + return -1; + } + } + saved = errno; + close (fromfd); + close (tofd); + if (nread < 0) + { + errno = saved; + return -1; + } + return 0; +} +#endif /* __CYGWIN32__ or not _WIN32 */ + +/* Set the times of the file DESTINATION to be the same as those in + STATBUF. */ + +void +set_times (const char *destination, const struct stat *statbuf) +{ + int result; + + { +#ifdef HAVE_GOOD_UTIME_H + struct utimbuf tb; + + tb.actime = statbuf->st_atime; + tb.modtime = statbuf->st_mtime; + result = utime (destination, &tb); +#else /* ! HAVE_GOOD_UTIME_H */ +#ifndef HAVE_UTIMES + long tb[2]; + + tb[0] = statbuf->st_atime; + tb[1] = statbuf->st_mtime; + result = utime (destination, tb); +#else /* HAVE_UTIMES */ + struct timeval tv[2]; + + tv[0].tv_sec = statbuf->st_atime; + tv[0].tv_usec = 0; + tv[1].tv_sec = statbuf->st_mtime; + tv[1].tv_usec = 0; + result = utimes (destination, tv); +#endif /* HAVE_UTIMES */ +#endif /* ! HAVE_GOOD_UTIME_H */ + } + + if (result != 0) + non_fatal (_("%s: cannot set time: %s"), destination, strerror (errno)); +} + +#ifndef S_ISLNK +#ifdef S_IFLNK +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#else +#define S_ISLNK(m) 0 +#define lstat stat +#endif +#endif + +/* Rename FROM to TO, copying if TO is a link. + Return 0 if ok, -1 if error. */ + +int +smart_rename (const char *from, const char *to, int preserve_dates ATTRIBUTE_UNUSED) +{ + bfd_boolean exists; + struct stat s; + int ret = 0; + + exists = lstat (to, &s) == 0; + +#if defined (_WIN32) && !defined (__CYGWIN32__) + /* Win32, unlike unix, will not erase `to' in `rename(from, to)' but + fail instead. Also, chown is not present. */ + + if (exists) + remove (to); + + ret = rename (from, to); + if (ret != 0) + { + /* We have to clean up here. */ + non_fatal (_("unable to rename '%s'; reason: %s"), to, strerror (errno)); + unlink (from); + } +#else + /* Use rename only if TO is not a symbolic link and has + only one hard link, and we have permission to write to it. */ + if (! exists + || (!S_ISLNK (s.st_mode) + && S_ISREG (s.st_mode) + && (s.st_mode & S_IWUSR) + && s.st_nlink == 1) + ) + { + ret = rename (from, to); + if (ret == 0) + { + if (exists) + { + /* Try to preserve the permission bits and ownership of + TO. First get the mode right except for the setuid + bit. Then change the ownership. Then fix the setuid + bit. We do the chmod before the chown because if the + chown succeeds, and we are a normal user, we won't be + able to do the chmod afterward. We don't bother to + fix the setuid bit first because that might introduce + a fleeting security problem, and because the chown + will clear the setuid bit anyhow. We only fix the + setuid bit if the chown succeeds, because we don't + want to introduce an unexpected setuid file owned by + the user running objcopy. */ + chmod (to, s.st_mode & 0777); + if (chown (to, s.st_uid, s.st_gid) >= 0) + chmod (to, s.st_mode & 07777); + } + } + else + { + /* We have to clean up here. */ + non_fatal (_("unable to rename '%s'; reason: %s"), to, strerror (errno)); + unlink (from); + } + } + else + { + ret = simple_copy (from, to); + if (ret != 0) + non_fatal (_("unable to copy file '%s'; reason: %s"), to, strerror (errno)); + + if (preserve_dates) + set_times (to, &s); + unlink (from); + } +#endif /* _WIN32 && !__CYGWIN32__ */ + + return ret; +} diff --git a/support/sdbinutils/binutils/resbin.c b/support/sdbinutils/binutils/resbin.c new file mode 100644 index 0000000..f7b83cf --- /dev/null +++ b/support/sdbinutils/binutils/resbin.c @@ -0,0 +1,2164 @@ +/* resbin.c -- manipulate the Windows binary resource format. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Support. + Rewritten by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + + +/* This file contains functions to convert between the binary resource + format and the internal structures that we want to use. The same + binary resource format is used in both res and COFF files. */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" +#include "libiberty.h" +#include "windres.h" + +/* Local functions. */ + +static void toosmall (const char *); + +static unichar *get_unicode (windres_bfd *, const bfd_byte *, rc_uint_type, rc_uint_type *); +static int get_resid (windres_bfd *, rc_res_id *, const bfd_byte *, rc_uint_type); +static rc_res_resource *bin_to_res_generic (windres_bfd *, enum rc_res_type, + const bfd_byte *, rc_uint_type); +static rc_res_resource *bin_to_res_cursor (windres_bfd *, const bfd_byte *, rc_uint_type); +static rc_res_resource *bin_to_res_menu (windres_bfd *,const bfd_byte *, rc_uint_type); +static rc_menuitem *bin_to_res_menuitems (windres_bfd *, const bfd_byte *, rc_uint_type, + rc_uint_type *); +static rc_menuitem *bin_to_res_menuexitems (windres_bfd *, const bfd_byte *, rc_uint_type, + rc_uint_type *); +static rc_res_resource *bin_to_res_dialog (windres_bfd *, const bfd_byte *, rc_uint_type); +static rc_res_resource *bin_to_res_string (windres_bfd *,const bfd_byte *, rc_uint_type); +static rc_res_resource *bin_to_res_fontdir (windres_bfd *, const bfd_byte *, rc_uint_type); +static rc_res_resource *bin_to_res_accelerators (windres_bfd *, const bfd_byte *, rc_uint_type); +static rc_res_resource *bin_to_res_rcdata (windres_bfd *, const bfd_byte *, rc_uint_type, int); +static rc_res_resource *bin_to_res_group_cursor (windres_bfd *, const bfd_byte *, rc_uint_type); +static rc_res_resource *bin_to_res_group_icon (windres_bfd *, const bfd_byte *, rc_uint_type); +static rc_res_resource *bin_to_res_version (windres_bfd *, const bfd_byte *, rc_uint_type); +static rc_res_resource *bin_to_res_userdata (windres_bfd *, const bfd_byte *, rc_uint_type); +static rc_res_resource *bin_to_res_toolbar (windres_bfd *, const bfd_byte *, rc_uint_type); +static void get_version_header (windres_bfd *, const bfd_byte *, rc_uint_type, const char *, + unichar **, rc_uint_type *, rc_uint_type *, rc_uint_type *, + rc_uint_type *); + +/* Given a resource type ID, a pointer to data, a length, return a + rc_res_resource structure which represents that resource. The caller + is responsible for initializing the res_info and coff_info fields + of the returned structure. */ + +rc_res_resource * +bin_to_res (windres_bfd *wrbfd, rc_res_id type, const bfd_byte *data, + rc_uint_type length) +{ + if (type.named) + return bin_to_res_userdata (wrbfd, data, length); + else + { + switch (type.u.id) + { + default: + return bin_to_res_userdata (wrbfd, data, length); + case RT_CURSOR: + return bin_to_res_cursor (wrbfd, data, length); + case RT_BITMAP: + return bin_to_res_generic (wrbfd, RES_TYPE_BITMAP, data, length); + case RT_ICON: + return bin_to_res_generic (wrbfd, RES_TYPE_ICON, data, length); + case RT_MENU: + return bin_to_res_menu (wrbfd, data, length); + case RT_DIALOG: + return bin_to_res_dialog (wrbfd, data, length); + case RT_STRING: + return bin_to_res_string (wrbfd, data, length); + case RT_FONTDIR: + return bin_to_res_fontdir (wrbfd, data, length); + case RT_FONT: + return bin_to_res_generic (wrbfd, RES_TYPE_FONT, data, length); + case RT_ACCELERATOR: + return bin_to_res_accelerators (wrbfd, data, length); + case RT_RCDATA: + return bin_to_res_rcdata (wrbfd, data, length, RES_TYPE_RCDATA); + case RT_MESSAGETABLE: + return bin_to_res_generic (wrbfd, RES_TYPE_MESSAGETABLE, data, length); + case RT_GROUP_CURSOR: + return bin_to_res_group_cursor (wrbfd, data, length); + case RT_GROUP_ICON: + return bin_to_res_group_icon (wrbfd, data, length); + case RT_VERSION: + return bin_to_res_version (wrbfd, data, length); + case RT_TOOLBAR: + return bin_to_res_toolbar (wrbfd, data, length); + + } + } +} + +/* Give an error if the binary data is too small. */ + +static void +toosmall (const char *msg) +{ + fatal (_("%s: not enough binary data"), msg); +} + +/* Swap in a NULL terminated unicode string. */ + +static unichar * +get_unicode (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length, + rc_uint_type *retlen) +{ + rc_uint_type c, i; + unichar *ret; + + c = 0; + while (1) + { + if (length < c * 2 + 2) + toosmall (_("null terminated unicode string")); + if (windres_get_16 (wrbfd, data + c * 2, 2) == 0) + break; + ++c; + } + + ret = (unichar *) res_alloc ((c + 1) * sizeof (unichar)); + + for (i = 0; i < c; i++) + ret[i] = windres_get_16 (wrbfd, data + i * 2, 2); + ret[i] = 0; + + if (retlen != NULL) + *retlen = c; + + return ret; +} + +/* Get a resource identifier. This returns the number of bytes used. */ + +static int +get_resid (windres_bfd *wrbfd, rc_res_id *id, const bfd_byte *data, + rc_uint_type length) +{ + rc_uint_type first; + + if (length < 2) + toosmall (_("resource ID")); + + first = windres_get_16 (wrbfd, data, 2); + if (first == 0xffff) + { + if (length < 4) + toosmall (_("resource ID")); + id->named = 0; + id->u.id = windres_get_16 (wrbfd, data + 2, 2); + return 4; + } + else + { + id->named = 1; + id->u.n.name = get_unicode (wrbfd, data, length, &id->u.n.length); + return id->u.n.length * 2 + 2; + } +} + +/* Convert a resource which just stores uninterpreted data from + binary. */ + +rc_res_resource * +bin_to_res_generic (windres_bfd *wrbfd ATTRIBUTE_UNUSED, enum rc_res_type type, + const bfd_byte *data, rc_uint_type length) +{ + rc_res_resource *r; + + r = (rc_res_resource *) res_alloc (sizeof (rc_res_resource)); + r->type = type; + r->u.data.data = data; + r->u.data.length = length; + + return r; +} + +/* Convert a cursor resource from binary. */ + +rc_res_resource * +bin_to_res_cursor (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +{ + rc_cursor *c; + rc_res_resource *r; + + if (length < 4) + toosmall (_("cursor")); + + c = (rc_cursor *) res_alloc (sizeof (rc_cursor)); + c->xhotspot = windres_get_16 (wrbfd, data, 2); + c->yhotspot = windres_get_16 (wrbfd, data + 2, 2); + c->length = length - 4; + c->data = data + 4; + + r = (rc_res_resource *) res_alloc (sizeof *r); + r->type = RES_TYPE_CURSOR; + r->u.cursor = c; + + return r; +} + +/* Convert a menu resource from binary. */ + +rc_res_resource * +bin_to_res_menu (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +{ + rc_res_resource *r; + rc_menu *m; + rc_uint_type version, got; + + r = (rc_res_resource *) res_alloc (sizeof *r); + r->type = RES_TYPE_MENU; + + m = (rc_menu *) res_alloc (sizeof (rc_menu)); + r->u.menu = m; + + if (length < 2) + toosmall (_("menu header")); + + version = windres_get_16 (wrbfd, data, 2); + + if (version == 0) + { + if (length < 4) + toosmall (_("menu header")); + m->help = 0; + m->items = bin_to_res_menuitems (wrbfd, data + 4, length - 4, &got); + } + else if (version == 1) + { + rc_uint_type offset; + + if (length < 8) + toosmall (_("menuex header")); + m->help = windres_get_32 (wrbfd, data + 4, 4); + offset = windres_get_16 (wrbfd, data + 2, 2); + if (offset + 4 >= length) + toosmall (_("menuex offset")); + m->items = bin_to_res_menuexitems (wrbfd, data + 4 + offset, + length - (4 + offset), &got); + } + else + fatal (_("unsupported menu version %d"), (int) version); + + return r; +} + +/* Convert menu items from binary. */ + +static rc_menuitem * +bin_to_res_menuitems (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length, + rc_uint_type *got) +{ + rc_menuitem *first, **pp; + + first = NULL; + pp = &first; + + *got = 0; + + while (length > 0) + { + rc_uint_type flags, slen, itemlen; + rc_uint_type stroff; + rc_menuitem *mi; + + if (length < 4) + toosmall (_("menuitem header")); + + mi = (rc_menuitem *) res_alloc (sizeof *mi); + mi->state = 0; + mi->help = 0; + + flags = windres_get_16 (wrbfd, data, 2); + mi->type = flags &~ (MENUITEM_POPUP | MENUITEM_ENDMENU); + + if ((flags & MENUITEM_POPUP) == 0) + stroff = 4; + else + stroff = 2; + + if (length < stroff + 2) + toosmall (_("menuitem header")); + + if (windres_get_16 (wrbfd, data + stroff, 2) == 0) + { + slen = 0; + mi->text = NULL; + } + else + mi->text = get_unicode (wrbfd, data + stroff, length - stroff, &slen); + + itemlen = stroff + slen * 2 + 2; + + if ((flags & MENUITEM_POPUP) == 0) + { + mi->popup = NULL; + mi->id = windres_get_16 (wrbfd, data + 2, 2); + } + else + { + rc_uint_type subread; + + mi->id = 0; + mi->popup = bin_to_res_menuitems (wrbfd, data + itemlen, length - itemlen, + &subread); + itemlen += subread; + } + + mi->next = NULL; + *pp = mi; + pp = &mi->next; + + data += itemlen; + length -= itemlen; + *got += itemlen; + + if ((flags & MENUITEM_ENDMENU) != 0) + return first; + } + + return first; +} + +/* Convert menuex items from binary. */ + +static rc_menuitem * +bin_to_res_menuexitems (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length, + rc_uint_type *got) +{ + rc_menuitem *first, **pp; + + first = NULL; + pp = &first; + + *got = 0; + + while (length > 0) + { + rc_uint_type flags, slen; + rc_uint_type itemlen; + rc_menuitem *mi; + + if (length < 16) + toosmall (_("menuitem header")); + + mi = (rc_menuitem *) res_alloc (sizeof (rc_menuitem)); + mi->type = windres_get_32 (wrbfd, data, 4); + mi->state = windres_get_32 (wrbfd, data + 4, 4); + mi->id = windres_get_32 (wrbfd, data + 8, 4); + + flags = windres_get_16 (wrbfd, data + 12, 2); + + if (windres_get_16 (wrbfd, data + 14, 2) == 0) + { + slen = 0; + mi->text = NULL; + } + else + mi->text = get_unicode (wrbfd, data + 14, length - 14, &slen); + + itemlen = 14 + slen * 2 + 2; + itemlen = (itemlen + 3) &~ 3; + + if ((flags & 1) == 0) + { + mi->popup = NULL; + mi->help = 0; + } + else + { + rc_uint_type subread; + + if (length < itemlen + 4) + toosmall (_("menuitem")); + mi->help = windres_get_32 (wrbfd, data + itemlen, 4); + itemlen += 4; + + mi->popup = bin_to_res_menuexitems (wrbfd, data + itemlen, + length - itemlen, &subread); + itemlen += subread; + } + + mi->next = NULL; + *pp = mi; + pp = &mi->next; + + data += itemlen; + length -= itemlen; + *got += itemlen; + + if ((flags & 0x80) != 0) + return first; + } + + return first; +} + +/* Convert a dialog resource from binary. */ + +static rc_res_resource * +bin_to_res_dialog (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +{ + rc_uint_type signature; + rc_dialog *d; + rc_uint_type c, sublen, i; + rc_uint_type off; + rc_dialog_control **pp; + rc_res_resource *r; + + if (length < 18) + toosmall (_("dialog header")); + + d = (rc_dialog *) res_alloc (sizeof (rc_dialog)); + + signature = windres_get_16 (wrbfd, data + 2, 2); + if (signature != 0xffff) + { + d->ex = NULL; + d->style = windres_get_32 (wrbfd, data, 4); + d->exstyle = windres_get_32 (wrbfd, data + 4, 4); + off = 8; + } + else + { + int version; + + version = windres_get_16 (wrbfd, data, 2); + if (version != 1) + fatal (_("unexpected DIALOGEX version %d"), version); + + d->ex = (rc_dialog_ex *) res_alloc (sizeof (rc_dialog_ex)); + d->ex->help = windres_get_32 (wrbfd, data + 4, 4); + d->exstyle = windres_get_32 (wrbfd, data + 8, 4); + d->style = windres_get_32 (wrbfd, data + 12, 4); + off = 16; + } + + if (length < off + 10) + toosmall (_("dialog header")); + + c = windres_get_16 (wrbfd, data + off, 2); + d->x = windres_get_16 (wrbfd, data + off + 2, 2); + d->y = windres_get_16 (wrbfd, data + off + 4, 2); + d->width = windres_get_16 (wrbfd, data + off + 6, 2); + d->height = windres_get_16 (wrbfd, data + off + 8, 2); + + off += 10; + + sublen = get_resid (wrbfd, &d->menu, data + off, length - off); + off += sublen; + + sublen = get_resid (wrbfd, &d->class, data + off, length - off); + off += sublen; + + d->caption = get_unicode (wrbfd, data + off, length - off, &sublen); + off += sublen * 2 + 2; + if (sublen == 0) + d->caption = NULL; + + if ((d->style & DS_SETFONT) == 0) + { + d->pointsize = 0; + d->font = NULL; + if (d->ex != NULL) + { + d->ex->weight = 0; + d->ex->italic = 0; + d->ex->charset = 1; /* Default charset. */ + } + } + else + { + if (length < off + 2) + toosmall (_("dialog font point size")); + + d->pointsize = windres_get_16 (wrbfd, data + off, 2); + off += 2; + + if (d->ex != NULL) + { + if (length < off + 4) + toosmall (_("dialogex font information")); + d->ex->weight = windres_get_16 (wrbfd, data + off, 2); + d->ex->italic = windres_get_8 (wrbfd, data + off + 2, 1); + d->ex->charset = windres_get_8 (wrbfd, data + off + 3, 1); + off += 4; + } + + d->font = get_unicode (wrbfd, data + off, length - off, &sublen); + off += sublen * 2 + 2; + } + + d->controls = NULL; + pp = &d->controls; + + for (i = 0; i < c; i++) + { + rc_dialog_control *dc; + int datalen; + + off = (off + 3) &~ 3; + + dc = (rc_dialog_control *) res_alloc (sizeof (rc_dialog_control)); + + if (d->ex == NULL) + { + if (length < off + 8) + toosmall (_("dialog control")); + + dc->style = windres_get_32 (wrbfd, data + off, 4); + dc->exstyle = windres_get_32 (wrbfd, data + off + 4, 4); + dc->help = 0; + off += 8; + } + else + { + if (length < off + 12) + toosmall (_("dialogex control")); + dc->help = windres_get_32 (wrbfd, data + off, 4); + dc->exstyle = windres_get_32 (wrbfd, data + off + 4, 4); + dc->style = windres_get_32 (wrbfd, data + off + 8, 4); + off += 12; + } + + if (length < off + (d->ex != NULL ? 2 : 0) + 10) + toosmall (_("dialog control")); + + dc->x = windres_get_16 (wrbfd, data + off, 2); + dc->y = windres_get_16 (wrbfd, data + off + 2, 2); + dc->width = windres_get_16 (wrbfd, data + off + 4, 2); + dc->height = windres_get_16 (wrbfd, data + off + 6, 2); + + if (d->ex != NULL) + dc->id = windres_get_32 (wrbfd, data + off + 8, 4); + else + dc->id = windres_get_16 (wrbfd, data + off + 8, 2); + + off += 10 + (d->ex != NULL ? 2 : 0); + + sublen = get_resid (wrbfd, &dc->class, data + off, length - off); + off += sublen; + + sublen = get_resid (wrbfd, &dc->text, data + off, length - off); + off += sublen; + + if (length < off + 2) + toosmall (_("dialog control end")); + + datalen = windres_get_16 (wrbfd, data + off, 2); + off += 2; + + if (datalen == 0) + dc->data = NULL; + else + { + if (length < off + datalen) + toosmall (_("dialog control data")); + + dc->data = ((rc_rcdata_item *) + res_alloc (sizeof (rc_rcdata_item))); + dc->data->next = NULL; + dc->data->type = RCDATA_BUFFER; + dc->data->u.buffer.length = datalen; + dc->data->u.buffer.data = data + off; + + off += datalen; + } + + dc->next = NULL; + *pp = dc; + pp = &dc->next; + } + + r = (rc_res_resource *) res_alloc (sizeof *r); + r->type = RES_TYPE_DIALOG; + r->u.dialog = d; + + return r; +} + +/* Convert a stringtable resource from binary. */ + +static rc_res_resource * +bin_to_res_string (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +{ + rc_stringtable *st; + int i; + rc_res_resource *r; + + st = (rc_stringtable *) res_alloc (sizeof (rc_stringtable)); + + for (i = 0; i < 16; i++) + { + unsigned int slen; + + if (length < 2) + toosmall (_("stringtable string length")); + slen = windres_get_16 (wrbfd, data, 2); + st->strings[i].length = slen; + + if (slen > 0) + { + unichar *s; + unsigned int j; + + if (length < 2 + 2 * slen) + toosmall (_("stringtable string")); + + s = (unichar *) res_alloc (slen * sizeof (unichar)); + st->strings[i].string = s; + + for (j = 0; j < slen; j++) + s[j] = windres_get_16 (wrbfd, data + 2 + j * 2, 2); + } + + data += 2 + 2 * slen; + length -= 2 + 2 * slen; + } + + r = (rc_res_resource *) res_alloc (sizeof *r); + r->type = RES_TYPE_STRINGTABLE; + r->u.stringtable = st; + + return r; +} + +/* Convert a fontdir resource from binary. */ + +static rc_res_resource * +bin_to_res_fontdir (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +{ + rc_uint_type c, i; + rc_fontdir *first, **pp; + rc_res_resource *r; + + if (length < 2) + toosmall (_("fontdir header")); + + c = windres_get_16 (wrbfd, data, 2); + + first = NULL; + pp = &first; + + for (i = 0; i < c; i++) + { + const struct bin_fontdir_item *bfi; + rc_fontdir *fd; + unsigned int off; + + if (length < 56) + toosmall (_("fontdir")); + + bfi = (const struct bin_fontdir_item *) data; + fd = (rc_fontdir *) res_alloc (sizeof *fd); + fd->index = windres_get_16 (wrbfd, bfi->index, 2); + + /* To work out the length of the fontdir data, we must get the + length of the device name and face name strings, even though + we don't store them in the rc_fontdir. The + documentation says that these are NULL terminated char + strings, not Unicode strings. */ + + off = 56; + + while (off < length && data[off] != '\0') + ++off; + if (off >= length) + toosmall (_("fontdir device name")); + ++off; + + while (off < length && data[off] != '\0') + ++off; + if (off >= length) + toosmall (_("fontdir face name")); + ++off; + + fd->length = off; + fd->data = data; + + fd->next = NULL; + *pp = fd; + pp = &fd->next; + + /* The documentation does not indicate that any rounding is + required. */ + + data += off; + length -= off; + } + + r = (rc_res_resource *) res_alloc (sizeof *r); + r->type = RES_TYPE_FONTDIR; + r->u.fontdir = first; + + return r; +} + +/* Convert an accelerators resource from binary. */ + +static rc_res_resource * +bin_to_res_accelerators (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +{ + rc_accelerator *first, **pp; + rc_res_resource *r; + + first = NULL; + pp = &first; + + while (1) + { + rc_accelerator *a; + + if (length < 8) + toosmall (_("accelerator")); + + a = (rc_accelerator *) res_alloc (sizeof (rc_accelerator)); + + a->flags = windres_get_16 (wrbfd, data, 2); + a->key = windres_get_16 (wrbfd, data + 2, 2); + a->id = windres_get_16 (wrbfd, data + 4, 2); + + a->next = NULL; + *pp = a; + pp = &a->next; + + if ((a->flags & ACC_LAST) != 0) + break; + + data += 8; + length -= 8; + } + + r = (rc_res_resource *) res_alloc (sizeof (rc_res_resource)); + r->type = RES_TYPE_ACCELERATOR; + r->u.acc = first; + + return r; +} + +/* Convert an rcdata resource from binary. */ + +static rc_res_resource * +bin_to_res_rcdata (windres_bfd *wrbfd ATTRIBUTE_UNUSED, const bfd_byte *data, + rc_uint_type length, int rctyp) +{ + rc_rcdata_item *ri; + rc_res_resource *r; + + ri = (rc_rcdata_item *) res_alloc (sizeof (rc_rcdata_item)); + + ri->next = NULL; + ri->type = RCDATA_BUFFER; + ri->u.buffer.length = length; + ri->u.buffer.data = data; + + r = (rc_res_resource *) res_alloc (sizeof *r); + r->type = rctyp; + r->u.rcdata = ri; + + return r; +} + +/* Convert a group cursor resource from binary. */ + +static rc_res_resource * +bin_to_res_group_cursor (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +{ + int type, c, i; + rc_group_cursor *first, **pp; + rc_res_resource *r; + + if (length < 6) + toosmall (_("group cursor header")); + + type = windres_get_16 (wrbfd, data + 2, 2); + if (type != 2) + fatal (_("unexpected group cursor type %d"), type); + + c = windres_get_16 (wrbfd, data + 4, 2); + + data += 6; + length -= 6; + + first = NULL; + pp = &first; + + for (i = 0; i < c; i++) + { + rc_group_cursor *gc; + + if (length < 14) + toosmall (_("group cursor")); + + gc = (rc_group_cursor *) res_alloc (sizeof *gc); + + gc->width = windres_get_16 (wrbfd, data, 2); + gc->height = windres_get_16 (wrbfd, data + 2, 2); + gc->planes = windres_get_16 (wrbfd, data + 4, 2); + gc->bits = windres_get_16 (wrbfd, data + 6, 2); + gc->bytes = windres_get_32 (wrbfd, data + 8, 4); + gc->index = windres_get_16 (wrbfd, data + 12, 2); + + gc->next = NULL; + *pp = gc; + pp = &gc->next; + + data += 14; + length -= 14; + } + + r = (rc_res_resource *) res_alloc (sizeof (rc_res_resource)); + r->type = RES_TYPE_GROUP_CURSOR; + r->u.group_cursor = first; + + return r; +} + +/* Convert a group icon resource from binary. */ + +static rc_res_resource * +bin_to_res_group_icon (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +{ + int type, c, i; + rc_group_icon *first, **pp; + rc_res_resource *r; + + if (length < 6) + toosmall (_("group icon header")); + + type = windres_get_16 (wrbfd, data + 2, 2); + if (type != 1) + fatal (_("unexpected group icon type %d"), type); + + c = windres_get_16 (wrbfd, data + 4, 2); + + data += 6; + length -= 6; + + first = NULL; + pp = &first; + + for (i = 0; i < c; i++) + { + rc_group_icon *gi; + + if (length < 14) + toosmall (_("group icon")); + + gi = (rc_group_icon *) res_alloc (sizeof (rc_group_icon)); + + gi->width = windres_get_8 (wrbfd, data, 1); + gi->height = windres_get_8 (wrbfd, data + 1, 1); + gi->colors = windres_get_8 (wrbfd, data + 2, 1); + gi->planes = windres_get_16 (wrbfd, data + 4, 2); + gi->bits = windres_get_16 (wrbfd, data + 6, 2); + gi->bytes = windres_get_32 (wrbfd, data + 8, 4); + gi->index = windres_get_16 (wrbfd, data + 12, 2); + + gi->next = NULL; + *pp = gi; + pp = &gi->next; + + data += 14; + length -= 14; + } + + r = (rc_res_resource *) res_alloc (sizeof *r); + r->type = RES_TYPE_GROUP_ICON; + r->u.group_icon = first; + + return r; +} + +/* Extract data from a version header. If KEY is not NULL, then the + key must be KEY; otherwise, the key is returned in *PKEY. This + sets *LEN to the total length, *VALLEN to the value length, *TYPE + to the type, and *OFF to the offset to the children. */ + +static void +get_version_header (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length, + const char *key, unichar **pkey, + rc_uint_type *len, rc_uint_type *vallen, rc_uint_type *type, + rc_uint_type *off) +{ + if (length < 8) + toosmall (key); + + *len = (windres_get_16 (wrbfd, data, 2) + 3) & ~3; + *vallen = windres_get_16 (wrbfd, data + 2, 2); + *type = windres_get_16 (wrbfd, data + 4, 2); + + *off = 6; + + length -= 6; + data += 6; + + if (key == NULL) + { + rc_uint_type sublen; + + *pkey = get_unicode (wrbfd, data, length, &sublen); + *off += (sublen + 1) * sizeof (unichar); + } + else + { + while (1) + { + if (length < 2) + toosmall (key); + if (windres_get_16 (wrbfd, data, 2) != (bfd_byte) *key) + fatal (_("unexpected version string")); + + *off += 2; + length -= 2; + data += 2; + + if (*key == '\0') + break; + + ++key; + } + } + + *off = (*off + 3) &~ 3; +} + +/* Convert a version resource from binary. */ + +static rc_res_resource * +bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +{ + rc_uint_type verlen, vallen, type, off; + rc_fixed_versioninfo *fi; + rc_ver_info *first, **pp; + rc_versioninfo *v; + rc_res_resource *r; + + get_version_header (wrbfd, data, length, "VS_VERSION_INFO", + (unichar **) NULL, &verlen, &vallen, &type, &off); + + /* PR 17512: The verlen field does not include padding length. */ + if (verlen > length) + fatal (_("version length %lu greater than resource length %lu"), + (unsigned long) verlen, (unsigned long) length); + + if (type != 0) + fatal (_("unexpected version type %d"), (int) type); + + data += off; + length -= off; + + if (vallen == 0) + fi = NULL; + else + { + unsigned long signature, fiv; + + if (vallen != 52) + fatal (_("unexpected fixed version information length %ld"), (long) vallen); + + if (length < 52) + toosmall (_("fixed version info")); + + signature = windres_get_32 (wrbfd, data, 4); + if (signature != 0xfeef04bd) + fatal (_("unexpected fixed version signature %lu"), signature); + + fiv = windres_get_32 (wrbfd, data + 4, 4); + if (fiv != 0 && fiv != 0x10000) + fatal (_("unexpected fixed version info version %lu"), fiv); + + fi = (rc_fixed_versioninfo *) res_alloc (sizeof (rc_fixed_versioninfo)); + + fi->file_version_ms = windres_get_32 (wrbfd, data + 8, 4); + fi->file_version_ls = windres_get_32 (wrbfd, data + 12, 4); + fi->product_version_ms = windres_get_32 (wrbfd, data + 16, 4); + fi->product_version_ls = windres_get_32 (wrbfd, data + 20, 4); + fi->file_flags_mask = windres_get_32 (wrbfd, data + 24, 4); + fi->file_flags = windres_get_32 (wrbfd, data + 28, 4); + fi->file_os = windres_get_32 (wrbfd, data + 32, 4); + fi->file_type = windres_get_32 (wrbfd, data + 36, 4); + fi->file_subtype = windres_get_32 (wrbfd, data + 40, 4); + fi->file_date_ms = windres_get_32 (wrbfd, data + 44, 4); + fi->file_date_ls = windres_get_32 (wrbfd, data + 48, 4); + + data += 52; + length -= 52; + } + + first = NULL; + pp = &first; + + while (length > 0) + { + rc_ver_info *vi; + int ch; + + if (length < 8) + toosmall (_("version var info")); + + vi = (rc_ver_info *) res_alloc (sizeof (rc_ver_info)); + + ch = windres_get_16 (wrbfd, data + 6, 2); + + if (ch == 'S') + { + rc_ver_stringtable **ppvst; + + vi->type = VERINFO_STRING; + + get_version_header (wrbfd, data, length, "StringFileInfo", + (unichar **) NULL, &verlen, &vallen, &type, + &off); + + if (vallen != 0) + fatal (_("unexpected stringfileinfo value length %ld"), (long) vallen); + + data += off; + length -= off; + + verlen -= off; + + vi->u.string.stringtables = NULL; + ppvst = &vi->u.string.stringtables; + + while (verlen > 0) + { + rc_ver_stringtable *vst; + rc_uint_type stverlen; + rc_ver_stringinfo **ppvs; + + if (length < 8) + toosmall (_("version stringtable")); + + vst = (rc_ver_stringtable *) res_alloc (sizeof (rc_ver_stringtable)); + + get_version_header (wrbfd, data, length, (const char *) NULL, + &vst->language, &stverlen, &vallen, &type, &off); + + if (vallen != 0) + fatal (_("unexpected version stringtable value length %ld"), (long) vallen); + + data += off; + length -= off; + verlen -= off; + + stverlen -= off; + + vst->strings = NULL; + ppvs = &vst->strings; + + while (stverlen > 0) + { + rc_ver_stringinfo *vs; + rc_uint_type sverlen, vslen, valoff; + + if (length < 8) + toosmall (_("version string")); + + vs = (rc_ver_stringinfo *) res_alloc (sizeof (rc_ver_stringinfo)); + + get_version_header (wrbfd, data, length, (const char *) NULL, + &vs->key, &sverlen, &vallen, &type, &off); + + data += off; + length -= off; + + vs->value = get_unicode (wrbfd, data, length, &vslen); + valoff = vslen * 2 + 2; + valoff = (valoff + 3) & ~3; + + if (off + valoff != sverlen) + fatal (_("unexpected version string length %ld != %ld + %ld"), + (long) sverlen, (long) off, (long) valoff); + + data += valoff; + length -= valoff; + + if (stverlen < sverlen) + fatal (_("unexpected version string length %ld < %ld"), + (long) verlen, (long) sverlen); + stverlen -= sverlen; + verlen -= sverlen; + + vs->next = NULL; + *ppvs = vs; + ppvs = &vs->next; + } + + vst->next = NULL; + *ppvst = vst; + ppvst = &vst->next; + } + } + else if (ch == 'V') + { + rc_ver_varinfo **ppvv; + + vi->type = VERINFO_VAR; + + get_version_header (wrbfd, data, length, "VarFileInfo", + (unichar **) NULL, &verlen, &vallen, &type, + &off); + + if (vallen != 0) + fatal (_("unexpected varfileinfo value length %ld"), (long) vallen); + + data += off; + length -= off; + + get_version_header (wrbfd, data, length, (const char *) NULL, + &vi->u.var.key, &verlen, &vallen, &type, &off); + + data += off; + length -= off; + + vi->u.var.var = NULL; + ppvv = &vi->u.var.var; + + while (vallen > 0) + { + rc_ver_varinfo *vv; + + if (length < 4) + toosmall (_("version varfileinfo")); + + vv = (rc_ver_varinfo *) res_alloc (sizeof (rc_ver_varinfo)); + + vv->language = windres_get_16 (wrbfd, data, 2); + vv->charset = windres_get_16 (wrbfd, data + 2, 2); + + vv->next = NULL; + *ppvv = vv; + ppvv = &vv->next; + + data += 4; + length -= 4; + + if (vallen < 4) + fatal (_("unexpected version value length %ld"), (long) vallen); + + vallen -= 4; + } + } + else if (ch == 0) + { + if (length == 8) + /* Padding - skip. */ + break; + fatal (_("nul bytes found in version string")); + } + else + fatal (_("unexpected version string character: %x"), ch); + + vi->next = NULL; + *pp = vi; + pp = &vi->next; + } + + v = (rc_versioninfo *) res_alloc (sizeof (rc_versioninfo)); + v->fixed = fi; + v->var = first; + + r = (rc_res_resource *) res_alloc (sizeof *r); + r->type = RES_TYPE_VERSIONINFO; + r->u.versioninfo = v; + + return r; +} + +/* Convert an arbitrary user defined resource from binary. */ + +static rc_res_resource * +bin_to_res_userdata (windres_bfd *wrbfd ATTRIBUTE_UNUSED, const bfd_byte *data, + rc_uint_type length) +{ + rc_rcdata_item *ri; + rc_res_resource *r; + + ri = (rc_rcdata_item *) res_alloc (sizeof (rc_rcdata_item)); + + ri->next = NULL; + ri->type = RCDATA_BUFFER; + ri->u.buffer.length = length; + ri->u.buffer.data = data; + + r = (rc_res_resource *) res_alloc (sizeof *r); + r->type = RES_TYPE_USERDATA; + r->u.rcdata = ri; + + return r; +} + +static rc_res_resource * +bin_to_res_toolbar (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +{ + rc_toolbar *ri; + rc_res_resource *r; + rc_uint_type i; + + ri = (rc_toolbar *) res_alloc (sizeof (rc_toolbar)); + ri->button_width = windres_get_32 (wrbfd, data, 4); + ri->button_height = windres_get_32 (wrbfd, data + 4, 4); + ri->nitems = windres_get_32 (wrbfd, data + 8, 4); + ri->items = NULL; + + data += 12; + length -= 12; + for (i=0 ; i < ri->nitems; i++) + { + rc_toolbar_item *it; + it = (rc_toolbar_item *) res_alloc (sizeof (rc_toolbar_item)); + it->id.named = 0; + it->id.u.id = (int) windres_get_32 (wrbfd, data, 4); + it->prev = it->next = NULL; + data += 4; + length -= 4; + if(ri->items) { + rc_toolbar_item *ii = ri->items; + while (ii->next != NULL) + ii = ii->next; + it->prev = ii; + ii->next = it; + } + else + ri->items = it; + } + r = (rc_res_resource *) res_alloc (sizeof *r); + r->type = RES_TYPE_TOOLBAR; + r->u.toolbar = ri; + return r; +} + + +/* Local functions used to convert resources to binary format. */ + +static rc_uint_type resid_to_bin (windres_bfd *, rc_uint_type, rc_res_id); +static rc_uint_type unicode_to_bin (windres_bfd *, rc_uint_type, const unichar *); +static rc_uint_type res_to_bin_accelerator (windres_bfd *, rc_uint_type, const rc_accelerator *); +static rc_uint_type res_to_bin_cursor (windres_bfd *, rc_uint_type, const rc_cursor *); +static rc_uint_type res_to_bin_group_cursor (windres_bfd *, rc_uint_type, const rc_group_cursor *); +static rc_uint_type res_to_bin_dialog (windres_bfd *, rc_uint_type, const rc_dialog *); +static rc_uint_type res_to_bin_fontdir (windres_bfd *, rc_uint_type, const rc_fontdir *); +static rc_uint_type res_to_bin_group_icon (windres_bfd *, rc_uint_type, const rc_group_icon *); +static rc_uint_type res_to_bin_menu (windres_bfd *, rc_uint_type, const rc_menu *); +static rc_uint_type res_to_bin_menuitems (windres_bfd *, rc_uint_type, const rc_menuitem *); +static rc_uint_type res_to_bin_menuexitems (windres_bfd *, rc_uint_type, const rc_menuitem *); +static rc_uint_type res_to_bin_rcdata (windres_bfd *, rc_uint_type, const rc_rcdata_item *); +static rc_uint_type res_to_bin_stringtable (windres_bfd *, rc_uint_type, const rc_stringtable *); +static rc_uint_type string_to_unicode_bin (windres_bfd *, rc_uint_type, const char *); +static rc_uint_type res_to_bin_toolbar (windres_bfd *, rc_uint_type, rc_toolbar *tb); +static rc_uint_type res_to_bin_versioninfo (windres_bfd *, rc_uint_type, const rc_versioninfo *); +static rc_uint_type res_to_bin_generic (windres_bfd *, rc_uint_type, rc_uint_type, + const bfd_byte *); + +/* Convert a resource to binary. */ + +rc_uint_type +res_to_bin (windres_bfd *wrbfd, rc_uint_type off, const rc_res_resource *res) +{ + switch (res->type) + { + case RES_TYPE_BITMAP: + case RES_TYPE_FONT: + case RES_TYPE_ICON: + case RES_TYPE_MESSAGETABLE: + return res_to_bin_generic (wrbfd, off, res->u.data.length, res->u.data.data); + case RES_TYPE_ACCELERATOR: + return res_to_bin_accelerator (wrbfd, off, res->u.acc); + case RES_TYPE_CURSOR: + return res_to_bin_cursor (wrbfd, off, res->u.cursor); + case RES_TYPE_GROUP_CURSOR: + return res_to_bin_group_cursor (wrbfd, off, res->u.group_cursor); + case RES_TYPE_DIALOG: + return res_to_bin_dialog (wrbfd, off, res->u.dialog); + case RES_TYPE_FONTDIR: + return res_to_bin_fontdir (wrbfd, off, res->u.fontdir); + case RES_TYPE_GROUP_ICON: + return res_to_bin_group_icon (wrbfd, off, res->u.group_icon); + case RES_TYPE_MENU: + return res_to_bin_menu (wrbfd, off, res->u.menu); + case RES_TYPE_STRINGTABLE: + return res_to_bin_stringtable (wrbfd, off, res->u.stringtable); + case RES_TYPE_VERSIONINFO: + return res_to_bin_versioninfo (wrbfd, off, res->u.versioninfo); + case RES_TYPE_TOOLBAR: + return res_to_bin_toolbar (wrbfd, off, res->u.toolbar); + case RES_TYPE_USERDATA: + case RES_TYPE_RCDATA: + default: + return res_to_bin_rcdata (wrbfd, off, res->u.rcdata); + } +} + +/* Convert a resource ID to binary. This always returns exactly one + bindata structure. */ + +static rc_uint_type +resid_to_bin (windres_bfd *wrbfd, rc_uint_type off, rc_res_id id) +{ + if (! id.named) + { + if (wrbfd) + { + struct bin_res_id bri; + + windres_put_16 (wrbfd, bri.sig, 0xffff); + windres_put_16 (wrbfd, bri.id, id.u.id); + set_windres_bfd_content (wrbfd, &bri, off, BIN_RES_ID); + } + off += BIN_RES_ID; + } + else + { + rc_uint_type len = (id.u.n.name ? unichar_len (id.u.n.name) : 0); + if (wrbfd) + { + bfd_byte *d = (bfd_byte *) reswr_alloc ((len + 1) * sizeof (unichar)); + rc_uint_type i; + for (i = 0; i < len; i++) + windres_put_16 (wrbfd, d + (i * sizeof (unichar)), id.u.n.name[i]); + windres_put_16 (wrbfd, d + (len * sizeof (unichar)), 0); + set_windres_bfd_content (wrbfd, d, off, (len + 1) * sizeof (unichar)); + } + off += (rc_uint_type) ((len + 1) * sizeof (unichar)); + } + return off; +} + +/* Convert a null terminated unicode string to binary. This always + returns exactly one bindata structure. */ + +static rc_uint_type +unicode_to_bin (windres_bfd *wrbfd, rc_uint_type off, const unichar *str) +{ + rc_uint_type len = 0; + + if (str != NULL) + len = unichar_len (str); + + if (wrbfd) + { + bfd_byte *d; + rc_uint_type i; + d = (bfd_byte *) reswr_alloc ( (len + 1) * sizeof (unichar)); + for (i = 0; i < len; i++) + windres_put_16 (wrbfd, d + (i * sizeof (unichar)), str[i]); + windres_put_16 (wrbfd, d + (len * sizeof (unichar)), 0); + set_windres_bfd_content (wrbfd, d, off, (len + 1) * sizeof (unichar)); + } + off += (rc_uint_type) ((len + 1) * sizeof (unichar)); + + return off; +} + +/* Convert an accelerator resource to binary. */ + +static rc_uint_type +res_to_bin_accelerator (windres_bfd *wrbfd, rc_uint_type off, + const rc_accelerator *accelerators) +{ + const rc_accelerator *a; + + for (a = accelerators; a != NULL; a = a->next) + { + if (wrbfd) + { + struct bin_accelerator ba; + + windres_put_16 (wrbfd, ba.flags, a->flags | (a->next != NULL ? 0 : ACC_LAST)); + windres_put_16 (wrbfd, ba.key, a->key); + windres_put_16 (wrbfd, ba.id, a->id); + windres_put_16 (wrbfd, ba.pad, 0); + set_windres_bfd_content (wrbfd, &ba, off, BIN_ACCELERATOR_SIZE); + } + off += BIN_ACCELERATOR_SIZE; + } + return off; +} + +/* Convert a cursor resource to binary. */ + +static rc_uint_type +res_to_bin_cursor (windres_bfd *wrbfd, rc_uint_type off, const rc_cursor *c) +{ + if (wrbfd) + { + struct bin_cursor bc; + + windres_put_16 (wrbfd, bc.xhotspot, c->xhotspot); + windres_put_16 (wrbfd, bc.yhotspot, c->yhotspot); + set_windres_bfd_content (wrbfd, &bc, off, BIN_CURSOR_SIZE); + if (c->length) + set_windres_bfd_content (wrbfd, c->data, off + BIN_CURSOR_SIZE, c->length); + } + off = (off + BIN_CURSOR_SIZE + (rc_uint_type) c->length); + return off; +} + +/* Convert a group cursor resource to binary. */ + +static rc_uint_type +res_to_bin_group_cursor (windres_bfd *wrbfd, rc_uint_type off, + const rc_group_cursor *group_cursors) +{ + int c = 0; + const rc_group_cursor *gc; + struct bin_group_cursor bgc; + struct bin_group_cursor_item bgci; + rc_uint_type start = off; + + off += BIN_GROUP_CURSOR_SIZE; + + for (c = 0, gc = group_cursors; gc != NULL; gc = gc->next, c++) + { + if (wrbfd) + { + windres_put_16 (wrbfd, bgci.width, gc->width); + windres_put_16 (wrbfd, bgci.height, gc->height); + windres_put_16 (wrbfd, bgci.planes, gc->planes); + windres_put_16 (wrbfd, bgci.bits, gc->bits); + windres_put_32 (wrbfd, bgci.bytes, gc->bytes); + windres_put_16 (wrbfd, bgci.index, gc->index); + set_windres_bfd_content (wrbfd, &bgci, off, BIN_GROUP_CURSOR_ITEM_SIZE); + } + + off += BIN_GROUP_CURSOR_ITEM_SIZE; + } + if (wrbfd) + { + windres_put_16 (wrbfd, bgc.sig1, 0); + windres_put_16 (wrbfd, bgc.sig2, 2); + windres_put_16 (wrbfd, bgc.nitems, c); + set_windres_bfd_content (wrbfd, &bgc, start, BIN_GROUP_CURSOR_SIZE); + } + return off; +} + +/* Convert a dialog resource to binary. */ + +static rc_uint_type +res_to_bin_dialog (windres_bfd *wrbfd, rc_uint_type off, const rc_dialog *dialog) +{ + rc_uint_type off_delta; + rc_uint_type start, marker; + int dialogex; + int c; + rc_dialog_control *dc; + struct bin_dialogex bdx; + struct bin_dialog bd; + + off_delta = off; + start = off; + dialogex = extended_dialog (dialog); + + if (wrbfd) + { + if (! dialogex) + { + windres_put_32 (wrbfd, bd.style, dialog->style); + windres_put_32 (wrbfd, bd.exstyle, dialog->exstyle); + windres_put_16 (wrbfd, bd.x, dialog->x); + windres_put_16 (wrbfd, bd.y, dialog->y); + windres_put_16 (wrbfd, bd.width, dialog->width); + windres_put_16 (wrbfd, bd.height, dialog->height); + } + else + { + windres_put_16 (wrbfd, bdx.sig1, 1); + windres_put_16 (wrbfd, bdx.sig2, 0xffff); + windres_put_32 (wrbfd, bdx.help, (dialog->ex ? dialog->ex->help : 0)); + windres_put_32 (wrbfd, bdx.exstyle, dialog->exstyle); + windres_put_32 (wrbfd, bdx.style, dialog->style); + windres_put_16 (wrbfd, bdx.x, dialog->x); + windres_put_16 (wrbfd, bdx.y, dialog->y); + windres_put_16 (wrbfd, bdx.width, dialog->width); + windres_put_16 (wrbfd, bdx.height, dialog->height); + } + } + + off += (dialogex != 0 ? BIN_DIALOGEX_SIZE : BIN_DIALOG_SIZE); + + off = resid_to_bin (wrbfd, off, dialog->menu); + off = resid_to_bin (wrbfd, off, dialog->class); + off = unicode_to_bin (wrbfd, off, dialog->caption); + + if ((dialog->style & DS_SETFONT) != 0) + { + if (wrbfd) + { + if (! dialogex) + { + struct bin_dialogfont bdf; + windres_put_16 (wrbfd, bdf.pointsize, dialog->pointsize); + set_windres_bfd_content (wrbfd, &bdf, off, BIN_DIALOGFONT_SIZE); + } + else + { + struct bin_dialogexfont bdxf; + windres_put_16 (wrbfd, bdxf.pointsize, dialog->pointsize); + windres_put_16 (wrbfd, bdxf.weight, (dialog->ex == NULL ? 0 : dialog->ex->weight)); + windres_put_8 (wrbfd, bdxf.italic, (dialog->ex == NULL ? 0 : dialog->ex->italic)); + windres_put_8 (wrbfd, bdxf.charset, (dialog->ex == NULL ? 1 : dialog->ex->charset)); + set_windres_bfd_content (wrbfd, &bdxf, off, BIN_DIALOGEXFONT_SIZE); + } + } + off += (dialogex ? BIN_DIALOGEXFONT_SIZE : BIN_DIALOGFONT_SIZE); + off = unicode_to_bin (wrbfd, off, dialog->font); + } + for (c = 0, dc = dialog->controls; dc != NULL; dc = dc->next, c++) + { + bfd_byte dc_rclen[2]; + + off += (4 - ((off - off_delta) & 3)) & 3; + if (wrbfd) + { + if (! dialogex) + { + struct bin_dialog_control bdc; + + windres_put_32 (wrbfd, bdc.style, dc->style); + windres_put_32 (wrbfd, bdc.exstyle, dc->exstyle); + windres_put_16 (wrbfd, bdc.x, dc->x); + windres_put_16 (wrbfd, bdc.y, dc->y); + windres_put_16 (wrbfd, bdc.width, dc->width); + windres_put_16 (wrbfd, bdc.height, dc->height); + windres_put_16 (wrbfd, bdc.id, dc->id); + set_windres_bfd_content (wrbfd, &bdc, off, BIN_DIALOG_CONTROL_SIZE); + } + else + { + struct bin_dialogex_control bdc; + + windres_put_32 (wrbfd, bdc.help, dc->help); + windres_put_32 (wrbfd, bdc.exstyle, dc->exstyle); + windres_put_32 (wrbfd, bdc.style, dc->style); + windres_put_16 (wrbfd, bdc.x, dc->x); + windres_put_16 (wrbfd, bdc.y, dc->y); + windres_put_16 (wrbfd, bdc.width, dc->width); + windres_put_16 (wrbfd, bdc.height, dc->height); + windres_put_32 (wrbfd, bdc.id, dc->id); + set_windres_bfd_content (wrbfd, &bdc, off, BIN_DIALOGEX_CONTROL_SIZE); + } + } + off += (dialogex != 0 ? BIN_DIALOGEX_CONTROL_SIZE : BIN_DIALOG_CONTROL_SIZE); + + off = resid_to_bin (wrbfd, off, dc->class); + off = resid_to_bin (wrbfd, off, dc->text); + + marker = off; /* Save two bytes for size of optional data. */ + off += 2; + + if (dc->data == NULL) + { + if (wrbfd) + windres_put_16 (wrbfd, dc_rclen, 0); + } + else + { + rc_uint_type saved_off = off; + rc_uint_type old_off; + + old_off = off; + off = res_to_bin_rcdata (wrbfd, off, dc->data); + if ((off - old_off) == 0) + old_off = off = saved_off; + if (wrbfd) + windres_put_16 (wrbfd, dc_rclen, off - old_off); + } + if (wrbfd) + set_windres_bfd_content (wrbfd, dc_rclen, marker, 2); + } + + if (wrbfd) + { + windres_put_16 (wrbfd, (dialogex != 0 ? bdx.off : bd.off), c); + if (! dialogex) + set_windres_bfd_content (wrbfd, &bd, start, BIN_DIALOG_SIZE); + else + set_windres_bfd_content (wrbfd, &bdx, start, BIN_DIALOGEX_SIZE); + } + + return off; +} + +/* Convert a fontdir resource to binary. */ +static rc_uint_type +res_to_bin_fontdir (windres_bfd *wrbfd, rc_uint_type off, const rc_fontdir *fontdirs) +{ + rc_uint_type start; + int c; + const rc_fontdir *fd; + + start = off; + off += 2; + + for (c = 0, fd = fontdirs; fd != NULL; fd = fd->next, c++) + { + if (wrbfd) + { + bfd_byte d[2]; + windres_put_16 (wrbfd, d, fd->index); + set_windres_bfd_content (wrbfd, d, off, 2); + if (fd->length) + set_windres_bfd_content (wrbfd, fd->data, off + 2, fd->length); + } + off += (rc_uint_type) fd->length + 2; + } + + if (wrbfd) + { + bfd_byte d[2]; + windres_put_16 (wrbfd, d, c); + set_windres_bfd_content (wrbfd, d, start, 2); + } + return off; +} + +/* Convert a group icon resource to binary. */ + +static rc_uint_type +res_to_bin_group_icon (windres_bfd *wrbfd, rc_uint_type off, const rc_group_icon *group_icons) +{ + rc_uint_type start; + struct bin_group_icon bgi; + int c; + const rc_group_icon *gi; + + start = off; + off += BIN_GROUP_ICON_SIZE; + + for (c = 0, gi = group_icons; gi != NULL; gi = gi->next, c++) + { + struct bin_group_icon_item bgii; + + if (wrbfd) + { + windres_put_8 (wrbfd, bgii.width, gi->width); + windres_put_8 (wrbfd, bgii.height, gi->height); + windres_put_8 (wrbfd, bgii.colors, gi->colors); + windres_put_8 (wrbfd, bgii.pad, 0); + windres_put_16 (wrbfd, bgii.planes, gi->planes); + windres_put_16 (wrbfd, bgii.bits, gi->bits); + windres_put_32 (wrbfd, bgii.bytes, gi->bytes); + windres_put_16 (wrbfd, bgii.index, gi->index); + set_windres_bfd_content (wrbfd, &bgii, off, BIN_GROUP_ICON_ITEM_SIZE); + } + off += BIN_GROUP_ICON_ITEM_SIZE; + } + + if (wrbfd) + { + windres_put_16 (wrbfd, bgi.sig1, 0); + windres_put_16 (wrbfd, bgi.sig2, 1); + windres_put_16 (wrbfd, bgi.count, c); + set_windres_bfd_content (wrbfd, &bgi, start, BIN_GROUP_ICON_SIZE); + } + return off; +} + +/* Convert a menu resource to binary. */ + +static rc_uint_type +res_to_bin_menu (windres_bfd *wrbfd, rc_uint_type off, const rc_menu *menu) +{ + int menuex; + + menuex = extended_menu (menu); + + if (wrbfd) + { + if (! menuex) + { + struct bin_menu bm; + windres_put_16 (wrbfd, bm.sig1, 0); + windres_put_16 (wrbfd, bm.sig2, 0); + set_windres_bfd_content (wrbfd, &bm, off, BIN_MENU_SIZE); + } + else + { + struct bin_menuex bm; + windres_put_16 (wrbfd, bm.sig1, 1); + windres_put_16 (wrbfd, bm.sig2, 4); + windres_put_32 (wrbfd, bm.help, menu->help); + set_windres_bfd_content (wrbfd, &bm, off, BIN_MENUEX_SIZE); + } + } + off += (menuex != 0 ? BIN_MENUEX_SIZE : BIN_MENU_SIZE); + if (! menuex) + { + off = res_to_bin_menuitems (wrbfd, off, menu->items); + } + else + { + off = res_to_bin_menuexitems (wrbfd, off, menu->items); + } + return off; +} + +/* Convert menu items to binary. */ + +static rc_uint_type +res_to_bin_menuitems (windres_bfd *wrbfd, rc_uint_type off, const rc_menuitem *items) +{ + const rc_menuitem *mi; + + for (mi = items; mi != NULL; mi = mi->next) + { + struct bin_menuitem bmi; + int flags; + + flags = mi->type; + if (mi->next == NULL) + flags |= MENUITEM_ENDMENU; + if (mi->popup != NULL) + flags |= MENUITEM_POPUP; + + if (wrbfd) + { + windres_put_16 (wrbfd, bmi.flags, flags); + if (mi->popup == NULL) + windres_put_16 (wrbfd, bmi.id, mi->id); + set_windres_bfd_content (wrbfd, &bmi, off, + mi->popup == NULL ? BIN_MENUITEM_SIZE + : BIN_MENUITEM_POPUP_SIZE); + } + off += (mi->popup == NULL ? BIN_MENUITEM_SIZE : BIN_MENUITEM_POPUP_SIZE); + + off = unicode_to_bin (wrbfd, off, mi->text); + + if (mi->popup != NULL) + { + off = res_to_bin_menuitems (wrbfd, off, mi->popup); + } + } + return off; +} + +/* Convert menuex items to binary. */ + +static rc_uint_type +res_to_bin_menuexitems (windres_bfd *wrbfd, rc_uint_type off, const rc_menuitem *items) +{ + rc_uint_type off_delta = off; + const rc_menuitem *mi; + + for (mi = items; mi != NULL; mi = mi->next) + { + struct bin_menuitemex bmi; + int flags; + + off += (4 - ((off - off_delta) & 3)) & 3; + + flags = 0; + if (mi->next == NULL) + flags |= 0x80; + if (mi->popup != NULL) + flags |= 1; + + if (wrbfd) + { + windres_put_32 (wrbfd, bmi.type, mi->type); + windres_put_32 (wrbfd, bmi.state, mi->state); + windres_put_32 (wrbfd, bmi.id, mi->id); + windres_put_16 (wrbfd, bmi.flags, flags); + set_windres_bfd_content (wrbfd, &bmi, off, BIN_MENUITEMEX_SIZE); + } + off += BIN_MENUITEMEX_SIZE; + + off = unicode_to_bin (wrbfd, off, mi->text); + + if (mi->popup != NULL) + { + bfd_byte help[4]; + + off += (4 - ((off - off_delta) & 3)) & 3; + + if (wrbfd) + { + windres_put_32 (wrbfd, help, mi->help); + set_windres_bfd_content (wrbfd, help, off, 4); + } + off += 4; + off = res_to_bin_menuexitems (wrbfd, off, mi->popup); + } + } + return off; +} + +/* Convert an rcdata resource to binary. This is also used to convert + other information which happens to be stored in rc_rcdata_item lists + to binary. */ + +static rc_uint_type +res_to_bin_rcdata (windres_bfd *wrbfd, rc_uint_type off, const rc_rcdata_item *items) +{ + const rc_rcdata_item *ri; + + for (ri = items; ri != NULL; ri = ri->next) + { + rc_uint_type len; + switch (ri->type) + { + default: + abort (); + case RCDATA_WORD: + len = 2; + break; + case RCDATA_DWORD: + len = 4; + break; + case RCDATA_STRING: + len = ri->u.string.length; + break; + case RCDATA_WSTRING: + len = ri->u.wstring.length * sizeof (unichar); + break; + case RCDATA_BUFFER: + len = ri->u.buffer.length; + break; + } + if (wrbfd) + { + bfd_byte h[4]; + bfd_byte *hp = &h[0]; + switch (ri->type) + { + case RCDATA_WORD: + windres_put_16 (wrbfd, hp, ri->u.word); + break; + case RCDATA_DWORD: + windres_put_32 (wrbfd, hp, ri->u.dword); + break; + case RCDATA_STRING: + hp = (bfd_byte *) ri->u.string.s; + break; + case RCDATA_WSTRING: + { + rc_uint_type i; + + hp = (bfd_byte *) reswr_alloc (len); + for (i = 0; i < ri->u.wstring.length; i++) + windres_put_16 (wrbfd, hp + i * sizeof (unichar), ri->u.wstring.w[i]); + } + break; + case RCDATA_BUFFER: + hp = (bfd_byte *) ri->u.buffer.data; + break; + } + set_windres_bfd_content (wrbfd, hp, off, len); + } + off += len; + } + return off; +} + +/* Convert a stringtable resource to binary. */ + +static rc_uint_type +res_to_bin_stringtable (windres_bfd *wrbfd, rc_uint_type off, + const rc_stringtable *st) +{ + int i; + + for (i = 0; i < 16; i++) + { + rc_uint_type slen, length; + unichar *s; + + slen = (rc_uint_type) st->strings[i].length; + if (slen == 0xffffffff) slen = 0; + s = st->strings[i].string; + + length = 2 + slen * 2; + if (wrbfd) + { + bfd_byte *hp; + rc_uint_type j; + + hp = (bfd_byte *) reswr_alloc (length); + windres_put_16 (wrbfd, hp, slen); + + for (j = 0; j < slen; j++) + windres_put_16 (wrbfd, hp + 2 + j * 2, s[j]); + set_windres_bfd_content (wrbfd, hp, off, length); + } + off += length; + } + return off; +} + +/* Convert an ASCII string to a unicode binary string. This always + returns exactly one bindata structure. */ + +static rc_uint_type +string_to_unicode_bin (windres_bfd *wrbfd, rc_uint_type off, const char *s) +{ + rc_uint_type len; + + len = (rc_uint_type) strlen (s); + + if (wrbfd) + { + rc_uint_type i; + bfd_byte *hp; + + hp = (bfd_byte *) reswr_alloc ((len + 1) * sizeof (unichar)); + + for (i = 0; i < len; i++) + windres_put_16 (wrbfd, hp + i * 2, s[i]); + windres_put_16 (wrbfd, hp + i * 2, 0); + set_windres_bfd_content (wrbfd, hp, off, (len + 1) * sizeof (unichar)); + } + off += (rc_uint_type) ((len + 1) * sizeof (unichar)); + return off; +} + +static rc_uint_type +res_to_bin_toolbar (windres_bfd *wrbfd, rc_uint_type off, rc_toolbar *tb) +{ + if (wrbfd) + { + struct bin_toolbar bt; + windres_put_32 (wrbfd, bt.button_width, tb->button_width); + windres_put_32 (wrbfd, bt.button_height, tb->button_height); + windres_put_32 (wrbfd, bt.nitems, tb->nitems); + set_windres_bfd_content (wrbfd, &bt, off, BIN_TOOLBAR_SIZE); + if (tb->nitems > 0) + { + rc_toolbar_item *it; + bfd_byte *ids; + rc_uint_type i = 0; + + ids = (bfd_byte *) reswr_alloc (tb->nitems * 4); + it=tb->items; + while(it != NULL) + { + windres_put_32 (wrbfd, ids + i, it->id.u.id); + i += 4; + it = it->next; + } + set_windres_bfd_content (wrbfd, ids, off + BIN_TOOLBAR_SIZE, i); + } + } + off += BIN_TOOLBAR_SIZE + tb->nitems * 4; + + return off; +} + +/* Convert a versioninfo resource to binary. */ + +static rc_uint_type +res_to_bin_versioninfo (windres_bfd *wrbfd, rc_uint_type off, + const rc_versioninfo *versioninfo) +{ + rc_uint_type off_delta = off; + rc_uint_type start; + struct bin_versioninfo bvi; + rc_ver_info *vi; + + start = off; + off += BIN_VERSIONINFO_SIZE; + off = string_to_unicode_bin (wrbfd, off, "VS_VERSION_INFO"); + off += (4 - ((off - off_delta) & 3)) & 3; + + if (versioninfo->fixed != NULL) + { + if (wrbfd) + { + struct bin_fixed_versioninfo bfv; + const rc_fixed_versioninfo *fi; + + fi = versioninfo->fixed; + windres_put_32 (wrbfd, bfv.sig1, 0xfeef04bd); + windres_put_32 (wrbfd, bfv.sig2, 0x10000); + windres_put_32 (wrbfd, bfv.file_version, fi->file_version_ms); + windres_put_32 (wrbfd, bfv.file_version_ls, fi->file_version_ls); + windres_put_32 (wrbfd, bfv.product_version_ms, fi->product_version_ms); + windres_put_32 (wrbfd, bfv.product_version_ls, fi->product_version_ls); + windres_put_32 (wrbfd, bfv.file_flags_mask, fi->file_flags_mask); + windres_put_32 (wrbfd, bfv.file_flags, fi->file_flags); + windres_put_32 (wrbfd, bfv.file_os, fi->file_os); + windres_put_32 (wrbfd, bfv.file_type, fi->file_type); + windres_put_32 (wrbfd, bfv.file_subtype, fi->file_subtype); + windres_put_32 (wrbfd, bfv.file_date_ms, fi->file_date_ms); + windres_put_32 (wrbfd, bfv.file_date_ls, fi->file_date_ls); + set_windres_bfd_content (wrbfd, &bfv, off, BIN_FIXED_VERSIONINFO_SIZE); + } + off += BIN_FIXED_VERSIONINFO_SIZE; + } + + for (vi = versioninfo->var; vi != NULL; vi = vi->next) + { + struct bin_ver_info bv; + rc_uint_type bv_off; + + off += (4 - ((off - off_delta) & 3)) & 3; + + bv_off = off; + + off += BIN_VER_INFO_SIZE; + + switch (vi->type) + { + default: + abort (); + case VERINFO_STRING: + { + const rc_ver_stringtable *vst; + + off = string_to_unicode_bin (wrbfd, off, "StringFileInfo"); + + if (!vi->u.string.stringtables) + off += (4 - ((off - off_delta) & 3)) & 3; + + for (vst = vi->u.string.stringtables; vst != NULL; vst = vst->next) + { + struct bin_ver_info bvst; + rc_uint_type vst_off; + const rc_ver_stringinfo *vs; + + off += (4 - ((off - off_delta) & 3)) & 3; + + vst_off = off; + off += BIN_VER_INFO_SIZE; + + off = unicode_to_bin (wrbfd, off, vst->language); + + for (vs = vst->strings; vs != NULL; vs = vs->next) + { + struct bin_ver_info bvs; + rc_uint_type vs_off, str_off; + + off += (4 - ((off - off_delta) & 3)) & 3; + + vs_off = off; + off += BIN_VER_INFO_SIZE; + + off = unicode_to_bin (wrbfd, off, vs->key); + + off += (4 - ((off - off_delta) & 3)) & 3; + + str_off = off; + off = unicode_to_bin (wrbfd, off, vs->value); + + if (wrbfd) + { + windres_put_16 (wrbfd, bvs.size, off - vs_off); + windres_put_16 (wrbfd, bvs.sig1, (off - str_off) / 2); + windres_put_16 (wrbfd, bvs.sig2, 1); + set_windres_bfd_content (wrbfd, &bvs, vs_off, + BIN_VER_INFO_SIZE); + } + } + + if (wrbfd) + { + windres_put_16 (wrbfd, bvst.size, off - vst_off); + windres_put_16 (wrbfd, bvst.sig1, 0); + windres_put_16 (wrbfd, bvst.sig2, 1); + set_windres_bfd_content (wrbfd, &bvst, vst_off, + BIN_VER_INFO_SIZE); + } + } + break; + } + + case VERINFO_VAR: + { + rc_uint_type vvd_off, vvvd_off; + struct bin_ver_info bvvd; + const rc_ver_varinfo *vv; + + off = string_to_unicode_bin (wrbfd, off, "VarFileInfo"); + + off += (4 - ((off - off_delta) & 3)) & 3; + + vvd_off = off; + off += BIN_VER_INFO_SIZE; + + off = unicode_to_bin (wrbfd, off, vi->u.var.key); + + off += (4 - ((off - off_delta) & 3)) & 3; + + vvvd_off = off; + + for (vv = vi->u.var.var; vv != NULL; vv = vv->next) + { + if (wrbfd) + { + bfd_byte vvsd[4]; + + windres_put_16 (wrbfd, &vvsd[0], vv->language); + windres_put_16 (wrbfd, &vvsd[2], vv->charset); + set_windres_bfd_content (wrbfd, vvsd, off, 4); + } + off += 4; + } + if (wrbfd) + { + windres_put_16 (wrbfd, bvvd.size, off - vvd_off); + windres_put_16 (wrbfd, bvvd.sig1, off - vvvd_off); + windres_put_16 (wrbfd, bvvd.sig2, 0); + set_windres_bfd_content (wrbfd, &bvvd, vvd_off, + BIN_VER_INFO_SIZE); + } + + break; + } + } + + if (wrbfd) + { + windres_put_16 (wrbfd, bv.size, off - bv_off); + windres_put_16 (wrbfd, bv.sig1, 0); + windres_put_16 (wrbfd, bv.sig2, 1); + set_windres_bfd_content (wrbfd, &bv, bv_off, + BIN_VER_INFO_SIZE); + } + } + + if (wrbfd) + { + windres_put_16 (wrbfd, bvi.size, off - start); + windres_put_16 (wrbfd, bvi.fixed_size, + versioninfo->fixed == NULL ? 0 + : BIN_FIXED_VERSIONINFO_SIZE); + windres_put_16 (wrbfd, bvi.sig2, 0); + set_windres_bfd_content (wrbfd, &bvi, start, BIN_VER_INFO_SIZE); + } + return off; +} + +/* Convert a generic resource to binary. */ + +static rc_uint_type +res_to_bin_generic (windres_bfd *wrbfd, rc_uint_type off, rc_uint_type length, + const bfd_byte *data) +{ + if (wrbfd && length != 0) + set_windres_bfd_content (wrbfd, data, off, length); + return off + (rc_uint_type) length; +} diff --git a/support/sdbinutils/binutils/rescoff.c b/support/sdbinutils/binutils/rescoff.c new file mode 100644 index 0000000..fed362e --- /dev/null +++ b/support/sdbinutils/binutils/rescoff.c @@ -0,0 +1,767 @@ +/* rescoff.c -- read and write resources in Windows COFF files. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Support. + Rewritten by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* This file contains function that read and write Windows resources + in COFF files. */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" +#include "libiberty.h" +#include "windres.h" + +#include + +/* In order to use the address of a resource data entry, we need to + get the image base of the file. Right now we extract it from + internal BFD information. FIXME. */ + +#include "coff/internal.h" +#include "libcoff.h" + +/* Information we extract from the file. */ + +struct coff_file_info +{ + /* File name. */ + const char *filename; + /* Data read from the file. */ + const bfd_byte *data; + /* End of data read from file. */ + const bfd_byte *data_end; + /* Address of the resource section minus the image base of the file. */ + rc_uint_type secaddr; +}; + +/* A resource directory table in a COFF file. */ + +struct __attribute__ ((__packed__)) extern_res_directory +{ + /* Characteristics. */ + bfd_byte characteristics[4]; + /* Time stamp. */ + bfd_byte time[4]; + /* Major version number. */ + bfd_byte major[2]; + /* Minor version number. */ + bfd_byte minor[2]; + /* Number of named directory entries. */ + bfd_byte name_count[2]; + /* Number of directory entries with IDs. */ + bfd_byte id_count[2]; +}; + +/* A resource directory entry in a COFF file. */ + +struct extern_res_entry +{ + /* Name or ID. */ + bfd_byte name[4]; + /* Address of resource entry or subdirectory. */ + bfd_byte rva[4]; +}; + +/* A resource data entry in a COFF file. */ + +struct extern_res_data +{ + /* Address of resource data. This is apparently a file relative + address, rather than a section offset. */ + bfd_byte rva[4]; + /* Size of resource data. */ + bfd_byte size[4]; + /* Code page. */ + bfd_byte codepage[4]; + /* Reserved. */ + bfd_byte reserved[4]; +}; + +/* Local functions. */ + +static void overrun (const struct coff_file_info *, const char *); +static rc_res_directory *read_coff_res_dir (windres_bfd *, const bfd_byte *, + const struct coff_file_info *, + const rc_res_id *, int); +static rc_res_resource *read_coff_data_entry (windres_bfd *, const bfd_byte *, + const struct coff_file_info *, + const rc_res_id *); + +/* Read the resources in a COFF file. */ + +rc_res_directory * +read_coff_rsrc (const char *filename, const char *target) +{ + rc_res_directory *ret; + bfd *abfd; + windres_bfd wrbfd; + char **matching; + asection *sec; + bfd_size_type size; + bfd_byte *data; + struct coff_file_info flaginfo; + + if (filename == NULL) + fatal (_("filename required for COFF input")); + + abfd = bfd_openr (filename, target); + if (abfd == NULL) + bfd_fatal (filename); + + if (! bfd_check_format_matches (abfd, bfd_object, &matching)) + { + bfd_nonfatal (bfd_get_filename (abfd)); + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + list_matching_formats (matching); + xexit (1); + } + + sec = bfd_get_section_by_name (abfd, ".rsrc"); + if (sec == NULL) + { + fatal (_("%s: no resource section"), filename); + } + + set_windres_bfd (&wrbfd, abfd, sec, WR_KIND_BFD); + size = bfd_section_size (abfd, sec); + /* PR 17512: file: 1b25ba5d + The call to get_file_size here may be expensive + but there is no other way to determine if the section size + is reasonable. */ + if (size > (bfd_size_type) get_file_size (filename)) + fatal (_("%s: .rsrc section is bigger than the file!"), filename); + + data = (bfd_byte *) res_alloc (size); + get_windres_bfd_content (&wrbfd, data, 0, size); + + flaginfo.filename = filename; + flaginfo.data = data; + flaginfo.data_end = data + size; + flaginfo.secaddr = (bfd_get_section_vma (abfd, sec) + - pe_data (abfd)->pe_opthdr.ImageBase); + + /* Now just read in the top level resource directory. Note that we + don't free data, since we create resource entries that point into + it. If we ever want to free up the resource information we read, + this will have to be cleaned up. */ + + ret = read_coff_res_dir (&wrbfd, data, &flaginfo, (const rc_res_id *) NULL, 0); + + bfd_close (abfd); + + return ret; +} + +/* Give an error if we are out of bounds. */ + +static void +overrun (const struct coff_file_info *flaginfo, const char *msg) +{ + fatal (_("%s: %s: address out of bounds"), flaginfo->filename, msg); +} + +/* Read a resource directory. */ + +static rc_res_directory * +read_coff_res_dir (windres_bfd *wrbfd, const bfd_byte *data, + const struct coff_file_info *flaginfo, + const rc_res_id *type, int level) +{ + const struct extern_res_directory *erd; + rc_res_directory *rd; + int name_count, id_count, i; + rc_res_entry **pp; + const struct extern_res_entry *ere; + + /* PR 17512: file: 09d80f53. + Whilst in theory resources can nest to any level, in practice + Microsoft only defines 3 levels. Corrupt files however might + claim to use more. */ + if (level > 4) + overrun (flaginfo, _("Resources nest too deep")); + + if ((size_t) (flaginfo->data_end - data) < sizeof (struct extern_res_directory)) + overrun (flaginfo, _("directory")); + + erd = (const struct extern_res_directory *) data; + + rd = (rc_res_directory *) res_alloc (sizeof (rc_res_directory)); + rd->characteristics = windres_get_32 (wrbfd, erd->characteristics, 4); + rd->time = windres_get_32 (wrbfd, erd->time, 4); + rd->major = windres_get_16 (wrbfd, erd->major, 2); + rd->minor = windres_get_16 (wrbfd, erd->minor, 2); + rd->entries = NULL; + + name_count = windres_get_16 (wrbfd, erd->name_count, 2); + id_count = windres_get_16 (wrbfd, erd->id_count, 2); + + pp = &rd->entries; + + /* The resource directory entries immediately follow the directory + table. */ + ere = (const struct extern_res_entry *) (erd + 1); + + for (i = 0; i < name_count; i++, ere++) + { + rc_uint_type name, rva; + rc_res_entry *re; + const bfd_byte *ers; + int length, j; + + if ((const bfd_byte *) ere >= flaginfo->data_end) + overrun (flaginfo, _("named directory entry")); + + name = windres_get_32 (wrbfd, ere->name, 4); + rva = windres_get_32 (wrbfd, ere->rva, 4); + + /* For some reason the high bit in NAME is set. */ + name &=~ 0x80000000; + + if (name > (rc_uint_type) (flaginfo->data_end - flaginfo->data)) + overrun (flaginfo, _("directory entry name")); + + ers = flaginfo->data + name; + + re = (rc_res_entry *) res_alloc (sizeof *re); + re->next = NULL; + re->id.named = 1; + length = windres_get_16 (wrbfd, ers, 2); + re->id.u.n.length = length; + re->id.u.n.name = (unichar *) res_alloc (length * sizeof (unichar)); + for (j = 0; j < length; j++) + { + /* PR 17512: file: 05dc4a16. */ + if (length < 0 || ers >= flaginfo->data_end || ers + j * 2 + 4 >= flaginfo->data_end) + overrun (flaginfo, _("resource name")); + re->id.u.n.name[j] = windres_get_16 (wrbfd, ers + j * 2 + 2, 2); + } + + if (level == 0) + type = &re->id; + + if ((rva & 0x80000000) != 0) + { + rva &=~ 0x80000000; + if (rva >= (rc_uint_type) (flaginfo->data_end - flaginfo->data)) + overrun (flaginfo, _("named subdirectory")); + re->subdir = 1; + re->u.dir = read_coff_res_dir (wrbfd, flaginfo->data + rva, flaginfo, type, + level + 1); + } + else + { + if (rva >= (rc_uint_type) (flaginfo->data_end - flaginfo->data)) + overrun (flaginfo, _("named resource")); + re->subdir = 0; + re->u.res = read_coff_data_entry (wrbfd, flaginfo->data + rva, flaginfo, type); + } + + *pp = re; + pp = &re->next; + } + + for (i = 0; i < id_count; i++, ere++) + { + unsigned long name, rva; + rc_res_entry *re; + + if ((const bfd_byte *) ere >= flaginfo->data_end) + overrun (flaginfo, _("ID directory entry")); + + name = windres_get_32 (wrbfd, ere->name, 4); + rva = windres_get_32 (wrbfd, ere->rva, 4); + + re = (rc_res_entry *) res_alloc (sizeof *re); + re->next = NULL; + re->id.named = 0; + re->id.u.id = name; + + if (level == 0) + type = &re->id; + + if ((rva & 0x80000000) != 0) + { + rva &=~ 0x80000000; + if (rva >= (rc_uint_type) (flaginfo->data_end - flaginfo->data)) + overrun (flaginfo, _("ID subdirectory")); + re->subdir = 1; + re->u.dir = read_coff_res_dir (wrbfd, flaginfo->data + rva, flaginfo, type, + level + 1); + } + else + { + if (rva >= (rc_uint_type) (flaginfo->data_end - flaginfo->data)) + overrun (flaginfo, _("ID resource")); + re->subdir = 0; + re->u.res = read_coff_data_entry (wrbfd, flaginfo->data + rva, flaginfo, type); + } + + *pp = re; + pp = &re->next; + } + + return rd; +} + +/* Read a resource data entry. */ + +static rc_res_resource * +read_coff_data_entry (windres_bfd *wrbfd, const bfd_byte *data, + const struct coff_file_info *flaginfo, + const rc_res_id *type) +{ + const struct extern_res_data *erd; + rc_res_resource *r; + rc_uint_type size, rva; + const bfd_byte *resdata; + + if (type == NULL) + fatal (_("resource type unknown")); + + if ((size_t) (flaginfo->data_end - data) < sizeof (struct extern_res_data)) + overrun (flaginfo, _("data entry")); + + erd = (const struct extern_res_data *) data; + + size = windres_get_32 (wrbfd, erd->size, 4); + rva = windres_get_32 (wrbfd, erd->rva, 4); + if (rva < flaginfo->secaddr + || rva - flaginfo->secaddr >= (rc_uint_type) (flaginfo->data_end - flaginfo->data)) + overrun (flaginfo, _("resource data")); + + resdata = flaginfo->data + (rva - flaginfo->secaddr); + + if (size > (rc_uint_type) (flaginfo->data_end - resdata)) + overrun (flaginfo, _("resource data size")); + + r = bin_to_res (wrbfd, *type, resdata, size); + + memset (&r->res_info, 0, sizeof (rc_res_res_info)); + r->coff_info.codepage = windres_get_32 (wrbfd, erd->codepage, 4); + r->coff_info.reserved = windres_get_32 (wrbfd, erd->reserved, 4); + + return r; +} + +/* This structure is used to build a list of bindata structures. */ + +struct bindata_build +{ + /* The data. */ + bindata *d; + /* The last structure we have added to the list. */ + bindata *last; + /* The size of the list as a whole. */ + unsigned long length; +}; + +struct coff_res_data_build +{ + /* The data. */ + coff_res_data *d; + /* The last structure we have added to the list. */ + coff_res_data *last; + /* The size of the list as a whole. */ + unsigned long length; +}; + +/* This structure keeps track of information as we build the directory + tree. */ + +struct coff_write_info +{ + /* These fields are based on the BFD. */ + /* The BFD itself. */ + windres_bfd *wrbfd; + /* Pointer to section symbol used to build RVA relocs. */ + asymbol **sympp; + + /* These fields are computed initially, and then not changed. */ + /* Length of directory tables and entries. */ + unsigned long dirsize; + /* Length of directory entry strings. */ + unsigned long dirstrsize; + /* Length of resource data entries. */ + unsigned long dataentsize; + + /* These fields are updated as we add data. */ + /* Directory tables and entries. */ + struct bindata_build dirs; + /* Directory entry strings. */ + struct bindata_build dirstrs; + /* Resource data entries. */ + struct bindata_build dataents; + /* Actual resource data. */ + struct coff_res_data_build resources; + /* Relocations. */ + arelent **relocs; + /* Number of relocations. */ + unsigned int reloc_count; +}; + +static void coff_bin_sizes (const rc_res_directory *, struct coff_write_info *); +static bfd_byte *coff_alloc (struct bindata_build *, rc_uint_type); +static void coff_to_bin + (const rc_res_directory *, struct coff_write_info *); +static void coff_res_to_bin + (const rc_res_resource *, struct coff_write_info *); + +/* Write resources to a COFF file. RESOURCES should already be + sorted. + + Right now we always create a new file. Someday we should also + offer the ability to merge resources into an existing file. This + would require doing the basic work of objcopy, just modifying or + adding the .rsrc section. */ + +void +write_coff_file (const char *filename, const char *target, + const rc_res_directory *resources) +{ + bfd *abfd; + asection *sec; + struct coff_write_info cwi; + windres_bfd wrbfd; + bindata *d; + coff_res_data *rd; + unsigned long length, offset; + + if (filename == NULL) + fatal (_("filename required for COFF output")); + + abfd = bfd_openw (filename, target); + if (abfd == NULL) + bfd_fatal (filename); + + if (! bfd_set_format (abfd, bfd_object)) + bfd_fatal ("bfd_set_format"); + +#if defined DLLTOOL_SH + if (! bfd_set_arch_mach (abfd, bfd_arch_sh, 0)) + bfd_fatal ("bfd_set_arch_mach(sh)"); +#elif defined DLLTOOL_MIPS + if (! bfd_set_arch_mach (abfd, bfd_arch_mips, 0)) + bfd_fatal ("bfd_set_arch_mach(mips)"); +#elif defined DLLTOOL_ARM + if (! bfd_set_arch_mach (abfd, bfd_arch_arm, 0)) + bfd_fatal ("bfd_set_arch_mach(arm)"); +#else + /* FIXME: This is obviously i386 specific. */ + if (! bfd_set_arch_mach (abfd, bfd_arch_i386, 0)) + bfd_fatal ("bfd_set_arch_mach(i386)"); +#endif + + if (! bfd_set_file_flags (abfd, HAS_SYMS | HAS_RELOC)) + bfd_fatal ("bfd_set_file_flags"); + + sec = bfd_make_section_with_flags (abfd, ".rsrc", + (SEC_HAS_CONTENTS | SEC_ALLOC + | SEC_LOAD | SEC_DATA)); + if (sec == NULL) + bfd_fatal ("bfd_make_section"); + + if (! bfd_set_symtab (abfd, sec->symbol_ptr_ptr, 1)) + bfd_fatal ("bfd_set_symtab"); + + /* Requiring this is probably a bug in BFD. */ + sec->output_section = sec; + + /* The order of data in the .rsrc section is + resource directory tables and entries + resource directory strings + resource data entries + actual resource data + + We build these different types of data in different lists. */ + + set_windres_bfd (&wrbfd, abfd, sec, WR_KIND_BFD); + + cwi.wrbfd = &wrbfd; + cwi.sympp = sec->symbol_ptr_ptr; + cwi.dirsize = 0; + cwi.dirstrsize = 0; + cwi.dataentsize = 0; + cwi.dirs.d = NULL; + cwi.dirs.last = NULL; + cwi.dirs.length = 0; + cwi.dirstrs.d = NULL; + cwi.dirstrs.last = NULL; + cwi.dirstrs.length = 0; + cwi.dataents.d = NULL; + cwi.dataents.last = NULL; + cwi.dataents.length = 0; + cwi.resources.d = NULL; + cwi.resources.last = NULL; + cwi.resources.length = 0; + cwi.relocs = NULL; + cwi.reloc_count = 0; + + /* Work out the sizes of the resource directory entries, so that we + know the various offsets we will need. */ + coff_bin_sizes (resources, &cwi); + + /* Force the directory strings to be 64 bit aligned. Every other + structure is 64 bit aligned anyhow. */ + cwi.dirstrsize = (cwi.dirstrsize + 7) & ~7; + + /* Actually convert the resources to binary. */ + coff_to_bin (resources, &cwi); + + /* Add another few bytes to the directory strings if needed for + alignment. */ + if ((cwi.dirstrs.length & 7) != 0) + { + rc_uint_type pad = 8 - (cwi.dirstrs.length & 7); + bfd_byte *ex; + + ex = coff_alloc (& cwi.dirstrs, pad); + memset (ex, 0, pad); + } + + /* Make sure that the data we built came out to the same size as we + calculated initially. */ + assert (cwi.dirs.length == cwi.dirsize); + assert (cwi.dirstrs.length == cwi.dirstrsize); + assert (cwi.dataents.length == cwi.dataentsize); + + length = (cwi.dirsize + + cwi.dirstrsize + + cwi.dataentsize + + cwi.resources.length); + + if (! bfd_set_section_size (abfd, sec, length)) + bfd_fatal ("bfd_set_section_size"); + + bfd_set_reloc (abfd, sec, cwi.relocs, cwi.reloc_count); + + offset = 0; + for (d = cwi.dirs.d; d != NULL; d = d->next) + { + if (! bfd_set_section_contents (abfd, sec, d->data, offset, d->length)) + bfd_fatal ("bfd_set_section_contents"); + offset += d->length; + } + for (d = cwi.dirstrs.d; d != NULL; d = d->next) + { + set_windres_bfd_content (&wrbfd, d->data, offset, d->length); + offset += d->length; + } + for (d = cwi.dataents.d; d != NULL; d = d->next) + { + set_windres_bfd_content (&wrbfd, d->data, offset, d->length); + offset += d->length; + } + for (rd = cwi.resources.d; rd != NULL; rd = rd->next) + { + res_to_bin (cwi.wrbfd, (rc_uint_type) offset, rd->res); + offset += rd->length; + } + + assert (offset == length); + + if (! bfd_close (abfd)) + bfd_fatal ("bfd_close"); + + /* We allocated the relocs array using malloc. */ + free (cwi.relocs); +} + +/* Work out the sizes of the various fixed size resource directory + entries. This updates fields in CWI. */ + +static void +coff_bin_sizes (const rc_res_directory *resdir, + struct coff_write_info *cwi) +{ + const rc_res_entry *re; + + cwi->dirsize += sizeof (struct extern_res_directory); + + for (re = resdir->entries; re != NULL; re = re->next) + { + cwi->dirsize += sizeof (struct extern_res_entry); + + if (re->id.named) + cwi->dirstrsize += re->id.u.n.length * 2 + 2; + + if (re->subdir) + coff_bin_sizes (re->u.dir, cwi); + else + cwi->dataentsize += sizeof (struct extern_res_data); + } +} + +/* Allocate data for a particular list. */ + +static bfd_byte * +coff_alloc (struct bindata_build *bb, rc_uint_type size) +{ + bindata *d; + + d = (bindata *) reswr_alloc (sizeof (bindata)); + + d->next = NULL; + d->data = (bfd_byte *) reswr_alloc (size); + d->length = size; + + if (bb->d == NULL) + bb->d = d; + else + bb->last->next = d; + bb->last = d; + bb->length += size; + + return d->data; +} + +/* Convert the resource directory RESDIR to binary. */ + +static void +coff_to_bin (const rc_res_directory *resdir, struct coff_write_info *cwi) +{ + struct extern_res_directory *erd; + int ci, cn; + const rc_res_entry *e; + struct extern_res_entry *ere; + + /* Write out the directory table. */ + + erd = ((struct extern_res_directory *) + coff_alloc (&cwi->dirs, sizeof (*erd))); + + windres_put_32 (cwi->wrbfd, erd->characteristics, resdir->characteristics); + windres_put_32 (cwi->wrbfd, erd->time, resdir->time); + windres_put_16 (cwi->wrbfd, erd->major, resdir->major); + windres_put_16 (cwi->wrbfd, erd->minor, resdir->minor); + + ci = 0; + cn = 0; + for (e = resdir->entries; e != NULL; e = e->next) + { + if (e->id.named) + ++cn; + else + ++ci; + } + + windres_put_16 (cwi->wrbfd, erd->name_count, cn); + windres_put_16 (cwi->wrbfd, erd->id_count, ci); + + /* Write out the data entries. Note that we allocate space for all + the entries before writing them out. That permits a recursive + call to work correctly when writing out subdirectories. */ + + ere = ((struct extern_res_entry *) + coff_alloc (&cwi->dirs, (ci + cn) * sizeof (*ere))); + for (e = resdir->entries; e != NULL; e = e->next, ere++) + { + if (! e->id.named) + windres_put_32 (cwi->wrbfd, ere->name, e->id.u.id); + else + { + bfd_byte *str; + rc_uint_type i; + + /* For some reason existing files seem to have the high bit + set on the address of the name, although that is not + documented. */ + windres_put_32 (cwi->wrbfd, ere->name, + 0x80000000 | (cwi->dirsize + cwi->dirstrs.length)); + + str = coff_alloc (&cwi->dirstrs, e->id.u.n.length * 2 + 2); + windres_put_16 (cwi->wrbfd, str, e->id.u.n.length); + for (i = 0; i < e->id.u.n.length; i++) + windres_put_16 (cwi->wrbfd, str + (i + 1) * sizeof (unichar), e->id.u.n.name[i]); + } + + if (e->subdir) + { + windres_put_32 (cwi->wrbfd, ere->rva, 0x80000000 | cwi->dirs.length); + coff_to_bin (e->u.dir, cwi); + } + else + { + windres_put_32 (cwi->wrbfd, ere->rva, + cwi->dirsize + cwi->dirstrsize + cwi->dataents.length); + + coff_res_to_bin (e->u.res, cwi); + } + } +} + +/* Convert the resource RES to binary. */ + +static void +coff_res_to_bin (const rc_res_resource *res, struct coff_write_info *cwi) +{ + arelent *r; + struct extern_res_data *erd; + coff_res_data *d; + + /* For some reason, although every other address is a section + offset, the address of the resource data itself is an RVA. That + means that we need to generate a relocation for it. We allocate + the relocs array using malloc so that we can use realloc. FIXME: + This relocation handling is correct for the i386, but probably + not for any other target. */ + + r = (arelent *) reswr_alloc (sizeof (arelent)); + r->sym_ptr_ptr = cwi->sympp; + r->address = cwi->dirsize + cwi->dirstrsize + cwi->dataents.length; + r->addend = 0; + r->howto = bfd_reloc_type_lookup (WR_BFD (cwi->wrbfd), BFD_RELOC_RVA); + if (r->howto == NULL) + bfd_fatal (_("can't get BFD_RELOC_RVA relocation type")); + + cwi->relocs = xrealloc (cwi->relocs, + (cwi->reloc_count + 2) * sizeof (arelent *)); + cwi->relocs[cwi->reloc_count] = r; + cwi->relocs[cwi->reloc_count + 1] = NULL; + ++cwi->reloc_count; + + erd = (struct extern_res_data *) coff_alloc (&cwi->dataents, sizeof (*erd)); + + windres_put_32 (cwi->wrbfd, erd->rva, + (cwi->dirsize + + cwi->dirstrsize + + cwi->dataentsize + + cwi->resources.length)); + windres_put_32 (cwi->wrbfd, erd->codepage, res->coff_info.codepage); + windres_put_32 (cwi->wrbfd, erd->reserved, res->coff_info.reserved); + + d = (coff_res_data *) reswr_alloc (sizeof (coff_res_data)); + d->length = res_to_bin (NULL, (rc_uint_type) 0, res); + d->res = res; + d->next = NULL; + + if (cwi->resources.d == NULL) + cwi->resources.d = d; + else + cwi->resources.last->next = d; + + cwi->resources.last = d; + cwi->resources.length += (d->length + 7) & ~7; + + windres_put_32 (cwi->wrbfd, erd->size, d->length); + + /* Force the next resource to have 64 bit alignment. */ + d->length = (d->length + 7) & ~7; +} diff --git a/support/sdbinutils/binutils/resrc.c b/support/sdbinutils/binutils/resrc.c new file mode 100644 index 0000000..5399a26 --- /dev/null +++ b/support/sdbinutils/binutils/resrc.c @@ -0,0 +1,3390 @@ +/* resrc.c -- read and write Windows rc files. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Support. + Rewritten by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* This file contains functions that read and write Windows rc files. + These are text files that represent resources. */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" +#include "libiberty.h" +#include "safe-ctype.h" +#include "windres.h" + +#include + +#ifdef HAVE_SYS_WAIT_H +#include +#else /* ! HAVE_SYS_WAIT_H */ +#if ! defined (_WIN32) || defined (__CYGWIN__) +#ifndef WIFEXITED +#define WIFEXITED(w) (((w)&0377) == 0) +#endif +#ifndef WIFSIGNALED +#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0) +#endif +#ifndef WTERMSIG +#define WTERMSIG(w) ((w) & 0177) +#endif +#ifndef WEXITSTATUS +#define WEXITSTATUS(w) (((w) >> 8) & 0377) +#endif +#else /* defined (_WIN32) && ! defined (__CYGWIN__) */ +#ifndef WIFEXITED +#define WIFEXITED(w) (((w) & 0xff) == 0) +#endif +#ifndef WIFSIGNALED +#define WIFSIGNALED(w) (((w) & 0xff) != 0 && ((w) & 0xff) != 0x7f) +#endif +#ifndef WTERMSIG +#define WTERMSIG(w) ((w) & 0x7f) +#endif +#ifndef WEXITSTATUS +#define WEXITSTATUS(w) (((w) & 0xff00) >> 8) +#endif +#endif /* defined (_WIN32) && ! defined (__CYGWIN__) */ +#endif /* ! HAVE_SYS_WAIT_H */ + +#ifndef STDOUT_FILENO +#define STDOUT_FILENO 1 +#endif + +#if defined (_WIN32) && ! defined (__CYGWIN__) +#define popen _popen +#define pclose _pclose +#endif + +/* The default preprocessor. */ + +#define DEFAULT_PREPROCESSOR "gcc -E -xc -DRC_INVOKED" + +/* We read the directory entries in a cursor or icon file into + instances of this structure. */ + +struct icondir +{ + /* Width of image. */ + bfd_byte width; + /* Height of image. */ + bfd_byte height; + /* Number of colors in image. */ + bfd_byte colorcount; + union + { + struct + { + /* Color planes. */ + unsigned short planes; + /* Bits per pixel. */ + unsigned short bits; + } icon; + struct + { + /* X coordinate of hotspot. */ + unsigned short xhotspot; + /* Y coordinate of hotspot. */ + unsigned short yhotspot; + } cursor; + } u; + /* Bytes in image. */ + unsigned long bytes; + /* File offset of image. */ + unsigned long offset; +}; + +/* The name of the rc file we are reading. */ + +char *rc_filename; + +/* The line number in the rc file. */ + +int rc_lineno; + +/* The pipe we are reading from, so that we can close it if we exit. */ + +FILE *cpp_pipe; + +/* The temporary file used if we're not using popen, so we can delete it + if we exit. */ + +static char *cpp_temp_file; + +/* Input stream is either a file or a pipe. */ + +static enum {ISTREAM_PIPE, ISTREAM_FILE} istream_type; + +/* As we read the rc file, we attach information to this structure. */ + +static rc_res_directory *resources; + +/* The number of cursor resources we have written out. */ + +static int cursors; + +/* The number of font resources we have written out. */ + +static int fonts; + +/* Font directory information. */ + +rc_fontdir *fontdirs; + +/* Resource info to use for fontdirs. */ + +rc_res_res_info fontdirs_resinfo; + +/* The number of icon resources we have written out. */ + +static int icons; + +/* The windres target bfd . */ + +static windres_bfd wrtarget = +{ + (bfd *) NULL, (asection *) NULL, WR_KIND_TARGET +}; + +/* Local functions for rcdata based resource definitions. */ + +static void define_font_rcdata (rc_res_id, const rc_res_res_info *, + rc_rcdata_item *); +static void define_icon_rcdata (rc_res_id, const rc_res_res_info *, + rc_rcdata_item *); +static void define_bitmap_rcdata (rc_res_id, const rc_res_res_info *, + rc_rcdata_item *); +static void define_cursor_rcdata (rc_res_id, const rc_res_res_info *, + rc_rcdata_item *); +static void define_fontdir_rcdata (rc_res_id, const rc_res_res_info *, + rc_rcdata_item *); +static void define_messagetable_rcdata (rc_res_id, const rc_res_res_info *, + rc_rcdata_item *); +static rc_uint_type rcdata_copy (const rc_rcdata_item *, bfd_byte *); +static bfd_byte *rcdata_render_as_buffer (const rc_rcdata_item *, rc_uint_type *); + +static int run_cmd (char *, const char *); +static FILE *open_input_stream (char *); +static FILE *look_for_default + (char *, const char *, int, const char *, const char *); +static void close_input_stream (void); +static void unexpected_eof (const char *); +static int get_word (FILE *, const char *); +static unsigned long get_long (FILE *, const char *); +static void get_data (FILE *, bfd_byte *, rc_uint_type, const char *); +static void define_fontdirs (void); + +/* Run `cmd' and redirect the output to `redir'. */ + +static int +run_cmd (char *cmd, const char *redir) +{ + char *s; + int pid, wait_status, retcode; + int i; + const char **argv; + char *errmsg_fmt, *errmsg_arg; + char *temp_base = choose_temp_base (); + int in_quote; + char sep; + int redir_handle = -1; + int stdout_save = -1; + + /* Count the args. */ + i = 0; + + for (s = cmd; *s; s++) + if (*s == ' ') + i++; + + i++; + argv = xmalloc (sizeof (char *) * (i + 3)); + i = 0; + s = cmd; + + while (1) + { + while (*s == ' ' && *s != 0) + s++; + + if (*s == 0) + break; + + in_quote = (*s == '\'' || *s == '"'); + sep = (in_quote) ? *s++ : ' '; + argv[i++] = s; + + while (*s != sep && *s != 0) + s++; + + if (*s == 0) + break; + + *s++ = 0; + + if (in_quote) + s++; + } + argv[i++] = NULL; + + /* Setup the redirection. We can't use the usual fork/exec and redirect + since we may be running on non-POSIX Windows host. */ + + fflush (stdout); + fflush (stderr); + + /* Open temporary output file. */ + redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT, 0666); + if (redir_handle == -1) + fatal (_("can't open temporary file `%s': %s"), redir, + strerror (errno)); + + /* Duplicate the stdout file handle so it can be restored later. */ + stdout_save = dup (STDOUT_FILENO); + if (stdout_save == -1) + fatal (_("can't redirect stdout: `%s': %s"), redir, strerror (errno)); + + /* Redirect stdout to our output file. */ + dup2 (redir_handle, STDOUT_FILENO); + + pid = pexecute (argv[0], (char * const *) argv, program_name, temp_base, + &errmsg_fmt, &errmsg_arg, PEXECUTE_ONE | PEXECUTE_SEARCH); + free (argv); + + /* Restore stdout to its previous setting. */ + dup2 (stdout_save, STDOUT_FILENO); + + /* Close response file. */ + close (redir_handle); + + if (pid == -1) + { + fatal ("%s %s: %s", errmsg_fmt, errmsg_arg, strerror (errno)); + return 1; + } + + retcode = 0; + pid = pwait (pid, &wait_status, 0); + + if (pid == -1) + { + fatal (_("wait: %s"), strerror (errno)); + retcode = 1; + } + else if (WIFSIGNALED (wait_status)) + { + fatal (_("subprocess got fatal signal %d"), WTERMSIG (wait_status)); + retcode = 1; + } + else if (WIFEXITED (wait_status)) + { + if (WEXITSTATUS (wait_status) != 0) + { + fatal (_("%s exited with status %d"), cmd, + WEXITSTATUS (wait_status)); + retcode = 1; + } + } + else + retcode = 1; + + return retcode; +} + +static FILE * +open_input_stream (char *cmd) +{ + if (istream_type == ISTREAM_FILE) + { + char *fileprefix; + + fileprefix = choose_temp_base (); + cpp_temp_file = (char *) xmalloc (strlen (fileprefix) + 5); + sprintf (cpp_temp_file, "%s.irc", fileprefix); + free (fileprefix); + + if (run_cmd (cmd, cpp_temp_file)) + fatal (_("can't execute `%s': %s"), cmd, strerror (errno)); + + cpp_pipe = fopen (cpp_temp_file, FOPEN_RT); + if (cpp_pipe == NULL) + fatal (_("can't open temporary file `%s': %s"), + cpp_temp_file, strerror (errno)); + + if (verbose) + fprintf (stderr, + _("Using temporary file `%s' to read preprocessor output\n"), + cpp_temp_file); + } + else + { + cpp_pipe = popen (cmd, FOPEN_RT); + if (cpp_pipe == NULL) + fatal (_("can't popen `%s': %s"), cmd, strerror (errno)); + if (verbose) + fprintf (stderr, _("Using popen to read preprocessor output\n")); + } + + xatexit (close_input_stream); + return cpp_pipe; +} + +/* Determine if FILENAME contains special characters that + can cause problems unless the entire filename is quoted. */ + +static int +filename_need_quotes (const char *filename) +{ + if (filename == NULL || (filename[0] == '-' && filename[1] == 0)) + return 0; + + while (*filename != 0) + { + switch (*filename) + { + case '&': + case ' ': + case '<': + case '>': + case '|': + case '%': + return 1; + } + ++filename; + } + return 0; +} + +/* Look for the preprocessor program. */ + +static FILE * +look_for_default (char *cmd, const char *prefix, int end_prefix, + const char *preprocargs, const char *filename) +{ + char *space; + int found; + struct stat s; + const char *fnquotes = (filename_need_quotes (filename) ? "\"" : ""); + + strcpy (cmd, prefix); + + sprintf (cmd + end_prefix, "%s", DEFAULT_PREPROCESSOR); + space = strchr (cmd + end_prefix, ' '); + if (space) + *space = 0; + + if ( +#if defined (__DJGPP__) || defined (__CYGWIN__) || defined (_WIN32) + strchr (cmd, '\\') || +#endif + strchr (cmd, '/')) + { + found = (stat (cmd, &s) == 0 +#ifdef HAVE_EXECUTABLE_SUFFIX + || stat (strcat (cmd, EXECUTABLE_SUFFIX), &s) == 0 +#endif + ); + + if (! found) + { + if (verbose) + fprintf (stderr, _("Tried `%s'\n"), cmd); + return NULL; + } + } + + strcpy (cmd, prefix); + + sprintf (cmd + end_prefix, "%s %s %s%s%s", + DEFAULT_PREPROCESSOR, preprocargs, fnquotes, filename, fnquotes); + + if (verbose) + fprintf (stderr, _("Using `%s'\n"), cmd); + + cpp_pipe = open_input_stream (cmd); + return cpp_pipe; +} + +/* Read an rc file. */ + +rc_res_directory * +read_rc_file (const char *filename, const char *preprocessor, + const char *preprocargs, int language, int use_temp_file) +{ + char *cmd; + const char *fnquotes = (filename_need_quotes (filename) ? "\"" : ""); + + if (filename == NULL) + filename = "-"; + /* Setup the default resource import path taken from input file. */ + else if (strchr (filename, '/') != NULL || strchr (filename, '\\') != NULL) + { + char *edit, *dir; + + if (filename[0] == '/' + || filename[0] == '\\' + || filename[1] == ':') + /* Absolute path. */ + edit = dir = xstrdup (filename); + else + { + /* Relative path. */ + edit = dir = xmalloc (strlen (filename) + 3); + sprintf (dir, "./%s", filename); + } + + /* Walk dir backwards stopping at the first directory separator. */ + edit += strlen (dir); + while (edit > dir && (edit[-1] != '\\' && edit[-1] != '/')) + { + --edit; + edit[0] = 0; + } + + /* Cut off trailing slash. */ + --edit; + edit[0] = 0; + + /* Convert all back slashes to forward slashes. */ + while ((edit = strchr (dir, '\\')) != NULL) + *edit = '/'; + + windres_add_include_dir (dir); + } + + istream_type = (use_temp_file) ? ISTREAM_FILE : ISTREAM_PIPE; + + if (preprocargs == NULL) + preprocargs = ""; + + if (preprocessor) + { + cmd = xmalloc (strlen (preprocessor) + + strlen (preprocargs) + + strlen (filename) + + strlen (fnquotes) * 2 + + 10); + sprintf (cmd, "%s %s %s%s%s", preprocessor, preprocargs, + fnquotes, filename, fnquotes); + + cpp_pipe = open_input_stream (cmd); + } + else + { + char *dash, *slash, *cp; + + preprocessor = DEFAULT_PREPROCESSOR; + + cmd = xmalloc (strlen (program_name) + + strlen (preprocessor) + + strlen (preprocargs) + + strlen (filename) + + strlen (fnquotes) * 2 +#ifdef HAVE_EXECUTABLE_SUFFIX + + strlen (EXECUTABLE_SUFFIX) +#endif + + 10); + + + dash = slash = 0; + for (cp = program_name; *cp; cp++) + { + if (*cp == '-') + dash = cp; + if ( +#if defined (__DJGPP__) || defined (__CYGWIN__) || defined(_WIN32) + *cp == ':' || *cp == '\\' || +#endif + *cp == '/') + { + slash = cp; + dash = 0; + } + } + + cpp_pipe = 0; + + if (dash) + { + /* First, try looking for a prefixed gcc in the windres + directory, with the same prefix as windres */ + + cpp_pipe = look_for_default (cmd, program_name, dash - program_name + 1, + preprocargs, filename); + } + + if (slash && ! cpp_pipe) + { + /* Next, try looking for a gcc in the same directory as + that windres */ + + cpp_pipe = look_for_default (cmd, program_name, slash - program_name + 1, + preprocargs, filename); + } + + if (! cpp_pipe) + { + /* Sigh, try the default */ + + cpp_pipe = look_for_default (cmd, "", 0, preprocargs, filename); + } + + } + + free (cmd); + + rc_filename = xstrdup (filename); + rc_lineno = 1; + if (language != -1) + rcparse_set_language (language); + yyparse (); + rcparse_discard_strings (); + + close_input_stream (); + + if (fontdirs != NULL) + define_fontdirs (); + + free (rc_filename); + rc_filename = NULL; + + return resources; +} + +/* Close the input stream if it is open. */ + +static void +close_input_stream (void) +{ + if (istream_type == ISTREAM_FILE) + { + if (cpp_pipe != NULL) + fclose (cpp_pipe); + + if (cpp_temp_file != NULL) + { + int errno_save = errno; + + unlink (cpp_temp_file); + errno = errno_save; + free (cpp_temp_file); + } + } + else + { + if (cpp_pipe != NULL) + { + int err; + err = pclose (cpp_pipe); + /* We are reading from a pipe, therefore we don't + know if cpp failed or succeeded until pclose. */ + if (err != 0 || errno == ECHILD) + { + /* Since this is also run via xatexit, safeguard. */ + cpp_pipe = NULL; + cpp_temp_file = NULL; + fatal (_("preprocessing failed.")); + } + } + } + + /* Since this is also run via xatexit, safeguard. */ + cpp_pipe = NULL; + cpp_temp_file = NULL; +} + +/* Report an error while reading an rc file. */ + +void +yyerror (const char *msg) +{ + fatal ("%s:%d: %s", rc_filename, rc_lineno, msg); +} + +/* Issue a warning while reading an rc file. */ + +void +rcparse_warning (const char *msg) +{ + fprintf (stderr, "%s:%d: %s\n", rc_filename, rc_lineno, msg); +} + +/* Die if we get an unexpected end of file. */ + +static void +unexpected_eof (const char *msg) +{ + fatal (_("%s: unexpected EOF"), msg); +} + +/* Read a 16 bit word from a file. The data is assumed to be little + endian. */ + +static int +get_word (FILE *e, const char *msg) +{ + int b1, b2; + + b1 = getc (e); + b2 = getc (e); + if (feof (e)) + unexpected_eof (msg); + return ((b2 & 0xff) << 8) | (b1 & 0xff); +} + +/* Read a 32 bit word from a file. The data is assumed to be little + endian. */ + +static unsigned long +get_long (FILE *e, const char *msg) +{ + int b1, b2, b3, b4; + + b1 = getc (e); + b2 = getc (e); + b3 = getc (e); + b4 = getc (e); + if (feof (e)) + unexpected_eof (msg); + return (((((((b4 & 0xff) << 8) + | (b3 & 0xff)) << 8) + | (b2 & 0xff)) << 8) + | (b1 & 0xff)); +} + +/* Read data from a file. This is a wrapper to do error checking. */ + +static void +get_data (FILE *e, bfd_byte *p, rc_uint_type c, const char *msg) +{ + rc_uint_type got; // $$$d + + got = (rc_uint_type) fread (p, 1, c, e); + if (got == c) + return; + + fatal (_("%s: read of %lu returned %lu"), + msg, (unsigned long) c, (unsigned long) got); +} + +/* Define an accelerator resource. */ + +void +define_accelerator (rc_res_id id, const rc_res_res_info *resinfo, + rc_accelerator *data) +{ + rc_res_resource *r; + + r = define_standard_resource (&resources, RT_ACCELERATOR, id, + resinfo->language, 0); + r->type = RES_TYPE_ACCELERATOR; + r->u.acc = data; + r->res_info = *resinfo; +} + +/* Define a bitmap resource. Bitmap data is stored in a file. The + first 14 bytes of the file are a standard header, which is not + included in the resource data. */ + +#define BITMAP_SKIP (14) + +void +define_bitmap (rc_res_id id, const rc_res_res_info *resinfo, + const char *filename) +{ + FILE *e; + char *real_filename; + struct stat s; + bfd_byte *data; + rc_uint_type i; + rc_res_resource *r; + + e = open_file_search (filename, FOPEN_RB, "bitmap file", &real_filename); + + if (stat (real_filename, &s) < 0) + fatal (_("stat failed on bitmap file `%s': %s"), real_filename, + strerror (errno)); + + data = (bfd_byte *) res_alloc (s.st_size - BITMAP_SKIP); + + for (i = 0; i < BITMAP_SKIP; i++) + getc (e); + + get_data (e, data, s.st_size - BITMAP_SKIP, real_filename); + + fclose (e); + free (real_filename); + + r = define_standard_resource (&resources, RT_BITMAP, id, + resinfo->language, 0); + + r->type = RES_TYPE_BITMAP; + r->u.data.length = s.st_size - BITMAP_SKIP; + r->u.data.data = data; + r->res_info = *resinfo; +} + +/* Define a cursor resource. A cursor file may contain a set of + bitmaps, each representing the same cursor at various different + resolutions. They each get written out with a different ID. The + real cursor resource is then a group resource which can be used to + select one of the actual cursors. */ + +void +define_cursor (rc_res_id id, const rc_res_res_info *resinfo, + const char *filename) +{ + FILE *e; + char *real_filename; + int type, count, i; + struct icondir *icondirs; + int first_cursor; + rc_res_resource *r; + rc_group_cursor *first, **pp; + + e = open_file_search (filename, FOPEN_RB, "cursor file", &real_filename); + + /* A cursor file is basically an icon file. The start of the file + is a three word structure. The first word is ignored. The + second word is the type of data. The third word is the number of + entries. */ + + get_word (e, real_filename); + type = get_word (e, real_filename); + count = get_word (e, real_filename); + if (type != 2) + fatal (_("cursor file `%s' does not contain cursor data"), real_filename); + + /* Read in the icon directory entries. */ + + icondirs = (struct icondir *) xmalloc (count * sizeof *icondirs); + + for (i = 0; i < count; i++) + { + icondirs[i].width = getc (e); + icondirs[i].height = getc (e); + icondirs[i].colorcount = getc (e); + getc (e); + icondirs[i].u.cursor.xhotspot = get_word (e, real_filename); + icondirs[i].u.cursor.yhotspot = get_word (e, real_filename); + icondirs[i].bytes = get_long (e, real_filename); + icondirs[i].offset = get_long (e, real_filename); + + if (feof (e)) + unexpected_eof (real_filename); + } + + /* Define each cursor as a unique resource. */ + + first_cursor = cursors; + + for (i = 0; i < count; i++) + { + bfd_byte *data; + rc_res_id name; + rc_cursor *c; + + if (fseek (e, icondirs[i].offset, SEEK_SET) != 0) + fatal (_("%s: fseek to %lu failed: %s"), real_filename, + icondirs[i].offset, strerror (errno)); + + data = (bfd_byte *) res_alloc (icondirs[i].bytes); + + get_data (e, data, icondirs[i].bytes, real_filename); + + c = (rc_cursor *) res_alloc (sizeof (rc_cursor)); + c->xhotspot = icondirs[i].u.cursor.xhotspot; + c->yhotspot = icondirs[i].u.cursor.yhotspot; + c->length = icondirs[i].bytes; + c->data = data; + + ++cursors; + + name.named = 0; + name.u.id = cursors; + + r = define_standard_resource (&resources, RT_CURSOR, name, + resinfo->language, 0); + r->type = RES_TYPE_CURSOR; + r->u.cursor = c; + r->res_info = *resinfo; + } + + fclose (e); + free (real_filename); + + /* Define a cursor group resource. */ + + first = NULL; + pp = &first; + for (i = 0; i < count; i++) + { + rc_group_cursor *cg; + + cg = (rc_group_cursor *) res_alloc (sizeof (rc_group_cursor)); + cg->next = NULL; + cg->width = icondirs[i].width; + cg->height = 2 * icondirs[i].height; + + /* FIXME: What should these be set to? */ + cg->planes = 1; + cg->bits = 1; + + cg->bytes = icondirs[i].bytes + 4; + cg->index = first_cursor + i + 1; + + *pp = cg; + pp = &(*pp)->next; + } + + free (icondirs); + + r = define_standard_resource (&resources, RT_GROUP_CURSOR, id, + resinfo->language, 0); + r->type = RES_TYPE_GROUP_CURSOR; + r->u.group_cursor = first; + r->res_info = *resinfo; +} + +/* Define a dialog resource. */ + +void +define_dialog (rc_res_id id, const rc_res_res_info *resinfo, + const rc_dialog *dialog) +{ + rc_dialog *copy; + rc_res_resource *r; + + copy = (rc_dialog *) res_alloc (sizeof *copy); + *copy = *dialog; + + r = define_standard_resource (&resources, RT_DIALOG, id, + resinfo->language, 0); + r->type = RES_TYPE_DIALOG; + r->u.dialog = copy; + r->res_info = *resinfo; +} + +/* Define a dialog control. This does not define a resource, but + merely allocates and fills in a structure. */ + +rc_dialog_control * +define_control (const rc_res_id iid, rc_uint_type id, rc_uint_type x, + rc_uint_type y, rc_uint_type width, rc_uint_type height, + const rc_res_id class, rc_uint_type style, + rc_uint_type exstyle) +{ + rc_dialog_control *n; + + n = (rc_dialog_control *) res_alloc (sizeof (rc_dialog_control)); + n->next = NULL; + n->id = id; + n->style = style; + n->exstyle = exstyle; + n->x = x; + n->y = y; + n->width = width; + n->height = height; + n->class = class; + n->text = iid; + n->data = NULL; + n->help = 0; + + return n; +} + +rc_dialog_control * +define_icon_control (rc_res_id iid, rc_uint_type id, rc_uint_type x, + rc_uint_type y, rc_uint_type style, + rc_uint_type exstyle, rc_uint_type help, + rc_rcdata_item *data, rc_dialog_ex *ex) +{ + rc_dialog_control *n; + rc_res_id tid; + rc_res_id cid; + + if (style == 0) + style = SS_ICON | WS_CHILD | WS_VISIBLE; + res_string_to_id (&tid, ""); + cid.named = 0; + cid.u.id = CTL_STATIC; + n = define_control (tid, id, x, y, 0, 0, cid, style, exstyle); + n->text = iid; + if (help && ! ex) + rcparse_warning (_("help ID requires DIALOGEX")); + if (data && ! ex) + rcparse_warning (_("control data requires DIALOGEX")); + n->help = help; + n->data = data; + + return n; +} + +/* Define a font resource. */ + +void +define_font (rc_res_id id, const rc_res_res_info *resinfo, + const char *filename) +{ + FILE *e; + char *real_filename; + struct stat s; + bfd_byte *data; + rc_res_resource *r; + long offset; + long fontdatalength; + bfd_byte *fontdata; + rc_fontdir *fd; + const char *device, *face; + rc_fontdir **pp; + + e = open_file_search (filename, FOPEN_RB, "font file", &real_filename); + + if (stat (real_filename, &s) < 0) + fatal (_("stat failed on font file `%s': %s"), real_filename, + strerror (errno)); + + data = (bfd_byte *) res_alloc (s.st_size); + + get_data (e, data, s.st_size, real_filename); + + fclose (e); + free (real_filename); + + r = define_standard_resource (&resources, RT_FONT, id, + resinfo->language, 0); + + r->type = RES_TYPE_FONT; + r->u.data.length = s.st_size; + r->u.data.data = data; + r->res_info = *resinfo; + + /* For each font resource, we must add an entry in the FONTDIR + resource. The FONTDIR resource includes some strings in the font + file. To find them, we have to do some magic on the data we have + read. */ + + offset = ((((((data[47] << 8) + | data[46]) << 8) + | data[45]) << 8) + | data[44]); + if (offset > 0 && offset < s.st_size) + device = (char *) data + offset; + else + device = ""; + + offset = ((((((data[51] << 8) + | data[50]) << 8) + | data[49]) << 8) + | data[48]); + if (offset > 0 && offset < s.st_size) + face = (char *) data + offset; + else + face = ""; + + ++fonts; + + fontdatalength = 58 + strlen (device) + strlen (face); + fontdata = (bfd_byte *) res_alloc (fontdatalength); + memcpy (fontdata, data, 56); + strcpy ((char *) fontdata + 56, device); + strcpy ((char *) fontdata + 57 + strlen (device), face); + + fd = (rc_fontdir *) res_alloc (sizeof (rc_fontdir)); + fd->next = NULL; + fd->index = fonts; + fd->length = fontdatalength; + fd->data = fontdata; + + for (pp = &fontdirs; *pp != NULL; pp = &(*pp)->next) + ; + *pp = fd; + + /* For the single fontdirs resource, we always use the resource + information of the last font. I don't know what else to do. */ + fontdirs_resinfo = *resinfo; +} + +static void +define_font_rcdata (rc_res_id id,const rc_res_res_info *resinfo, + rc_rcdata_item *data) +{ + rc_res_resource *r; + rc_uint_type len_data; + bfd_byte *pb_data; + + r = define_standard_resource (&resources, RT_FONT, id, + resinfo->language, 0); + + pb_data = rcdata_render_as_buffer (data, &len_data); + + r->type = RES_TYPE_FONT; + r->u.data.length = len_data; + r->u.data.data = pb_data; + r->res_info = *resinfo; +} + +/* Define the fontdirs resource. This is called after the entire rc + file has been parsed, if any font resources were seen. */ + +static void +define_fontdirs (void) +{ + rc_res_resource *r; + rc_res_id id; + + id.named = 0; + id.u.id = 1; + + r = define_standard_resource (&resources, RT_FONTDIR, id, 0x409, 0); + + r->type = RES_TYPE_FONTDIR; + r->u.fontdir = fontdirs; + r->res_info = fontdirs_resinfo; +} + +static bfd_byte * +rcdata_render_as_buffer (const rc_rcdata_item *data, rc_uint_type *plen) +{ + const rc_rcdata_item *d; + bfd_byte *ret = NULL, *pret; + rc_uint_type len = 0; + + for (d = data; d != NULL; d = d->next) + len += rcdata_copy (d, NULL); + if (len != 0) + { + ret = pret = (bfd_byte *) res_alloc (len); + for (d = data; d != NULL; d = d->next) + pret += rcdata_copy (d, pret); + } + if (plen) + *plen = len; + return ret; +} + +static void +define_fontdir_rcdata (rc_res_id id,const rc_res_res_info *resinfo, + rc_rcdata_item *data) +{ + rc_res_resource *r; + rc_fontdir *fd, *fd_first, *fd_cur; + rc_uint_type len_data; + bfd_byte *pb_data; + rc_uint_type c; + + fd_cur = fd_first = NULL; + r = define_standard_resource (&resources, RT_FONTDIR, id, 0x409, 0); + + pb_data = rcdata_render_as_buffer (data, &len_data); + + if (pb_data) + { + rc_uint_type off = 2; + c = windres_get_16 (&wrtarget, pb_data, len_data); + for (; c > 0; c--) + { + size_t len; + rc_uint_type safe_pos = off; + const struct bin_fontdir_item *bfi; + + bfi = (const struct bin_fontdir_item *) pb_data + off; + fd = (rc_fontdir *) res_alloc (sizeof (rc_fontdir)); + fd->index = windres_get_16 (&wrtarget, bfi->index, len_data - off); + fd->data = pb_data + off; + off += 56; + len = strlen ((char *) bfi->device_name) + 1; + off += (rc_uint_type) len; + off += (rc_uint_type) strlen ((char *) bfi->device_name + len) + 1; + fd->length = (off - safe_pos); + fd->next = NULL; + if (fd_first == NULL) + fd_first = fd; + else + fd_cur->next = fd; + fd_cur = fd; + } + } + r->type = RES_TYPE_FONTDIR; + r->u.fontdir = fd_first; + r->res_info = *resinfo; +} + +static void define_messagetable_rcdata (rc_res_id id, const rc_res_res_info *resinfo, + rc_rcdata_item *data) +{ + rc_res_resource *r; + rc_uint_type len_data; + bfd_byte *pb_data; + + r = define_standard_resource (&resources, RT_MESSAGETABLE, id, resinfo->language, 0); + + pb_data = rcdata_render_as_buffer (data, &len_data); + r->type = RES_TYPE_MESSAGETABLE; + r->u.data.length = len_data; + r->u.data.data = pb_data; + r->res_info = *resinfo; +} + +/* Define an icon resource. An icon file may contain a set of + bitmaps, each representing the same icon at various different + resolutions. They each get written out with a different ID. The + real icon resource is then a group resource which can be used to + select one of the actual icon bitmaps. */ + +void +define_icon (rc_res_id id, const rc_res_res_info *resinfo, + const char *filename) +{ + FILE *e; + char *real_filename; + int type, count, i; + struct icondir *icondirs; + int first_icon; + rc_res_resource *r; + rc_group_icon *first, **pp; + + e = open_file_search (filename, FOPEN_RB, "icon file", &real_filename); + + /* The start of an icon file is a three word structure. The first + word is ignored. The second word is the type of data. The third + word is the number of entries. */ + + get_word (e, real_filename); + type = get_word (e, real_filename); + count = get_word (e, real_filename); + if (type != 1) + fatal (_("icon file `%s' does not contain icon data"), real_filename); + + /* Read in the icon directory entries. */ + + icondirs = (struct icondir *) xmalloc (count * sizeof *icondirs); + + for (i = 0; i < count; i++) + { + icondirs[i].width = getc (e); + icondirs[i].height = getc (e); + icondirs[i].colorcount = getc (e); + getc (e); + icondirs[i].u.icon.planes = get_word (e, real_filename); + icondirs[i].u.icon.bits = get_word (e, real_filename); + icondirs[i].bytes = get_long (e, real_filename); + icondirs[i].offset = get_long (e, real_filename); + + if (feof (e)) + unexpected_eof (real_filename); + } + + /* Define each icon as a unique resource. */ + + first_icon = icons; + + for (i = 0; i < count; i++) + { + bfd_byte *data; + rc_res_id name; + + if (fseek (e, icondirs[i].offset, SEEK_SET) != 0) + fatal (_("%s: fseek to %lu failed: %s"), real_filename, + icondirs[i].offset, strerror (errno)); + + data = (bfd_byte *) res_alloc (icondirs[i].bytes); + + get_data (e, data, icondirs[i].bytes, real_filename); + + ++icons; + + name.named = 0; + name.u.id = icons; + + r = define_standard_resource (&resources, RT_ICON, name, + resinfo->language, 0); + r->type = RES_TYPE_ICON; + r->u.data.length = icondirs[i].bytes; + r->u.data.data = data; + r->res_info = *resinfo; + } + + fclose (e); + free (real_filename); + + /* Define an icon group resource. */ + + first = NULL; + pp = &first; + for (i = 0; i < count; i++) + { + rc_group_icon *cg; + + /* For some reason, at least in some files the planes and bits + are zero. We instead set them from the color. This is + copied from rcl. */ + + cg = (rc_group_icon *) res_alloc (sizeof (rc_group_icon)); + cg->next = NULL; + cg->width = icondirs[i].width; + cg->height = icondirs[i].height; + cg->colors = icondirs[i].colorcount; + + if (icondirs[i].u.icon.planes) + cg->planes = icondirs[i].u.icon.planes; + else + cg->planes = 1; + + if (icondirs[i].u.icon.bits) + cg->bits = icondirs[i].u.icon.bits; + else + { + cg->bits = 0; + + while ((1L << cg->bits) < cg->colors) + ++cg->bits; + } + + cg->bytes = icondirs[i].bytes; + cg->index = first_icon + i + 1; + + *pp = cg; + pp = &(*pp)->next; + } + + free (icondirs); + + r = define_standard_resource (&resources, RT_GROUP_ICON, id, + resinfo->language, 0); + r->type = RES_TYPE_GROUP_ICON; + r->u.group_icon = first; + r->res_info = *resinfo; +} + +static void +define_group_icon_rcdata (rc_res_id id, const rc_res_res_info *resinfo, + rc_rcdata_item *data) +{ + rc_res_resource *r; + rc_group_icon *cg, *first, *cur; + rc_uint_type len_data; + bfd_byte *pb_data; + + pb_data = rcdata_render_as_buffer (data, &len_data); + + cur = NULL; + first = NULL; + + while (len_data >= 6) + { + int c, i; + unsigned short type; + type = windres_get_16 (&wrtarget, pb_data + 2, len_data - 2); + if (type != 1) + fatal (_("unexpected group icon type %d"), type); + c = windres_get_16 (&wrtarget, pb_data + 4, len_data - 4); + len_data -= 6; + pb_data += 6; + + for (i = 0; i < c; i++) + { + if (len_data < 14) + fatal ("too small group icon rcdata"); + cg = (rc_group_icon *) res_alloc (sizeof (rc_group_icon)); + cg->next = NULL; + cg->width = pb_data[0]; + cg->height = pb_data[1]; + cg->colors = pb_data[2]; + cg->planes = windres_get_16 (&wrtarget, pb_data + 4, len_data - 4); + cg->bits = windres_get_16 (&wrtarget, pb_data + 6, len_data - 6); + cg->bytes = windres_get_32 (&wrtarget, pb_data + 8, len_data - 8); + cg->index = windres_get_16 (&wrtarget, pb_data + 12, len_data - 12); + if (! first) + first = cg; + else + cur->next = cg; + cur = cg; + pb_data += 14; + len_data -= 14; + } + } + r = define_standard_resource (&resources, RT_GROUP_ICON, id, + resinfo->language, 0); + r->type = RES_TYPE_GROUP_ICON; + r->u.group_icon = first; + r->res_info = *resinfo; +} + +static void +define_group_cursor_rcdata (rc_res_id id, const rc_res_res_info *resinfo, + rc_rcdata_item *data) +{ + rc_res_resource *r; + rc_group_cursor *cg, *first, *cur; + rc_uint_type len_data; + bfd_byte *pb_data; + + pb_data = rcdata_render_as_buffer (data, &len_data); + + first = cur = NULL; + + while (len_data >= 6) + { + int c, i; + unsigned short type; + type = windres_get_16 (&wrtarget, pb_data + 2, len_data - 2); + if (type != 2) + fatal (_("unexpected group cursor type %d"), type); + c = windres_get_16 (&wrtarget, pb_data + 4, len_data - 4); + len_data -= 6; + pb_data += 6; + + for (i = 0; i < c; i++) + { + if (len_data < 14) + fatal ("too small group icon rcdata"); + cg = (rc_group_cursor *) res_alloc (sizeof (rc_group_cursor)); + cg->next = NULL; + cg->width = windres_get_16 (&wrtarget, pb_data, len_data); + cg->height = windres_get_16 (&wrtarget, pb_data + 2, len_data - 2); + cg->planes = windres_get_16 (&wrtarget, pb_data + 4, len_data - 4); + cg->bits = windres_get_16 (&wrtarget, pb_data + 6, len_data - 6); + cg->bytes = windres_get_32 (&wrtarget, pb_data + 8, len_data - 8); + cg->index = windres_get_16 (&wrtarget, pb_data + 12, len_data - 12); + if (! first) + first = cg; + else + cur->next = cg; + cur = cg; + pb_data += 14; + len_data -= 14; + } + } + + r = define_standard_resource (&resources, RT_GROUP_ICON, id, + resinfo->language, 0); + r->type = RES_TYPE_GROUP_CURSOR; + r->u.group_cursor = first; + r->res_info = *resinfo; +} + +static void +define_cursor_rcdata (rc_res_id id, const rc_res_res_info *resinfo, + rc_rcdata_item *data) +{ + rc_cursor *c; + rc_res_resource *r; + rc_uint_type len_data; + bfd_byte *pb_data; + + pb_data = rcdata_render_as_buffer (data, &len_data); + + c = (rc_cursor *) res_alloc (sizeof (rc_cursor)); + c->xhotspot = windres_get_16 (&wrtarget, pb_data, len_data); + c->yhotspot = windres_get_16 (&wrtarget, pb_data + 2, len_data - 2); + c->length = len_data - BIN_CURSOR_SIZE; + c->data = (const bfd_byte *) (data + BIN_CURSOR_SIZE); + + r = define_standard_resource (&resources, RT_CURSOR, id, resinfo->language, 0); + r->type = RES_TYPE_CURSOR; + r->u.cursor = c; + r->res_info = *resinfo; +} + +static void +define_bitmap_rcdata (rc_res_id id, const rc_res_res_info *resinfo, + rc_rcdata_item *data) +{ + rc_res_resource *r; + rc_uint_type len_data; + bfd_byte *pb_data; + + pb_data = rcdata_render_as_buffer (data, &len_data); + + r = define_standard_resource (&resources, RT_BITMAP, id, resinfo->language, 0); + r->type = RES_TYPE_BITMAP; + r->u.data.length = len_data; + r->u.data.data = pb_data; + r->res_info = *resinfo; +} + +static void +define_icon_rcdata (rc_res_id id, const rc_res_res_info *resinfo, + rc_rcdata_item *data) +{ + rc_res_resource *r; + rc_uint_type len_data; + bfd_byte *pb_data; + + pb_data = rcdata_render_as_buffer (data, &len_data); + + r = define_standard_resource (&resources, RT_ICON, id, resinfo->language, 0); + r->type = RES_TYPE_ICON; + r->u.data.length = len_data; + r->u.data.data = pb_data; + r->res_info = *resinfo; +} + +/* Define a menu resource. */ + +void +define_menu (rc_res_id id, const rc_res_res_info *resinfo, + rc_menuitem *menuitems) +{ + rc_menu *m; + rc_res_resource *r; + + m = (rc_menu *) res_alloc (sizeof (rc_menu)); + m->items = menuitems; + m->help = 0; + + r = define_standard_resource (&resources, RT_MENU, id, resinfo->language, 0); + r->type = RES_TYPE_MENU; + r->u.menu = m; + r->res_info = *resinfo; +} + +/* Define a menu item. This does not define a resource, but merely + allocates and fills in a structure. */ + +rc_menuitem * +define_menuitem (const unichar *text, rc_uint_type menuid, rc_uint_type type, + rc_uint_type state, rc_uint_type help, + rc_menuitem *menuitems) +{ + rc_menuitem *mi; + + mi = (rc_menuitem *) res_alloc (sizeof (rc_menuitem)); + mi->next = NULL; + mi->type = type; + mi->state = state; + mi->id = menuid; + mi->text = unichar_dup (text); + mi->help = help; + mi->popup = menuitems; + return mi; +} + +/* Define a messagetable resource. */ + +void +define_messagetable (rc_res_id id, const rc_res_res_info *resinfo, + const char *filename) +{ + FILE *e; + char *real_filename; + struct stat s; + bfd_byte *data; + rc_res_resource *r; + + e = open_file_search (filename, FOPEN_RB, "messagetable file", + &real_filename); + + if (stat (real_filename, &s) < 0) + fatal (_("stat failed on bitmap file `%s': %s"), real_filename, + strerror (errno)); + + data = (bfd_byte *) res_alloc (s.st_size); + + get_data (e, data, s.st_size, real_filename); + + fclose (e); + free (real_filename); + + r = define_standard_resource (&resources, RT_MESSAGETABLE, id, + resinfo->language, 0); + + r->type = RES_TYPE_MESSAGETABLE; + r->u.data.length = s.st_size; + r->u.data.data = data; + r->res_info = *resinfo; +} + +/* Define an rcdata resource. */ + +void +define_rcdata (rc_res_id id, const rc_res_res_info *resinfo, + rc_rcdata_item *data) +{ + rc_res_resource *r; + + r = define_standard_resource (&resources, RT_RCDATA, id, + resinfo->language, 0); + r->type = RES_TYPE_RCDATA; + r->u.rcdata = data; + r->res_info = *resinfo; +} + +/* Create an rcdata item holding a string. */ + +rc_rcdata_item * +define_rcdata_string (const char *string, rc_uint_type len) +{ + rc_rcdata_item *ri; + char *s; + + ri = (rc_rcdata_item *) res_alloc (sizeof (rc_rcdata_item)); + ri->next = NULL; + ri->type = RCDATA_STRING; + ri->u.string.length = len; + s = (char *) res_alloc (len); + memcpy (s, string, len); + ri->u.string.s = s; + + return ri; +} + +/* Create an rcdata item holding a unicode string. */ + +rc_rcdata_item * +define_rcdata_unistring (const unichar *string, rc_uint_type len) +{ + rc_rcdata_item *ri; + unichar *s; + + ri = (rc_rcdata_item *) res_alloc (sizeof (rc_rcdata_item)); + ri->next = NULL; + ri->type = RCDATA_WSTRING; + ri->u.wstring.length = len; + s = (unichar *) res_alloc (len * sizeof (unichar)); + memcpy (s, string, len * sizeof (unichar)); + ri->u.wstring.w = s; + + return ri; +} + +/* Create an rcdata item holding a number. */ + +rc_rcdata_item * +define_rcdata_number (rc_uint_type val, int dword) +{ + rc_rcdata_item *ri; + + ri = (rc_rcdata_item *) res_alloc (sizeof (rc_rcdata_item)); + ri->next = NULL; + ri->type = dword ? RCDATA_DWORD : RCDATA_WORD; + ri->u.word = val; + + return ri; +} + +/* Define a stringtable resource. This is called for each string + which appears in a STRINGTABLE statement. */ + +void +define_stringtable (const rc_res_res_info *resinfo, + rc_uint_type stringid, const unichar *string, int len) +{ + unichar *h; + rc_res_id id; + rc_res_resource *r; + + id.named = 0; + id.u.id = (stringid >> 4) + 1; + r = define_standard_resource (&resources, RT_STRING, id, + resinfo->language, 1); + + if (r->type == RES_TYPE_UNINITIALIZED) + { + int i; + + r->type = RES_TYPE_STRINGTABLE; + r->u.stringtable = ((rc_stringtable *) + res_alloc (sizeof (rc_stringtable))); + for (i = 0; i < 16; i++) + { + r->u.stringtable->strings[i].length = 0; + r->u.stringtable->strings[i].string = NULL; + } + + r->res_info = *resinfo; + } + h = (unichar *) res_alloc ((len + 1) * sizeof (unichar)); + if (len) + memcpy (h, string, len * sizeof (unichar)); + h[len] = 0; + r->u.stringtable->strings[stringid & 0xf].length = (rc_uint_type) len; + r->u.stringtable->strings[stringid & 0xf].string = h; +} + +void +define_toolbar (rc_res_id id, rc_res_res_info *resinfo, rc_uint_type width, rc_uint_type height, + rc_toolbar_item *items) +{ + rc_toolbar *t; + rc_res_resource *r; + + t = (rc_toolbar *) res_alloc (sizeof (rc_toolbar)); + t->button_width = width; + t->button_height = height; + t->nitems = 0; + t->items = items; + while (items != NULL) + { + t->nitems+=1; + items = items->next; + } + r = define_standard_resource (&resources, RT_TOOLBAR, id, resinfo->language, 0); + r->type = RES_TYPE_TOOLBAR; + r->u.toolbar = t; + r->res_info = *resinfo; +} + +/* Define a user data resource where the data is in the rc file. */ + +void +define_user_data (rc_res_id id, rc_res_id type, + const rc_res_res_info *resinfo, + rc_rcdata_item *data) +{ + rc_res_id ids[3]; + rc_res_resource *r; + bfd_byte *pb_data; + rc_uint_type len_data; + + /* We have to check if the binary data is parsed specially. */ + if (type.named == 0) + { + switch (type.u.id) + { + case RT_FONTDIR: + define_fontdir_rcdata (id, resinfo, data); + return; + case RT_FONT: + define_font_rcdata (id, resinfo, data); + return; + case RT_ICON: + define_icon_rcdata (id, resinfo, data); + return; + case RT_BITMAP: + define_bitmap_rcdata (id, resinfo, data); + return; + case RT_CURSOR: + define_cursor_rcdata (id, resinfo, data); + return; + case RT_GROUP_ICON: + define_group_icon_rcdata (id, resinfo, data); + return; + case RT_GROUP_CURSOR: + define_group_cursor_rcdata (id, resinfo, data); + return; + case RT_MESSAGETABLE: + define_messagetable_rcdata (id, resinfo, data); + return; + default: + /* Treat as normal user-data. */ + break; + } + } + ids[0] = type; + ids[1] = id; + ids[2].named = 0; + ids[2].u.id = resinfo->language; + + r = define_resource (& resources, 3, ids, 0); + r->type = RES_TYPE_USERDATA; + r->u.userdata = ((rc_rcdata_item *) + res_alloc (sizeof (rc_rcdata_item))); + r->u.userdata->next = NULL; + r->u.userdata->type = RCDATA_BUFFER; + pb_data = rcdata_render_as_buffer (data, &len_data); + r->u.userdata->u.buffer.length = len_data; + r->u.userdata->u.buffer.data = pb_data; + r->res_info = *resinfo; +} + +void +define_rcdata_file (rc_res_id id, const rc_res_res_info *resinfo, + const char *filename) +{ + rc_rcdata_item *ri; + FILE *e; + char *real_filename; + struct stat s; + bfd_byte *data; + + e = open_file_search (filename, FOPEN_RB, "file", &real_filename); + + + if (stat (real_filename, &s) < 0) + fatal (_("stat failed on file `%s': %s"), real_filename, + strerror (errno)); + + data = (bfd_byte *) res_alloc (s.st_size); + + get_data (e, data, s.st_size, real_filename); + + fclose (e); + free (real_filename); + + ri = (rc_rcdata_item *) res_alloc (sizeof (rc_rcdata_item)); + ri->next = NULL; + ri->type = RCDATA_BUFFER; + ri->u.buffer.length = s.st_size; + ri->u.buffer.data = data; + + define_rcdata (id, resinfo, ri); +} + +/* Define a user data resource where the data is in a file. */ + +void +define_user_file (rc_res_id id, rc_res_id type, + const rc_res_res_info *resinfo, const char *filename) +{ + FILE *e; + char *real_filename; + struct stat s; + bfd_byte *data; + rc_res_id ids[3]; + rc_res_resource *r; + + e = open_file_search (filename, FOPEN_RB, "file", &real_filename); + + if (stat (real_filename, &s) < 0) + fatal (_("stat failed on file `%s': %s"), real_filename, + strerror (errno)); + + data = (bfd_byte *) res_alloc (s.st_size); + + get_data (e, data, s.st_size, real_filename); + + fclose (e); + free (real_filename); + + ids[0] = type; + ids[1] = id; + ids[2].named = 0; + ids[2].u.id = resinfo->language; + + r = define_resource (&resources, 3, ids, 0); + r->type = RES_TYPE_USERDATA; + r->u.userdata = ((rc_rcdata_item *) + res_alloc (sizeof (rc_rcdata_item))); + r->u.userdata->next = NULL; + r->u.userdata->type = RCDATA_BUFFER; + r->u.userdata->u.buffer.length = s.st_size; + r->u.userdata->u.buffer.data = data; + r->res_info = *resinfo; +} + +/* Define a versioninfo resource. */ + +void +define_versioninfo (rc_res_id id, rc_uint_type language, + rc_fixed_versioninfo *fixedverinfo, + rc_ver_info *verinfo) +{ + rc_res_resource *r; + + r = define_standard_resource (&resources, RT_VERSION, id, language, 0); + r->type = RES_TYPE_VERSIONINFO; + r->u.versioninfo = ((rc_versioninfo *) + res_alloc (sizeof (rc_versioninfo))); + r->u.versioninfo->fixed = fixedverinfo; + r->u.versioninfo->var = verinfo; + r->res_info.language = language; +} + +/* Add string version info to a list of version information. */ + +rc_ver_info * +append_ver_stringfileinfo (rc_ver_info *verinfo, + rc_ver_stringtable *stringtables) +{ + rc_ver_info *vi, **pp; + + vi = (rc_ver_info *) res_alloc (sizeof (rc_ver_info)); + vi->next = NULL; + vi->type = VERINFO_STRING; + vi->u.string.stringtables = stringtables; + + for (pp = &verinfo; *pp != NULL; pp = &(*pp)->next) + ; + *pp = vi; + + return verinfo; +} + +rc_ver_stringtable * +append_ver_stringtable (rc_ver_stringtable *stringtable, + const char *language, + rc_ver_stringinfo *strings) +{ + rc_ver_stringtable *vst, **pp; + + vst = (rc_ver_stringtable *) res_alloc (sizeof (rc_ver_stringtable)); + vst->next = NULL; + unicode_from_ascii ((rc_uint_type *) NULL, &vst->language, language); + vst->strings = strings; + + for (pp = &stringtable; *pp != NULL; pp = &(*pp)->next) + ; + *pp = vst; + + return stringtable; +} + +/* Add variable version info to a list of version information. */ + +rc_ver_info * +append_ver_varfileinfo (rc_ver_info *verinfo, const unichar *key, + rc_ver_varinfo *var) +{ + rc_ver_info *vi, **pp; + + vi = (rc_ver_info *) res_alloc (sizeof *vi); + vi->next = NULL; + vi->type = VERINFO_VAR; + vi->u.var.key = unichar_dup (key); + vi->u.var.var = var; + + for (pp = &verinfo; *pp != NULL; pp = &(*pp)->next) + ; + *pp = vi; + + return verinfo; +} + +/* Append version string information to a list. */ + +rc_ver_stringinfo * +append_verval (rc_ver_stringinfo *strings, const unichar *key, + const unichar *value) +{ + rc_ver_stringinfo *vs, **pp; + + vs = (rc_ver_stringinfo *) res_alloc (sizeof (rc_ver_stringinfo)); + vs->next = NULL; + vs->key = unichar_dup (key); + vs->value = unichar_dup (value); + + for (pp = &strings; *pp != NULL; pp = &(*pp)->next) + ; + *pp = vs; + + return strings; +} + +/* Append version variable information to a list. */ + +rc_ver_varinfo * +append_vertrans (rc_ver_varinfo *var, rc_uint_type language, + rc_uint_type charset) +{ + rc_ver_varinfo *vv, **pp; + + vv = (rc_ver_varinfo *) res_alloc (sizeof (rc_ver_varinfo)); + vv->next = NULL; + vv->language = language; + vv->charset = charset; + + for (pp = &var; *pp != NULL; pp = &(*pp)->next) + ; + *pp = vv; + + return var; +} + +/* Local functions used to write out an rc file. */ + +static void indent (FILE *, int); +static void write_rc_directory (FILE *, const rc_res_directory *, const rc_res_id *, + const rc_res_id *, rc_uint_type *, int); +static void write_rc_subdir (FILE *, const rc_res_entry *, const rc_res_id *, + const rc_res_id *, rc_uint_type *, int); +static void write_rc_resource (FILE *, const rc_res_id *, const rc_res_id *, + const rc_res_resource *, rc_uint_type *); +static void write_rc_accelerators (FILE *, const rc_accelerator *); +static void write_rc_cursor (FILE *, const rc_cursor *); +static void write_rc_group_cursor (FILE *, const rc_group_cursor *); +static void write_rc_dialog (FILE *, const rc_dialog *); +static void write_rc_dialog_control (FILE *, const rc_dialog_control *); +static void write_rc_fontdir (FILE *, const rc_fontdir *); +static void write_rc_group_icon (FILE *, const rc_group_icon *); +static void write_rc_menu (FILE *, const rc_menu *, int); +static void write_rc_toolbar (FILE *, const rc_toolbar *); +static void write_rc_menuitems (FILE *, const rc_menuitem *, int, int); +static void write_rc_messagetable (FILE *, rc_uint_type , const bfd_byte *); + +static void write_rc_datablock (FILE *, rc_uint_type , const bfd_byte *, int, int, int); +static void write_rc_rcdata (FILE *, const rc_rcdata_item *, int); +static void write_rc_stringtable (FILE *, const rc_res_id *, const rc_stringtable *); +static void write_rc_versioninfo (FILE *, const rc_versioninfo *); + +/* Indent a given number of spaces. */ + +static void +indent (FILE *e, int c) +{ + int i; + + for (i = 0; i < c; i++) + putc (' ', e); +} + +/* Dump the resources we have read in the format of an rc file. + + Reasoned by the fact, that some resources need to be stored into file and + refer to that file, we use the user-data model for that to express it binary + without the need to store it somewhere externally. */ + +void +write_rc_file (const char *filename, const rc_res_directory *res_dir) +{ + FILE *e; + rc_uint_type language; + + if (filename == NULL) + e = stdout; + else + { + e = fopen (filename, FOPEN_WT); + if (e == NULL) + fatal (_("can't open `%s' for output: %s"), filename, strerror (errno)); + } + + language = (rc_uint_type) ((bfd_signed_vma) -1); + write_rc_directory (e, res_dir, (const rc_res_id *) NULL, + (const rc_res_id *) NULL, &language, 1); +} + +/* Write out a directory. E is the file to write to. RD is the + directory. TYPE is a pointer to the level 1 ID which serves as the + resource type. NAME is a pointer to the level 2 ID which serves as + an individual resource name. LANGUAGE is a pointer to the current + language. LEVEL is the level in the tree. */ + +static void +write_rc_directory (FILE *e, const rc_res_directory *rd, + const rc_res_id *type, const rc_res_id *name, + rc_uint_type *language, int level) +{ + const rc_res_entry *re; + + /* Print out some COFF information that rc files can't represent. */ + if (rd->time != 0 || rd->characteristics != 0 || rd->major != 0 || rd->minor != 0) + { + wr_printcomment (e, "COFF information not part of RC"); + if (rd->time != 0) + wr_printcomment (e, "Time stamp: %u", rd->time); + if (rd->characteristics != 0) + wr_printcomment (e, "Characteristics: %u", rd->characteristics); + if (rd->major != 0 || rd->minor != 0) + wr_printcomment (e, "Version major:%d minor:%d", rd->major, rd->minor); + } + + for (re = rd->entries; re != NULL; re = re->next) + { + switch (level) + { + case 1: + /* If we're at level 1, the key of this resource is the + type. This normally duplicates the information we have + stored with the resource itself, but we need to remember + the type if this is a user define resource type. */ + type = &re->id; + break; + + case 2: + /* If we're at level 2, the key of this resource is the name + we are going to use in the rc printout. */ + name = &re->id; + break; + + case 3: + /* If we're at level 3, then this key represents a language. + Use it to update the current language. */ + if (! re->id.named + && re->id.u.id != (unsigned long) (unsigned int) *language + && (re->id.u.id & 0xffff) == re->id.u.id) + { + wr_print (e, "LANGUAGE %u, %u\n", + re->id.u.id & ((1 << SUBLANG_SHIFT) - 1), + (re->id.u.id >> SUBLANG_SHIFT) & 0xff); + *language = re->id.u.id; + } + break; + + default: + break; + } + + if (re->subdir) + write_rc_subdir (e, re, type, name, language, level); + else + { + if (level == 3) + { + /* This is the normal case: the three levels are + TYPE/NAME/LANGUAGE. NAME will have been set at level + 2, and represents the name to use. We probably just + set LANGUAGE, and it will probably match what the + resource itself records if anything. */ + write_rc_resource (e, type, name, re->u.res, language); + } + else + { + wr_printcomment (e, "Resource at unexpected level %d", level); + write_rc_resource (e, type, (rc_res_id *) NULL, re->u.res, + language); + } + } + } + if (rd->entries == NULL) + { + wr_print_flush (e); + } +} + +/* Write out a subdirectory entry. E is the file to write to. RE is + the subdirectory entry. TYPE and NAME are pointers to higher level + IDs, or NULL. LANGUAGE is a pointer to the current language. + LEVEL is the level in the tree. */ + +static void +write_rc_subdir (FILE *e, const rc_res_entry *re, + const rc_res_id *type, const rc_res_id *name, + rc_uint_type *language, int level) +{ + fprintf (e, "\n"); + switch (level) + { + case 1: + wr_printcomment (e, "Type: "); + if (re->id.named) + res_id_print (e, re->id, 1); + else + { + const char *s; + + switch (re->id.u.id) + { + case RT_CURSOR: s = "cursor"; break; + case RT_BITMAP: s = "bitmap"; break; + case RT_ICON: s = "icon"; break; + case RT_MENU: s = "menu"; break; + case RT_DIALOG: s = "dialog"; break; + case RT_STRING: s = "stringtable"; break; + case RT_FONTDIR: s = "fontdir"; break; + case RT_FONT: s = "font"; break; + case RT_ACCELERATOR: s = "accelerators"; break; + case RT_RCDATA: s = "rcdata"; break; + case RT_MESSAGETABLE: s = "messagetable"; break; + case RT_GROUP_CURSOR: s = "group cursor"; break; + case RT_GROUP_ICON: s = "group icon"; break; + case RT_VERSION: s = "version"; break; + case RT_DLGINCLUDE: s = "dlginclude"; break; + case RT_PLUGPLAY: s = "plugplay"; break; + case RT_VXD: s = "vxd"; break; + case RT_ANICURSOR: s = "anicursor"; break; + case RT_ANIICON: s = "aniicon"; break; + case RT_TOOLBAR: s = "toolbar"; break; + case RT_HTML: s = "html"; break; + default: s = NULL; break; + } + + if (s != NULL) + fprintf (e, "%s", s); + else + res_id_print (e, re->id, 1); + } + break; + + case 2: + wr_printcomment (e, "Name: "); + res_id_print (e, re->id, 1); + break; + + case 3: + wr_printcomment (e, "Language: "); + res_id_print (e, re->id, 1); + break; + + default: + wr_printcomment (e, "Level %d: ", level); + res_id_print (e, re->id, 1); + } + + write_rc_directory (e, re->u.dir, type, name, language, level + 1); +} + +/* Write out a single resource. E is the file to write to. TYPE is a + pointer to the type of the resource. NAME is a pointer to the name + of the resource; it will be NULL if there is a level mismatch. RES + is the resource data. LANGUAGE is a pointer to the current + language. */ + +static void +write_rc_resource (FILE *e, const rc_res_id *type, + const rc_res_id *name, const rc_res_resource *res, + rc_uint_type *language) +{ + const char *s; + int rt; + int menuex = 0; + + switch (res->type) + { + default: + abort (); + + case RES_TYPE_ACCELERATOR: + s = "ACCELERATORS"; + rt = RT_ACCELERATOR; + break; + + case RES_TYPE_BITMAP: + s = "2 /* RT_BITMAP */"; + rt = RT_BITMAP; + break; + + case RES_TYPE_CURSOR: + s = "1 /* RT_CURSOR */"; + rt = RT_CURSOR; + break; + + case RES_TYPE_GROUP_CURSOR: + s = "12 /* RT_GROUP_CURSOR */"; + rt = RT_GROUP_CURSOR; + break; + + case RES_TYPE_DIALOG: + if (extended_dialog (res->u.dialog)) + s = "DIALOGEX"; + else + s = "DIALOG"; + rt = RT_DIALOG; + break; + + case RES_TYPE_FONT: + s = "8 /* RT_FONT */"; + rt = RT_FONT; + break; + + case RES_TYPE_FONTDIR: + s = "7 /* RT_FONTDIR */"; + rt = RT_FONTDIR; + break; + + case RES_TYPE_ICON: + s = "3 /* RT_ICON */"; + rt = RT_ICON; + break; + + case RES_TYPE_GROUP_ICON: + s = "14 /* RT_GROUP_ICON */"; + rt = RT_GROUP_ICON; + break; + + case RES_TYPE_MENU: + if (extended_menu (res->u.menu)) + { + s = "MENUEX"; + menuex = 1; + } + else + { + s = "MENU"; + menuex = 0; + } + rt = RT_MENU; + break; + + case RES_TYPE_MESSAGETABLE: + s = "11 /* RT_MESSAGETABLE */"; + rt = RT_MESSAGETABLE; + break; + + case RES_TYPE_RCDATA: + s = "RCDATA"; + rt = RT_RCDATA; + break; + + case RES_TYPE_STRINGTABLE: + s = "STRINGTABLE"; + rt = RT_STRING; + break; + + case RES_TYPE_USERDATA: + s = NULL; + rt = 0; + break; + + case RES_TYPE_VERSIONINFO: + s = "VERSIONINFO"; + rt = RT_VERSION; + break; + + case RES_TYPE_TOOLBAR: + s = "TOOLBAR"; + rt = RT_TOOLBAR; + break; + } + + if (rt != 0 + && type != NULL + && (type->named || type->u.id != (unsigned long) rt)) + { + wr_printcomment (e, "Unexpected resource type mismatch: "); + res_id_print (e, *type, 1); + fprintf (e, " != %d", rt); + } + + if (res->coff_info.codepage != 0) + wr_printcomment (e, "Code page: %u", res->coff_info.codepage); + if (res->coff_info.reserved != 0) + wr_printcomment (e, "COFF reserved value: %u", res->coff_info.reserved); + + wr_print (e, "\n"); + if (rt == RT_STRING) + ; + else + { + if (name != NULL) + res_id_print (e, *name, 1); + else + fprintf (e, "??Unknown-Name??"); + fprintf (e, " "); + } + + if (s != NULL) + fprintf (e, "%s", s); + else if (type != NULL) + { + if (type->named == 0) + { +#define PRINT_RT_NAME(NAME) case NAME: \ + fprintf (e, "%u /* %s */", (unsigned int) NAME, #NAME); \ + break + + switch (type->u.id) + { + default: + res_id_print (e, *type, 0); + break; + + PRINT_RT_NAME(RT_MANIFEST); + PRINT_RT_NAME(RT_ANICURSOR); + PRINT_RT_NAME(RT_ANIICON); + PRINT_RT_NAME(RT_RCDATA); + PRINT_RT_NAME(RT_ICON); + PRINT_RT_NAME(RT_CURSOR); + PRINT_RT_NAME(RT_BITMAP); + PRINT_RT_NAME(RT_PLUGPLAY); + PRINT_RT_NAME(RT_VXD); + PRINT_RT_NAME(RT_FONT); + PRINT_RT_NAME(RT_FONTDIR); + PRINT_RT_NAME(RT_HTML); + PRINT_RT_NAME(RT_MESSAGETABLE); + PRINT_RT_NAME(RT_DLGINCLUDE); + PRINT_RT_NAME(RT_DLGINIT); + } +#undef PRINT_RT_NAME + } + else + res_id_print (e, *type, 1); + } + else + fprintf (e, "??Unknown-Type??"); + + if (res->res_info.memflags != 0) + { + if ((res->res_info.memflags & MEMFLAG_MOVEABLE) != 0) + fprintf (e, " MOVEABLE"); + if ((res->res_info.memflags & MEMFLAG_PURE) != 0) + fprintf (e, " PURE"); + if ((res->res_info.memflags & MEMFLAG_PRELOAD) != 0) + fprintf (e, " PRELOAD"); + if ((res->res_info.memflags & MEMFLAG_DISCARDABLE) != 0) + fprintf (e, " DISCARDABLE"); + } + + if (res->type == RES_TYPE_DIALOG) + { + fprintf (e, " %d, %d, %d, %d", + (int) res->u.dialog->x, (int) res->u.dialog->y, + (int) res->u.dialog->width, (int) res->u.dialog->height); + if (res->u.dialog->ex != NULL + && res->u.dialog->ex->help != 0) + fprintf (e, ", %u", (unsigned int) res->u.dialog->ex->help); + } + else if (res->type == RES_TYPE_TOOLBAR) + { + fprintf (e, " %d, %d", (int) res->u.toolbar->button_width, + (int) res->u.toolbar->button_height); + } + + fprintf (e, "\n"); + + if ((res->res_info.language != 0 && res->res_info.language != *language) + || res->res_info.characteristics != 0 + || res->res_info.version != 0) + { + int modifiers; + + switch (res->type) + { + case RES_TYPE_ACCELERATOR: + case RES_TYPE_DIALOG: + case RES_TYPE_MENU: + case RES_TYPE_RCDATA: + case RES_TYPE_STRINGTABLE: + modifiers = 1; + break; + + default: + modifiers = 0; + break; + } + + if (res->res_info.language != 0 && res->res_info.language != *language) + fprintf (e, "%sLANGUAGE %d, %d\n", + modifiers ? "// " : "", + (int) res->res_info.language & ((1<res_info.language >> SUBLANG_SHIFT) & 0xff); + if (res->res_info.characteristics != 0) + fprintf (e, "%sCHARACTERISTICS %u\n", + modifiers ? "// " : "", + (unsigned int) res->res_info.characteristics); + if (res->res_info.version != 0) + fprintf (e, "%sVERSION %u\n", + modifiers ? "// " : "", + (unsigned int) res->res_info.version); + } + + switch (res->type) + { + default: + abort (); + + case RES_TYPE_ACCELERATOR: + write_rc_accelerators (e, res->u.acc); + break; + + case RES_TYPE_CURSOR: + write_rc_cursor (e, res->u.cursor); + break; + + case RES_TYPE_GROUP_CURSOR: + write_rc_group_cursor (e, res->u.group_cursor); + break; + + case RES_TYPE_DIALOG: + write_rc_dialog (e, res->u.dialog); + break; + + case RES_TYPE_FONTDIR: + write_rc_fontdir (e, res->u.fontdir); + break; + + case RES_TYPE_GROUP_ICON: + write_rc_group_icon (e, res->u.group_icon); + break; + + case RES_TYPE_MENU: + write_rc_menu (e, res->u.menu, menuex); + break; + + case RES_TYPE_RCDATA: + write_rc_rcdata (e, res->u.rcdata, 0); + break; + + case RES_TYPE_STRINGTABLE: + write_rc_stringtable (e, name, res->u.stringtable); + break; + + case RES_TYPE_USERDATA: + write_rc_rcdata (e, res->u.userdata, 0); + break; + + case RES_TYPE_TOOLBAR: + write_rc_toolbar (e, res->u.toolbar); + break; + + case RES_TYPE_VERSIONINFO: + write_rc_versioninfo (e, res->u.versioninfo); + break; + + case RES_TYPE_BITMAP: + case RES_TYPE_FONT: + case RES_TYPE_ICON: + write_rc_datablock (e, res->u.data.length, res->u.data.data, 0, 1, 0); + break; + case RES_TYPE_MESSAGETABLE: + write_rc_messagetable (e, res->u.data.length, res->u.data.data); + break; + } +} + +/* Write out accelerator information. */ + +static void +write_rc_accelerators (FILE *e, const rc_accelerator *accelerators) +{ + const rc_accelerator *acc; + + fprintf (e, "BEGIN\n"); + for (acc = accelerators; acc != NULL; acc = acc->next) + { + int printable; + + fprintf (e, " "); + + if ((acc->key & 0x7f) == acc->key + && ISPRINT (acc->key) + && (acc->flags & ACC_VIRTKEY) == 0) + { + fprintf (e, "\"%c\"", (char) acc->key); + printable = 1; + } + else + { + fprintf (e, "%d", (int) acc->key); + printable = 0; + } + + fprintf (e, ", %d", (int) acc->id); + + if (! printable) + { + if ((acc->flags & ACC_VIRTKEY) != 0) + fprintf (e, ", VIRTKEY"); + else + fprintf (e, ", ASCII"); + } + + if ((acc->flags & ACC_SHIFT) != 0) + fprintf (e, ", SHIFT"); + if ((acc->flags & ACC_CONTROL) != 0) + fprintf (e, ", CONTROL"); + if ((acc->flags & ACC_ALT) != 0) + fprintf (e, ", ALT"); + + fprintf (e, "\n"); + } + + fprintf (e, "END\n"); +} + +/* Write out cursor information. This would normally be in a separate + file, which the rc file would include. */ + +static void +write_rc_cursor (FILE *e, const rc_cursor *cursor) +{ + fprintf (e, "BEGIN\n"); + indent (e, 2); + fprintf (e, " 0x%x, 0x%x,\t/* Hotspot x: %d, y: %d. */\n", + (unsigned int) cursor->xhotspot, (unsigned int) cursor->yhotspot, + (int) cursor->xhotspot, (int) cursor->yhotspot); + write_rc_datablock (e, (rc_uint_type) cursor->length, (const bfd_byte *) cursor->data, + 0, 0, 0); + fprintf (e, "END\n"); +} + +/* Write out group cursor data. This would normally be built from the + cursor data. */ + +static void +write_rc_group_cursor (FILE *e, const rc_group_cursor *group_cursor) +{ + const rc_group_cursor *gc; + int c; + + for (c = 0, gc = group_cursor; gc != NULL; gc = gc->next, c++) + ; + fprintf (e, "BEGIN\n"); + + indent (e, 2); + fprintf (e, "0, 2, %d%s\t /* Having %d items. */\n", c, (c != 0 ? "," : ""), c); + indent (e, 4); + fprintf (e, "/* width, height, planes, bits, bytes, index. */\n"); + + for (c = 1, gc = group_cursor; gc != NULL; gc = gc->next, c++) + { + indent (e, 4); + fprintf (e, "%d, %d, %d, %d, 0x%xL, %d%s /* Element %d. */\n", + (int) gc->width, (int) gc->height, (int) gc->planes, (int) gc->bits, + (unsigned int) gc->bytes, (int) gc->index, (gc->next != NULL ? "," : ""), c); + fprintf (e, "/* width: %d; height %d; planes %d; bits %d. */\n", + (int) gc->width, (int) gc->height, (int) gc->planes, + (int) gc->bits); + } + fprintf (e, "END\n"); +} + +/* Write dialog data. */ + +static void +write_rc_dialog (FILE *e, const rc_dialog *dialog) +{ + const rc_dialog_control *control; + + fprintf (e, "STYLE 0x%x\n", dialog->style); + + if (dialog->exstyle != 0) + fprintf (e, "EXSTYLE 0x%x\n", (unsigned int) dialog->exstyle); + + if ((dialog->class.named && dialog->class.u.n.length > 0) + || dialog->class.u.id != 0) + { + fprintf (e, "CLASS "); + res_id_print (e, dialog->class, 1); + fprintf (e, "\n"); + } + + if (dialog->caption != NULL) + { + fprintf (e, "CAPTION "); + unicode_print_quoted (e, dialog->caption, -1); + fprintf (e, "\n"); + } + + if ((dialog->menu.named && dialog->menu.u.n.length > 0) + || dialog->menu.u.id != 0) + { + fprintf (e, "MENU "); + res_id_print (e, dialog->menu, 0); + fprintf (e, "\n"); + } + + if (dialog->font != NULL) + { + fprintf (e, "FONT %d, ", (int) dialog->pointsize); + unicode_print_quoted (e, dialog->font, -1); + if (dialog->ex != NULL + && (dialog->ex->weight != 0 + || dialog->ex->italic != 0 + || dialog->ex->charset != 1)) + fprintf (e, ", %d, %d, %d", + (int) dialog->ex->weight, + (int) dialog->ex->italic, + (int) dialog->ex->charset); + fprintf (e, "\n"); + } + + fprintf (e, "BEGIN\n"); + + for (control = dialog->controls; control != NULL; control = control->next) + write_rc_dialog_control (e, control); + + fprintf (e, "END\n"); +} + +/* For each predefined control keyword, this table provides the class + and the style. */ + +struct control_info +{ + const char *name; + unsigned short class; + unsigned long style; +}; + +static const struct control_info control_info[] = +{ + { "AUTO3STATE", CTL_BUTTON, BS_AUTO3STATE }, + { "AUTOCHECKBOX", CTL_BUTTON, BS_AUTOCHECKBOX }, + { "AUTORADIOBUTTON", CTL_BUTTON, BS_AUTORADIOBUTTON }, + { "CHECKBOX", CTL_BUTTON, BS_CHECKBOX }, + { "COMBOBOX", CTL_COMBOBOX, (unsigned long) -1 }, + { "CTEXT", CTL_STATIC, SS_CENTER }, + { "DEFPUSHBUTTON", CTL_BUTTON, BS_DEFPUSHBUTTON }, + { "EDITTEXT", CTL_EDIT, (unsigned long) -1 }, + { "GROUPBOX", CTL_BUTTON, BS_GROUPBOX }, + { "ICON", CTL_STATIC, SS_ICON }, + { "LISTBOX", CTL_LISTBOX, (unsigned long) -1 }, + { "LTEXT", CTL_STATIC, SS_LEFT }, + { "PUSHBOX", CTL_BUTTON, BS_PUSHBOX }, + { "PUSHBUTTON", CTL_BUTTON, BS_PUSHBUTTON }, + { "RADIOBUTTON", CTL_BUTTON, BS_RADIOBUTTON }, + { "RTEXT", CTL_STATIC, SS_RIGHT }, + { "SCROLLBAR", CTL_SCROLLBAR, (unsigned long) -1 }, + { "STATE3", CTL_BUTTON, BS_3STATE }, + /* It's important that USERBUTTON come after all the other button + types, so that it won't be matched too early. */ + { "USERBUTTON", CTL_BUTTON, (unsigned long) -1 }, + { NULL, 0, 0 } +}; + +/* Write a dialog control. */ + +static void +write_rc_dialog_control (FILE *e, const rc_dialog_control *control) +{ + const struct control_info *ci; + + fprintf (e, " "); + + if (control->class.named) + ci = NULL; + else + { + for (ci = control_info; ci->name != NULL; ++ci) + if (ci->class == control->class.u.id + && (ci->style == (unsigned long) -1 + || ci->style == (control->style & 0xff))) + break; + } + if (ci == NULL) + fprintf (e, "CONTROL"); + else if (ci->name != NULL) + fprintf (e, "%s", ci->name); + else + { + fprintf (e, "CONTROL"); + ci = NULL; + } + + /* For EDITTEXT, COMBOBOX, LISTBOX, and SCROLLBAR don't dump text. */ + if ((control->text.named || control->text.u.id != 0) + && (!ci + || (ci->class != CTL_EDIT + && ci->class != CTL_COMBOBOX + && ci->class != CTL_LISTBOX + && ci->class != CTL_SCROLLBAR))) + { + fprintf (e, " "); + res_id_print (e, control->text, 1); + fprintf (e, ","); + } + + fprintf (e, " %d, ", (int) control->id); + + if (ci == NULL) + { + if (control->class.named) + fprintf (e, "\""); + res_id_print (e, control->class, 0); + if (control->class.named) + fprintf (e, "\""); + fprintf (e, ", 0x%x, ", (unsigned int) control->style); + } + + fprintf (e, "%d, %d", (int) control->x, (int) control->y); + + if (control->style != SS_ICON + || control->exstyle != 0 + || control->width != 0 + || control->height != 0 + || control->help != 0) + { + fprintf (e, ", %d, %d", (int) control->width, (int) control->height); + + /* FIXME: We don't need to print the style if it is the default. + More importantly, in certain cases we actually need to turn + off parts of the forced style, by using NOT. */ + if (ci != NULL) + fprintf (e, ", 0x%x", (unsigned int) control->style); + + if (control->exstyle != 0 || control->help != 0) + fprintf (e, ", 0x%x, %u", (unsigned int) control->exstyle, + (unsigned int) control->help); + } + + fprintf (e, "\n"); + + if (control->data != NULL) + write_rc_rcdata (e, control->data, 2); +} + +/* Write out font directory data. This would normally be built from + the font data. */ + +static void +write_rc_fontdir (FILE *e, const rc_fontdir *fontdir) +{ + const rc_fontdir *fc; + int c; + + for (c = 0, fc = fontdir; fc != NULL; fc = fc->next, c++) + ; + fprintf (e, "BEGIN\n"); + indent (e, 2); + fprintf (e, "%d%s\t /* Has %d elements. */\n", c, (c != 0 ? "," : ""), c); + for (c = 1, fc = fontdir; fc != NULL; fc = fc->next, c++) + { + indent (e, 4); + fprintf (e, "%d,\t/* Font no %d with index %d. */\n", + (int) fc->index, c, (int) fc->index); + write_rc_datablock (e, (rc_uint_type) fc->length - 2, + (const bfd_byte *) fc->data + 4,fc->next != NULL, + 0, 0); + } + fprintf (e, "END\n"); +} + +/* Write out group icon data. This would normally be built from the + icon data. */ + +static void +write_rc_group_icon (FILE *e, const rc_group_icon *group_icon) +{ + const rc_group_icon *gi; + int c; + + for (c = 0, gi = group_icon; gi != NULL; gi = gi->next, c++) + ; + + fprintf (e, "BEGIN\n"); + indent (e, 2); + fprintf (e, " 0, 1, %d%s\t /* Has %d elements. */\n", c, (c != 0 ? "," : ""), c); + + indent (e, 4); + fprintf (e, "/* \"width height colors pad\", planes, bits, bytes, index. */\n"); + for (c = 1, gi = group_icon; gi != NULL; gi = gi->next, c++) + { + indent (e, 4); + fprintf (e, "\"\\%03o\\%03o\\%03o\\%03o\", %d, %d, 0x%xL, %d%s\t/* Element no %d. */\n", + gi->width, gi->height, gi->colors, 0, (int) gi->planes, (int) gi->bits, + (unsigned int) gi->bytes, (int) gi->index, (gi->next != NULL ? "," : ""), c); + } + fprintf (e, "END\n"); +} + +/* Write out a menu resource. */ + +static void +write_rc_menu (FILE *e, const rc_menu *menu, int menuex) +{ + if (menu->help != 0) + fprintf (e, "// Help ID: %u\n", (unsigned int) menu->help); + write_rc_menuitems (e, menu->items, menuex, 0); +} + +static void +write_rc_toolbar (FILE *e, const rc_toolbar *tb) +{ + rc_toolbar_item *it; + indent (e, 0); + fprintf (e, "BEGIN\n"); + it = tb->items; + while(it != NULL) + { + indent (e, 2); + if (it->id.u.id == 0) + fprintf (e, "SEPARATOR\n"); + else + fprintf (e, "BUTTON %d\n", (int) it->id.u.id); + it = it->next; + } + indent (e, 0); + fprintf (e, "END\n"); +} + +/* Write out menuitems. */ + +static void +write_rc_menuitems (FILE *e, const rc_menuitem *menuitems, int menuex, + int ind) +{ + const rc_menuitem *mi; + + indent (e, ind); + fprintf (e, "BEGIN\n"); + + for (mi = menuitems; mi != NULL; mi = mi->next) + { + indent (e, ind + 2); + + if (mi->popup == NULL) + fprintf (e, "MENUITEM"); + else + fprintf (e, "POPUP"); + + if (! menuex + && mi->popup == NULL + && mi->text == NULL + && mi->type == 0 + && mi->id == 0) + { + fprintf (e, " SEPARATOR\n"); + continue; + } + + if (mi->text == NULL) + fprintf (e, " \"\""); + else + { + fprintf (e, " "); + unicode_print_quoted (e, mi->text, -1); + } + + if (! menuex) + { + if (mi->popup == NULL) + fprintf (e, ", %d", (int) mi->id); + + if ((mi->type & MENUITEM_CHECKED) != 0) + fprintf (e, ", CHECKED"); + if ((mi->type & MENUITEM_GRAYED) != 0) + fprintf (e, ", GRAYED"); + if ((mi->type & MENUITEM_HELP) != 0) + fprintf (e, ", HELP"); + if ((mi->type & MENUITEM_INACTIVE) != 0) + fprintf (e, ", INACTIVE"); + if ((mi->type & MENUITEM_MENUBARBREAK) != 0) + fprintf (e, ", MENUBARBREAK"); + if ((mi->type & MENUITEM_MENUBREAK) != 0) + fprintf (e, ", MENUBREAK"); + } + else + { + if (mi->id != 0 || mi->type != 0 || mi->state != 0 || mi->help != 0) + { + fprintf (e, ", %d", (int) mi->id); + if (mi->type != 0 || mi->state != 0 || mi->help != 0) + { + fprintf (e, ", %u", (unsigned int) mi->type); + if (mi->state != 0 || mi->help != 0) + { + fprintf (e, ", %u", (unsigned int) mi->state); + if (mi->help != 0) + fprintf (e, ", %u", (unsigned int) mi->help); + } + } + } + } + + fprintf (e, "\n"); + + if (mi->popup != NULL) + write_rc_menuitems (e, mi->popup, menuex, ind + 2); + } + + indent (e, ind); + fprintf (e, "END\n"); +} + +static int +test_rc_datablock_unicode (rc_uint_type length, const bfd_byte *data) +{ + rc_uint_type i; + if ((length & 1) != 0) + return 0; + + for (i = 0; i < length; i += 2) + { + if (data[i] == 0 && data[i + 1] == 0 && (i + 2) < length) + return 0; + if (data[i] == 0xff && data[i + 1] == 0xff) + return 0; + } + return 1; +} + +static int +test_rc_datablock_text (rc_uint_type length, const bfd_byte *data) +{ + int has_nl; + rc_uint_type c; + rc_uint_type i; + + if (length <= 1) + return 0; + + has_nl = 0; + for (i = 0, c = 0; i < length; i++) + { + if (! ISPRINT (data[i]) && data[i] != '\n' + && ! (data[i] == '\r' && (i + 1) < length && data[i + 1] == '\n') + && data[i] != '\t' + && ! (data[i] == 0 && (i + 1) != length)) + { + if (data[i] <= 7) + return 0; + c++; + } + else if (data[i] == '\n') has_nl++; + } + if (length > 80 && ! has_nl) + return 0; + c = (((c * 10000) + (i / 100) - 1)) / i; + if (c >= 150) + return 0; + return 1; +} + +static void +write_rc_messagetable (FILE *e, rc_uint_type length, const bfd_byte *data) +{ + int has_error = 0; + const struct bin_messagetable *mt; + + fprintf (e, "BEGIN\n"); + + write_rc_datablock (e, length, data, 0, 0, 0); + + fprintf (e, "\n"); + wr_printcomment (e, "MC syntax dump"); + if (length < BIN_MESSAGETABLE_SIZE) + has_error = 1; + else + do + { + rc_uint_type m, i; + + mt = (const struct bin_messagetable *) data; + m = windres_get_32 (&wrtarget, mt->cblocks, length); + + if (length < (BIN_MESSAGETABLE_SIZE + m * BIN_MESSAGETABLE_BLOCK_SIZE)) + { + has_error = 1; + break; + } + for (i = 0; i < m; i++) + { + rc_uint_type low, high, offset; + const struct bin_messagetable_item *mti; + + low = windres_get_32 (&wrtarget, mt->items[i].lowid, 4); + high = windres_get_32 (&wrtarget, mt->items[i].highid, 4); + offset = windres_get_32 (&wrtarget, mt->items[i].offset, 4); + + while (low <= high) + { + rc_uint_type elen, flags; + if ((offset + BIN_MESSAGETABLE_ITEM_SIZE) > length) + { + has_error = 1; + break; + } + mti = (const struct bin_messagetable_item *) &data[offset]; + elen = windres_get_16 (&wrtarget, mti->length, 2); + flags = windres_get_16 (&wrtarget, mti->flags, 2); + if ((offset + elen) > length) + { + has_error = 1; + break; + } + wr_printcomment (e, "MessageId = 0x%x", low); + wr_printcomment (e, ""); + + if ((flags & MESSAGE_RESOURCE_UNICODE) == MESSAGE_RESOURCE_UNICODE) + { + /* PR 17512: file: 5c3232dc. */ + if (elen > BIN_MESSAGETABLE_ITEM_SIZE * 2) + unicode_print (e, (const unichar *) mti->data, + (elen - BIN_MESSAGETABLE_ITEM_SIZE) / 2); + } + else + { + if (elen > BIN_MESSAGETABLE_ITEM_SIZE) + ascii_print (e, (const char *) mti->data, + (elen - BIN_MESSAGETABLE_ITEM_SIZE)); + } + + wr_printcomment (e,""); + ++low; + offset += elen; + } + } + } + while (0); + + if (has_error) + wr_printcomment (e, "Illegal data"); + wr_print_flush (e); + fprintf (e, "END\n"); +} + +static void +write_rc_datablock (FILE *e, rc_uint_type length, const bfd_byte *data, int has_next, + int hasblock, int show_comment) +{ + int plen; + + if (hasblock) + fprintf (e, "BEGIN\n"); + + if (show_comment == -1) + { + if (test_rc_datablock_text(length, data)) + { + rc_uint_type i, c; + for (i = 0; i < length;) + { + indent (e, 2); + fprintf (e, "\""); + + for (c = 0; i < length && c < 160 && data[i] != '\n'; c++, i++) + ; + if (i < length && data[i] == '\n') + ++i, ++c; + ascii_print(e, (const char *) &data[i - c], c); + fprintf (e, "\""); + if (i < length) + fprintf (e, "\n"); + } + + if (i == 0) + { + indent (e, 2); + fprintf (e, "\"\""); + } + if (has_next) + fprintf (e, ","); + fprintf (e, "\n"); + if (hasblock) + fprintf (e, "END\n"); + return; + } + if (test_rc_datablock_unicode (length, data)) + { + rc_uint_type i, c; + for (i = 0; i < length;) + { + const unichar *u; + + u = (const unichar *) &data[i]; + indent (e, 2); + fprintf (e, "L\""); + + for (c = 0; i < length && c < 160 && u[c] != '\n'; c++, i += 2) + ; + if (i < length && u[c] == '\n') + i += 2, ++c; + unicode_print (e, u, c); + fprintf (e, "\""); + if (i < length) + fprintf (e, "\n"); + } + + if (i == 0) + { + indent (e, 2); + fprintf (e, "L\"\""); + } + if (has_next) + fprintf (e, ","); + fprintf (e, "\n"); + if (hasblock) + fprintf (e, "END\n"); + return; + } + + show_comment = 0; + } + + if (length != 0) + { + rc_uint_type i, max_row; + int first = 1; + + max_row = (show_comment ? 4 : 8); + indent (e, 2); + for (i = 0; i + 3 < length;) + { + rc_uint_type k; + rc_uint_type comment_start; + + comment_start = i; + + if (! first) + indent (e, 2); + + for (k = 0; k < max_row && i + 3 < length; k++, i += 4) + { + if (k == 0) + plen = fprintf (e, "0x%lxL", + (unsigned long) windres_get_32 (&wrtarget, data + i, length - i)); + else + plen = fprintf (e, " 0x%lxL", + (unsigned long) windres_get_32 (&wrtarget, data + i, length - i)) - 1; + if (has_next || (i + 4) < length) + { + if (plen>0 && plen < 11) + indent (e, 11 - plen); + fprintf (e, ","); + } + } + if (show_comment) + { + fprintf (e, "\t/* "); + ascii_print (e, (const char *) &data[comment_start], i - comment_start); + fprintf (e, ". */"); + } + fprintf (e, "\n"); + first = 0; + } + + if (i + 1 < length) + { + if (! first) + indent (e, 2); + plen = fprintf (e, "0x%x", + (int) windres_get_16 (&wrtarget, data + i, length - i)); + if (has_next || i + 2 < length) + { + if (plen > 0 && plen < 11) + indent (e, 11 - plen); + fprintf (e, ","); + } + if (show_comment) + { + fprintf (e, "\t/* "); + ascii_print (e, (const char *) &data[i], 2); + fprintf (e, ". */"); + } + fprintf (e, "\n"); + i += 2; + first = 0; + } + + if (i < length) + { + if (! first) + indent (e, 2); + fprintf (e, "\""); + ascii_print (e, (const char *) &data[i], 1); + fprintf (e, "\""); + if (has_next) + fprintf (e, ","); + fprintf (e, "\n"); + first = 0; + } + } + if (hasblock) + fprintf (e, "END\n"); +} + +/* Write out an rcdata resource. This is also used for other types of + resources that need to print arbitrary data. */ + +static void +write_rc_rcdata (FILE *e, const rc_rcdata_item *rcdata, int ind) +{ + const rc_rcdata_item *ri; + + indent (e, ind); + fprintf (e, "BEGIN\n"); + + for (ri = rcdata; ri != NULL; ri = ri->next) + { + if (ri->type == RCDATA_BUFFER && ri->u.buffer.length == 0) + continue; + + switch (ri->type) + { + default: + abort (); + + case RCDATA_WORD: + indent (e, ind + 2); + fprintf (e, "%ld", (long) (ri->u.word & 0xffff)); + break; + + case RCDATA_DWORD: + indent (e, ind + 2); + fprintf (e, "%luL", (unsigned long) ri->u.dword); + break; + + case RCDATA_STRING: + indent (e, ind + 2); + fprintf (e, "\""); + ascii_print (e, ri->u.string.s, ri->u.string.length); + fprintf (e, "\""); + break; + + case RCDATA_WSTRING: + indent (e, ind + 2); + fprintf (e, "L\""); + unicode_print (e, ri->u.wstring.w, ri->u.wstring.length); + fprintf (e, "\""); + break; + + case RCDATA_BUFFER: + write_rc_datablock (e, (rc_uint_type) ri->u.buffer.length, + (const bfd_byte *) ri->u.buffer.data, + ri->next != NULL, 0, -1); + break; + } + + if (ri->type != RCDATA_BUFFER) + { + if (ri->next != NULL) + fprintf (e, ","); + fprintf (e, "\n"); + } + } + + indent (e, ind); + fprintf (e, "END\n"); +} + +/* Write out a stringtable resource. */ + +static void +write_rc_stringtable (FILE *e, const rc_res_id *name, + const rc_stringtable *stringtable) +{ + rc_uint_type offset; + int i; + + if (name != NULL && ! name->named) + offset = (name->u.id - 1) << 4; + else + { + fprintf (e, "/* %s string table name. */\n", + name == NULL ? "Missing" : "Invalid"); + offset = 0; + } + + fprintf (e, "BEGIN\n"); + + for (i = 0; i < 16; i++) + { + if (stringtable->strings[i].length != 0) + { + fprintf (e, " %lu, ", (unsigned long) offset + i); + unicode_print_quoted (e, stringtable->strings[i].string, + stringtable->strings[i].length); + fprintf (e, "\n"); + } + } + + fprintf (e, "END\n"); +} + +/* Write out a versioninfo resource. */ + +static void +write_rc_versioninfo (FILE *e, const rc_versioninfo *versioninfo) +{ + const rc_fixed_versioninfo *f; + const rc_ver_info *vi; + + f = versioninfo->fixed; + if (f->file_version_ms != 0 || f->file_version_ls != 0) + fprintf (e, " FILEVERSION %u, %u, %u, %u\n", + (unsigned int) ((f->file_version_ms >> 16) & 0xffff), + (unsigned int) (f->file_version_ms & 0xffff), + (unsigned int) ((f->file_version_ls >> 16) & 0xffff), + (unsigned int) (f->file_version_ls & 0xffff)); + if (f->product_version_ms != 0 || f->product_version_ls != 0) + fprintf (e, " PRODUCTVERSION %u, %u, %u, %u\n", + (unsigned int) ((f->product_version_ms >> 16) & 0xffff), + (unsigned int) (f->product_version_ms & 0xffff), + (unsigned int) ((f->product_version_ls >> 16) & 0xffff), + (unsigned int) (f->product_version_ls & 0xffff)); + if (f->file_flags_mask != 0) + fprintf (e, " FILEFLAGSMASK 0x%x\n", (unsigned int) f->file_flags_mask); + if (f->file_flags != 0) + fprintf (e, " FILEFLAGS 0x%x\n", (unsigned int) f->file_flags); + if (f->file_os != 0) + fprintf (e, " FILEOS 0x%x\n", (unsigned int) f->file_os); + if (f->file_type != 0) + fprintf (e, " FILETYPE 0x%x\n", (unsigned int) f->file_type); + if (f->file_subtype != 0) + fprintf (e, " FILESUBTYPE 0x%x\n", (unsigned int) f->file_subtype); + if (f->file_date_ms != 0 || f->file_date_ls != 0) + fprintf (e, "/* Date: %u, %u. */\n", + (unsigned int) f->file_date_ms, (unsigned int) f->file_date_ls); + + fprintf (e, "BEGIN\n"); + + for (vi = versioninfo->var; vi != NULL; vi = vi->next) + { + switch (vi->type) + { + case VERINFO_STRING: + { + const rc_ver_stringtable *vst; + const rc_ver_stringinfo *vs; + + fprintf (e, " BLOCK \"StringFileInfo\"\n"); + fprintf (e, " BEGIN\n"); + + for (vst = vi->u.string.stringtables; vst != NULL; vst = vst->next) + { + fprintf (e, " BLOCK "); + unicode_print_quoted (e, vst->language, -1); + + fprintf (e, "\n"); + fprintf (e, " BEGIN\n"); + + for (vs = vst->strings; vs != NULL; vs = vs->next) + { + fprintf (e, " VALUE "); + unicode_print_quoted (e, vs->key, -1); + fprintf (e, ", "); + unicode_print_quoted (e, vs->value, -1); + fprintf (e, "\n"); + } + + fprintf (e, " END\n"); + } + fprintf (e, " END\n"); + break; + } + + case VERINFO_VAR: + { + const rc_ver_varinfo *vv; + + fprintf (e, " BLOCK \"VarFileInfo\"\n"); + fprintf (e, " BEGIN\n"); + fprintf (e, " VALUE "); + unicode_print_quoted (e, vi->u.var.key, -1); + + for (vv = vi->u.var.var; vv != NULL; vv = vv->next) + fprintf (e, ", 0x%x, %d", (unsigned int) vv->language, + (int) vv->charset); + + fprintf (e, "\n END\n"); + + break; + } + } + } + + fprintf (e, "END\n"); +} + +static rc_uint_type +rcdata_copy (const rc_rcdata_item *src, bfd_byte *dst) +{ + if (! src) + return 0; + switch (src->type) + { + case RCDATA_WORD: + if (dst) + windres_put_16 (&wrtarget, dst, (rc_uint_type) src->u.word); + return 2; + case RCDATA_DWORD: + if (dst) + windres_put_32 (&wrtarget, dst, (rc_uint_type) src->u.dword); + return 4; + case RCDATA_STRING: + if (dst && src->u.string.length) + memcpy (dst, src->u.string.s, src->u.string.length); + return (rc_uint_type) src->u.string.length; + case RCDATA_WSTRING: + if (dst && src->u.wstring.length) + memcpy (dst, src->u.wstring.w, src->u.wstring.length * sizeof (unichar)); + return (rc_uint_type) (src->u.wstring.length * sizeof (unichar)); + case RCDATA_BUFFER: + if (dst && src->u.buffer.length) + memcpy (dst, src->u.buffer.data, src->u.buffer.length); + return (rc_uint_type) src->u.buffer.length; + default: + abort (); + } + /* Never reached. */ + return 0; +} diff --git a/support/sdbinutils/binutils/resres.c b/support/sdbinutils/binutils/resres.c new file mode 100644 index 0000000..6f26c65 --- /dev/null +++ b/support/sdbinutils/binutils/resres.c @@ -0,0 +1,730 @@ +/* resres.c: read_res_file and write_res_file implementation for windres. + Copyright (C) 1998-2018 Free Software Foundation, Inc. + Written by Anders Norlander . + Rewritten by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* FIXME: This file does not work correctly in a cross configuration. + It assumes that it can use fread and fwrite to read and write + integers. It does no swapping. */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" +#include "libiberty.h" +#include "windres.h" + +#include + +static rc_uint_type write_res_directory (windres_bfd *, rc_uint_type, + const rc_res_directory *, const rc_res_id *, + const rc_res_id *, rc_uint_type *, int); +static rc_uint_type write_res_resource (windres_bfd *, rc_uint_type,const rc_res_id *, + const rc_res_id *, const rc_res_resource *, + rc_uint_type *); +static rc_uint_type write_res_bin (windres_bfd *, rc_uint_type, const rc_res_resource *, + const rc_res_id *, const rc_res_id *, + const rc_res_res_info *); + +static rc_uint_type write_res_id (windres_bfd *, rc_uint_type, const rc_res_id *); +static rc_uint_type write_res_info (windres_bfd *, rc_uint_type, const rc_res_res_info *); +static rc_uint_type write_res_data_hdr (windres_bfd *, rc_uint_type, res_hdr *); + +static rc_uint_type write_res_header (windres_bfd *, rc_uint_type, rc_uint_type, + const rc_res_id *, const rc_res_id *, + const rc_res_res_info *); + +static int read_resource_entry (windres_bfd *, rc_uint_type *, rc_uint_type); +static void read_res_data (windres_bfd *, rc_uint_type *, rc_uint_type, void *, + rc_uint_type); +static void read_res_data_hdr (windres_bfd *, rc_uint_type *, rc_uint_type, res_hdr *); +static void read_res_id (windres_bfd *, rc_uint_type *, rc_uint_type, rc_res_id *); +static unichar *read_unistring (windres_bfd *, rc_uint_type *, rc_uint_type, rc_uint_type *); +static void skip_null_resource (windres_bfd *, rc_uint_type *, rc_uint_type); +static int probe_binary (windres_bfd *wrbfd, rc_uint_type); + +static unsigned long get_id_size (const rc_res_id *); + +static void res_add_resource (rc_res_resource *, const rc_res_id *, + const rc_res_id *, rc_uint_type, int); + +static void res_append_resource (rc_res_directory **, rc_res_resource *, + int, const rc_res_id *, int); + +static rc_res_directory *resources = NULL; + +static const char *filename; + +extern char *program_name; + +/* Read resource file */ +rc_res_directory * +read_res_file (const char *fn) +{ + rc_uint_type off, flen; + windres_bfd wrbfd; + bfd *abfd; + asection *sec; + filename = fn; + + flen = (rc_uint_type) get_file_size (filename); + if (! flen) + fatal ("can't open '%s' for input.", filename); + abfd = windres_open_as_binary (filename, 1); + sec = bfd_get_section_by_name (abfd, ".data"); + if (sec == NULL) + bfd_fatal ("bfd_get_section_by_name"); + set_windres_bfd (&wrbfd, abfd, sec, + (target_is_bigendian ? WR_KIND_BFD_BIN_B + : WR_KIND_BFD_BIN_L)); + off = 0; + + if (! probe_binary (&wrbfd, flen)) + set_windres_bfd_endianness (&wrbfd, ! target_is_bigendian); + + skip_null_resource (&wrbfd, &off, flen); + + while (read_resource_entry (&wrbfd, &off, flen)) + ; + + bfd_close (abfd); + + return resources; +} + +/* Write resource file */ +void +write_res_file (const char *fn,const rc_res_directory *resdir) +{ + asection *sec; + rc_uint_type language; + bfd *abfd; + windres_bfd wrbfd; + unsigned long sec_length = 0,sec_length_wrote; + static const bfd_byte sign[] = + {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + filename = fn; + + abfd = windres_open_as_binary (filename, 0); + sec = bfd_make_section_with_flags (abfd, ".data", + (SEC_HAS_CONTENTS | SEC_ALLOC + | SEC_LOAD | SEC_DATA)); + if (sec == NULL) + bfd_fatal ("bfd_make_section"); + /* Requiring this is probably a bug in BFD. */ + sec->output_section = sec; + + set_windres_bfd (&wrbfd, abfd, sec, + (target_is_bigendian ? WR_KIND_BFD_BIN_B + : WR_KIND_BFD_BIN_L)); + + language = -1; + sec_length = write_res_directory ((windres_bfd *) NULL, 0x20UL, resdir, + (const rc_res_id *) NULL, + (const rc_res_id *) NULL, &language, 1); + if (! bfd_set_section_size (abfd, sec, (sec_length + 3) & ~3)) + bfd_fatal ("bfd_set_section_size"); + if ((sec_length & 3) != 0) + set_windres_bfd_content (&wrbfd, sign, sec_length, 4-(sec_length & 3)); + set_windres_bfd_content (&wrbfd, sign, 0, sizeof (sign)); + language = -1; + sec_length_wrote = write_res_directory (&wrbfd, 0x20UL, resdir, + (const rc_res_id *) NULL, + (const rc_res_id *) NULL, + &language, 1); + if (sec_length != sec_length_wrote) + fatal ("res write failed with different sizes (%lu/%lu).", + (unsigned long) sec_length, (unsigned long) sec_length_wrote); + + bfd_close (abfd); + return; +} + +/* Read a resource entry, returns 0 when all resources are read */ +static int +read_resource_entry (windres_bfd *wrbfd, rc_uint_type *off, rc_uint_type omax) +{ + rc_res_id type; + rc_res_id name; + rc_res_res_info resinfo; + res_hdr reshdr; + void *buff; + + rc_res_resource *r; + struct bin_res_info l; + + off[0] = (off[0] + 3) & ~3; + + /* Read header */ + if ((off[0] + 8) > omax) + return 0; + read_res_data_hdr (wrbfd, off, omax, &reshdr); + + /* read resource type */ + read_res_id (wrbfd, off, omax, &type); + /* read resource id */ + read_res_id (wrbfd, off, omax, &name); + + off[0] = (off[0] + 3) & ~3; + + /* Read additional resource header */ + read_res_data (wrbfd, off, omax, &l, BIN_RES_INFO_SIZE); + resinfo.version = windres_get_32 (wrbfd, l.version, 4); + resinfo.memflags = windres_get_16 (wrbfd, l.memflags, 2); + resinfo.language = windres_get_16 (wrbfd, l.language, 2); + /* resinfo.version2 = windres_get_32 (wrbfd, l.version2, 4); */ + resinfo.characteristics = windres_get_32 (wrbfd, l.characteristics, 4); + + off[0] = (off[0] + 3) & ~3; + + /* Allocate buffer for data */ + buff = res_alloc (reshdr.data_size); + /* Read data */ + read_res_data (wrbfd, off, omax, buff, reshdr.data_size); + /* Convert binary data to resource */ + r = bin_to_res (wrbfd, type, buff, reshdr.data_size); + r->res_info = resinfo; + /* Add resource to resource directory */ + res_add_resource (r, &type, &name, resinfo.language, 0); + + return 1; +} + +/* write resource directory to binary resource file */ +static rc_uint_type +write_res_directory (windres_bfd *wrbfd, rc_uint_type off, const rc_res_directory *rd, + const rc_res_id *type, const rc_res_id *name, rc_uint_type *language, + int level) +{ + const rc_res_entry *re; + + for (re = rd->entries; re != NULL; re = re->next) + { + switch (level) + { + case 1: + /* If we're at level 1, the key of this resource is the + type. This normally duplicates the information we have + stored with the resource itself, but we need to remember + the type if this is a user define resource type. */ + type = &re->id; + break; + + case 2: + /* If we're at level 2, the key of this resource is the name + we are going to use in the rc printout. */ + name = &re->id; + break; + + case 3: + /* If we're at level 3, then this key represents a language. + Use it to update the current language. */ + if (! re->id.named + && re->id.u.id != (unsigned long) *language + && (re->id.u.id & 0xffff) == re->id.u.id) + { + *language = re->id.u.id; + } + break; + + default: + break; + } + + if (re->subdir) + off = write_res_directory (wrbfd, off, re->u.dir, type, name, language, + level + 1); + else + { + if (level == 3) + { + /* This is the normal case: the three levels are + TYPE/NAME/LANGUAGE. NAME will have been set at level + 2, and represents the name to use. We probably just + set LANGUAGE, and it will probably match what the + resource itself records if anything. */ + off = write_res_resource (wrbfd, off, type, name, re->u.res, + language); + } + else + { + fprintf (stderr, "// Resource at unexpected level %d\n", level); + off = write_res_resource (wrbfd, off, type, (rc_res_id *) NULL, + re->u.res, language); + } + } + } + + return off; +} + +static rc_uint_type +write_res_resource (windres_bfd *wrbfd, rc_uint_type off, const rc_res_id *type, + const rc_res_id *name, const rc_res_resource *res, + rc_uint_type *language ATTRIBUTE_UNUSED) +{ + int rt; + + switch (res->type) + { + default: + abort (); + + case RES_TYPE_ACCELERATOR: + rt = RT_ACCELERATOR; + break; + + case RES_TYPE_BITMAP: + rt = RT_BITMAP; + break; + + case RES_TYPE_CURSOR: + rt = RT_CURSOR; + break; + + case RES_TYPE_GROUP_CURSOR: + rt = RT_GROUP_CURSOR; + break; + + case RES_TYPE_DIALOG: + rt = RT_DIALOG; + break; + + case RES_TYPE_FONT: + rt = RT_FONT; + break; + + case RES_TYPE_FONTDIR: + rt = RT_FONTDIR; + break; + + case RES_TYPE_ICON: + rt = RT_ICON; + break; + + case RES_TYPE_GROUP_ICON: + rt = RT_GROUP_ICON; + break; + + case RES_TYPE_MENU: + rt = RT_MENU; + break; + + case RES_TYPE_MESSAGETABLE: + rt = RT_MESSAGETABLE; + break; + + case RES_TYPE_RCDATA: + rt = RT_RCDATA; + break; + + case RES_TYPE_STRINGTABLE: + rt = RT_STRING; + break; + + case RES_TYPE_USERDATA: + rt = 0; + break; + + case RES_TYPE_VERSIONINFO: + rt = RT_VERSION; + break; + + case RES_TYPE_TOOLBAR: + rt = RT_TOOLBAR; + break; + } + + if (rt != 0 + && type != NULL + && (type->named || type->u.id != (unsigned long) rt)) + { + fprintf (stderr, "// Unexpected resource type mismatch: "); + res_id_print (stderr, *type, 1); + fprintf (stderr, " != %d", rt); + abort (); + } + + return write_res_bin (wrbfd, off, res, type, name, &res->res_info); +} + +/* Write a resource in binary resource format */ +static rc_uint_type +write_res_bin (windres_bfd *wrbfd, rc_uint_type off, const rc_res_resource *res, + const rc_res_id *type, const rc_res_id *name, + const rc_res_res_info *resinfo) +{ + rc_uint_type noff; + rc_uint_type datasize = 0; + + noff = res_to_bin ((windres_bfd *) NULL, off, res); + datasize = noff - off; + + off = write_res_header (wrbfd, off, datasize, type, name, resinfo); + return res_to_bin (wrbfd, off, res); +} + +/* Get number of bytes needed to store an id in binary format */ +static unsigned long +get_id_size (const rc_res_id *id) +{ + if (id->named) + return sizeof (unichar) * (id->u.n.length + 1); + else + return sizeof (unichar) * 2; +} + +/* Write a resource header */ +static rc_uint_type +write_res_header (windres_bfd *wrbfd, rc_uint_type off, rc_uint_type datasize, + const rc_res_id *type, const rc_res_id *name, + const rc_res_res_info *resinfo) +{ + res_hdr reshdr; + reshdr.data_size = datasize; + reshdr.header_size = 24 + get_id_size (type) + get_id_size (name); + + reshdr.header_size = (reshdr.header_size + 3) & ~3; + + off = (off + 3) & ~3; + + off = write_res_data_hdr (wrbfd, off, &reshdr); + off = write_res_id (wrbfd, off, type); + off = write_res_id (wrbfd, off, name); + + off = (off + 3) & ~3; + + off = write_res_info (wrbfd, off, resinfo); + off = (off + 3) & ~3; + return off; +} + +static rc_uint_type +write_res_data_hdr (windres_bfd *wrbfd, rc_uint_type off, res_hdr *hdr) +{ + if (wrbfd) + { + struct bin_res_hdr brh; + windres_put_32 (wrbfd, brh.data_size, hdr->data_size); + windres_put_32 (wrbfd, brh.header_size, hdr->header_size); + set_windres_bfd_content (wrbfd, &brh, off, BIN_RES_HDR_SIZE); + } + return off + BIN_RES_HDR_SIZE; +} + +static void +read_res_data_hdr (windres_bfd *wrbfd, rc_uint_type *off, rc_uint_type omax, + res_hdr *reshdr) +{ + struct bin_res_hdr brh; + + if ((off[0] + BIN_RES_HDR_SIZE) > omax) + fatal ("%s: unexpected end of file %ld/%ld", filename,(long) off[0], (long) omax); + + get_windres_bfd_content (wrbfd, &brh, off[0], BIN_RES_HDR_SIZE); + reshdr->data_size = windres_get_32 (wrbfd, brh.data_size, 4); + reshdr->header_size = windres_get_32 (wrbfd, brh.header_size, 4); + off[0] += BIN_RES_HDR_SIZE; +} + +/* Read data from file, abort on failure */ +static void +read_res_data (windres_bfd *wrbfd, rc_uint_type *off, rc_uint_type omax, void *data, + rc_uint_type size) +{ + if ((off[0] + size) > omax) + fatal ("%s: unexpected end of file %ld/%ld %ld", filename,(long) off[0], + (long) omax, (long) size); + get_windres_bfd_content (wrbfd, data, off[0], size); + off[0] += size; +} + +/* Write a resource id */ +static rc_uint_type +write_res_id (windres_bfd *wrbfd, rc_uint_type off, const rc_res_id *id) +{ + if (id->named) + { + rc_uint_type len = (((bfd_signed_vma) id->u.n.length < 0 ? 0 : id->u.n.length) + 1); + if (wrbfd) + { + rc_uint_type i; + bfd_byte *d = (bfd_byte *) xmalloc (len * sizeof (unichar)); + for (i = 0; i < (len - 1); i++) + windres_put_16 (wrbfd, d + (i * sizeof (unichar)), id->u.n.name[i]); + windres_put_16 (wrbfd, d + (i * sizeof (unichar)), 0); + set_windres_bfd_content (wrbfd, d, off, (len * sizeof (unichar))); + } + off += (len * sizeof (unichar)); + } + else + { + if (wrbfd) + { + struct bin_res_id bid; + windres_put_16 (wrbfd, bid.sig, 0xffff); + windres_put_16 (wrbfd, bid.id, id->u.id); + set_windres_bfd_content (wrbfd, &bid, off, BIN_RES_ID); + } + off += BIN_RES_ID; + } + return off; +} + +/* Write resource info */ +static rc_uint_type +write_res_info (windres_bfd *wrbfd, rc_uint_type off, const rc_res_res_info *info) +{ + if (wrbfd) + { + struct bin_res_info l; + + windres_put_32 (wrbfd, l.version, info->version); + windres_put_16 (wrbfd, l.memflags, info->memflags); + windres_put_16 (wrbfd, l.language, info->language); + windres_put_32 (wrbfd, l.version2, info->version); + windres_put_32 (wrbfd, l.characteristics, info->characteristics); + set_windres_bfd_content (wrbfd, &l, off, BIN_RES_INFO_SIZE); + } + return off + BIN_RES_INFO_SIZE; +} + +/* read a resource identifier */ +static void +read_res_id (windres_bfd *wrbfd, rc_uint_type *off, rc_uint_type omax, rc_res_id *id) +{ + struct bin_res_id bid; + unsigned short ord; + unichar *id_s = NULL; + rc_uint_type len; + + read_res_data (wrbfd, off, omax, &bid, BIN_RES_ID - 2); + ord = (unsigned short) windres_get_16 (wrbfd, bid.sig, 2); + if (ord == 0xFFFF) /* an ordinal id */ + { + read_res_data (wrbfd, off, omax, bid.id, BIN_RES_ID - 2); + id->named = 0; + id->u.id = windres_get_16 (wrbfd, bid.id, 2); + } + else + /* named id */ + { + off[0] -= 2; + id_s = read_unistring (wrbfd, off, omax, &len); + id->named = 1; + id->u.n.length = len; + id->u.n.name = id_s; + } +} + +/* Read a null terminated UNICODE string */ +static unichar * +read_unistring (windres_bfd *wrbfd, rc_uint_type *off, rc_uint_type omax, + rc_uint_type *len) +{ + unichar *s; + bfd_byte d[2]; + unichar c; + unichar *p; + rc_uint_type l; + rc_uint_type soff = off[0]; + + do + { + read_res_data (wrbfd, &soff, omax, d, sizeof (unichar)); + c = windres_get_16 (wrbfd, d, 2); + } + while (c != 0); + l = ((soff - off[0]) / sizeof (unichar)); + + /* there are hardly any names longer than 256 characters, but anyway. */ + p = s = (unichar *) xmalloc (sizeof (unichar) * l); + do + { + read_res_data (wrbfd, off, omax, d, sizeof (unichar)); + c = windres_get_16 (wrbfd, d, 2); + *p++ = c; + } + while (c != 0); + *len = l - 1; + return s; +} + +static int +probe_binary (windres_bfd *wrbfd, rc_uint_type omax) +{ + rc_uint_type off; + res_hdr reshdr; + + off = 0; + read_res_data_hdr (wrbfd, &off, omax, &reshdr); + if (reshdr.data_size != 0) + return 1; + if ((reshdr.header_size != 0x20 && ! target_is_bigendian) + || (reshdr.header_size != 0x20000000 && target_is_bigendian)) + return 1; + + /* Subtract size of HeaderSize. DataSize has to be zero. */ + off += 0x20 - BIN_RES_HDR_SIZE; + if ((off + BIN_RES_HDR_SIZE) >= omax) + return 1; + read_res_data_hdr (wrbfd, &off, omax, &reshdr); + /* off is advanced by BIN_RES_HDR_SIZE in read_res_data_hdr() + which is part of reshdr.header_size. We shouldn't take it + into account twice. */ + if ((off - BIN_RES_HDR_SIZE + reshdr.data_size + reshdr.header_size) > omax) + return 0; + return 1; +} + +/* Check if file is a win32 binary resource file, if so + skip past the null resource. Returns 0 if successful, -1 on + error. + */ +static void +skip_null_resource (windres_bfd *wrbfd, rc_uint_type *off, rc_uint_type omax) +{ + res_hdr reshdr; + read_res_data_hdr (wrbfd, off, omax, &reshdr); + if (reshdr.data_size != 0) + goto skip_err; + if ((reshdr.header_size != 0x20 && ! target_is_bigendian) + || (reshdr.header_size != 0x20000000 && target_is_bigendian)) + goto skip_err; + + /* Subtract size of HeaderSize. DataSize has to be zero. */ + off[0] += 0x20 - BIN_RES_HDR_SIZE; + if (off[0] >= omax) + goto skip_err; + + return; + +skip_err: + fprintf (stderr, "%s: %s: Not a valid WIN32 resource file\n", program_name, + filename); + xexit (1); +} + +/* Add a resource to resource directory */ +static void +res_add_resource (rc_res_resource *r, const rc_res_id *type, const rc_res_id *id, + rc_uint_type language, int dupok) +{ + rc_res_id a[3]; + + a[0] = *type; + a[1] = *id; + a[2].named = 0; + a[2].u.id = language; + res_append_resource (&resources, r, 3, a, dupok); +} + +/* Append a resource to resource directory. + This is just copied from define_resource + and modified to add an existing resource. + */ +static void +res_append_resource (rc_res_directory **res_dirs, rc_res_resource *resource, + int cids, const rc_res_id *ids, int dupok) +{ + rc_res_entry *re = NULL; + int i; + + assert (cids > 0); + for (i = 0; i < cids; i++) + { + rc_res_entry **pp; + + if (*res_dirs == NULL) + { + *res_dirs = ((rc_res_directory *) + res_alloc (sizeof (rc_res_directory))); + + (*res_dirs)->characteristics = 0; + /* Using a real timestamp only serves to create non-deterministic + results. Use zero instead. */ + (*res_dirs)->time = 0; + (*res_dirs)->major = 0; + (*res_dirs)->minor = 0; + (*res_dirs)->entries = NULL; + } + + for (pp = &(*res_dirs)->entries; *pp != NULL; pp = &(*pp)->next) + if (res_id_cmp ((*pp)->id, ids[i]) == 0) + break; + + if (*pp != NULL) + re = *pp; + else + { + re = (rc_res_entry *) res_alloc (sizeof (rc_res_entry)); + re->next = NULL; + re->id = ids[i]; + if ((i + 1) < cids) + { + re->subdir = 1; + re->u.dir = NULL; + } + else + { + re->subdir = 0; + re->u.res = NULL; + } + + *pp = re; + } + + if ((i + 1) < cids) + { + if (! re->subdir) + { + fprintf (stderr, "%s: ", program_name); + res_ids_print (stderr, i, ids); + fprintf (stderr, ": expected to be a directory\n"); + xexit (1); + } + + res_dirs = &re->u.dir; + } + } + + if (re->subdir) + { + fprintf (stderr, "%s: ", program_name); + res_ids_print (stderr, cids, ids); + fprintf (stderr, ": expected to be a leaf\n"); + xexit (1); + } + + if (re->u.res != NULL) + { + if (dupok) + return; + + fprintf (stderr, "%s: warning: ", program_name); + res_ids_print (stderr, cids, ids); + fprintf (stderr, ": duplicate value\n"); + } + + re->u.res = resource; +} diff --git a/support/sdbinutils/binutils/sanity.sh b/support/sdbinutils/binutils/sanity.sh new file mode 100755 index 0000000..923ca9e --- /dev/null +++ b/support/sdbinutils/binutils/sanity.sh @@ -0,0 +1,67 @@ +#!/bin/sh +### quick sanity test for the binutils. +### +# This file was written K. Richard Pixley. +# Copyright (C) 2007-2018 Free Software Foundation, Inc. + +# This program is part of GNU Binutils. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. */ + +### fail on errors +set -e + +### first arg is directory in which binaries to be tested reside. +case "$1" in +"") BIN=. ;; +*) BIN="$1" ;; +esac + +### size +for i in size objdump nm ar strip ranlib ; do + ${BIN}/size ${BIN}/$i > /dev/null +done + +### objdump +for i in size objdump nm ar strip ranlib ; do + ${BIN}/objdump -ahifdrtxsl ${BIN}/$i > /dev/null +done + +### nm +for i in size objdump nm ar strip ranlib ; do + ${BIN}/nm ${BIN}/$i > /dev/null +done + +### strip +TMPDIR=./binutils-$$ +mkdir ${TMPDIR} + +cp ${BIN}/strip ${TMPDIR}/strip + +for i in size objdump nm ar ranlib ; do + cp ${BIN}/$i ${TMPDIR}/$i + ${BIN}/strip ${TMPDIR}/$i + cp ${BIN}/$i ${TMPDIR}/$i + ${TMPDIR}/strip ${TMPDIR}/$i +done + +### ar + +### ranlib + +rm -rf ${TMPDIR} + +exit 0 diff --git a/support/sdbinutils/binutils/size.c b/support/sdbinutils/binutils/size.c new file mode 100644 index 0000000..47f14fc --- /dev/null +++ b/support/sdbinutils/binutils/size.c @@ -0,0 +1,617 @@ +/* size.c -- report size of various sections of an executable file. + Copyright (C) 1991-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +/* Extensions/incompatibilities: + o - BSD output has filenames at the end. + o - BSD output can appear in different radicies. + o - SysV output has less redundant whitespace. Filename comes at end. + o - SysV output doesn't show VMA which is always the same as the PMA. + o - We also handle core files. + o - We also handle archives. + If you write shell scripts which manipulate this info then you may be + out of luck; there's no --compatibility or --pedantic option. */ + +#include "sysdep.h" +#include "bfd.h" +#include "libiberty.h" +#include "getopt.h" +#include "bucomm.h" + +#ifndef BSD_DEFAULT +#define BSD_DEFAULT 1 +#endif + +/* Program options. */ + +static enum + { + decimal, octal, hex + } +radix = decimal; + +/* 0 means use AT&T-style output. */ +static int berkeley_format = BSD_DEFAULT; + +static int show_version = 0; +static int show_help = 0; +static int show_totals = 0; +static int show_common = 0; + +static bfd_size_type common_size; +static bfd_size_type total_bsssize; +static bfd_size_type total_datasize; +static bfd_size_type total_textsize; + +/* Program exit status. */ +static int return_code = 0; + +static char *target = NULL; + +/* Forward declarations. */ + +static void display_file (char *); +static void rprint_number (int, bfd_size_type); +static void print_sizes (bfd * file); + +static void +usage (FILE *stream, int status) +{ + fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name); + fprintf (stream, _(" Displays the sizes of sections inside binary files\n")); + fprintf (stream, _(" If no input file(s) are specified, a.out is assumed\n")); + fprintf (stream, _(" The options are:\n\ + -A|-B --format={sysv|berkeley} Select output style (default is %s)\n\ + -o|-d|-x --radix={8|10|16} Display numbers in octal, decimal or hex\n\ + -t --totals Display the total sizes (Berkeley only)\n\ + --common Display total size for *COM* syms\n\ + --target= Set the binary file format\n\ + @ Read options from \n\ + -h --help Display this information\n\ + -v --version Display the program's version\n\ +\n"), +#if BSD_DEFAULT + "berkeley" +#else + "sysv" +#endif +); + list_supported_targets (program_name, stream); + if (REPORT_BUGS_TO[0] && status == 0) + fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); + exit (status); +} + +#define OPTION_FORMAT (200) +#define OPTION_RADIX (OPTION_FORMAT + 1) +#define OPTION_TARGET (OPTION_RADIX + 1) + +static struct option long_options[] = +{ + {"common", no_argument, &show_common, 1}, + {"format", required_argument, 0, OPTION_FORMAT}, + {"radix", required_argument, 0, OPTION_RADIX}, + {"target", required_argument, 0, OPTION_TARGET}, + {"totals", no_argument, &show_totals, 1}, + {"version", no_argument, &show_version, 1}, + {"help", no_argument, &show_help, 1}, + {0, no_argument, 0, 0} +}; + +int main (int, char **); + +int +main (int argc, char **argv) +{ + int temp; + int c; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + program_name = *argv; + xmalloc_set_program_name (program_name); + bfd_set_error_program_name (program_name); + + expandargv (&argc, &argv); + + bfd_init (); + set_default_bfd_target (); + + while ((c = getopt_long (argc, argv, "ABHhVvdfotx", long_options, + (int *) 0)) != EOF) + switch (c) + { + case OPTION_FORMAT: + switch (*optarg) + { + case 'B': + case 'b': + berkeley_format = 1; + break; + case 'S': + case 's': + berkeley_format = 0; + break; + default: + non_fatal (_("invalid argument to --format: %s"), optarg); + usage (stderr, 1); + } + break; + + case OPTION_TARGET: + target = optarg; + break; + + case OPTION_RADIX: +#ifdef ANSI_LIBRARIES + temp = strtol (optarg, NULL, 10); +#else + temp = atol (optarg); +#endif + switch (temp) + { + case 10: + radix = decimal; + break; + case 8: + radix = octal; + break; + case 16: + radix = hex; + break; + default: + non_fatal (_("Invalid radix: %s\n"), optarg); + usage (stderr, 1); + } + break; + + case 'A': + berkeley_format = 0; + break; + case 'B': + berkeley_format = 1; + break; + case 'v': + case 'V': + show_version = 1; + break; + case 'd': + radix = decimal; + break; + case 'x': + radix = hex; + break; + case 'o': + radix = octal; + break; + case 't': + show_totals = 1; + break; + case 'f': /* FIXME : For sysv68, `-f' means `full format', i.e. + `[fname:] M(.text) + N(.data) + O(.bss) + P(.comment) = Q' + where `fname: ' appears only if there are >= 2 input files, + and M, N, O, P, Q are expressed in decimal by default, + hexa or octal if requested by `-x' or `-o'. + Just to make things interesting, Solaris also accepts -f, + which prints out the size of each allocatable section, the + name of the section, and the total of the section sizes. */ + /* For the moment, accept `-f' silently, and ignore it. */ + break; + case 0: + break; + case 'h': + case 'H': + case '?': + usage (stderr, 1); + } + + if (show_version) + print_version ("size"); + if (show_help) + usage (stdout, 0); + + if (optind == argc) + display_file ("a.out"); + else + for (; optind < argc;) + display_file (argv[optind++]); + + if (show_totals && berkeley_format) + { + bfd_size_type total = total_textsize + total_datasize + total_bsssize; + + rprint_number (7, total_textsize); + putchar('\t'); + rprint_number (7, total_datasize); + putchar('\t'); + rprint_number (7, total_bsssize); + printf (((radix == octal) ? "\t%7lo\t%7lx\t" : "\t%7lu\t%7lx\t"), + (unsigned long) total, (unsigned long) total); + fputs ("(TOTALS)\n", stdout); + } + + return return_code; +} + +/* Total size required for common symbols in ABFD. */ + +static void +calculate_common_size (bfd *abfd) +{ + asymbol **syms = NULL; + long storage, symcount; + + common_size = 0; + if ((bfd_get_file_flags (abfd) & (EXEC_P | DYNAMIC | HAS_SYMS)) != HAS_SYMS) + return; + + storage = bfd_get_symtab_upper_bound (abfd); + if (storage < 0) + bfd_fatal (bfd_get_filename (abfd)); + if (storage) + syms = (asymbol **) xmalloc (storage); + + symcount = bfd_canonicalize_symtab (abfd, syms); + if (symcount < 0) + bfd_fatal (bfd_get_filename (abfd)); + + while (--symcount >= 0) + { + asymbol *sym = syms[symcount]; + + if (bfd_is_com_section (sym->section) + && (sym->flags & BSF_SECTION_SYM) == 0) + common_size += sym->value; + } + free (syms); +} + +/* Display stats on file or archive member ABFD. */ + +static void +display_bfd (bfd *abfd) +{ + char **matching; + + if (bfd_check_format (abfd, bfd_archive)) + /* An archive within an archive. */ + return; + + if (bfd_check_format_matches (abfd, bfd_object, &matching)) + { + print_sizes (abfd); + printf ("\n"); + return; + } + + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + bfd_nonfatal (bfd_get_filename (abfd)); + list_matching_formats (matching); + free (matching); + return_code = 3; + return; + } + + if (bfd_check_format_matches (abfd, bfd_core, &matching)) + { + const char *core_cmd; + + print_sizes (abfd); + fputs (" (core file", stdout); + + core_cmd = bfd_core_file_failing_command (abfd); + if (core_cmd) + printf (" invoked as %s", core_cmd); + + puts (")\n"); + return; + } + + bfd_nonfatal (bfd_get_filename (abfd)); + + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (matching); + free (matching); + } + + return_code = 3; +} + +static void +display_archive (bfd *file) +{ + bfd *arfile = (bfd *) NULL; + bfd *last_arfile = (bfd *) NULL; + + for (;;) + { + bfd_set_error (bfd_error_no_error); + + arfile = bfd_openr_next_archived_file (file, arfile); + if (arfile == NULL) + { + if (bfd_get_error () != bfd_error_no_more_archived_files) + { + bfd_nonfatal (bfd_get_filename (file)); + return_code = 2; + } + break; + } + + display_bfd (arfile); + + if (last_arfile != NULL) + { + bfd_close (last_arfile); + + /* PR 17512: file: a244edbc. */ + if (last_arfile == arfile) + return; + } + + last_arfile = arfile; + } + + if (last_arfile != NULL) + bfd_close (last_arfile); +} + +static void +display_file (char *filename) +{ + bfd *file; + + if (get_file_size (filename) < 1) + { + return_code = 1; + return; + } + + file = bfd_openr (filename, target); + if (file == NULL) + { + bfd_nonfatal (filename); + return_code = 1; + return; + } + + if (bfd_check_format (file, bfd_archive)) + display_archive (file); + else + display_bfd (file); + + if (!bfd_close (file)) + { + bfd_nonfatal (filename); + return_code = 1; + return; + } +} + +static int +size_number (bfd_size_type num) +{ + char buffer[40]; + + sprintf (buffer, + (radix == decimal ? "%" BFD_VMA_FMT "u" : + ((radix == octal) ? "0%" BFD_VMA_FMT "o" : "0x%" BFD_VMA_FMT "x")), + num); + + return strlen (buffer); +} + +static void +rprint_number (int width, bfd_size_type num) +{ + char buffer[40]; + + sprintf (buffer, + (radix == decimal ? "%" BFD_VMA_FMT "u" : + ((radix == octal) ? "0%" BFD_VMA_FMT "o" : "0x%" BFD_VMA_FMT "x")), + num); + + printf ("%*s", width, buffer); +} + +static bfd_size_type bsssize; +static bfd_size_type datasize; +static bfd_size_type textsize; + +static void +berkeley_sum (bfd *abfd ATTRIBUTE_UNUSED, sec_ptr sec, + void *ignore ATTRIBUTE_UNUSED) +{ + flagword flags; + bfd_size_type size; + + flags = bfd_get_section_flags (abfd, sec); + if ((flags & SEC_ALLOC) == 0) + return; + + size = bfd_get_section_size (sec); + if ((flags & SEC_CODE) != 0 || (flags & SEC_READONLY) != 0) + textsize += size; + else if ((flags & SEC_HAS_CONTENTS) != 0) + datasize += size; + else + bsssize += size; +} + +static void +print_berkeley_format (bfd *abfd) +{ + static int files_seen = 0; + bfd_size_type total; + + bsssize = 0; + datasize = 0; + textsize = 0; + + bfd_map_over_sections (abfd, berkeley_sum, NULL); + + bsssize += common_size; + if (files_seen++ == 0) + puts ((radix == octal) ? " text\t data\t bss\t oct\t hex\tfilename" : + " text\t data\t bss\t dec\t hex\tfilename"); + + total = textsize + datasize + bsssize; + + if (show_totals) + { + total_textsize += textsize; + total_datasize += datasize; + total_bsssize += bsssize; + } + + rprint_number (7, textsize); + putchar ('\t'); + rprint_number (7, datasize); + putchar ('\t'); + rprint_number (7, bsssize); + printf (((radix == octal) ? "\t%7lo\t%7lx\t" : "\t%7lu\t%7lx\t"), + (unsigned long) total, (unsigned long) total); + + fputs (bfd_get_filename (abfd), stdout); + + if (abfd->my_archive) + printf (" (ex %s)", bfd_get_filename (abfd->my_archive)); +} + +/* I REALLY miss lexical functions! */ +bfd_size_type svi_total = 0; +bfd_vma svi_maxvma = 0; +int svi_namelen = 0; +int svi_vmalen = 0; +int svi_sizelen = 0; + +static void +sysv_internal_sizer (bfd *file ATTRIBUTE_UNUSED, sec_ptr sec, + void *ignore ATTRIBUTE_UNUSED) +{ + bfd_size_type size = bfd_section_size (file, sec); + + if ( ! bfd_is_abs_section (sec) + && ! bfd_is_com_section (sec) + && ! bfd_is_und_section (sec)) + { + int namelen = strlen (bfd_section_name (file, sec)); + + if (namelen > svi_namelen) + svi_namelen = namelen; + + svi_total += size; + + if (bfd_section_vma (file, sec) > svi_maxvma) + svi_maxvma = bfd_section_vma (file, sec); + } +} + +static void +sysv_one_line (const char *name, bfd_size_type size, bfd_vma vma) +{ + printf ("%-*s ", svi_namelen, name); + rprint_number (svi_sizelen, size); + printf (" "); + rprint_number (svi_vmalen, vma); + printf ("\n"); +} + +static void +sysv_internal_printer (bfd *file ATTRIBUTE_UNUSED, sec_ptr sec, + void *ignore ATTRIBUTE_UNUSED) +{ + bfd_size_type size = bfd_section_size (file, sec); + + if ( ! bfd_is_abs_section (sec) + && ! bfd_is_com_section (sec) + && ! bfd_is_und_section (sec)) + { + svi_total += size; + + sysv_one_line (bfd_section_name (file, sec), + size, + bfd_section_vma (file, sec)); + } +} + +static void +print_sysv_format (bfd *file) +{ + /* Size all of the columns. */ + svi_total = 0; + svi_maxvma = 0; + svi_namelen = 0; + bfd_map_over_sections (file, sysv_internal_sizer, NULL); + if (show_common) + { + if (svi_namelen < (int) sizeof ("*COM*") - 1) + svi_namelen = sizeof ("*COM*") - 1; + svi_total += common_size; + } + + svi_vmalen = size_number ((bfd_size_type)svi_maxvma); + + if ((size_t) svi_vmalen < sizeof ("addr") - 1) + svi_vmalen = sizeof ("addr")-1; + + svi_sizelen = size_number (svi_total); + if ((size_t) svi_sizelen < sizeof ("size") - 1) + svi_sizelen = sizeof ("size")-1; + + svi_total = 0; + printf ("%s ", bfd_get_filename (file)); + + if (file->my_archive) + printf (" (ex %s)", bfd_get_filename (file->my_archive)); + + printf (":\n%-*s %*s %*s\n", svi_namelen, "section", + svi_sizelen, "size", svi_vmalen, "addr"); + + bfd_map_over_sections (file, sysv_internal_printer, NULL); + if (show_common) + { + svi_total += common_size; + sysv_one_line ("*COM*", common_size, 0); + } + + printf ("%-*s ", svi_namelen, "Total"); + rprint_number (svi_sizelen, svi_total); + printf ("\n\n"); +} + +static void +print_sizes (bfd *file) +{ + if (show_common) + calculate_common_size (file); + if (berkeley_format) + print_berkeley_format (file); + else + print_sysv_format (file); +} diff --git a/support/sdbinutils/binutils/srconv.c b/support/sdbinutils/binutils/srconv.c new file mode 100644 index 0000000..f89d998 --- /dev/null +++ b/support/sdbinutils/binutils/srconv.c @@ -0,0 +1,1858 @@ +/* srconv.c -- Sysroff conversion program + Copyright (C) 1994-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Written by Steve Chamberlain (sac@cygnus.com) + + This program can be used to convert a coff object file + into a Hitachi OM/LM (Sysroff) format. + + All debugging information is preserved */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" +#include "sysroff.h" +#include "coffgrok.h" +#include "libiberty.h" +#include "filenames.h" +#include "getopt.h" + +#include "coff/internal.h" +#include "../bfd/libcoff.h" + +/*#define FOOP1 1 */ + +static int addrsize; +static char *toolname; +static char **rnames; + +static void walk_tree_symbol + (struct coff_sfile *, struct coff_section *, struct coff_symbol *, int); +static void walk_tree_scope + (struct coff_section *, struct coff_sfile *, struct coff_scope *, int, int); +static int find_base (struct coff_sfile *, struct coff_section *); +static void wr_globals (struct coff_ofile *, struct coff_sfile *, int); + +static FILE *file; +static bfd *abfd; +static int debug = 0; +static int quick = 0; +static int noprescan = 0; +static struct coff_ofile *tree; +/* Obsolete ?? + static int absolute_p; + */ + +static int segmented_p; +static int code; + +static int ids1[20000]; +static int ids2[20000]; + +static int base1 = 0x18; +static int base2 = 0x2018; + +static int +get_member_id (int x) +{ + if (ids2[x]) + return ids2[x]; + + ids2[x] = base2++; + return ids2[x]; +} + +static int +get_ordinary_id (int x) +{ + if (ids1[x]) + return ids1[x]; + + ids1[x] = base1++; + return ids1[x]; +} +static char * +section_translate (char *n) +{ + if (strcmp (n, ".text") == 0) + return "P"; + if (strcmp (n, ".data") == 0) + return "D"; + if (strcmp (n, ".bss") == 0) + return "B"; + return n; +} + +#define DATE "940201073000"; /* Just a time on my birthday */ + +static char * +strip_suffix (const char *name) +{ + int i; + char *res; + + for (i = 0; name[i] != 0 && name[i] != '.'; i++) + ; + res = (char *) xmalloc (i + 1); + memcpy (res, name, i); + res[i] = 0; + return res; +} + +/* IT LEN stuff CS */ +static void +checksum (FILE *ffile, unsigned char *ptr, int size, int ccode) +{ + int j; + int last; + int sum = 0; + int bytes = size / 8; + + last = !(ccode & 0xff00); + if (size & 0x7) + fatal (_("Checksum failure")); + + ptr[0] = ccode | (last ? 0x80 : 0); + ptr[1] = bytes + 1; + + for (j = 0; j < bytes; j++) + sum += ptr[j]; + + /* Glue on a checksum too. */ + ptr[bytes] = ~sum; + if (fwrite (ptr, bytes + 1, 1, ffile) != 1) + /* FIXME: Return error status. */ + fatal (_("Failed to write checksum")); +} + + +static void +writeINT (int n, unsigned char *ptr, int *idx, int size, FILE *ffile) +{ + int byte = *idx / 8; + + if (size == -2) + size = addrsize; + else if (size == -1) + size = 0; + + if (byte > 240) + { + /* Lets write out that record and do another one. */ + checksum (ffile, ptr, *idx, code | 0x1000); + *idx = 16; + byte = *idx / 8; + } + + switch (size) + { + case 0: + break; + case 1: + ptr[byte] = n; + break; + case 2: + ptr[byte + 0] = n >> 8; + ptr[byte + 1] = n; + break; + case 4: + ptr[byte + 0] = n >> 24; + ptr[byte + 1] = n >> 16; + ptr[byte + 2] = n >> 8; + ptr[byte + 3] = n >> 0; + break; + default: + fatal (_("Unsupported integer write size: %d"), size); + } + *idx += size * 8; +} + +static void +writeBITS (int val, unsigned char *ptr, int *idx, int size) +{ + int byte = *idx / 8; + int bit = *idx % 8; + int old; + + *idx += size; + + old = ptr[byte]; + /* Turn off all about to change bits. */ + old &= ~((~0 >> (8 - bit - size)) & ((1 << size) - 1)); + /* Turn on the bits we want. */ + old |= (val & ((1 << size) - 1)) << (8 - bit - size); + ptr[byte] = old; +} + +static void +writeBARRAY (barray data, unsigned char *ptr, int *idx, + int size ATTRIBUTE_UNUSED, FILE *ffile) +{ + int i; + + writeINT (data.len, ptr, idx, 1, ffile); + for (i = 0; i < data.len; i++) + writeINT (data.data[i], ptr, idx, 1, ffile); +} + +static void +writeCHARS (char *string, unsigned char *ptr, int *idx, int size, FILE *ffile) +{ + int i = *idx / 8; + + if (i > 240) + { + /* Lets write out that record and do another one. */ + checksum (ffile, ptr, *idx, code | 0x1000); + *idx = 16; + i = *idx / 8; + } + + if (size == 0) + { + /* Variable length string. */ + size = strlen (string); + ptr[i++] = size; + } + + /* BUG WAITING TO HAPPEN. */ + memcpy (ptr + i, string, size); + i += size; + *idx = i * 8; +} + +#define SYSROFF_SWAP_OUT +#include "sysroff.c" + +static char *rname_sh[] = +{ + "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15" +}; + +static char *rname_h8300[] = +{ + "ER0", "ER1", "ER2", "ER3", "ER4", "ER5", "ER6", "ER7", "PC", "CCR" +}; + +static void +wr_tr (void) +{ + /* The TR block is not normal - it doesn't have any contents. */ + + static char b[] = + { + 0xff, /* IT */ + 0x03, /* RL */ + 0xfd, /* CS */ + }; + + if (fwrite (b, sizeof (b), 1, file) != 1) + /* FIXME: Return error status. */ + fatal (_("Failed to write TR block")); +} + +static void +wr_un (struct coff_ofile *ptr, struct coff_sfile *sfile, int first, + int nsecs ATTRIBUTE_UNUSED) +{ + struct IT_un un; + struct coff_symbol *s; + + un.spare1 = 0; + + if (bfd_get_file_flags (abfd) & EXEC_P) + un.format = FORMAT_LM; + else + un.format = FORMAT_OM; + un.spare1 = 0; + + /* Don't count the abs section. */ + un.nsections = ptr->nsections - 1; + + un.nextdefs = 0; + un.nextrefs = 0; + /* Count all the undefined and defined variables with global scope. */ + + if (first) + { + for (s = ptr->symbol_list_head; s; s = s->next_in_ofile_list) + { + if (s->visible->type == coff_vis_ext_def + || s->visible->type == coff_vis_common) + un.nextdefs++; + + if (s->visible->type == coff_vis_ext_ref) + un.nextrefs++; + } + } + un.tool = toolname; + un.tcd = DATE; + un.linker = "L_GX00"; + un.lcd = DATE; + un.name = sfile->name; + sysroff_swap_un_out (file, &un); +} + +static void +wr_hd (struct coff_ofile *p) +{ + struct IT_hd hd; + + hd.spare1 = 0; + if (bfd_get_file_flags (abfd) & EXEC_P) + hd.mt = MTYPE_ABS_LM; + else + hd.mt = MTYPE_OMS_OR_LMS; + + hd.cd = DATE; + + hd.nu = p->nsources; /* Always one unit */ + hd.code = 0; /* Always ASCII */ + hd.ver = "0200"; /* Version 2.00 */ + + switch (bfd_get_arch (abfd)) + { + case bfd_arch_h8300: + hd.au = 8; + hd.si = 0; + hd.spcsz = 32; + hd.segsz = 0; + hd.segsh = 0; + switch (bfd_get_mach (abfd)) + { + case bfd_mach_h8300: + hd.cpu = "H8300"; + hd.afl = 2; + addrsize = 2; + toolname = "C_H8/300"; + break; + case bfd_mach_h8300h: + hd.cpu = "H8300H"; + hd.afl = 4; + addrsize = 4; + toolname = "C_H8/300H"; + break; + case bfd_mach_h8300s: + hd.cpu = "H8300S"; + hd.afl = 4; + addrsize = 4; + toolname = "C_H8/300S"; + break; + default: + fatal (_("Unrecognized H8300 sub-architecture: %ld"), + bfd_get_mach (abfd)); + } + rnames = rname_h8300; + break; + case bfd_arch_sh: + hd.au = 8; + hd.si = 0; + hd.afl = 4; + hd.spcsz = 32; + hd.segsz = 0; + hd.segsh = 0; + hd.cpu = "SH"; + addrsize = 4; + toolname = "C_SH"; + rnames = rname_sh; + break; + default: + fatal (_("Unsupported architecture: %d"), bfd_get_arch (abfd)); + } + + if (! (bfd_get_file_flags(abfd) & EXEC_P)) + { + hd.ep = 0; + } + else + { + hd.ep = 1; + hd.uan = 0; + hd.sa = 0; + hd.sad = 0; + hd.address = bfd_get_start_address (abfd); + } + + hd.os = ""; + hd.sys = ""; + hd.mn = strip_suffix (bfd_get_filename (abfd)); + + sysroff_swap_hd_out (file, &hd); +} + + +static void +wr_sh (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_section *sec) +{ + struct IT_sh sh; + sh.unit = 0; + sh.section = sec->number; +#ifdef FOOP1 + sh.section = 0; +#endif + sysroff_swap_sh_out (file, &sh); +} + + +static void +wr_ob (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_section *section) +{ + bfd_size_type i; + int first = 1; + unsigned char stuff[200]; + + i = 0; + while (i < bfd_get_section_size (section->bfd_section)) + { + struct IT_ob ob; + int todo = 200; /* Copy in 200 byte lumps. */ + + ob.spare = 0; + if (i + todo > bfd_get_section_size (section->bfd_section)) + todo = bfd_get_section_size (section->bfd_section) - i; + + if (first) + { + ob.saf = 1; + if (bfd_get_file_flags (abfd) & EXEC_P) + ob.address = section->address; + else + ob.address = 0; + + first = 0; + } + else + { + ob.saf = 0; + } + + ob.cpf = 0; /* Never compress. */ + ob.data.len = todo; + bfd_get_section_contents (abfd, section->bfd_section, stuff, i, todo); + ob.data.data = stuff; + sysroff_swap_ob_out (file, &ob /*, i + todo < section->size */ ); + i += todo; + } + + /* Now fill the rest with blanks. */ + while (i < (bfd_size_type) section->size) + { + struct IT_ob ob; + int todo = 200; /* Copy in 200 byte lumps. */ + + ob.spare = 0; + if (i + todo > (bfd_size_type) section->size) + todo = section->size - i; + ob.saf = 0; + + ob.cpf = 0; /* Never compress. */ + ob.data.len = todo; + memset (stuff, 0, todo); + ob.data.data = stuff; + sysroff_swap_ob_out (file, &ob); + i += todo; + } + /* Now fill the rest with blanks. */ +} + +static void +wr_rl (struct coff_ofile *ptr ATTRIBUTE_UNUSED, struct coff_section *sec) +{ + int nr = sec->nrelocs; + int i; + + for (i = 0; i < nr; i++) + { + struct coff_reloc *r = sec->relocs + i; + struct coff_symbol *ref; + struct IT_rl rl; + + rl.apol = 0; + rl.boundary = 0; + rl.segment = 1; + rl.sign = 0; + rl.check = 0; + rl.addr = r->offset; + rl.bitloc = 0; + rl.flen = 32; /* SH Specific. */ + + /* What sort of reloc ? Look in the section to find out. */ + ref = r->symbol; + if (ref->visible->type == coff_vis_ext_ref) + { + rl.bcount = 4; /* Always 4 for us. */ + rl.op = OP_EXT_REF; + rl.symn = ref->er_number; + } + else if (ref->visible->type == coff_vis_common) + { + rl.bcount = 11; /* Always 11 for us. */ + rl.op = OP_SEC_REF; + rl.secn = ref->where->section->number; + rl.copcode_is_3 = 3; + rl.alength_is_4 = 4; + rl.addend = ref->where->offset - ref->where->section->address; + rl.aopcode_is_0x20 = 0x20; + } + else + { + rl.bcount = 11; /* Always 11 for us. */ + rl.op = OP_SEC_REF; + rl.secn = ref->where->section->number; + rl.copcode_is_3 = 3; + rl.alength_is_4 = 4; + rl.addend = -ref->where->section->address; + rl.aopcode_is_0x20 = 0x20; + } + + rl.end = 0xff; + + if ( rl.op == OP_SEC_REF + || rl.op == OP_EXT_REF) + sysroff_swap_rl_out (file, &rl); + } +} + +static void +wr_object_body (struct coff_ofile *p) +{ + int i; + + for (i = 1; i < p->nsections; i++) + { + wr_sh (p, p->sections + i); + wr_ob (p, p->sections + i); + wr_rl (p, p->sections + i); + } +} + +static void +wr_dps_start (struct coff_sfile *sfile, + struct coff_section *section ATTRIBUTE_UNUSED, + struct coff_scope *scope, int type, int nest) +{ + struct IT_dps dps; + + dps.end = 0; + dps.opt = 0; + dps.type = type; + + if (scope->sec) + { + dps.san = scope->sec->number; + dps.address = scope->offset - find_base (sfile, scope->sec); + dps.block_size = scope->size; + + if (debug) + { + printf ("DPS %s %d %x\n", + sfile->name, + nest, + dps.address); + } + } + else + { + dps.san = 0; + dps.address = 0; + dps.block_size = 0; + } + + dps.nesting = nest; + dps.neg = 0x1001; + sysroff_swap_dps_out (file, &dps); +} + +static void +wr_dps_end (struct coff_section *section ATTRIBUTE_UNUSED, + struct coff_scope *scope ATTRIBUTE_UNUSED, int type) +{ + struct IT_dps dps; + + dps.end = 1; + dps.type = type; + sysroff_swap_dps_out (file, &dps); +} + +static int * +nints (int x) +{ + return (int *) (xcalloc (sizeof (int), x)); +} + +static void +walk_tree_type_1 (struct coff_sfile *sfile, struct coff_symbol *symbol, + struct coff_type *type, int nest) +{ + switch (type->type) + { + case coff_secdef_type: + case coff_basic_type: + { + struct IT_dbt dbt; + + switch (type->u.basic) + { + case T_NULL: + case T_VOID: + dbt.btype = BTYPE_VOID; + dbt.sign = BTYPE_UNSPEC; + dbt.fptype = FPTYPE_NOTSPEC; + break; + + case T_CHAR: + dbt.btype = BTYPE_CHAR; + dbt.sign = BTYPE_UNSPEC; + dbt.fptype = FPTYPE_NOTSPEC; + break; + + case T_SHORT: + case T_INT: + case T_LONG: + dbt.btype = BTYPE_INT; + dbt.sign = SIGN_SIGNED; + dbt.fptype = FPTYPE_NOTSPEC; + break; + + case T_FLOAT: + dbt.btype = BTYPE_FLOAT; + dbt.fptype = FPTYPE_SINGLE; + break; + + case T_DOUBLE: + dbt.btype = BTYPE_FLOAT; + dbt.fptype = FPTYPE_DOUBLE; + break; + + case T_LNGDBL: + dbt.btype = BTYPE_FLOAT; + dbt.fptype = FPTYPE_EXTENDED; + break; + + case T_UCHAR: + dbt.btype = BTYPE_CHAR; + dbt.sign = SIGN_UNSIGNED; + dbt.fptype = FPTYPE_NOTSPEC; + break; + + case T_USHORT: + case T_UINT: + case T_ULONG: + dbt.btype = BTYPE_INT; + dbt.sign = SIGN_UNSIGNED; + dbt.fptype = FPTYPE_NOTSPEC; + break; + } + + dbt.bitsize = type->size; + dbt.neg = 0x1001; + sysroff_swap_dbt_out (file, &dbt); + break; + } + + case coff_pointer_type: + { + struct IT_dpt dpt; + + dpt.dunno = 0; + walk_tree_type_1 (sfile, symbol, type->u.pointer.points_to, nest + 1); + dpt.neg = 0x1001; + sysroff_swap_dpt_out (file, &dpt); + break; + } + + case coff_function_type: + { + struct IT_dfp dfp; + struct coff_symbol *param; + + dfp.end = 0; + dfp.spare = 0; + dfp.nparams = type->u.function.parameters->nvars; + dfp.neg = 0x1001; + + walk_tree_type_1 (sfile, symbol, type->u.function.function_returns, nest + 1); + + sysroff_swap_dfp_out (file, &dfp); + + for (param = type->u.function.parameters->vars_head; + param; + param = param->next) + walk_tree_symbol (sfile, 0, param, nest); + + dfp.end = 1; + sysroff_swap_dfp_out (file, &dfp); + break; + } + + case coff_structdef_type: + { + struct IT_dbt dbt; + struct IT_dds dds; + struct coff_symbol *member; + + dds.spare = 0; + dbt.btype = BTYPE_STRUCT; + dbt.bitsize = type->size; + dbt.sign = SIGN_UNSPEC; + dbt.fptype = FPTYPE_NOTSPEC; + dbt.sid = get_member_id (type->u.astructdef.idx); + dbt.neg = 0x1001; + sysroff_swap_dbt_out (file, &dbt); + dds.end = 0; + dds.neg = 0x1001; + sysroff_swap_dds_out (file, &dds); + + for (member = type->u.astructdef.elements->vars_head; + member; + member = member->next) + walk_tree_symbol (sfile, 0, member, nest + 1); + + dds.end = 1; + sysroff_swap_dds_out (file, &dds); + + } + break; + + case coff_structref_type: + { + struct IT_dbt dbt; + + dbt.btype = BTYPE_TAG; + dbt.bitsize = type->size; + dbt.sign = SIGN_UNSPEC; + dbt.fptype = FPTYPE_NOTSPEC; + + if (type->u.astructref.ref) + dbt.sid = get_member_id (type->u.astructref.ref->number); + else + dbt.sid = 0; + + dbt.neg = 0x1001; + sysroff_swap_dbt_out (file, &dbt); + } + break; + + case coff_array_type: + { + struct IT_dar dar; + int j; + int dims = 1; /* Only output one dimension at a time. */ + + dar.dims = dims; + dar.variable = nints (dims); + dar.subtype = nints (dims); + dar.spare = nints (dims); + dar.max_variable = nints (dims); + dar.maxspare = nints (dims); + dar.max = nints (dims); + dar.min_variable = nints (dims); + dar.min = nints (dims); + dar.minspare = nints (dims); + dar.neg = 0x1001; + dar.length = type->size / type->u.array.dim; + + for (j = 0; j < dims; j++) + { + dar.variable[j] = VARIABLE_FIXED; + dar.subtype[j] = SUB_INTEGER; + dar.spare[j] = 0; + dar.max_variable[j] = 0; + dar.max[j] = type->u.array.dim; + dar.min_variable[j] = 0; + dar.min[j] = 1; /* Why isn't this 0 ? */ + } + walk_tree_type_1 (sfile, symbol, type->u.array.array_of, nest + 1); + sysroff_swap_dar_out (file, &dar); + } + break; + + case coff_enumdef_type: + { + struct IT_dbt dbt; + struct IT_den den; + struct coff_symbol *member; + + dbt.btype = BTYPE_ENUM; + dbt.bitsize = type->size; + dbt.sign = SIGN_UNSPEC; + dbt.fptype = FPTYPE_NOTSPEC; + dbt.sid = get_member_id (type->u.aenumdef.idx); + dbt.neg = 0x1001; + sysroff_swap_dbt_out (file, &dbt); + + den.end = 0; + den.neg = 0x1001; + den.spare = 0; + sysroff_swap_den_out (file, &den); + + for (member = type->u.aenumdef.elements->vars_head; + member; + member = member->next) + walk_tree_symbol (sfile, 0, member, nest + 1); + + den.end = 1; + sysroff_swap_den_out (file, &den); + } + break; + + case coff_enumref_type: + { + struct IT_dbt dbt; + + dbt.btype = BTYPE_TAG; + dbt.bitsize = type->size; + dbt.sign = SIGN_UNSPEC; + dbt.fptype = FPTYPE_NOTSPEC; + dbt.sid = get_member_id (type->u.aenumref.ref->number); + dbt.neg = 0x1001; + sysroff_swap_dbt_out (file, &dbt); + } + break; + + default: + fatal (_("Unrecognised type: %d"), type->type); + } +} + +/* Obsolete ? + static void + dty_start () + { + struct IT_dty dty; + dty.end = 0; + dty.neg = 0x1001; + dty.spare = 0; + sysroff_swap_dty_out (file, &dty); + } + + static void + dty_stop () + { + struct IT_dty dty; + dty.end = 0; + dty.neg = 0x1001; + dty.end = 1; + sysroff_swap_dty_out (file, &dty); + } + + + static void + dump_tree_structure (sfile, symbol, type, nest) + struct coff_sfile *sfile; + struct coff_symbol *symbol; + struct coff_type *type; + int nest; + { + if (symbol->type->type == coff_function_type) + { + + + } + + } + */ + +static void +walk_tree_type (struct coff_sfile *sfile, struct coff_symbol *symbol, + struct coff_type *type, int nest) +{ + struct IT_dty dty; + + dty.spare = 0; + dty.end = 0; + dty.neg = 0x1001; + + if (symbol->type->type == coff_function_type) + { + sysroff_swap_dty_out (file, &dty); + walk_tree_type_1 (sfile, symbol, type, nest); + dty.end = 1; + sysroff_swap_dty_out (file, &dty); + + wr_dps_start (sfile, + symbol->where->section, + symbol->type->u.function.code, + BLOCK_TYPE_FUNCTION, nest); + wr_dps_start (sfile, symbol->where->section, + symbol->type->u.function.code, + BLOCK_TYPE_BLOCK, nest); + walk_tree_scope (symbol->where->section, + sfile, + symbol->type->u.function.code, + nest + 1, BLOCK_TYPE_BLOCK); + + wr_dps_end (symbol->where->section, + symbol->type->u.function.code, + BLOCK_TYPE_BLOCK); + wr_dps_end (symbol->where->section, + symbol->type->u.function.code, BLOCK_TYPE_FUNCTION); + } + else + { + sysroff_swap_dty_out (file, &dty); + walk_tree_type_1 (sfile, symbol, type, nest); + dty.end = 1; + sysroff_swap_dty_out (file, &dty); + } +} + +static void +walk_tree_symbol (struct coff_sfile *sfile, struct coff_section *section ATTRIBUTE_UNUSED, struct coff_symbol *symbol, int nest) +{ + struct IT_dsy dsy; + + memset (&dsy, 0, sizeof(dsy)); + dsy.nesting = nest; + + switch (symbol->type->type) + { + case coff_function_type: + dsy.type = STYPE_FUNC; + dsy.assign = 1; + break; + + case coff_structref_type: + case coff_pointer_type: + case coff_array_type: + case coff_basic_type: + case coff_enumref_type: + dsy.type = STYPE_VAR; + dsy.assign = 1; + break; + + case coff_enumdef_type: + dsy.type = STYPE_TAG; + dsy.assign = 0; + dsy.magic = 2; + break; + + case coff_structdef_type: + dsy.type = STYPE_TAG; + dsy.assign = 0; + dsy.magic = symbol->type->u.astructdef.isstruct ? 0 : 1; + break; + + case coff_secdef_type: + return; + + default: + fatal (_("Unrecognised coff symbol type: %d"), symbol->type->type); + } + + if (symbol->where->where == coff_where_member_of_struct) + { + dsy.assign = 0; + dsy.type = STYPE_MEMBER; + } + + if (symbol->where->where == coff_where_member_of_enum) + { + dsy.type = STYPE_ENUM; + dsy.assign = 0; + dsy.evallen = 4; + dsy.evalue = symbol->where->offset; + } + + if (symbol->type->type == coff_structdef_type + || symbol->where->where == coff_where_entag + || symbol->where->where == coff_where_strtag) + { + dsy.snumber = get_member_id (symbol->number); + } + else + { + dsy.snumber = get_ordinary_id (symbol->number); + } + + dsy.sname = symbol->name[0] == '_' ? symbol->name + 1 : symbol->name; + + switch (symbol->visible->type) + { + case coff_vis_common: + case coff_vis_ext_def: + dsy.ainfo = AINFO_STATIC_EXT_DEF; + break; + + case coff_vis_ext_ref: + dsy.ainfo = AINFO_STATIC_EXT_REF; + break; + + case coff_vis_int_def: + dsy.ainfo = AINFO_STATIC_INT; + break; + + case coff_vis_auto: + case coff_vis_autoparam: + dsy.ainfo = AINFO_AUTO; + break; + + case coff_vis_register: + case coff_vis_regparam: + dsy.ainfo = AINFO_REG; + break; + break; + + case coff_vis_tag: + case coff_vis_member_of_struct: + case coff_vis_member_of_enum: + break; + + default: + fatal (_("Unrecognised coff symbol visibility: %d"), symbol->visible->type); + } + + dsy.dlength = symbol->type->size; + + switch (symbol->where->where) + { + case coff_where_memory: + + dsy.section = symbol->where->section->number; +#ifdef FOOP + dsy.section = 0; +#endif + break; + + case coff_where_member_of_struct: + case coff_where_member_of_enum: + case coff_where_stack: + case coff_where_register: + case coff_where_unknown: + case coff_where_strtag: + case coff_where_entag: + case coff_where_typedef: + break; + + default: + fatal (_("Unrecognised coff symbol location: %d"), symbol->where->where); + } + + switch (symbol->where->where) + { + case coff_where_memory: + dsy.address = symbol->where->offset - find_base (sfile, symbol->where->section); + break; + + case coff_where_stack: + dsy.address = symbol->where->offset; + break; + + case coff_where_member_of_struct: + if (symbol->where->bitsize) + { + int bits = (symbol->where->offset * 8 + symbol->where->bitoffset); + dsy.bitunit = 1; + dsy.field_len = symbol->where->bitsize; + dsy.field_off = (bits / 32) * 4; + dsy.field_bitoff = bits % 32; + } + else + { + dsy.bitunit = 0; + + dsy.field_len = symbol->type->size; + dsy.field_off = symbol->where->offset; + } + break; + + case coff_where_member_of_enum: + /* dsy.bitunit = 0; + dsy.field_len = symbol->type->size; + dsy.field_off = symbol->where->offset; */ + break; + + case coff_where_register: + case coff_where_unknown: + case coff_where_strtag: + case coff_where_entag: + case coff_where_typedef: + break; + + default: + fatal (_("Unrecognised coff symbol location: %d"), symbol->where->where); + } + + if (symbol->where->where == coff_where_register) + dsy.reg = rnames[symbol->where->offset]; + + switch (symbol->visible->type) + { + case coff_vis_common: + /* We do this 'cause common C symbols are treated as extdefs. */ + case coff_vis_ext_def: + case coff_vis_ext_ref: + dsy.ename = symbol->name; + break; + + case coff_vis_regparam: + case coff_vis_autoparam: + dsy.type = STYPE_PARAMETER; + break; + + case coff_vis_int_def: + case coff_vis_auto: + case coff_vis_register: + case coff_vis_tag: + case coff_vis_member_of_struct: + case coff_vis_member_of_enum: + break; + + default: + fatal (_("Unrecognised coff symbol visibility: %d"), symbol->visible->type); + } + + dsy.sfn = 0; + dsy.sln = 2; + dsy.neg = 0x1001; + + sysroff_swap_dsy_out (file, &dsy); + + walk_tree_type (sfile, symbol, symbol->type, nest); +} + +static void +walk_tree_scope (struct coff_section *section, struct coff_sfile *sfile, struct coff_scope *scope, int nest, int type) +{ + struct coff_symbol *vars; + struct coff_scope *child; + + if (scope->vars_head + || (scope->list_head && scope->list_head->vars_head)) + { + wr_dps_start (sfile, section, scope, type, nest); + + if (nest == 0) + wr_globals (tree, sfile, nest + 1); + + for (vars = scope->vars_head; vars; vars = vars->next) + walk_tree_symbol (sfile, section, vars, nest); + + for (child = scope->list_head; child; child = child->next) + walk_tree_scope (section, sfile, child, nest + 1, BLOCK_TYPE_BLOCK); + + wr_dps_end (section, scope, type); + } +} + +static void +walk_tree_sfile (struct coff_section *section, struct coff_sfile *sfile) +{ + walk_tree_scope (section, sfile, sfile->scope, 0, BLOCK_TYPE_COMPUNIT); +} + +static void +wr_program_structure (struct coff_ofile *p, struct coff_sfile *sfile) +{ + if (p->nsections < 4) + return; + walk_tree_sfile (p->sections + 4, sfile); +} + +static void +wr_du (struct coff_ofile *p, struct coff_sfile *sfile, int n) +{ + struct IT_du du; + int lim; + int i; + int j; + unsigned int *lowest = (unsigned *) nints (p->nsections); + unsigned int *highest = (unsigned *) nints (p->nsections); + + du.format = bfd_get_file_flags (abfd) & EXEC_P ? 0 : 1; + du.optimized = 0; + du.stackfrmt = 0; + du.spare = 0; + du.unit = n; + du.sections = p->nsections - 1; + du.san = (int *) xcalloc (sizeof (int), du.sections); + du.address = nints (du.sections); + du.length = nints (du.sections); + + for (i = 0; i < du.sections; i++) + { + lowest[i] = ~0; + highest[i] = 0; + } + + lim = du.sections; + for (j = 0; j < lim; j++) + { + int src = j; + int dst = j; + + du.san[dst] = dst; + + if (sfile->section[src].init) + { + du.length[dst] + = sfile->section[src].high - sfile->section[src].low + 1; + du.address[dst] + = sfile->section[src].low; + } + else + { + du.length[dst] = 0; + du.address[dst] = 0; + } + + if (debug) + { + if (sfile->section[src].parent) + { + printf (" section %6s 0x%08x..0x%08x\n", + sfile->section[src].parent->name, + du.address[dst], + du.address[dst] + du.length[dst] - 1); + } + } + + du.sections = dst + 1; + } + + du.tool = "c_gcc"; + du.date = DATE; + + sysroff_swap_du_out (file, &du); +} + +static void +wr_dus (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_sfile *sfile) +{ + struct IT_dus dus; + + dus.efn = 0x1001; + dus.ns = 1; /* p->nsources; sac 14 jul 94 */ + dus.drb = nints (dus.ns); + dus.fname = (char **) xcalloc (sizeof (char *), dus.ns); + dus.spare = nints (dus.ns); + dus.ndir = 0; + /* Find the filenames. */ + dus.drb[0] = 0; + dus.fname[0] = sfile->name; + + sysroff_swap_dus_out (file, &dus); + +} + +/* Find the offset of the .text section for this sfile in the + .text section for the output file. */ + +static int +find_base (struct coff_sfile *sfile, struct coff_section *section) +{ + return sfile->section[section->number].low; +} + +static void +wr_dln (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_sfile *sfile, + int n ATTRIBUTE_UNUSED) +{ + /* Count up all the linenumbers */ + + struct coff_symbol *sy; + int lc = 0; + struct IT_dln dln; + + int idx; + + for (sy = sfile->scope->vars_head; + sy; + sy = sy->next) + { + struct coff_type *t = sy->type; + if (t->type == coff_function_type) + { + struct coff_line *l = t->u.function.lines; + if (l) + lc += l->nlines; + } + } + + dln.sfn = nints (lc); + dln.sln = nints (lc); + dln.cc = nints (lc); + dln.section = nints (lc); + + dln.from_address = nints (lc); + dln.to_address = nints (lc); + + + dln.neg = 0x1001; + + dln.nln = lc; + + /* Run through once more and fill up the structure */ + idx = 0; + for (sy = sfile->scope->vars_head; + sy; + sy = sy->next) + { + if (sy->type->type == coff_function_type) + { + int i; + struct coff_line *l = sy->type->u.function.lines; + if (l) + { + int base = find_base (sfile, sy->where->section); + for (i = 0; i < l->nlines; i++) + { + dln.section[idx] = sy->where->section->number; + dln.sfn[idx] = 0; + dln.sln[idx] = l->lines[i]; + dln.from_address[idx] = + l->addresses[i] + sy->where->section->address - base; + dln.cc[idx] = 0; + if (idx) + dln.to_address[idx - 1] = dln.from_address[idx]; + idx++; + + } + dln.to_address[idx - 1] = dln.from_address[idx - 1] + 2; + } + } + } + if (lc) + sysroff_swap_dln_out (file, &dln); +} + +/* Write the global symbols out to the debug info. */ + +static void +wr_globals (struct coff_ofile *p, struct coff_sfile *sfile, + int n ATTRIBUTE_UNUSED) +{ + struct coff_symbol *sy; + + for (sy = p->symbol_list_head; + sy; + sy = sy->next_in_ofile_list) + { + if (sy->visible->type == coff_vis_ext_def + || sy->visible->type == coff_vis_ext_ref) + { + /* Only write out symbols if they belong to + the current source file. */ + if (sy->sfile == sfile) + walk_tree_symbol (sfile, 0, sy, 0); + } + } +} + +static void +wr_debug (struct coff_ofile *p) +{ + struct coff_sfile *sfile; + int n = 0; + + for (sfile = p->source_head; + sfile; + sfile = sfile->next) + { + if (debug) + printf ("%s\n", sfile->name); + + wr_du (p, sfile, n); + wr_dus (p, sfile); + wr_program_structure (p, sfile); + wr_dln (p, sfile, n); + n++; + } +} + +static void +wr_cs (void) +{ + /* It seems that the CS struct is not normal - the size is wrong + heres one I prepared earlier. */ + static char b[] = + { + 0x80, /* IT */ + 0x21, /* RL */ + 0x00, /* number of chars in variable length part */ + 0x80, /* hd */ + 0x00, /* hs */ + 0x80, /* un */ + 0x00, /* us */ + 0x80, /* sc */ + 0x00, /* ss */ + 0x80, /* er */ + 0x80, /* ed */ + 0x80, /* sh */ + 0x80, /* ob */ + 0x80, /* rl */ + 0x80, /* du */ + 0x80, /* dps */ + 0x80, /* dsy */ + 0x80, /* dty */ + 0x80, /* dln */ + 0x80, /* dso */ + 0x80, /* dus */ + 0x00, /* dss */ + 0x80, /* dbt */ + 0x00, /* dpp */ + 0x80, /* dfp */ + 0x80, /* den */ + 0x80, /* dds */ + 0x80, /* dar */ + 0x80, /* dpt */ + 0x00, /* dul */ + 0x00, /* dse */ + 0x00, /* dot */ + 0xDE /* CS */ + }; + + if (fwrite (b, sizeof (b), 1, file) != 1) + /* FIXME: Return error status. */ + fatal (_("Failed to write CS struct")); +} + +/* Write out the SC records for a unit. Create an SC + for all the sections which appear in the output file, even + if there isn't an equivalent one on the input. */ + +static int +wr_sc (struct coff_ofile *ptr, struct coff_sfile *sfile) +{ + int i; + int scount = 0; + /* First work out the total number of sections. */ + int total_sec = ptr->nsections; + struct myinfo + { + struct coff_section *sec; + struct coff_symbol *symbol; + }; + struct coff_symbol *symbol; + struct myinfo *info + = (struct myinfo *) calloc (total_sec, sizeof (struct myinfo)); + + + for (i = 0; i < total_sec; i++) + { + info[i].sec = ptr->sections + i; + info[i].symbol = 0; + } + + for (symbol = sfile->scope->vars_head; + symbol; + symbol = symbol->next) + { + + if (symbol->type->type == coff_secdef_type) + { + for (i = 0; i < total_sec; i++) + { + if (symbol->where->section == info[i].sec) + { + info[i].symbol = symbol; + break; + } + } + } + } + + /* Now output all the section info, and fake up some stuff for sections + we don't have. */ + for (i = 1; i < total_sec; i++) + { + struct IT_sc sc; + char *name; + + symbol = info[i].symbol; + sc.spare = 0; + sc.spare1 = 0; + + if (!symbol) + { + /* Don't have a symbol set aside for this section, which means + that nothing in this file does anything for the section. */ + sc.format = !(bfd_get_file_flags (abfd) & EXEC_P); + sc.addr = 0; + sc.length = 0; + name = info[i].sec->name; + } + else + { + if (bfd_get_file_flags (abfd) & EXEC_P) + { + sc.format = 0; + sc.addr = symbol->where->offset; + } + else + { + sc.format = 1; + sc.addr = 0; + } + sc.length = symbol->type->size; + name = symbol->name; + } + + sc.align = 4; + sc.concat = CONCAT_SIMPLE; + sc.read = 3; + sc.write = 3; + sc.exec = 3; + sc.init = 3; + sc.mode = 3; + sc.spare = 0; + sc.segadd = 0; + sc.spare1 = 0; /* If not zero, then it doesn't work. */ + sc.name = section_translate (name); + + if (strlen (sc.name) == 1) + { + switch (sc.name[0]) + { + case 'D': + case 'B': + sc.contents = CONTENTS_DATA; + break; + + default: + sc.contents = CONTENTS_CODE; + } + } + else + { + sc.contents = CONTENTS_CODE; + } + + sysroff_swap_sc_out (file, &sc); + scount++; + } + free (info); + return scount; +} + +/* Write out the ER records for a unit. */ + +static void +wr_er (struct coff_ofile *ptr, struct coff_sfile *sfile ATTRIBUTE_UNUSED, + int first) +{ + int idx = 0; + struct coff_symbol *sym; + + if (first) + { + for (sym = ptr->symbol_list_head; sym; sym = sym->next_in_ofile_list) + { + if (sym->visible->type == coff_vis_ext_ref) + { + struct IT_er er; + + er.spare = 0; + er.type = ER_NOTSPEC; + er.name = sym->name; + sysroff_swap_er_out (file, &er); + sym->er_number = idx++; + } + } + } +} + +/* Write out the ED records for a unit. */ + +static void +wr_ed (struct coff_ofile *ptr, struct coff_sfile *sfile ATTRIBUTE_UNUSED, + int first) +{ + struct coff_symbol *s; + + if (first) + { + for (s = ptr->symbol_list_head; s; s = s->next_in_ofile_list) + { + if (s->visible->type == coff_vis_ext_def + || s->visible->type == coff_vis_common) + { + struct IT_ed ed; + + ed.section = s->where->section->number; + ed.spare = 0; + + if (s->where->section->data) + { + ed.type = ED_TYPE_DATA; + } + else if (s->where->section->code & SEC_CODE) + { + ed.type = ED_TYPE_ENTRY; + } + else + { + ed.type = ED_TYPE_NOTSPEC; + ed.type = ED_TYPE_DATA; + } + + ed.address = s->where->offset - s->where->section->address; + ed.name = s->name; + sysroff_swap_ed_out (file, &ed); + } + } + } +} + +static void +wr_unit_info (struct coff_ofile *ptr) +{ + struct coff_sfile *sfile; + int first = 1; + + for (sfile = ptr->source_head; + sfile; + sfile = sfile->next) + { + long p1; + long p2; + int nsecs; + + p1 = ftell (file); + wr_un (ptr, sfile, first, 0); + nsecs = wr_sc (ptr, sfile); + p2 = ftell (file); + fseek (file, p1, SEEK_SET); + wr_un (ptr, sfile, first, nsecs); + fseek (file, p2, SEEK_SET); + wr_er (ptr, sfile, first); + wr_ed (ptr, sfile, first); + first = 0; + } +} + +static void +wr_module (struct coff_ofile *p) +{ + wr_cs (); + wr_hd (p); + wr_unit_info (p); + wr_object_body (p); + wr_debug (p); + wr_tr (); +} + +static int +align (int x) +{ + return (x + 3) & ~3; +} + +/* Find all the common variables and turn them into + ordinary defs - dunno why, but thats what hitachi does with 'em. */ + +static void +prescan (struct coff_ofile *otree) +{ + struct coff_symbol *s; + struct coff_section *common_section; + + if (otree->nsections < 3) + return; + + /* Find the common section - always section 3. */ + common_section = otree->sections + 3; + + for (s = otree->symbol_list_head; + s; + s = s->next_in_ofile_list) + { + if (s->visible->type == coff_vis_common) + { + struct coff_where *w = s->where; + /* s->visible->type = coff_vis_ext_def; leave it as common */ + common_section->size = align (common_section->size); + w->offset = common_section->size + common_section->address; + w->section = common_section; + common_section->size += s->type->size; + common_section->size = align (common_section->size); + } + } +} + +char *program_name; + +ATTRIBUTE_NORETURN static void +show_usage (FILE *ffile, int status) +{ + fprintf (ffile, _("Usage: %s [option(s)] in-file [out-file]\n"), program_name); + fprintf (ffile, _("Convert a COFF object file into a SYSROFF object file\n")); + fprintf (ffile, _(" The options are:\n\ + -q --quick (Obsolete - ignored)\n\ + -n --noprescan Do not perform a scan to convert commons into defs\n\ + -d --debug Display information about what is being done\n\ + @ Read options from \n\ + -h --help Display this information\n\ + -v --version Print the program's version number\n")); + + if (REPORT_BUGS_TO[0] && status == 0) + fprintf (ffile, _("Report bugs to %s\n"), REPORT_BUGS_TO); + exit (status); +} + +int +main (int ac, char **av) +{ + int opt; + static struct option long_options[] = + { + {"debug", no_argument, 0, 'd'}, + {"quick", no_argument, 0, 'q'}, + {"noprescan", no_argument, 0, 'n'}, + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'V'}, + {NULL, no_argument, 0, 0} + }; + char **matching; + char *input_file; + char *output_file; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + program_name = av[0]; + xmalloc_set_program_name (program_name); + bfd_set_error_program_name (program_name); + + expandargv (&ac, &av); + + while ((opt = getopt_long (ac, av, "dHhVvqn", long_options, + (int *) NULL)) + != EOF) + { + switch (opt) + { + case 'q': + quick = 1; + break; + case 'n': + noprescan = 1; + break; + case 'd': + debug = 1; + break; + case 'H': + case 'h': + show_usage (stdout, 0); + /*NOTREACHED */ + case 'v': + case 'V': + print_version ("srconv"); + exit (0); + /*NOTREACHED */ + case 0: + break; + default: + show_usage (stderr, 1); + /*NOTREACHED */ + } + } + + /* The input and output files may be named on the command line. */ + output_file = NULL; + if (optind < ac) + { + input_file = av[optind]; + ++optind; + if (optind < ac) + { + output_file = av[optind]; + ++optind; + if (optind < ac) + show_usage (stderr, 1); + if (filename_cmp (input_file, output_file) == 0) + { + fatal (_("input and output files must be different")); + } + } + } + else + input_file = 0; + + if (!input_file) + { + fatal (_("no input file specified")); + } + + if (!output_file) + { + /* Take a .o off the input file and stick on a .obj. If + it doesn't end in .o, then stick a .obj on anyway */ + + int len = strlen (input_file); + + output_file = xmalloc (len + 5); + strcpy (output_file, input_file); + + if (len > 3 + && output_file[len - 2] == '.' + && output_file[len - 1] == 'o') + { + output_file[len] = 'b'; + output_file[len + 1] = 'j'; + output_file[len + 2] = 0; + } + else + { + strcat (output_file, ".obj"); + } + } + + abfd = bfd_openr (input_file, 0); + + if (!abfd) + bfd_fatal (input_file); + + if (!bfd_check_format_matches (abfd, bfd_object, &matching)) + { + bfd_nonfatal (input_file); + + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (matching); + free (matching); + } + exit (1); + } + + file = fopen (output_file, FOPEN_WB); + + if (!file) + fatal (_("unable to open output file %s"), output_file); + + if (debug) + printf ("ids %d %d\n", base1, base2); + + tree = coff_grok (abfd); + if (tree) + { + if (!noprescan) + prescan (tree); + + wr_module (tree); + } + return 0; +} diff --git a/support/sdbinutils/binutils/stabs.c b/support/sdbinutils/binutils/stabs.c new file mode 100644 index 0000000..a3ff345 --- /dev/null +++ b/support/sdbinutils/binutils/stabs.c @@ -0,0 +1,5451 @@ +/* stabs.c -- Parse stabs debugging information + Copyright (C) 1995-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor . + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* This file contains code which parses stabs debugging information. + The organization of this code is based on the gdb stabs reading + code. The job it does is somewhat different, because it is not + trying to identify the correct address for anything. */ + +#include "sysdep.h" +#include "bfd.h" +#include "libiberty.h" +#include "safe-ctype.h" +#include "demangle.h" +#include "debug.h" +#include "budbg.h" +#include "filenames.h" +#include "aout/aout64.h" +#include "aout/stab_gnu.h" + +/* The number of predefined XCOFF types. */ + +#define XCOFF_TYPE_COUNT 34 + +/* This structure is used as a handle so that the stab parsing doesn't + need to use any static variables. */ + +struct stab_handle +{ + /* The BFD. */ + bfd *abfd; + /* TRUE if this is stabs in sections. */ + bfd_boolean sections; + /* The symbol table. */ + asymbol **syms; + /* The number of symbols. */ + long symcount; + /* The accumulated file name string. */ + char *so_string; + /* The value of the last N_SO symbol. */ + bfd_vma so_value; + /* The value of the start of the file, so that we can handle file + relative N_LBRAC and N_RBRAC symbols. */ + bfd_vma file_start_offset; + /* The offset of the start of the function, so that we can handle + function relative N_LBRAC and N_RBRAC symbols. */ + bfd_vma function_start_offset; + /* The version number of gcc which compiled the current compilation + unit, 0 if not compiled by gcc. */ + int gcc_compiled; + /* Whether an N_OPT symbol was seen that was not generated by gcc, + so that we can detect the SunPRO compiler. */ + bfd_boolean n_opt_found; + /* The main file name. */ + char *main_filename; + /* A stack of unfinished N_BINCL files. */ + struct bincl_file *bincl_stack; + /* A list of finished N_BINCL files. */ + struct bincl_file *bincl_list; + /* Whether we are inside a function or not. */ + bfd_boolean within_function; + /* The address of the end of the function, used if we have seen an + N_FUN symbol while in a function. This is -1 if we have not seen + an N_FUN (the normal case). */ + bfd_vma function_end; + /* The depth of block nesting. */ + int block_depth; + /* List of pending variable definitions. */ + struct stab_pending_var *pending; + /* Number of files for which we have types. */ + unsigned int files; + /* Lists of types per file. */ + struct stab_types **file_types; + /* Predefined XCOFF types. */ + debug_type xcoff_types[XCOFF_TYPE_COUNT]; + /* Undefined tags. */ + struct stab_tag *tags; + /* Set by parse_stab_type if it sees a structure defined as a cross + reference to itself. Reset by parse_stab_type otherwise. */ + bfd_boolean self_crossref; +}; + +/* A list of these structures is used to hold pending variable + definitions seen before the N_LBRAC of a block. */ + +struct stab_pending_var +{ + /* Next pending variable definition. */ + struct stab_pending_var *next; + /* Name. */ + const char *name; + /* Type. */ + debug_type type; + /* Kind. */ + enum debug_var_kind kind; + /* Value. */ + bfd_vma val; +}; + +/* A list of these structures is used to hold the types for a single + file. */ + +struct stab_types +{ + /* Next set of slots for this file. */ + struct stab_types *next; + /* Types indexed by type number. */ +#define STAB_TYPES_SLOTS (16) + debug_type types[STAB_TYPES_SLOTS]; +}; + +/* We keep a list of undefined tags that we encounter, so that we can + fill them in if the tag is later defined. */ + +struct stab_tag +{ + /* Next undefined tag. */ + struct stab_tag *next; + /* Tag name. */ + const char *name; + /* Type kind. */ + enum debug_type_kind kind; + /* Slot to hold real type when we discover it. If we don't, we fill + in an undefined tag type. */ + debug_type slot; + /* Indirect type we have created to point at slot. */ + debug_type type; +}; + +static char *savestring (const char *, int); +static bfd_vma parse_number (const char **, bfd_boolean *); +static void bad_stab (const char *); +static void warn_stab (const char *, const char *); +static bfd_boolean parse_stab_string + (void *, struct stab_handle *, int, int, bfd_vma, const char *); +static debug_type parse_stab_type + (void *, struct stab_handle *, const char *, const char **, debug_type **); +static bfd_boolean parse_stab_type_number (const char **, int *); +static debug_type parse_stab_range_type + (void *, struct stab_handle *, const char *, const char **, const int *); +static debug_type parse_stab_sun_builtin_type (void *, const char **); +static debug_type parse_stab_sun_floating_type (void *, const char **); +static debug_type parse_stab_enum_type (void *, const char **); +static debug_type parse_stab_struct_type + (void *, struct stab_handle *, const char *, const char **, + bfd_boolean, const int *); +static bfd_boolean parse_stab_baseclasses + (void *, struct stab_handle *, const char **, debug_baseclass **); +static bfd_boolean parse_stab_struct_fields + (void *, struct stab_handle *, const char **, debug_field **, bfd_boolean *); +static bfd_boolean parse_stab_cpp_abbrev + (void *, struct stab_handle *, const char **, debug_field *); +static bfd_boolean parse_stab_one_struct_field + (void *, struct stab_handle *, const char **, const char *, + debug_field *, bfd_boolean *); +static bfd_boolean parse_stab_members + (void *, struct stab_handle *, const char *, const char **, const int *, + debug_method **); +static debug_type parse_stab_argtypes + (void *, struct stab_handle *, debug_type, const char *, const char *, + debug_type, const char *, bfd_boolean, bfd_boolean, const char **); +static bfd_boolean parse_stab_tilde_field + (void *, struct stab_handle *, const char **, const int *, debug_type *, + bfd_boolean *); +static debug_type parse_stab_array_type + (void *, struct stab_handle *, const char **, bfd_boolean); +static void push_bincl (struct stab_handle *, const char *, bfd_vma); +static const char *pop_bincl (struct stab_handle *); +static bfd_boolean find_excl (struct stab_handle *, const char *, bfd_vma); +static bfd_boolean stab_record_variable + (void *, struct stab_handle *, const char *, debug_type, + enum debug_var_kind, bfd_vma); +static bfd_boolean stab_emit_pending_vars (void *, struct stab_handle *); +static debug_type *stab_find_slot (struct stab_handle *, const int *); +static debug_type stab_find_type (void *, struct stab_handle *, const int *); +static bfd_boolean stab_record_type + (void *, struct stab_handle *, const int *, debug_type); +static debug_type stab_xcoff_builtin_type + (void *, struct stab_handle *, int); +static debug_type stab_find_tagged_type + (void *, struct stab_handle *, const char *, int, enum debug_type_kind); +static debug_type *stab_demangle_argtypes + (void *, struct stab_handle *, const char *, bfd_boolean *, unsigned int); +static debug_type *stab_demangle_v3_argtypes + (void *, struct stab_handle *, const char *, bfd_boolean *); +static debug_type *stab_demangle_v3_arglist + (void *, struct stab_handle *, struct demangle_component *, bfd_boolean *); +static debug_type stab_demangle_v3_arg + (void *, struct stab_handle *, struct demangle_component *, debug_type, + bfd_boolean *); + +/* Save a string in memory. */ + +static char * +savestring (const char *start, int len) +{ + char *ret; + + ret = (char *) xmalloc (len + 1); + memcpy (ret, start, len); + ret[len] = '\0'; + return ret; +} + +/* Read a number from a string. */ + +static bfd_vma +parse_number (const char **pp, bfd_boolean *poverflow) +{ + unsigned long ul; + const char *orig; + + if (poverflow != NULL) + *poverflow = FALSE; + + orig = *pp; + + /* Stop early if we are passed an empty string. */ + if (*orig == 0) + return (bfd_vma) 0; + + errno = 0; + ul = strtoul (*pp, (char **) pp, 0); + if (ul + 1 != 0 || errno == 0) + { + /* If bfd_vma is larger than unsigned long, and the number is + meant to be negative, we have to make sure that we sign + extend properly. */ + if (*orig == '-') + return (bfd_vma) (bfd_signed_vma) (long) ul; + return (bfd_vma) ul; + } + + /* Note that even though strtoul overflowed, it should have set *pp + to the end of the number, which is where we want it. */ + if (sizeof (bfd_vma) > sizeof (unsigned long)) + { + const char *p; + bfd_boolean neg; + int base; + bfd_vma over, lastdig; + bfd_boolean overflow; + bfd_vma v; + + /* Our own version of strtoul, for a bfd_vma. */ + p = orig; + + neg = FALSE; + if (*p == '+') + ++p; + else if (*p == '-') + { + neg = TRUE; + ++p; + } + + base = 10; + if (*p == '0') + { + if (p[1] == 'x' || p[1] == 'X') + { + base = 16; + p += 2; + } + else + { + base = 8; + ++p; + } + } + + over = ((bfd_vma) (bfd_signed_vma) -1) / (bfd_vma) base; + lastdig = ((bfd_vma) (bfd_signed_vma) -1) % (bfd_vma) base; + + overflow = FALSE; + v = 0; + while (1) + { + int d; + + d = *p++; + if (ISDIGIT (d)) + d -= '0'; + else if (ISUPPER (d)) + d -= 'A'; + else if (ISLOWER (d)) + d -= 'a'; + else + break; + + if (d >= base) + break; + + if (v > over || (v == over && (bfd_vma) d > lastdig)) + { + overflow = TRUE; + break; + } + } + + if (! overflow) + { + if (neg) + v = - v; + return v; + } + } + + /* If we get here, the number is too large to represent in a + bfd_vma. */ + if (poverflow != NULL) + *poverflow = TRUE; + else + warn_stab (orig, _("numeric overflow")); + + return 0; +} + +/* Give an error for a bad stab string. */ + +static void +bad_stab (const char *p) +{ + fprintf (stderr, _("Bad stab: %s\n"), p); +} + +/* Warn about something in a stab string. */ + +static void +warn_stab (const char *p, const char *err) +{ + fprintf (stderr, _("Warning: %s: %s\n"), err, p); +} + +/* Create a handle to parse stabs symbols with. */ + +void * +start_stab (void *dhandle ATTRIBUTE_UNUSED, bfd *abfd, bfd_boolean sections, + asymbol **syms, long symcount) +{ + struct stab_handle *ret; + + ret = (struct stab_handle *) xmalloc (sizeof *ret); + memset (ret, 0, sizeof *ret); + ret->abfd = abfd; + ret->sections = sections; + ret->syms = syms; + ret->symcount = symcount; + ret->files = 1; + ret->file_types = (struct stab_types **) xmalloc (sizeof *ret->file_types); + ret->file_types[0] = NULL; + ret->function_end = (bfd_vma) -1; + return (void *) ret; +} + +/* When we have processed all the stabs information, we need to go + through and fill in all the undefined tags. */ + +bfd_boolean +finish_stab (void *dhandle, void *handle) +{ + struct stab_handle *info = (struct stab_handle *) handle; + struct stab_tag *st; + + if (info->within_function) + { + if (! stab_emit_pending_vars (dhandle, info) + || ! debug_end_function (dhandle, info->function_end)) + return FALSE; + info->within_function = FALSE; + info->function_end = (bfd_vma) -1; + } + + for (st = info->tags; st != NULL; st = st->next) + { + enum debug_type_kind kind; + + kind = st->kind; + if (kind == DEBUG_KIND_ILLEGAL) + kind = DEBUG_KIND_STRUCT; + st->slot = debug_make_undefined_tagged_type (dhandle, st->name, kind); + if (st->slot == DEBUG_TYPE_NULL) + return FALSE; + } + + return TRUE; +} + +/* Handle a single stabs symbol. */ + +bfd_boolean +parse_stab (void *dhandle, void *handle, int type, int desc, bfd_vma value, + const char *string) +{ + struct stab_handle *info = (struct stab_handle *) handle; + + /* gcc will emit two N_SO strings per compilation unit, one for the + directory name and one for the file name. We just collect N_SO + strings as we see them, and start the new compilation unit when + we see a non N_SO symbol. */ + if (info->so_string != NULL + && (type != N_SO || *string == '\0' || value != info->so_value)) + { + if (! debug_set_filename (dhandle, info->so_string)) + return FALSE; + info->main_filename = info->so_string; + + info->gcc_compiled = 0; + info->n_opt_found = FALSE; + + /* Generally, for stabs in the symbol table, the N_LBRAC and + N_RBRAC symbols are relative to the N_SO symbol value. */ + if (! info->sections) + info->file_start_offset = info->so_value; + + /* We need to reset the mapping from type numbers to types. We + can't free the old mapping, because of the use of + debug_make_indirect_type. */ + info->files = 1; + info->file_types = ((struct stab_types **) + xmalloc (sizeof *info->file_types)); + info->file_types[0] = NULL; + + info->so_string = NULL; + + /* Now process whatever type we just got. */ + } + + switch (type) + { + case N_FN: + case N_FN_SEQ: + break; + + case N_LBRAC: + /* Ignore extra outermost context from SunPRO cc and acc. */ + if (info->n_opt_found && desc == 1) + break; + + if (! info->within_function) + { + fprintf (stderr, _("N_LBRAC not within function\n")); + return FALSE; + } + + /* Start an inner lexical block. */ + if (! debug_start_block (dhandle, + (value + + info->file_start_offset + + info->function_start_offset))) + return FALSE; + + /* Emit any pending variable definitions. */ + if (! stab_emit_pending_vars (dhandle, info)) + return FALSE; + + ++info->block_depth; + break; + + case N_RBRAC: + /* Ignore extra outermost context from SunPRO cc and acc. */ + if (info->n_opt_found && desc == 1) + break; + + /* We shouldn't have any pending variable definitions here, but, + if we do, we probably need to emit them before closing the + block. */ + if (! stab_emit_pending_vars (dhandle, info)) + return FALSE; + + /* End an inner lexical block. */ + if (! debug_end_block (dhandle, + (value + + info->file_start_offset + + info->function_start_offset))) + return FALSE; + + --info->block_depth; + if (info->block_depth < 0) + { + fprintf (stderr, _("Too many N_RBRACs\n")); + return FALSE; + } + break; + + case N_SO: + /* This always ends a function. */ + if (info->within_function) + { + bfd_vma endval; + + endval = value; + if (*string != '\0' + && info->function_end != (bfd_vma) -1 + && info->function_end < endval) + endval = info->function_end; + if (! stab_emit_pending_vars (dhandle, info) + || ! debug_end_function (dhandle, endval)) + return FALSE; + info->within_function = FALSE; + info->function_end = (bfd_vma) -1; + } + + /* An empty string is emitted by gcc at the end of a compilation + unit. */ + if (*string == '\0') + return TRUE; + + /* Just accumulate strings until we see a non N_SO symbol. If + the string starts with a directory separator or some other + form of absolute path specification, we discard the previously + accumulated strings. */ + if (info->so_string == NULL) + info->so_string = xstrdup (string); + else + { + char *f; + + f = info->so_string; + + if (IS_ABSOLUTE_PATH (string)) + info->so_string = xstrdup (string); + else + info->so_string = concat (info->so_string, string, + (const char *) NULL); + free (f); + } + + info->so_value = value; + + break; + + case N_SOL: + /* Start an include file. */ + if (! debug_start_source (dhandle, string)) + return FALSE; + break; + + case N_BINCL: + /* Start an include file which may be replaced. */ + push_bincl (info, string, value); + if (! debug_start_source (dhandle, string)) + return FALSE; + break; + + case N_EINCL: + /* End an N_BINCL include. */ + if (! debug_start_source (dhandle, pop_bincl (info))) + return FALSE; + break; + + case N_EXCL: + /* This is a duplicate of a header file named by N_BINCL which + was eliminated by the linker. */ + if (! find_excl (info, string, value)) + return FALSE; + break; + + case N_SLINE: + if (! debug_record_line (dhandle, desc, + value + (info->within_function + ? info->function_start_offset : 0))) + return FALSE; + break; + + case N_BCOMM: + if (! debug_start_common_block (dhandle, string)) + return FALSE; + break; + + case N_ECOMM: + if (! debug_end_common_block (dhandle, string)) + return FALSE; + break; + + case N_FUN: + if (*string == '\0') + { + if (info->within_function) + { + /* This always marks the end of a function; we don't + need to worry about info->function_end. */ + if (info->sections) + value += info->function_start_offset; + if (! stab_emit_pending_vars (dhandle, info) + || ! debug_end_function (dhandle, value)) + return FALSE; + info->within_function = FALSE; + info->function_end = (bfd_vma) -1; + } + break; + } + + /* A const static symbol in the .text section will have an N_FUN + entry. We need to use these to mark the end of the function, + in case we are looking at gcc output before it was changed to + always emit an empty N_FUN. We can't call debug_end_function + here, because it might be a local static symbol. */ + if (info->within_function + && (info->function_end == (bfd_vma) -1 + || value < info->function_end)) + info->function_end = value; + + /* Fall through. */ + /* FIXME: gdb checks the string for N_STSYM, N_LCSYM or N_ROSYM + symbols, and if it does not start with :S, gdb relocates the + value to the start of the section. gcc always seems to use + :S, so we don't worry about this. */ + /* Fall through. */ + default: + { + const char *colon; + + colon = strchr (string, ':'); + if (colon != NULL + && (colon[1] == 'f' || colon[1] == 'F')) + { + if (info->within_function) + { + bfd_vma endval; + + endval = value; + if (info->function_end != (bfd_vma) -1 + && info->function_end < endval) + endval = info->function_end; + if (! stab_emit_pending_vars (dhandle, info) + || ! debug_end_function (dhandle, endval)) + return FALSE; + info->function_end = (bfd_vma) -1; + } + /* For stabs in sections, line numbers and block addresses + are offsets from the start of the function. */ + if (info->sections) + info->function_start_offset = value; + info->within_function = TRUE; + } + + if (! parse_stab_string (dhandle, info, type, desc, value, string)) + return FALSE; + } + break; + + case N_OPT: + if (string != NULL && strcmp (string, "gcc2_compiled.") == 0) + info->gcc_compiled = 2; + else if (string != NULL && strcmp (string, "gcc_compiled.") == 0) + info->gcc_compiled = 1; + else + info->n_opt_found = TRUE; + break; + + case N_OBJ: + case N_ENDM: + case N_MAIN: + case N_WARNING: + break; + } + + return TRUE; +} + +/* Parse the stabs string. */ + +static bfd_boolean +parse_stab_string (void *dhandle, struct stab_handle *info, int stabtype, + int desc ATTRIBUTE_UNUSED, bfd_vma value, const char *string) +{ + const char *p; + char *name; + int type; + debug_type dtype; + bfd_boolean synonym; + bfd_boolean self_crossref; + debug_type *slot; + + p = strchr (string, ':'); + if (p == NULL) + return TRUE; + + while (p[1] == ':') + { + p += 2; + p = strchr (p, ':'); + if (p == NULL) + { + bad_stab (string); + return FALSE; + } + } + + /* FIXME: Sometimes the special C++ names start with '.'. */ + name = NULL; + if (string[0] == '$') + { + switch (string[1]) + { + case 't': + name = "this"; + break; + case 'v': + /* Was: name = "vptr"; */ + break; + case 'e': + name = "eh_throw"; + break; + case '_': + /* This was an anonymous type that was never fixed up. */ + break; + case 'X': + /* SunPRO (3.0 at least) static variable encoding. */ + break; + default: + warn_stab (string, _("unknown C++ encoded name")); + break; + } + } + + if (name == NULL) + { + if (p == string || (string[0] == ' ' && p == string + 1)) + name = NULL; + else + name = savestring (string, p - string); + } + + ++p; + if (ISDIGIT (*p) || *p == '(' || *p == '-') + type = 'l'; + else + type = *p++; + + switch (type) + { + case 'c': + /* c is a special case, not followed by a type-number. + SYMBOL:c=iVALUE for an integer constant symbol. + SYMBOL:c=rVALUE for a floating constant symbol. + SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol. + e.g. "b:c=e6,0" for "const b = blob1" + (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */ + if (*p != '=') + { + bad_stab (string); + return FALSE; + } + ++p; + switch (*p++) + { + case 'r': + /* Floating point constant. */ + if (! debug_record_float_const (dhandle, name, atof (p))) + return FALSE; + break; + case 'i': + /* Integer constant. */ + /* Defining integer constants this way is kind of silly, + since 'e' constants allows the compiler to give not only + the value, but the type as well. C has at least int, + long, unsigned int, and long long as constant types; + other languages probably should have at least unsigned as + well as signed constants. */ + if (! debug_record_int_const (dhandle, name, atoi (p))) + return FALSE; + break; + case 'e': + /* SYMBOL:c=eTYPE,INTVALUE for a constant symbol whose value + can be represented as integral. + e.g. "b:c=e6,0" for "const b = blob1" + (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */ + dtype = parse_stab_type (dhandle, info, (const char *) NULL, + &p, (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (*p != ',') + { + bad_stab (string); + return FALSE; + } + if (! debug_record_typed_const (dhandle, name, dtype, atoi (p))) + return FALSE; + break; + default: + bad_stab (string); + return FALSE; + } + + break; + + case 'C': + /* The name of a caught exception. */ + dtype = parse_stab_type (dhandle, info, (const char *) NULL, + &p, (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (! debug_record_label (dhandle, name, dtype, value)) + return FALSE; + break; + + case 'f': + case 'F': + /* A function definition. */ + dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (! debug_record_function (dhandle, name, dtype, type == 'F', value)) + return FALSE; + + /* Sun acc puts declared types of arguments here. We don't care + about their actual types (FIXME -- we should remember the whole + function prototype), but the list may define some new types + that we have to remember, so we must scan it now. */ + while (*p == ';') + { + ++p; + if (parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL) + == DEBUG_TYPE_NULL) + return FALSE; + } + + break; + + case 'G': + { + asymbol **ps; + + /* A global symbol. The value must be extracted from the + symbol table. */ + dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (name != NULL) + { + char leading; + long c; + + leading = bfd_get_symbol_leading_char (info->abfd); + for (c = info->symcount, ps = info->syms; c > 0; --c, ++ps) + { + const char *n; + + n = bfd_asymbol_name (*ps); + if (leading != '\0' && *n == leading) + ++n; + if (*n == *name && strcmp (n, name) == 0) + break; + } + + if (c > 0) + value = bfd_asymbol_value (*ps); + } + + if (! stab_record_variable (dhandle, info, name, dtype, DEBUG_GLOBAL, + value)) + return FALSE; + } + break; + + /* This case is faked by a conditional above, when there is no + code letter in the dbx data. Dbx data never actually + contains 'l'. */ + case 'l': + case 's': + dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (! stab_record_variable (dhandle, info, name, dtype, DEBUG_LOCAL, + value)) + return FALSE; + break; + + case 'p': + /* A function parameter. */ + if (*p != 'F') + dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL); + else + { + /* pF is a two-letter code that means a function parameter in + Fortran. The type-number specifies the type of the return + value. Translate it into a pointer-to-function type. */ + ++p; + dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL); + if (dtype != DEBUG_TYPE_NULL) + { + debug_type ftype; + + ftype = debug_make_function_type (dhandle, dtype, + (debug_type *) NULL, FALSE); + dtype = debug_make_pointer_type (dhandle, ftype); + } + } + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (! debug_record_parameter (dhandle, name, dtype, DEBUG_PARM_STACK, + value)) + return FALSE; + + /* FIXME: At this point gdb considers rearranging the parameter + address on a big endian machine if it is smaller than an int. + We have no way to do that, since we don't really know much + about the target. */ + break; + + case 'P': + if (stabtype == N_FUN) + { + /* Prototype of a function referenced by this file. */ + while (*p == ';') + { + ++p; + if (parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL) + == DEBUG_TYPE_NULL) + return FALSE; + } + break; + } + /* Fall through. */ + case 'R': + /* Parameter which is in a register. */ + dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (! debug_record_parameter (dhandle, name, dtype, DEBUG_PARM_REG, + value)) + return FALSE; + break; + + case 'r': + /* Register variable (either global or local). */ + dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (! stab_record_variable (dhandle, info, name, dtype, DEBUG_REGISTER, + value)) + return FALSE; + + /* FIXME: At this point gdb checks to combine pairs of 'p' and + 'r' stabs into a single 'P' stab. */ + break; + + case 'S': + /* Static symbol at top level of file. */ + dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (! stab_record_variable (dhandle, info, name, dtype, DEBUG_STATIC, + value)) + return FALSE; + break; + + case 't': + /* A typedef. */ + dtype = parse_stab_type (dhandle, info, name, &p, &slot); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (name == NULL) + { + /* A nameless type. Nothing to do. */ + return TRUE; + } + + dtype = debug_name_type (dhandle, name, dtype); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + + if (slot != NULL) + *slot = dtype; + + break; + + case 'T': + /* Struct, union, or enum tag. For GNU C++, this can be followed + by 't' which means we are typedef'ing it as well. */ + if (*p != 't') + { + synonym = FALSE; + /* FIXME: gdb sets synonym to TRUE if the current language + is C++. */ + } + else + { + synonym = TRUE; + ++p; + } + + dtype = parse_stab_type (dhandle, info, name, &p, &slot); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (name == NULL) + return TRUE; + + /* INFO->SELF_CROSSREF is set by parse_stab_type if this type is + a cross reference to itself. These are generated by some + versions of g++. */ + self_crossref = info->self_crossref; + + dtype = debug_tag_type (dhandle, name, dtype); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (slot != NULL) + *slot = dtype; + + /* See if we have a cross reference to this tag which we can now + fill in. Avoid filling in a cross reference to ourselves, + because that would lead to circular debugging information. */ + if (! self_crossref) + { + register struct stab_tag **pst; + + for (pst = &info->tags; *pst != NULL; pst = &(*pst)->next) + { + if ((*pst)->name[0] == name[0] + && strcmp ((*pst)->name, name) == 0) + { + (*pst)->slot = dtype; + *pst = (*pst)->next; + break; + } + } + } + + if (synonym) + { + dtype = debug_name_type (dhandle, name, dtype); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + + if (slot != NULL) + *slot = dtype; + } + + break; + + case 'V': + /* Static symbol of local scope */ + dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + /* FIXME: gdb checks os9k_stabs here. */ + if (! stab_record_variable (dhandle, info, name, dtype, + DEBUG_LOCAL_STATIC, value)) + return FALSE; + break; + + case 'v': + /* Reference parameter. */ + dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (! debug_record_parameter (dhandle, name, dtype, DEBUG_PARM_REFERENCE, + value)) + return FALSE; + break; + + case 'a': + /* Reference parameter which is in a register. */ + dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (! debug_record_parameter (dhandle, name, dtype, DEBUG_PARM_REF_REG, + value)) + return FALSE; + break; + + case 'X': + /* This is used by Sun FORTRAN for "function result value". + Sun claims ("dbx and dbxtool interfaces", 2nd ed) + that Pascal uses it too, but when I tried it Pascal used + "x:3" (local symbol) instead. */ + dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p, + (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; + if (! stab_record_variable (dhandle, info, name, dtype, DEBUG_LOCAL, + value)) + return FALSE; + break; + + case 'Y': + /* SUNPro C++ Namespace =Yn0. */ + /* Skip the namespace mapping, as it is not used now. */ + if (*(++p) == 'n' && *(++p) == '0') + { + /* =Yn0name; */ + while (*p != ';') + ++p; + ++p; + return TRUE; + } + /* TODO SUNPro C++ support: + Support default arguments after F,P parameters + Ya = Anonymous unions + YM,YD = Pointers to class members + YT,YI = Templates + YR = Run-time type information (RTTI) */ + + /* Fall through. */ + + default: + bad_stab (string); + return FALSE; + } + + /* FIXME: gdb converts structure values to structure pointers in a + couple of cases, depending upon the target. */ + + return TRUE; +} + +/* Parse a stabs type. The typename argument is non-NULL if this is a + typedef or a tag definition. The pp argument points to the stab + string, and is updated. The slotp argument points to a place to + store the slot used if the type is being defined. */ + +static debug_type +parse_stab_type (void *dhandle, struct stab_handle *info, const char *type_name, const char **pp, debug_type **slotp) +{ + const char *orig; + int typenums[2]; + int size; + bfd_boolean stringp; + int descriptor; + debug_type dtype; + + if (slotp != NULL) + *slotp = NULL; + + orig = *pp; + + size = -1; + stringp = FALSE; + + info->self_crossref = FALSE; + + /* Read type number if present. The type number may be omitted. + for instance in a two-dimensional array declared with type + "ar1;1;10;ar1;1;10;4". */ + if (! ISDIGIT (**pp) && **pp != '(' && **pp != '-') + { + /* 'typenums=' not present, type is anonymous. Read and return + the definition, but don't put it in the type vector. */ + typenums[0] = typenums[1] = -1; + } + else + { + if (! parse_stab_type_number (pp, typenums)) + return DEBUG_TYPE_NULL; + + if (**pp != '=') + /* Type is not being defined here. Either it already + exists, or this is a forward reference to it. */ + return stab_find_type (dhandle, info, typenums); + + /* Only set the slot if the type is being defined. This means + that the mapping from type numbers to types will only record + the name of the typedef which defines a type. If we don't do + this, then something like + typedef int foo; + int i; + will record that i is of type foo. Unfortunately, stabs + information is ambiguous about variable types. For this code, + typedef int foo; + int i; + foo j; + the stabs information records both i and j as having the same + type. This could be fixed by patching the compiler. */ + if (slotp != NULL && typenums[0] >= 0 && typenums[1] >= 0) + *slotp = stab_find_slot (info, typenums); + + /* Type is being defined here. */ + /* Skip the '='. */ + ++*pp; + + while (**pp == '@') + { + const char *p = *pp + 1; + const char *attr; + + if (ISDIGIT (*p) || *p == '(' || *p == '-') + /* Member type. */ + break; + + /* Type attributes. */ + attr = p; + + for (; *p != ';'; ++p) + { + if (*p == '\0') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + } + *pp = p + 1; + + switch (*attr) + { + case 's': + size = atoi (attr + 1); + size /= 8; /* Size is in bits. We store it in bytes. */ + if (size <= 0) + size = -1; + break; + + case 'S': + stringp = TRUE; + break; + + default: + /* Ignore unrecognized type attributes, so future + compilers can invent new ones. */ + break; + } + } + } + + descriptor = **pp; + ++*pp; + + switch (descriptor) + { + case 'x': + { + enum debug_type_kind code; + const char *q1, *q2, *p; + + /* A cross reference to another type. */ + switch (**pp) + { + case 's': + code = DEBUG_KIND_STRUCT; + break; + case 'u': + code = DEBUG_KIND_UNION; + break; + case 'e': + code = DEBUG_KIND_ENUM; + break; + default: + /* Complain and keep going, so compilers can invent new + cross-reference types. */ + warn_stab (orig, _("unrecognized cross reference type")); + code = DEBUG_KIND_STRUCT; + break; + } + ++*pp; + + q1 = strchr (*pp, '<'); + p = strchr (*pp, ':'); + if (p == NULL) + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + if (q1 != NULL && p > q1 && p[1] == ':') + { + int nest = 0; + + for (q2 = q1; *q2 != '\0'; ++q2) + { + if (*q2 == '<') + ++nest; + else if (*q2 == '>') + --nest; + else if (*q2 == ':' && nest == 0) + break; + } + p = q2; + if (*p != ':') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + } + + /* Some versions of g++ can emit stabs like + fleep:T20=xsfleep: + which define structures in terms of themselves. We need to + tell the caller to avoid building a circular structure. */ + if (type_name != NULL + && strncmp (type_name, *pp, p - *pp) == 0 + && type_name[p - *pp] == '\0') + info->self_crossref = TRUE; + + dtype = stab_find_tagged_type (dhandle, info, *pp, p - *pp, code); + + *pp = p + 1; + } + break; + + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '(': + { + const char *hold; + int xtypenums[2]; + + /* This type is defined as another type. */ + (*pp)--; + hold = *pp; + + /* Peek ahead at the number to detect void. */ + if (! parse_stab_type_number (pp, xtypenums)) + return DEBUG_TYPE_NULL; + + if (typenums[0] == xtypenums[0] && typenums[1] == xtypenums[1]) + { + /* This type is being defined as itself, which means that + it is void. */ + dtype = debug_make_void_type (dhandle); + } + else + { + *pp = hold; + + /* Go back to the number and have parse_stab_type get it. + This means that we can deal with something like + t(1,2)=(3,4)=... which the Lucid compiler uses. */ + dtype = parse_stab_type (dhandle, info, (const char *) NULL, + pp, (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return DEBUG_TYPE_NULL; + } + + if (typenums[0] != -1) + { + if (! stab_record_type (dhandle, info, typenums, dtype)) + return DEBUG_TYPE_NULL; + } + + break; + } + + case '*': + dtype = debug_make_pointer_type (dhandle, + parse_stab_type (dhandle, info, + (const char *) NULL, + pp, + (debug_type **) NULL)); + break; + + case '&': + /* Reference to another type. */ + dtype = (debug_make_reference_type + (dhandle, + parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL))); + break; + + case 'f': + /* Function returning another type. */ + /* FIXME: gdb checks os9k_stabs here. */ + dtype = (debug_make_function_type + (dhandle, + parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL), + (debug_type *) NULL, FALSE)); + break; + + case 'k': + /* Const qualifier on some type (Sun). */ + /* FIXME: gdb accepts 'c' here if os9k_stabs. */ + dtype = debug_make_const_type (dhandle, + parse_stab_type (dhandle, info, + (const char *) NULL, + pp, + (debug_type **) NULL)); + break; + + case 'B': + /* Volatile qual on some type (Sun). */ + /* FIXME: gdb accepts 'i' here if os9k_stabs. */ + dtype = (debug_make_volatile_type + (dhandle, + parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL))); + break; + + case '@': + /* Offset (class & variable) type. This is used for a pointer + relative to an object. */ + { + debug_type domain; + debug_type memtype; + + /* Member type. */ + + domain = parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL); + if (domain == DEBUG_TYPE_NULL) + return DEBUG_TYPE_NULL; + + if (**pp != ',') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + + memtype = parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL); + if (memtype == DEBUG_TYPE_NULL) + return DEBUG_TYPE_NULL; + + dtype = debug_make_offset_type (dhandle, domain, memtype); + } + break; + + case '#': + /* Method (class & fn) type. */ + if (**pp == '#') + { + debug_type return_type; + + ++*pp; + return_type = parse_stab_type (dhandle, info, (const char *) NULL, + pp, (debug_type **) NULL); + if (return_type == DEBUG_TYPE_NULL) + return DEBUG_TYPE_NULL; + if (**pp != ';') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + dtype = debug_make_method_type (dhandle, return_type, + DEBUG_TYPE_NULL, + (debug_type *) NULL, FALSE); + } + else + { + debug_type domain; + debug_type return_type; + debug_type *args; + unsigned int n; + unsigned int alloc; + bfd_boolean varargs; + + domain = parse_stab_type (dhandle, info, (const char *) NULL, + pp, (debug_type **) NULL); + if (domain == DEBUG_TYPE_NULL) + return DEBUG_TYPE_NULL; + + if (**pp != ',') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + + return_type = parse_stab_type (dhandle, info, (const char *) NULL, + pp, (debug_type **) NULL); + if (return_type == DEBUG_TYPE_NULL) + return DEBUG_TYPE_NULL; + + alloc = 10; + args = (debug_type *) xmalloc (alloc * sizeof *args); + n = 0; + while (**pp != ';') + { + if (**pp != ',') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + + if (n + 1 >= alloc) + { + alloc += 10; + args = ((debug_type *) + xrealloc (args, alloc * sizeof *args)); + } + + args[n] = parse_stab_type (dhandle, info, (const char *) NULL, + pp, (debug_type **) NULL); + if (args[n] == DEBUG_TYPE_NULL) + return DEBUG_TYPE_NULL; + ++n; + } + ++*pp; + + /* If the last type is not void, then this function takes a + variable number of arguments. Otherwise, we must strip + the void type. */ + if (n == 0 + || debug_get_type_kind (dhandle, args[n - 1]) != DEBUG_KIND_VOID) + varargs = TRUE; + else + { + --n; + varargs = FALSE; + } + + args[n] = DEBUG_TYPE_NULL; + + dtype = debug_make_method_type (dhandle, return_type, domain, args, + varargs); + } + break; + + case 'r': + /* Range type. */ + dtype = parse_stab_range_type (dhandle, info, type_name, pp, typenums); + break; + + case 'b': + /* FIXME: gdb checks os9k_stabs here. */ + /* Sun ACC builtin int type. */ + dtype = parse_stab_sun_builtin_type (dhandle, pp); + break; + + case 'R': + /* Sun ACC builtin float type. */ + dtype = parse_stab_sun_floating_type (dhandle, pp); + break; + + case 'e': + /* Enumeration type. */ + dtype = parse_stab_enum_type (dhandle, pp); + break; + + case 's': + case 'u': + /* Struct or union type. */ + dtype = parse_stab_struct_type (dhandle, info, type_name, pp, + descriptor == 's', typenums); + break; + + case 'a': + /* Array type. */ + if (**pp != 'r') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + + dtype = parse_stab_array_type (dhandle, info, pp, stringp); + break; + + case 'S': + dtype = debug_make_set_type (dhandle, + parse_stab_type (dhandle, info, + (const char *) NULL, + pp, + (debug_type **) NULL), + stringp); + break; + + default: + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + + if (dtype == DEBUG_TYPE_NULL) + return DEBUG_TYPE_NULL; + + if (typenums[0] != -1) + { + if (! stab_record_type (dhandle, info, typenums, dtype)) + return DEBUG_TYPE_NULL; + } + + if (size != -1) + { + if (! debug_record_type_size (dhandle, dtype, (unsigned int) size)) + return DEBUG_TYPE_NULL; + } + + return dtype; +} + +/* Read a number by which a type is referred to in dbx data, or + perhaps read a pair (FILENUM, TYPENUM) in parentheses. Just a + single number N is equivalent to (0,N). Return the two numbers by + storing them in the vector TYPENUMS. */ + +static bfd_boolean +parse_stab_type_number (const char **pp, int *typenums) +{ + const char *orig; + + orig = *pp; + + if (**pp != '(') + { + typenums[0] = 0; + typenums[1] = (int) parse_number (pp, (bfd_boolean *) NULL); + } + else + { + ++*pp; + typenums[0] = (int) parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ',') + { + bad_stab (orig); + return FALSE; + } + ++*pp; + typenums[1] = (int) parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ')') + { + bad_stab (orig); + return FALSE; + } + ++*pp; + } + + return TRUE; +} + +/* Parse a range type. */ + +static debug_type +parse_stab_range_type (void *dhandle, struct stab_handle *info, const char *type_name, const char **pp, const int *typenums) +{ + const char *orig; + int rangenums[2]; + bfd_boolean self_subrange; + debug_type index_type; + const char *s2, *s3; + bfd_signed_vma n2, n3; + bfd_boolean ov2, ov3; + + orig = *pp; + + index_type = DEBUG_TYPE_NULL; + + /* First comes a type we are a subrange of. + In C it is usually 0, 1 or the type being defined. */ + if (! parse_stab_type_number (pp, rangenums)) + return DEBUG_TYPE_NULL; + + self_subrange = (rangenums[0] == typenums[0] + && rangenums[1] == typenums[1]); + + if (**pp == '=') + { + *pp = orig; + index_type = parse_stab_type (dhandle, info, (const char *) NULL, + pp, (debug_type **) NULL); + if (index_type == DEBUG_TYPE_NULL) + return DEBUG_TYPE_NULL; + } + + if (**pp == ';') + ++*pp; + + /* The remaining two operands are usually lower and upper bounds of + the range. But in some special cases they mean something else. */ + s2 = *pp; + n2 = parse_number (pp, &ov2); + if (**pp != ';') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + + s3 = *pp; + n3 = parse_number (pp, &ov3); + if (**pp != ';') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + + if (ov2 || ov3) + { + /* gcc will emit range stabs for long long types. Handle this + as a special case. FIXME: This needs to be more general. */ +#define LLLOW "01000000000000000000000;" +#define LLHIGH "0777777777777777777777;" +#define ULLHIGH "01777777777777777777777;" + if (index_type == DEBUG_TYPE_NULL) + { + if (CONST_STRNEQ (s2, LLLOW) + && CONST_STRNEQ (s3, LLHIGH)) + return debug_make_int_type (dhandle, 8, FALSE); + if (! ov2 + && n2 == 0 + && CONST_STRNEQ (s3, ULLHIGH)) + return debug_make_int_type (dhandle, 8, TRUE); + } + + warn_stab (orig, _("numeric overflow")); + } + + if (index_type == DEBUG_TYPE_NULL) + { + /* A type defined as a subrange of itself, with both bounds 0, + is void. */ + if (self_subrange && n2 == 0 && n3 == 0) + return debug_make_void_type (dhandle); + + /* A type defined as a subrange of itself, with n2 positive and + n3 zero, is a complex type, and n2 is the number of bytes. */ + if (self_subrange && n3 == 0 && n2 > 0) + return debug_make_complex_type (dhandle, n2); + + /* If n3 is zero and n2 is positive, this is a floating point + type, and n2 is the number of bytes. */ + if (n3 == 0 && n2 > 0) + return debug_make_float_type (dhandle, n2); + + /* If the upper bound is -1, this is an unsigned int. */ + if (n2 == 0 && n3 == -1) + { + /* When gcc is used with -gstabs, but not -gstabs+, it will emit + long long int:t6=r1;0;-1; + long long unsigned int:t7=r1;0;-1; + We hack here to handle this reasonably. */ + if (type_name != NULL) + { + if (strcmp (type_name, "long long int") == 0) + return debug_make_int_type (dhandle, 8, FALSE); + else if (strcmp (type_name, "long long unsigned int") == 0) + return debug_make_int_type (dhandle, 8, TRUE); + } + /* FIXME: The size here really depends upon the target. */ + return debug_make_int_type (dhandle, 4, TRUE); + } + + /* A range of 0 to 127 is char. */ + if (self_subrange && n2 == 0 && n3 == 127) + return debug_make_int_type (dhandle, 1, FALSE); + + /* FIXME: gdb checks for the language CHILL here. */ + + if (n2 == 0) + { + if (n3 < 0) + return debug_make_int_type (dhandle, - n3, TRUE); + else if (n3 == 0xff) + return debug_make_int_type (dhandle, 1, TRUE); + else if (n3 == 0xffff) + return debug_make_int_type (dhandle, 2, TRUE); + else if (n3 == (bfd_signed_vma) 0xffffffff) + return debug_make_int_type (dhandle, 4, TRUE); +#ifdef BFD64 + else if (n3 == (bfd_signed_vma) 0xffffffffffffffffLL) + return debug_make_int_type (dhandle, 8, TRUE); +#endif + } + else if (n3 == 0 + && n2 < 0 + && (self_subrange || n2 == -8)) + return debug_make_int_type (dhandle, - n2, TRUE); + else if (n2 == - n3 - 1 || n2 == n3 + 1) + { + if (n3 == 0x7f) + return debug_make_int_type (dhandle, 1, FALSE); + else if (n3 == 0x7fff) + return debug_make_int_type (dhandle, 2, FALSE); + else if (n3 == 0x7fffffff) + return debug_make_int_type (dhandle, 4, FALSE); +#ifdef BFD64 + else if (n3 == ((((bfd_vma) 0x7fffffff) << 32) | 0xffffffff)) + return debug_make_int_type (dhandle, 8, FALSE); +#endif + } + } + + /* At this point I don't have the faintest idea how to deal with a + self_subrange type; I'm going to assume that this is used as an + idiom, and that all of them are special cases. So . . . */ + if (self_subrange) + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + + index_type = stab_find_type (dhandle, info, rangenums); + if (index_type == DEBUG_TYPE_NULL) + { + /* Does this actually ever happen? Is that why we are worrying + about dealing with it rather than just calling error_type? */ + warn_stab (orig, _("missing index type")); + index_type = debug_make_int_type (dhandle, 4, FALSE); + } + + return debug_make_range_type (dhandle, index_type, n2, n3); +} + +/* Sun's ACC uses a somewhat saner method for specifying the builtin + typedefs in every file (for int, long, etc): + + type = b ; ; + signed = u or s. Possible c in addition to u or s (for char?). + offset = offset from high order bit to start bit of type. + width is # bytes in object of this type, nbits is # bits in type. + + The width/offset stuff appears to be for small objects stored in + larger ones (e.g. `shorts' in `int' registers). We ignore it for now, + FIXME. */ + +static debug_type +parse_stab_sun_builtin_type (void *dhandle, const char **pp) +{ + const char *orig; + bfd_boolean unsignedp; + bfd_vma bits; + + orig = *pp; + + switch (**pp) + { + case 's': + unsignedp = FALSE; + break; + case 'u': + unsignedp = TRUE; + break; + default: + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + + /* OpenSolaris source code indicates that one of "cbv" characters + can come next and specify the intrinsic 'iformat' encoding. + 'c' is character encoding, 'b' is boolean encoding, and 'v' is + varargs encoding. This field can be safely ignored because + the type of the field is determined from the bitwidth extracted + below. */ + if (**pp == 'c' || **pp == 'b' || **pp == 'v') + ++*pp; + + /* The first number appears to be the number of bytes occupied + by this type, except that unsigned short is 4 instead of 2. + Since this information is redundant with the third number, + we will ignore it. */ + (void) parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ';') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + + /* The second number is always 0, so ignore it too. */ + (void) parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ';') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + + /* The third number is the number of bits for this type. */ + bits = parse_number (pp, (bfd_boolean *) NULL); + + /* The type *should* end with a semicolon. If it are embedded + in a larger type the semicolon may be the only way to know where + the type ends. If this type is at the end of the stabstring we + can deal with the omitted semicolon (but we don't have to like + it). Don't bother to complain(), Sun's compiler omits the semicolon + for "void". */ + if (**pp == ';') + ++*pp; + + if (bits == 0) + return debug_make_void_type (dhandle); + + return debug_make_int_type (dhandle, bits / 8, unsignedp); +} + +/* Parse a builtin floating type generated by the Sun compiler. */ + +static debug_type +parse_stab_sun_floating_type (void *dhandle, const char **pp) +{ + const char *orig; + bfd_vma details; + bfd_vma bytes; + + orig = *pp; + + /* The first number has more details about the type, for example + FN_COMPLEX. */ + details = parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ';') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + + /* The second number is the number of bytes occupied by this type */ + bytes = parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ';') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + + if (details == NF_COMPLEX + || details == NF_COMPLEX16 + || details == NF_COMPLEX32) + return debug_make_complex_type (dhandle, bytes); + + return debug_make_float_type (dhandle, bytes); +} + +/* Handle an enum type. */ + +static debug_type +parse_stab_enum_type (void *dhandle, const char **pp) +{ + const char *orig; + const char **names; + bfd_signed_vma *values; + unsigned int n; + unsigned int alloc; + + orig = *pp; + + /* FIXME: gdb checks os9k_stabs here. */ + + /* The aix4 compiler emits an extra field before the enum members; + my guess is it's a type of some sort. Just ignore it. */ + if (**pp == '-') + { + while (**pp != ':') + ++*pp; + ++*pp; + } + + /* Read the value-names and their values. + The input syntax is NAME:VALUE,NAME:VALUE, and so on. + A semicolon or comma instead of a NAME means the end. */ + alloc = 10; + names = (const char **) xmalloc (alloc * sizeof *names); + values = (bfd_signed_vma *) xmalloc (alloc * sizeof *values); + n = 0; + while (**pp != '\0' && **pp != ';' && **pp != ',') + { + const char *p; + char *name; + bfd_signed_vma val; + + p = *pp; + while (*p != ':' && *p != 0) + ++p; + + if (*p == 0) + { + bad_stab (orig); + free (names); + free (values); + return DEBUG_TYPE_NULL; + } + + name = savestring (*pp, p - *pp); + + *pp = p + 1; + val = (bfd_signed_vma) parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ',') + { + bad_stab (orig); + free (name); + free (names); + free (values); + return DEBUG_TYPE_NULL; + } + ++*pp; + + if (n + 1 >= alloc) + { + alloc += 10; + names = ((const char **) + xrealloc (names, alloc * sizeof *names)); + values = ((bfd_signed_vma *) + xrealloc (values, alloc * sizeof *values)); + } + + names[n] = name; + values[n] = val; + ++n; + } + + names[n] = NULL; + values[n] = 0; + + if (**pp == ';') + ++*pp; + + return debug_make_enum_type (dhandle, names, values); +} + +/* Read the description of a structure (or union type) and return an object + describing the type. + + PP points to a character pointer that points to the next unconsumed token + in the stabs string. For example, given stabs "A:T4=s4a:1,0,32;;", + *PP will point to "4a:1,0,32;;". */ + +static debug_type +parse_stab_struct_type (void *dhandle, struct stab_handle *info, + const char *tagname, const char **pp, + bfd_boolean structp, const int *typenums) +{ + bfd_vma size; + debug_baseclass *baseclasses; + debug_field *fields = NULL; + bfd_boolean statics; + debug_method *methods; + debug_type vptrbase; + bfd_boolean ownvptr; + + /* Get the size. */ + size = parse_number (pp, (bfd_boolean *) NULL); + + /* Get the other information. */ + if (! parse_stab_baseclasses (dhandle, info, pp, &baseclasses) + || ! parse_stab_struct_fields (dhandle, info, pp, &fields, &statics) + || ! parse_stab_members (dhandle, info, tagname, pp, typenums, &methods) + || ! parse_stab_tilde_field (dhandle, info, pp, typenums, &vptrbase, + &ownvptr)) + { + if (fields != NULL) + free (fields); + return DEBUG_TYPE_NULL; + } + + if (! statics + && baseclasses == NULL + && methods == NULL + && vptrbase == DEBUG_TYPE_NULL + && ! ownvptr) + return debug_make_struct_type (dhandle, structp, size, fields); + + return debug_make_object_type (dhandle, structp, size, fields, baseclasses, + methods, vptrbase, ownvptr); +} + +/* The stabs for C++ derived classes contain baseclass information which + is marked by a '!' character after the total size. This function is + called when we encounter the baseclass marker, and slurps up all the + baseclass information. + + Immediately following the '!' marker is the number of base classes that + the class is derived from, followed by information for each base class. + For each base class, there are two visibility specifiers, a bit offset + to the base class information within the derived class, a reference to + the type for the base class, and a terminating semicolon. + + A typical example, with two base classes, would be "!2,020,19;0264,21;". + ^^ ^ ^ ^ ^ ^ ^ + Baseclass information marker __________________|| | | | | | | + Number of baseclasses __________________________| | | | | | | + Visibility specifiers (2) ________________________| | | | | | + Offset in bits from start of class _________________| | | | | + Type number for base class ___________________________| | | | + Visibility specifiers (2) _______________________________| | | + Offset in bits from start of class ________________________| | + Type number of base class ____________________________________| + + Return TRUE for success, FALSE for failure. */ + +static bfd_boolean +parse_stab_baseclasses (void *dhandle, struct stab_handle *info, + const char **pp, debug_baseclass **retp) +{ + const char *orig; + unsigned int c, i; + debug_baseclass *classes; + + *retp = NULL; + + orig = *pp; + + if (**pp != '!') + { + /* No base classes. */ + return TRUE; + } + ++*pp; + + c = (unsigned int) parse_number (pp, (bfd_boolean *) NULL); + + if (**pp != ',') + { + bad_stab (orig); + return FALSE; + } + ++*pp; + + classes = (debug_baseclass *) xmalloc ((c + 1) * sizeof (**retp)); + + for (i = 0; i < c; i++) + { + bfd_boolean is_virtual; + enum debug_visibility visibility; + bfd_vma bitpos; + debug_type type; + + switch (**pp) + { + case '0': + is_virtual = FALSE; + break; + case '1': + is_virtual = TRUE; + break; + default: + warn_stab (orig, _("unknown virtual character for baseclass")); + is_virtual = FALSE; + break; + } + ++*pp; + + switch (**pp) + { + case '0': + visibility = DEBUG_VISIBILITY_PRIVATE; + break; + case '1': + visibility = DEBUG_VISIBILITY_PROTECTED; + break; + case '2': + visibility = DEBUG_VISIBILITY_PUBLIC; + break; + default: + warn_stab (orig, _("unknown visibility character for baseclass")); + visibility = DEBUG_VISIBILITY_PUBLIC; + break; + } + ++*pp; + + /* The remaining value is the bit offset of the portion of the + object corresponding to this baseclass. Always zero in the + absence of multiple inheritance. */ + bitpos = parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ',') + { + bad_stab (orig); + return FALSE; + } + ++*pp; + + type = parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL); + if (type == DEBUG_TYPE_NULL) + return FALSE; + + classes[i] = debug_make_baseclass (dhandle, type, bitpos, is_virtual, + visibility); + if (classes[i] == DEBUG_BASECLASS_NULL) + return FALSE; + + if (**pp != ';') + return FALSE; + ++*pp; + } + + classes[i] = DEBUG_BASECLASS_NULL; + + *retp = classes; + + return TRUE; +} + +/* Read struct or class data fields. They have the form: + + NAME : [VISIBILITY] TYPENUM , BITPOS , BITSIZE ; + + At the end, we see a semicolon instead of a field. + + In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for + a static field. + + The optional VISIBILITY is one of: + + '/0' (VISIBILITY_PRIVATE) + '/1' (VISIBILITY_PROTECTED) + '/2' (VISIBILITY_PUBLIC) + '/9' (VISIBILITY_IGNORE) + + or nothing, for C style fields with public visibility. + + Returns 1 for success, 0 for failure. */ + +static bfd_boolean +parse_stab_struct_fields (void *dhandle, struct stab_handle *info, + const char **pp, debug_field **retp, + bfd_boolean *staticsp) +{ + const char *orig; + const char *p; + debug_field *fields; + unsigned int c; + unsigned int alloc; + + *retp = NULL; + *staticsp = FALSE; + + orig = *pp; + + c = 0; + alloc = 10; + fields = (debug_field *) xmalloc (alloc * sizeof *fields); + while (**pp != ';') + { + /* FIXME: gdb checks os9k_stabs here. */ + + p = *pp; + + /* Add 1 to c to leave room for NULL pointer at end. */ + if (c + 1 >= alloc) + { + alloc += 10; + fields = ((debug_field *) + xrealloc (fields, alloc * sizeof *fields)); + } + + /* If it starts with CPLUS_MARKER it is a special abbreviation, + unless the CPLUS_MARKER is followed by an underscore, in + which case it is just the name of an anonymous type, which we + should handle like any other type name. We accept either '$' + or '.', because a field name can never contain one of these + characters except as a CPLUS_MARKER. */ + + if ((*p == '$' || *p == '.') && p[1] != '_') + { + ++*pp; + if (! parse_stab_cpp_abbrev (dhandle, info, pp, fields + c)) + { + free (fields); + return FALSE; + } + ++c; + continue; + } + + /* Look for the ':' that separates the field name from the field + values. Data members are delimited by a single ':', while member + functions are delimited by a pair of ':'s. When we hit the member + functions (if any), terminate scan loop and return. */ + + p = strchr (p, ':'); + if (p == NULL) + { + bad_stab (orig); + free (fields); + return FALSE; + } + + if (p[1] == ':') + break; + + if (! parse_stab_one_struct_field (dhandle, info, pp, p, fields + c, + staticsp)) + return FALSE; + + ++c; + } + + fields[c] = DEBUG_FIELD_NULL; + + *retp = fields; + + return TRUE; +} + +/* Special GNU C++ name. */ + +static bfd_boolean +parse_stab_cpp_abbrev (void *dhandle, struct stab_handle *info, + const char **pp, debug_field *retp) +{ + const char *orig; + int cpp_abbrev; + debug_type context; + const char *name; + const char *type_name; + debug_type type; + bfd_vma bitpos; + + *retp = DEBUG_FIELD_NULL; + + orig = *pp; + + if (**pp != 'v') + { + bad_stab (*pp); + return FALSE; + } + ++*pp; + + cpp_abbrev = **pp; + ++*pp; + + /* At this point, *pp points to something like "22:23=*22...", where + the type number before the ':' is the "context" and everything + after is a regular type definition. Lookup the type, find it's + name, and construct the field name. */ + + context = parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL); + if (context == DEBUG_TYPE_NULL) + return FALSE; + + switch (cpp_abbrev) + { + case 'f': + /* $vf -- a virtual function table pointer. */ + name = "_vptr$"; + break; + case 'b': + /* $vb -- a virtual bsomethingorother */ + type_name = debug_get_type_name (dhandle, context); + if (type_name == NULL) + { + warn_stab (orig, _("unnamed $vb type")); + type_name = "FOO"; + } + name = concat ("_vb$", type_name, (const char *) NULL); + break; + default: + warn_stab (orig, _("unrecognized C++ abbreviation")); + name = "INVALID_CPLUSPLUS_ABBREV"; + break; + } + + if (**pp != ':') + { + bad_stab (orig); + return FALSE; + } + ++*pp; + + type = parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL); + if (**pp != ',') + { + bad_stab (orig); + return FALSE; + } + ++*pp; + + bitpos = parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ';') + { + bad_stab (orig); + return FALSE; + } + ++*pp; + + *retp = debug_make_field (dhandle, name, type, bitpos, 0, + DEBUG_VISIBILITY_PRIVATE); + if (*retp == DEBUG_FIELD_NULL) + return FALSE; + + return TRUE; +} + +/* Parse a single field in a struct or union. */ + +static bfd_boolean +parse_stab_one_struct_field (void *dhandle, struct stab_handle *info, + const char **pp, const char *p, + debug_field *retp, bfd_boolean *staticsp) +{ + const char *orig; + char *name; + enum debug_visibility visibility; + debug_type type; + bfd_vma bitpos; + bfd_vma bitsize; + + orig = *pp; + + /* FIXME: gdb checks ARM_DEMANGLING here. */ + + name = savestring (*pp, p - *pp); + + *pp = p + 1; + + if (**pp != '/') + visibility = DEBUG_VISIBILITY_PUBLIC; + else + { + ++*pp; + switch (**pp) + { + case '0': + visibility = DEBUG_VISIBILITY_PRIVATE; + break; + case '1': + visibility = DEBUG_VISIBILITY_PROTECTED; + break; + case '2': + visibility = DEBUG_VISIBILITY_PUBLIC; + break; + default: + warn_stab (orig, _("unknown visibility character for field")); + visibility = DEBUG_VISIBILITY_PUBLIC; + break; + } + ++*pp; + } + + type = parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL); + if (type == DEBUG_TYPE_NULL) + { + free (name); + return FALSE; + } + + if (**pp == ':') + { + char *varname; + + /* This is a static class member. */ + ++*pp; + p = strchr (*pp, ';'); + if (p == NULL) + { + bad_stab (orig); + free (name); + return FALSE; + } + + varname = savestring (*pp, p - *pp); + + *pp = p + 1; + + *retp = debug_make_static_member (dhandle, name, type, varname, + visibility); + *staticsp = TRUE; + + return TRUE; + } + + if (**pp != ',') + { + bad_stab (orig); + free (name); + return FALSE; + } + ++*pp; + + bitpos = parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ',') + { + bad_stab (orig); + free (name); + return FALSE; + } + ++*pp; + + bitsize = parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ';') + { + bad_stab (orig); + free (name); + return FALSE; + } + ++*pp; + + if (bitpos == 0 && bitsize == 0) + { + /* This can happen in two cases: (1) at least for gcc 2.4.5 or + so, it is a field which has been optimized out. The correct + stab for this case is to use VISIBILITY_IGNORE, but that is a + recent invention. (2) It is a 0-size array. For example + union { int num; char str[0]; } foo. Printing "" + for str in "p foo" is OK, since foo.str (and thus foo.str[3]) + will continue to work, and a 0-size array as a whole doesn't + have any contents to print. + + I suspect this probably could also happen with gcc -gstabs + (not -gstabs+) for static fields, and perhaps other C++ + extensions. Hopefully few people use -gstabs with gdb, since + it is intended for dbx compatibility. */ + visibility = DEBUG_VISIBILITY_IGNORE; + } + + /* FIXME: gdb does some stuff here to mark fields as unpacked. */ + + *retp = debug_make_field (dhandle, name, type, bitpos, bitsize, visibility); + + return TRUE; +} + +/* Read member function stabs info for C++ classes. The form of each member + function data is: + + NAME :: TYPENUM[=type definition] ARGS : PHYSNAME ; + + An example with two member functions is: + + afunc1::20=##15;:i;2A.;afunc2::20:i;2A.; + + For the case of overloaded operators, the format is op$::*.funcs, where + $ is the CPLUS_MARKER (usually '$'), `*' holds the place for an operator + name (such as `+=') and `.' marks the end of the operator name. */ + +static bfd_boolean +parse_stab_members (void *dhandle, struct stab_handle *info, + const char *tagname, const char **pp, + const int *typenums, debug_method **retp) +{ + const char *orig; + debug_method *methods; + unsigned int c; + unsigned int alloc; + char *name = NULL; + debug_method_variant *variants = NULL; + char *argtypes = NULL; + + *retp = NULL; + + orig = *pp; + + alloc = 0; + methods = NULL; + c = 0; + + while (**pp != ';') + { + const char *p; + unsigned int cvars; + unsigned int allocvars; + debug_type look_ahead_type; + + p = strchr (*pp, ':'); + if (p == NULL || p[1] != ':') + break; + + /* FIXME: Some systems use something other than '$' here. */ + if ((*pp)[0] != 'o' || (*pp)[1] != 'p' || (*pp)[2] != '$') + { + name = savestring (*pp, p - *pp); + *pp = p + 2; + } + else + { + /* This is a completely weird case. In order to stuff in the + names that might contain colons (the usual name delimiter), + Mike Tiemann defined a different name format which is + signalled if the identifier is "op$". In that case, the + format is "op$::XXXX." where XXXX is the name. This is + used for names like "+" or "=". YUUUUUUUK! FIXME! */ + *pp = p + 2; + for (p = *pp; *p != '.' && *p != '\0'; p++) + ; + if (*p != '.') + { + bad_stab (orig); + goto fail; + } + name = savestring (*pp, p - *pp); + *pp = p + 1; + } + + allocvars = 10; + variants = ((debug_method_variant *) + xmalloc (allocvars * sizeof *variants)); + cvars = 0; + + look_ahead_type = DEBUG_TYPE_NULL; + + do + { + debug_type type; + bfd_boolean stub; + enum debug_visibility visibility; + bfd_boolean constp, volatilep, staticp; + bfd_vma voffset; + debug_type context; + const char *physname; + bfd_boolean varargs; + + if (look_ahead_type != DEBUG_TYPE_NULL) + { + /* g++ version 1 kludge */ + type = look_ahead_type; + look_ahead_type = DEBUG_TYPE_NULL; + } + else + { + type = parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL); + if (type == DEBUG_TYPE_NULL) + goto fail; + + if (**pp != ':') + { + bad_stab (orig); + goto fail; + } + } + + ++*pp; + p = strchr (*pp, ';'); + if (p == NULL) + { + bad_stab (orig); + goto fail; + } + + stub = FALSE; + if (debug_get_type_kind (dhandle, type) == DEBUG_KIND_METHOD + && debug_get_parameter_types (dhandle, type, &varargs) == NULL) + stub = TRUE; + + argtypes = savestring (*pp, p - *pp); + *pp = p + 1; + + switch (**pp) + { + case '0': + visibility = DEBUG_VISIBILITY_PRIVATE; + break; + case '1': + visibility = DEBUG_VISIBILITY_PROTECTED; + break; + default: + visibility = DEBUG_VISIBILITY_PUBLIC; + break; + } + ++*pp; + + constp = FALSE; + volatilep = FALSE; + switch (**pp) + { + case 'A': + /* Normal function. */ + ++*pp; + break; + case 'B': + /* const member function. */ + constp = TRUE; + ++*pp; + break; + case 'C': + /* volatile member function. */ + volatilep = TRUE; + ++*pp; + break; + case 'D': + /* const volatile member function. */ + constp = TRUE; + volatilep = TRUE; + ++*pp; + break; + case '*': + case '?': + case '.': + /* File compiled with g++ version 1; no information. */ + break; + default: + warn_stab (orig, _("const/volatile indicator missing")); + break; + } + + staticp = FALSE; + switch (**pp) + { + case '*': + /* virtual member function, followed by index. The sign + bit is supposedly set to distinguish + pointers-to-methods from virtual function indices. */ + ++*pp; + voffset = parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ';') + { + bad_stab (orig); + goto fail; + } + ++*pp; + voffset &= 0x7fffffff; + + if (**pp == ';' || **pp == '\0') + { + /* Must be g++ version 1. */ + context = DEBUG_TYPE_NULL; + } + else + { + /* Figure out from whence this virtual function + came. It may belong to virtual function table of + one of its baseclasses. */ + look_ahead_type = parse_stab_type (dhandle, info, + (const char *) NULL, + pp, + (debug_type **) NULL); + if (**pp == ':') + { + /* g++ version 1 overloaded methods. */ + context = DEBUG_TYPE_NULL; + } + else + { + context = look_ahead_type; + look_ahead_type = DEBUG_TYPE_NULL; + if (**pp != ';') + { + bad_stab (orig); + goto fail; + } + ++*pp; + } + } + break; + + case '?': + /* static member function. */ + ++*pp; + staticp = TRUE; + voffset = 0; + context = DEBUG_TYPE_NULL; + if (strncmp (argtypes, name, strlen (name)) != 0) + stub = TRUE; + break; + + default: + warn_stab (orig, "member function type missing"); + voffset = 0; + context = DEBUG_TYPE_NULL; + break; + + case '.': + ++*pp; + voffset = 0; + context = DEBUG_TYPE_NULL; + break; + } + + /* If the type is not a stub, then the argtypes string is + the physical name of the function. Otherwise the + argtypes string is the mangled form of the argument + types, and the full type and the physical name must be + extracted from them. */ + physname = argtypes; + if (stub) + { + debug_type class_type, return_type; + + class_type = stab_find_type (dhandle, info, typenums); + if (class_type == DEBUG_TYPE_NULL) + goto fail; + return_type = debug_get_return_type (dhandle, type); + if (return_type == DEBUG_TYPE_NULL) + { + bad_stab (orig); + goto fail; + } + type = parse_stab_argtypes (dhandle, info, class_type, name, + tagname, return_type, argtypes, + constp, volatilep, &physname); + if (type == DEBUG_TYPE_NULL) + goto fail; + } + + if (cvars + 1 >= allocvars) + { + allocvars += 10; + variants = ((debug_method_variant *) + xrealloc (variants, + allocvars * sizeof *variants)); + } + + if (! staticp) + variants[cvars] = debug_make_method_variant (dhandle, physname, + type, visibility, + constp, volatilep, + voffset, context); + else + variants[cvars] = debug_make_static_method_variant (dhandle, + physname, + type, + visibility, + constp, + volatilep); + if (variants[cvars] == DEBUG_METHOD_VARIANT_NULL) + goto fail; + + ++cvars; + } + while (**pp != ';' && **pp != '\0'); + + variants[cvars] = DEBUG_METHOD_VARIANT_NULL; + + if (**pp != '\0') + ++*pp; + + if (c + 1 >= alloc) + { + alloc += 10; + methods = ((debug_method *) + xrealloc (methods, alloc * sizeof *methods)); + } + + methods[c] = debug_make_method (dhandle, name, variants); + + ++c; + } + + if (methods != NULL) + methods[c] = DEBUG_METHOD_NULL; + + *retp = methods; + + return TRUE; + + fail: + if (name != NULL) + free (name); + if (variants != NULL) + free (variants); + if (argtypes != NULL) + free (argtypes); + return FALSE; +} + +/* Parse a string representing argument types for a method. Stabs + tries to save space by packing argument types into a mangled + string. This string should give us enough information to extract + both argument types and the physical name of the function, given + the tag name. */ + +static debug_type +parse_stab_argtypes (void *dhandle, struct stab_handle *info, + debug_type class_type, const char *fieldname, + const char *tagname, debug_type return_type, + const char *argtypes, bfd_boolean constp, + bfd_boolean volatilep, const char **pphysname) +{ + bfd_boolean is_full_physname_constructor; + bfd_boolean is_constructor; + bfd_boolean is_destructor; + bfd_boolean is_v3; + debug_type *args; + bfd_boolean varargs; + unsigned int physname_len = 0; + + /* Constructors are sometimes handled specially. */ + is_full_physname_constructor = ((argtypes[0] == '_' + && argtypes[1] == '_' + && (ISDIGIT (argtypes[2]) + || argtypes[2] == 'Q' + || argtypes[2] == 't')) + || CONST_STRNEQ (argtypes, "__ct")); + + is_constructor = (is_full_physname_constructor + || (tagname != NULL + && strcmp (fieldname, tagname) == 0)); + is_destructor = ((argtypes[0] == '_' + && (argtypes[1] == '$' || argtypes[1] == '.') + && argtypes[2] == '_') + || CONST_STRNEQ (argtypes, "__dt")); + is_v3 = argtypes[0] == '_' && argtypes[1] == 'Z'; + + if (!(is_destructor || is_full_physname_constructor || is_v3)) + { + unsigned int len; + const char *const_prefix; + const char *volatile_prefix; + char buf[20]; + unsigned int mangled_name_len; + char *physname; + + len = tagname == NULL ? 0 : strlen (tagname); + const_prefix = constp ? "C" : ""; + volatile_prefix = volatilep ? "V" : ""; + + if (len == 0) + sprintf (buf, "__%s%s", const_prefix, volatile_prefix); + else if (tagname != NULL && strchr (tagname, '<') != NULL) + { + /* Template methods are fully mangled. */ + sprintf (buf, "__%s%s", const_prefix, volatile_prefix); + tagname = NULL; + len = 0; + } + else + sprintf (buf, "__%s%s%d", const_prefix, volatile_prefix, len); + + mangled_name_len = ((is_constructor ? 0 : strlen (fieldname)) + + strlen (buf) + + len + + strlen (argtypes) + + 1); + + if (fieldname[0] == 'o' + && fieldname[1] == 'p' + && (fieldname[2] == '$' || fieldname[2] == '.')) + { + const char *opname; + + opname = cplus_mangle_opname (fieldname + 3, 0); + if (opname == NULL) + { + fprintf (stderr, _("No mangling for \"%s\"\n"), fieldname); + return DEBUG_TYPE_NULL; + } + mangled_name_len += strlen (opname); + physname = (char *) xmalloc (mangled_name_len); + strncpy (physname, fieldname, 3); + strcpy (physname + 3, opname); + } + else + { + physname = (char *) xmalloc (mangled_name_len); + if (is_constructor) + physname[0] = '\0'; + else + strcpy (physname, fieldname); + } + + physname_len = strlen (physname); + strcat (physname, buf); + if (tagname != NULL) + strcat (physname, tagname); + strcat (physname, argtypes); + + *pphysname = physname; + } + + if (*argtypes == '\0' || is_destructor) + { + args = (debug_type *) xmalloc (sizeof *args); + *args = NULL; + return debug_make_method_type (dhandle, return_type, class_type, args, + FALSE); + } + + args = stab_demangle_argtypes (dhandle, info, *pphysname, &varargs, physname_len); + if (args == NULL) + return DEBUG_TYPE_NULL; + + return debug_make_method_type (dhandle, return_type, class_type, args, + varargs); +} + +/* The tail end of stabs for C++ classes that contain a virtual function + pointer contains a tilde, a %, and a type number. + The type number refers to the base class (possibly this class itself) which + contains the vtable pointer for the current class. + + This function is called when we have parsed all the method declarations, + so we can look for the vptr base class info. */ + +static bfd_boolean +parse_stab_tilde_field (void *dhandle, struct stab_handle *info, + const char **pp, const int *typenums, + debug_type *retvptrbase, bfd_boolean *retownvptr) +{ + const char *orig; + const char *hold; + int vtypenums[2]; + + *retvptrbase = DEBUG_TYPE_NULL; + *retownvptr = FALSE; + + orig = *pp; + + /* If we are positioned at a ';', then skip it. */ + if (**pp == ';') + ++*pp; + + if (**pp != '~') + return TRUE; + + ++*pp; + + if (**pp == '=' || **pp == '+' || **pp == '-') + { + /* Obsolete flags that used to indicate the presence of + constructors and/or destructors. */ + ++*pp; + } + + if (**pp != '%') + return TRUE; + + ++*pp; + + hold = *pp; + + /* The next number is the type number of the base class (possibly + our own class) which supplies the vtable for this class. */ + if (! parse_stab_type_number (pp, vtypenums)) + return FALSE; + + if (vtypenums[0] == typenums[0] + && vtypenums[1] == typenums[1]) + *retownvptr = TRUE; + else + { + debug_type vtype; + const char *p; + + *pp = hold; + + vtype = parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL); + for (p = *pp; *p != ';' && *p != '\0'; p++) + ; + if (*p != ';') + { + bad_stab (orig); + return FALSE; + } + + *retvptrbase = vtype; + + *pp = p + 1; + } + + return TRUE; +} + +/* Read a definition of an array type. */ + +static debug_type +parse_stab_array_type (void *dhandle, struct stab_handle *info, + const char **pp, bfd_boolean stringp) +{ + const char *orig; + const char *p; + int typenums[2]; + debug_type index_type; + bfd_boolean adjustable; + bfd_signed_vma lower, upper; + debug_type element_type; + + /* Format of an array type: + "ar;lower;upper;". + OS9000: "arlower,upper;". + + Fortran adjustable arrays use Adigits or Tdigits for lower or upper; + for these, produce a type like float[][]. */ + + orig = *pp; + + /* FIXME: gdb checks os9k_stabs here. */ + + /* If the index type is type 0, we take it as int. */ + p = *pp; + if (! parse_stab_type_number (&p, typenums)) + return DEBUG_TYPE_NULL; + if (typenums[0] == 0 && typenums[1] == 0 && **pp != '=') + { + index_type = debug_find_named_type (dhandle, "int"); + if (index_type == DEBUG_TYPE_NULL) + { + index_type = debug_make_int_type (dhandle, 4, FALSE); + if (index_type == DEBUG_TYPE_NULL) + return DEBUG_TYPE_NULL; + } + *pp = p; + } + else + { + index_type = parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL); + } + + if (**pp != ';') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + + adjustable = FALSE; + + if (! ISDIGIT (**pp) && **pp != '-') + { + ++*pp; + adjustable = TRUE; + } + + lower = (bfd_signed_vma) parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ';') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + + if (! ISDIGIT (**pp) && **pp != '-') + { + ++*pp; + adjustable = TRUE; + } + + upper = (bfd_signed_vma) parse_number (pp, (bfd_boolean *) NULL); + if (**pp != ';') + { + bad_stab (orig); + return DEBUG_TYPE_NULL; + } + ++*pp; + + element_type = parse_stab_type (dhandle, info, (const char *) NULL, pp, + (debug_type **) NULL); + if (element_type == DEBUG_TYPE_NULL) + return DEBUG_TYPE_NULL; + + if (adjustable) + { + lower = 0; + upper = -1; + } + + return debug_make_array_type (dhandle, element_type, index_type, lower, + upper, stringp); +} + +/* This struct holds information about files we have seen using + N_BINCL. */ + +struct bincl_file +{ + /* The next N_BINCL file. */ + struct bincl_file *next; + /* The next N_BINCL on the stack. */ + struct bincl_file *next_stack; + /* The file name. */ + const char *name; + /* The hash value. */ + bfd_vma hash; + /* The file index. */ + unsigned int file; + /* The list of types defined in this file. */ + struct stab_types *file_types; +}; + +/* Start a new N_BINCL file, pushing it onto the stack. */ + +static void +push_bincl (struct stab_handle *info, const char *name, bfd_vma hash) +{ + struct bincl_file *n; + + n = (struct bincl_file *) xmalloc (sizeof *n); + n->next = info->bincl_list; + n->next_stack = info->bincl_stack; + n->name = name; + n->hash = hash; + n->file = info->files; + n->file_types = NULL; + info->bincl_list = n; + info->bincl_stack = n; + + ++info->files; + info->file_types = ((struct stab_types **) + xrealloc (info->file_types, + (info->files + * sizeof *info->file_types))); + info->file_types[n->file] = NULL; +} + +/* Finish an N_BINCL file, at an N_EINCL, popping the name off the + stack. */ + +static const char * +pop_bincl (struct stab_handle *info) +{ + struct bincl_file *o; + + o = info->bincl_stack; + if (o == NULL) + return info->main_filename; + info->bincl_stack = o->next_stack; + + o->file_types = info->file_types[o->file]; + + if (info->bincl_stack == NULL) + return info->main_filename; + return info->bincl_stack->name; +} + +/* Handle an N_EXCL: get the types from the corresponding N_BINCL. */ + +static bfd_boolean +find_excl (struct stab_handle *info, const char *name, bfd_vma hash) +{ + struct bincl_file *l; + + ++info->files; + info->file_types = ((struct stab_types **) + xrealloc (info->file_types, + (info->files + * sizeof *info->file_types))); + + for (l = info->bincl_list; l != NULL; l = l->next) + if (l->hash == hash && strcmp (l->name, name) == 0) + break; + if (l == NULL) + { + warn_stab (name, _("Undefined N_EXCL")); + info->file_types[info->files - 1] = NULL; + return TRUE; + } + + info->file_types[info->files - 1] = l->file_types; + + return TRUE; +} + +/* Handle a variable definition. gcc emits variable definitions for a + block before the N_LBRAC, so we must hold onto them until we see + it. The SunPRO compiler emits variable definitions after the + N_LBRAC, so we can call debug_record_variable immediately. */ + +static bfd_boolean +stab_record_variable (void *dhandle, struct stab_handle *info, + const char *name, debug_type type, + enum debug_var_kind kind, bfd_vma val) +{ + struct stab_pending_var *v; + + if ((kind == DEBUG_GLOBAL || kind == DEBUG_STATIC) + || ! info->within_function + || (info->gcc_compiled == 0 && info->n_opt_found)) + return debug_record_variable (dhandle, name, type, kind, val); + + v = (struct stab_pending_var *) xmalloc (sizeof *v); + memset (v, 0, sizeof *v); + + v->next = info->pending; + v->name = name; + v->type = type; + v->kind = kind; + v->val = val; + info->pending = v; + + return TRUE; +} + +/* Emit pending variable definitions. This is called after we see the + N_LBRAC that starts the block. */ + +static bfd_boolean +stab_emit_pending_vars (void *dhandle, struct stab_handle *info) +{ + struct stab_pending_var *v; + + v = info->pending; + while (v != NULL) + { + struct stab_pending_var *next; + + if (! debug_record_variable (dhandle, v->name, v->type, v->kind, v->val)) + return FALSE; + + next = v->next; + free (v); + v = next; + } + + info->pending = NULL; + + return TRUE; +} + +/* Find the slot for a type in the database. */ + +static debug_type * +stab_find_slot (struct stab_handle *info, const int *typenums) +{ + int filenum; + int tindex; + struct stab_types **ps; + + filenum = typenums[0]; + tindex = typenums[1]; + + if (filenum < 0 || (unsigned int) filenum >= info->files) + { + fprintf (stderr, _("Type file number %d out of range\n"), filenum); + return NULL; + } + if (tindex < 0) + { + fprintf (stderr, _("Type index number %d out of range\n"), tindex); + return NULL; + } + + ps = info->file_types + filenum; + + while (tindex >= STAB_TYPES_SLOTS) + { + if (*ps == NULL) + { + *ps = (struct stab_types *) xmalloc (sizeof **ps); + memset (*ps, 0, sizeof **ps); + } + ps = &(*ps)->next; + tindex -= STAB_TYPES_SLOTS; + } + if (*ps == NULL) + { + *ps = (struct stab_types *) xmalloc (sizeof **ps); + memset (*ps, 0, sizeof **ps); + } + + return (*ps)->types + tindex; +} + +/* Find a type given a type number. If the type has not been + allocated yet, create an indirect type. */ + +static debug_type +stab_find_type (void *dhandle, struct stab_handle *info, const int *typenums) +{ + debug_type *slot; + + if (typenums[0] == 0 && typenums[1] < 0) + { + /* A negative type number indicates an XCOFF builtin type. */ + return stab_xcoff_builtin_type (dhandle, info, typenums[1]); + } + + slot = stab_find_slot (info, typenums); + if (slot == NULL) + return DEBUG_TYPE_NULL; + + if (*slot == DEBUG_TYPE_NULL) + return debug_make_indirect_type (dhandle, slot, (const char *) NULL); + + return *slot; +} + +/* Record that a given type number refers to a given type. */ + +static bfd_boolean +stab_record_type (void *dhandle ATTRIBUTE_UNUSED, struct stab_handle *info, + const int *typenums, debug_type type) +{ + debug_type *slot; + + slot = stab_find_slot (info, typenums); + if (slot == NULL) + return FALSE; + + /* gdb appears to ignore type redefinitions, so we do as well. */ + + *slot = type; + + return TRUE; +} + +/* Return an XCOFF builtin type. */ + +static debug_type +stab_xcoff_builtin_type (void *dhandle, struct stab_handle *info, + int typenum) +{ + debug_type rettype; + const char *name; + + if (typenum >= 0 || typenum < -XCOFF_TYPE_COUNT) + { + fprintf (stderr, _("Unrecognized XCOFF type %d\n"), typenum); + return DEBUG_TYPE_NULL; + } + if (info->xcoff_types[-typenum] != NULL) + return info->xcoff_types[-typenum]; + + switch (-typenum) + { + case 1: + /* The size of this and all the other types are fixed, defined + by the debugging format. */ + name = "int"; + rettype = debug_make_int_type (dhandle, 4, FALSE); + break; + case 2: + name = "char"; + rettype = debug_make_int_type (dhandle, 1, FALSE); + break; + case 3: + name = "short"; + rettype = debug_make_int_type (dhandle, 2, FALSE); + break; + case 4: + name = "long"; + rettype = debug_make_int_type (dhandle, 4, FALSE); + break; + case 5: + name = "unsigned char"; + rettype = debug_make_int_type (dhandle, 1, TRUE); + break; + case 6: + name = "signed char"; + rettype = debug_make_int_type (dhandle, 1, FALSE); + break; + case 7: + name = "unsigned short"; + rettype = debug_make_int_type (dhandle, 2, TRUE); + break; + case 8: + name = "unsigned int"; + rettype = debug_make_int_type (dhandle, 4, TRUE); + break; + case 9: + name = "unsigned"; + rettype = debug_make_int_type (dhandle, 4, TRUE); + break; + case 10: + name = "unsigned long"; + rettype = debug_make_int_type (dhandle, 4, TRUE); + break; + case 11: + name = "void"; + rettype = debug_make_void_type (dhandle); + break; + case 12: + /* IEEE single precision (32 bit). */ + name = "float"; + rettype = debug_make_float_type (dhandle, 4); + break; + case 13: + /* IEEE double precision (64 bit). */ + name = "double"; + rettype = debug_make_float_type (dhandle, 8); + break; + case 14: + /* This is an IEEE double on the RS/6000, and different machines + with different sizes for "long double" should use different + negative type numbers. See stabs.texinfo. */ + name = "long double"; + rettype = debug_make_float_type (dhandle, 8); + break; + case 15: + name = "integer"; + rettype = debug_make_int_type (dhandle, 4, FALSE); + break; + case 16: + name = "boolean"; + rettype = debug_make_bool_type (dhandle, 4); + break; + case 17: + name = "short real"; + rettype = debug_make_float_type (dhandle, 4); + break; + case 18: + name = "real"; + rettype = debug_make_float_type (dhandle, 8); + break; + case 19: + /* FIXME */ + name = "stringptr"; + rettype = NULL; + break; + case 20: + /* FIXME */ + name = "character"; + rettype = debug_make_int_type (dhandle, 1, TRUE); + break; + case 21: + name = "logical*1"; + rettype = debug_make_bool_type (dhandle, 1); + break; + case 22: + name = "logical*2"; + rettype = debug_make_bool_type (dhandle, 2); + break; + case 23: + name = "logical*4"; + rettype = debug_make_bool_type (dhandle, 4); + break; + case 24: + name = "logical"; + rettype = debug_make_bool_type (dhandle, 4); + break; + case 25: + /* Complex type consisting of two IEEE single precision values. */ + name = "complex"; + rettype = debug_make_complex_type (dhandle, 8); + break; + case 26: + /* Complex type consisting of two IEEE double precision values. */ + name = "double complex"; + rettype = debug_make_complex_type (dhandle, 16); + break; + case 27: + name = "integer*1"; + rettype = debug_make_int_type (dhandle, 1, FALSE); + break; + case 28: + name = "integer*2"; + rettype = debug_make_int_type (dhandle, 2, FALSE); + break; + case 29: + name = "integer*4"; + rettype = debug_make_int_type (dhandle, 4, FALSE); + break; + case 30: + /* FIXME */ + name = "wchar"; + rettype = debug_make_int_type (dhandle, 2, FALSE); + break; + case 31: + name = "long long"; + rettype = debug_make_int_type (dhandle, 8, FALSE); + break; + case 32: + name = "unsigned long long"; + rettype = debug_make_int_type (dhandle, 8, TRUE); + break; + case 33: + name = "logical*8"; + rettype = debug_make_bool_type (dhandle, 8); + break; + case 34: + name = "integer*8"; + rettype = debug_make_int_type (dhandle, 8, FALSE); + break; + default: + abort (); + } + + rettype = debug_name_type (dhandle, name, rettype); + + info->xcoff_types[-typenum] = rettype; + + return rettype; +} + +/* Find or create a tagged type. */ + +static debug_type +stab_find_tagged_type (void *dhandle, struct stab_handle *info, + const char *p, int len, enum debug_type_kind kind) +{ + char *name; + debug_type dtype; + struct stab_tag *st; + + name = savestring (p, len); + + /* We pass DEBUG_KIND_ILLEGAL because we want all tags in the same + namespace. This is right for C, and I don't know how to handle + other languages. FIXME. */ + dtype = debug_find_tagged_type (dhandle, name, DEBUG_KIND_ILLEGAL); + if (dtype != DEBUG_TYPE_NULL) + { + free (name); + return dtype; + } + + /* We need to allocate an entry on the undefined tag list. */ + for (st = info->tags; st != NULL; st = st->next) + { + if (st->name[0] == name[0] + && strcmp (st->name, name) == 0) + { + if (st->kind == DEBUG_KIND_ILLEGAL) + st->kind = kind; + free (name); + break; + } + } + if (st == NULL) + { + st = (struct stab_tag *) xmalloc (sizeof *st); + memset (st, 0, sizeof *st); + + st->next = info->tags; + st->name = name; + st->kind = kind; + st->slot = DEBUG_TYPE_NULL; + st->type = debug_make_indirect_type (dhandle, &st->slot, name); + info->tags = st; + } + + return st->type; +} + +/* In order to get the correct argument types for a stubbed method, we + need to extract the argument types from a C++ mangled string. + Since the argument types can refer back to the return type, this + means that we must demangle the entire physical name. In gdb this + is done by calling cplus_demangle and running the results back + through the C++ expression parser. Since we have no expression + parser, we must duplicate much of the work of cplus_demangle here. + + We assume that GNU style demangling is used, since this is only + done for method stubs, and only g++ should output that form of + debugging information. */ + +/* This structure is used to hold a pointer to type information which + demangling a string. */ + +struct stab_demangle_typestring +{ + /* The start of the type. This is not null terminated. */ + const char *typestring; + /* The length of the type. */ + unsigned int len; +}; + +/* This structure is used to hold information while demangling a + string. */ + +struct stab_demangle_info +{ + /* The debugging information handle. */ + void *dhandle; + /* The stab information handle. */ + struct stab_handle *info; + /* The array of arguments we are building. */ + debug_type *args; + /* Whether the method takes a variable number of arguments. */ + bfd_boolean varargs; + /* The array of types we have remembered. */ + struct stab_demangle_typestring *typestrings; + /* The number of typestrings. */ + unsigned int typestring_count; + /* The number of typestring slots we have allocated. */ + unsigned int typestring_alloc; +}; + +static void stab_bad_demangle (const char *); +static unsigned int stab_demangle_count (const char **); +static bfd_boolean stab_demangle_get_count (const char **, unsigned int *); +static bfd_boolean stab_demangle_prefix + (struct stab_demangle_info *, const char **, unsigned int); +static bfd_boolean stab_demangle_function_name + (struct stab_demangle_info *, const char **, const char *); +static bfd_boolean stab_demangle_signature + (struct stab_demangle_info *, const char **); +static bfd_boolean stab_demangle_qualified + (struct stab_demangle_info *, const char **, debug_type *); +static bfd_boolean stab_demangle_template + (struct stab_demangle_info *, const char **, char **); +static bfd_boolean stab_demangle_class + (struct stab_demangle_info *, const char **, const char **); +static bfd_boolean stab_demangle_args + (struct stab_demangle_info *, const char **, debug_type **, bfd_boolean *); +static bfd_boolean stab_demangle_arg + (struct stab_demangle_info *, const char **, debug_type **, + unsigned int *, unsigned int *); +static bfd_boolean stab_demangle_type + (struct stab_demangle_info *, const char **, debug_type *); +static bfd_boolean stab_demangle_fund_type + (struct stab_demangle_info *, const char **, debug_type *); +static bfd_boolean stab_demangle_remember_type + (struct stab_demangle_info *, const char *, int); + +/* Warn about a bad demangling. */ + +static void +stab_bad_demangle (const char *s) +{ + fprintf (stderr, _("bad mangled name `%s'\n"), s); +} + +/* Get a count from a stab string. */ + +static unsigned int +stab_demangle_count (const char **pp) +{ + unsigned int count; + + count = 0; + while (ISDIGIT (**pp)) + { + count *= 10; + count += **pp - '0'; + ++*pp; + } + return count; +} + +/* Require a count in a string. The count may be multiple digits, in + which case it must end in an underscore. */ + +static bfd_boolean +stab_demangle_get_count (const char **pp, unsigned int *pi) +{ + if (! ISDIGIT (**pp)) + return FALSE; + + *pi = **pp - '0'; + ++*pp; + if (ISDIGIT (**pp)) + { + unsigned int count; + const char *p; + + count = *pi; + p = *pp; + do + { + count *= 10; + count += *p - '0'; + ++p; + } + while (ISDIGIT (*p)); + if (*p == '_') + { + *pp = p + 1; + *pi = count; + } + } + + return TRUE; +} + +/* This function demangles a physical name, returning a NULL + terminated array of argument types. */ + +static debug_type * +stab_demangle_argtypes (void *dhandle, struct stab_handle *info, + const char *physname, bfd_boolean *pvarargs, + unsigned int physname_len) +{ + struct stab_demangle_info minfo; + + /* Check for the g++ V3 ABI. */ + if (physname[0] == '_' && physname[1] == 'Z') + return stab_demangle_v3_argtypes (dhandle, info, physname, pvarargs); + + minfo.dhandle = dhandle; + minfo.info = info; + minfo.args = NULL; + minfo.varargs = FALSE; + minfo.typestring_alloc = 10; + minfo.typestrings = ((struct stab_demangle_typestring *) + xmalloc (minfo.typestring_alloc + * sizeof *minfo.typestrings)); + minfo.typestring_count = 0; + + /* cplus_demangle checks for special GNU mangled forms, but we can't + see any of them in mangled method argument types. */ + + if (! stab_demangle_prefix (&minfo, &physname, physname_len)) + goto error_return; + + if (*physname != '\0') + { + if (! stab_demangle_signature (&minfo, &physname)) + goto error_return; + } + + free (minfo.typestrings); + minfo.typestrings = NULL; + + if (minfo.args == NULL) + fprintf (stderr, _("no argument types in mangled string\n")); + + *pvarargs = minfo.varargs; + return minfo.args; + + error_return: + if (minfo.typestrings != NULL) + free (minfo.typestrings); + return NULL; +} + +/* Demangle the prefix of the mangled name. */ + +static bfd_boolean +stab_demangle_prefix (struct stab_demangle_info *minfo, const char **pp, + unsigned int physname_len) +{ + const char *scan; + unsigned int i; + + /* cplus_demangle checks for global constructors and destructors, + but we can't see them in mangled argument types. */ + + if (physname_len) + scan = *pp + physname_len; + else + { + /* Look for `__'. */ + scan = *pp; + do + scan = strchr (scan, '_'); + while (scan != NULL && *++scan != '_'); + + if (scan == NULL) + { + stab_bad_demangle (*pp); + return FALSE; + } + + --scan; + + /* We found `__'; move ahead to the last contiguous `__' pair. */ + i = strspn (scan, "_"); + if (i > 2) + scan += i - 2; + } + + if (scan == *pp + && (ISDIGIT (scan[2]) + || scan[2] == 'Q' + || scan[2] == 't')) + { + /* This is a GNU style constructor name. */ + *pp = scan + 2; + return TRUE; + } + else if (scan == *pp + && ! ISDIGIT (scan[2]) + && scan[2] != 't') + { + /* Look for the `__' that separates the prefix from the + signature. */ + while (*scan == '_') + ++scan; + scan = strstr (scan, "__"); + if (scan == NULL || scan[2] == '\0') + { + stab_bad_demangle (*pp); + return FALSE; + } + + return stab_demangle_function_name (minfo, pp, scan); + } + else if (scan[2] != '\0') + { + /* The name doesn't start with `__', but it does contain `__'. */ + return stab_demangle_function_name (minfo, pp, scan); + } + else + { + stab_bad_demangle (*pp); + return FALSE; + } + /*NOTREACHED*/ +} + +/* Demangle a function name prefix. The scan argument points to the + double underscore which separates the function name from the + signature. */ + +static bfd_boolean +stab_demangle_function_name (struct stab_demangle_info *minfo, + const char **pp, const char *scan) +{ + const char *name; + + /* The string from *pp to scan is the name of the function. We + don't care about the name, since we just looking for argument + types. However, for conversion operators, the name may include a + type which we must remember in order to handle backreferences. */ + + name = *pp; + *pp = scan + 2; + + if (*pp - name >= 5 + && CONST_STRNEQ (name, "type") + && (name[4] == '$' || name[4] == '.')) + { + const char *tem; + + /* This is a type conversion operator. */ + tem = name + 5; + if (! stab_demangle_type (minfo, &tem, (debug_type *) NULL)) + return FALSE; + } + else if (name[0] == '_' + && name[1] == '_' + && name[2] == 'o' + && name[3] == 'p') + { + const char *tem; + + /* This is a type conversion operator. */ + tem = name + 4; + if (! stab_demangle_type (minfo, &tem, (debug_type *) NULL)) + return FALSE; + } + + return TRUE; +} + +/* Demangle the signature. This is where the argument types are + found. */ + +static bfd_boolean +stab_demangle_signature (struct stab_demangle_info *minfo, const char **pp) +{ + const char *orig; + bfd_boolean expect_func, func_done; + const char *hold; + + orig = *pp; + + expect_func = FALSE; + func_done = FALSE; + hold = NULL; + + while (**pp != '\0') + { + switch (**pp) + { + case 'Q': + hold = *pp; + if (! stab_demangle_qualified (minfo, pp, (debug_type *) NULL) + || ! stab_demangle_remember_type (minfo, hold, *pp - hold)) + return FALSE; + expect_func = TRUE; + hold = NULL; + break; + + case 'S': + /* Static member function. FIXME: Can this happen? */ + if (hold == NULL) + hold = *pp; + ++*pp; + break; + + case 'C': + /* Const member function. */ + if (hold == NULL) + hold = *pp; + ++*pp; + break; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + if (hold == NULL) + hold = *pp; + if (! stab_demangle_class (minfo, pp, (const char **) NULL) + || ! stab_demangle_remember_type (minfo, hold, *pp - hold)) + return FALSE; + expect_func = TRUE; + hold = NULL; + break; + + case 'F': + /* Function. I don't know if this actually happens with g++ + output. */ + hold = NULL; + func_done = TRUE; + ++*pp; + if (! stab_demangle_args (minfo, pp, &minfo->args, &minfo->varargs)) + return FALSE; + break; + + case 't': + /* Template. */ + if (hold == NULL) + hold = *pp; + if (! stab_demangle_template (minfo, pp, (char **) NULL) + || ! stab_demangle_remember_type (minfo, hold, *pp - hold)) + return FALSE; + hold = NULL; + expect_func = TRUE; + break; + + case '_': + /* At the outermost level, we cannot have a return type + specified, so if we run into another '_' at this point we + are dealing with a mangled name that is either bogus, or + has been mangled by some algorithm we don't know how to + deal with. So just reject the entire demangling. */ + stab_bad_demangle (orig); + return FALSE; + + default: + /* Assume we have stumbled onto the first outermost function + argument token, and start processing args. */ + func_done = TRUE; + if (! stab_demangle_args (minfo, pp, &minfo->args, &minfo->varargs)) + return FALSE; + break; + } + + if (expect_func) + { + func_done = TRUE; + if (! stab_demangle_args (minfo, pp, &minfo->args, &minfo->varargs)) + return FALSE; + } + } + + if (! func_done) + { + /* With GNU style demangling, bar__3foo is 'foo::bar(void)', and + bar__3fooi is 'foo::bar(int)'. We get here when we find the + first case, and need to ensure that the '(void)' gets added + to the current declp. */ + if (! stab_demangle_args (minfo, pp, &minfo->args, &minfo->varargs)) + return FALSE; + } + + return TRUE; +} + +/* Demangle a qualified name, such as "Q25Outer5Inner" which is the + mangled form of "Outer::Inner". */ + +static bfd_boolean +stab_demangle_qualified (struct stab_demangle_info *minfo, const char **pp, + debug_type *ptype) +{ + const char *orig; + const char *p; + unsigned int qualifiers; + debug_type context; + + orig = *pp; + + switch ((*pp)[1]) + { + case '_': + /* GNU mangled name with more than 9 classes. The count is + preceded by an underscore (to distinguish it from the <= 9 + case) and followed by an underscore. */ + p = *pp + 2; + if (! ISDIGIT (*p) || *p == '0') + { + stab_bad_demangle (orig); + return FALSE; + } + qualifiers = atoi (p); + while (ISDIGIT (*p)) + ++p; + if (*p != '_') + { + stab_bad_demangle (orig); + return FALSE; + } + *pp = p + 1; + break; + + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + qualifiers = (*pp)[1] - '0'; + /* Skip an optional underscore after the count. */ + if ((*pp)[2] == '_') + ++*pp; + *pp += 2; + break; + + case '0': + default: + stab_bad_demangle (orig); + return FALSE; + } + + context = DEBUG_TYPE_NULL; + + /* Pick off the names. */ + while (qualifiers-- > 0) + { + if (**pp == '_') + ++*pp; + if (**pp == 't') + { + char *name; + + if (! stab_demangle_template (minfo, pp, + ptype != NULL ? &name : NULL)) + return FALSE; + + if (ptype != NULL) + { + context = stab_find_tagged_type (minfo->dhandle, minfo->info, + name, strlen (name), + DEBUG_KIND_CLASS); + free (name); + if (context == DEBUG_TYPE_NULL) + return FALSE; + } + } + else + { + unsigned int len; + + len = stab_demangle_count (pp); + if (strlen (*pp) < len) + { + stab_bad_demangle (orig); + return FALSE; + } + + if (ptype != NULL) + { + const debug_field *fields; + + fields = NULL; + if (context != DEBUG_TYPE_NULL) + fields = debug_get_fields (minfo->dhandle, context); + + context = DEBUG_TYPE_NULL; + + if (fields != NULL) + { + char *name; + + /* Try to find the type by looking through the + fields of context until we find a field with the + same type. This ought to work for a class + defined within a class, but it won't work for, + e.g., an enum defined within a class. stabs does + not give us enough information to figure out the + latter case. */ + + name = savestring (*pp, len); + + for (; *fields != DEBUG_FIELD_NULL; fields++) + { + debug_type ft; + const char *dn; + + ft = debug_get_field_type (minfo->dhandle, *fields); + if (ft == NULL) + { + free (name); + return FALSE; + } + dn = debug_get_type_name (minfo->dhandle, ft); + if (dn != NULL && strcmp (dn, name) == 0) + { + context = ft; + break; + } + } + + free (name); + } + + if (context == DEBUG_TYPE_NULL) + { + /* We have to fall back on finding the type by name. + If there are more types to come, then this must + be a class. Otherwise, it could be anything. */ + + if (qualifiers == 0) + { + char *name; + + name = savestring (*pp, len); + context = debug_find_named_type (minfo->dhandle, + name); + free (name); + } + + if (context == DEBUG_TYPE_NULL) + { + context = stab_find_tagged_type (minfo->dhandle, + minfo->info, + *pp, len, + (qualifiers == 0 + ? DEBUG_KIND_ILLEGAL + : DEBUG_KIND_CLASS)); + if (context == DEBUG_TYPE_NULL) + return FALSE; + } + } + } + + *pp += len; + } + } + + if (ptype != NULL) + *ptype = context; + + return TRUE; +} + +/* Demangle a template. If PNAME is not NULL, this sets *PNAME to a + string representation of the template. */ + +static bfd_boolean +stab_demangle_template (struct stab_demangle_info *minfo, const char **pp, + char **pname) +{ + const char *orig; + unsigned int r, i; + + orig = *pp; + + ++*pp; + + /* Skip the template name. */ + r = stab_demangle_count (pp); + if (r == 0 || strlen (*pp) < r) + { + stab_bad_demangle (orig); + return FALSE; + } + *pp += r; + + /* Get the size of the parameter list. */ + if (stab_demangle_get_count (pp, &r) == 0) + { + stab_bad_demangle (orig); + return FALSE; + } + + for (i = 0; i < r; i++) + { + if (**pp == 'Z') + { + /* This is a type parameter. */ + ++*pp; + if (! stab_demangle_type (minfo, pp, (debug_type *) NULL)) + return FALSE; + } + else + { + const char *old_p; + bfd_boolean pointerp, realp, integralp, charp, boolp; + bfd_boolean done; + + old_p = *pp; + pointerp = FALSE; + realp = FALSE; + integralp = FALSE; + charp = FALSE; + boolp = FALSE; + done = FALSE; + + /* This is a value parameter. */ + + if (! stab_demangle_type (minfo, pp, (debug_type *) NULL)) + return FALSE; + + while (*old_p != '\0' && ! done) + { + switch (*old_p) + { + case 'P': + case 'p': + case 'R': + pointerp = TRUE; + done = TRUE; + break; + case 'C': /* Const. */ + case 'S': /* Signed. */ + case 'U': /* Unsigned. */ + case 'V': /* Volatile. */ + case 'F': /* Function. */ + case 'M': /* Member function. */ + case 'O': /* ??? */ + ++old_p; + break; + case 'Q': /* Qualified name. */ + integralp = TRUE; + done = TRUE; + break; + case 'T': /* Remembered type. */ + abort (); + case 'v': /* Void. */ + abort (); + case 'x': /* Long long. */ + case 'l': /* Long. */ + case 'i': /* Int. */ + case 's': /* Short. */ + case 'w': /* Wchar_t. */ + integralp = TRUE; + done = TRUE; + break; + case 'b': /* Bool. */ + boolp = TRUE; + done = TRUE; + break; + case 'c': /* Char. */ + charp = TRUE; + done = TRUE; + break; + case 'r': /* Long double. */ + case 'd': /* Double. */ + case 'f': /* Float. */ + realp = TRUE; + done = TRUE; + break; + default: + /* Assume it's a user defined integral type. */ + integralp = TRUE; + done = TRUE; + break; + } + } + + if (integralp) + { + if (**pp == 'm') + ++*pp; + while (ISDIGIT (**pp)) + ++*pp; + } + else if (charp) + { + unsigned int val; + + if (**pp == 'm') + ++*pp; + val = stab_demangle_count (pp); + if (val == 0) + { + stab_bad_demangle (orig); + return FALSE; + } + } + else if (boolp) + { + unsigned int val; + + val = stab_demangle_count (pp); + if (val != 0 && val != 1) + { + stab_bad_demangle (orig); + return FALSE; + } + } + else if (realp) + { + if (**pp == 'm') + ++*pp; + while (ISDIGIT (**pp)) + ++*pp; + if (**pp == '.') + { + ++*pp; + while (ISDIGIT (**pp)) + ++*pp; + } + if (**pp == 'e') + { + ++*pp; + while (ISDIGIT (**pp)) + ++*pp; + } + } + else if (pointerp) + { + unsigned int len; + + len = stab_demangle_count (pp); + if (len == 0) + { + stab_bad_demangle (orig); + return FALSE; + } + *pp += len; + } + } + } + + /* We can translate this to a string fairly easily by invoking the + regular demangling routine. */ + if (pname != NULL) + { + char *s1, *s2, *s3, *s4 = NULL; + char *from, *to; + + s1 = savestring (orig, *pp - orig); + + s2 = concat ("NoSuchStrinG__", s1, (const char *) NULL); + + free (s1); + + s3 = cplus_demangle (s2, DMGL_ANSI); + + free (s2); + + if (s3 != NULL) + s4 = strstr (s3, "::NoSuchStrinG"); + if (s3 == NULL || s4 == NULL) + { + stab_bad_demangle (orig); + if (s3 != NULL) + free (s3); + return FALSE; + } + + /* Eliminating all spaces, except those between > characters, + makes it more likely that the demangled name will match the + name which g++ used as the structure name. */ + for (from = to = s3; from != s4; ++from) + if (*from != ' ' + || (from[1] == '>' && from > s3 && from[-1] == '>')) + *to++ = *from; + + *pname = savestring (s3, to - s3); + + free (s3); + } + + return TRUE; +} + +/* Demangle a class name. */ + +static bfd_boolean +stab_demangle_class (struct stab_demangle_info *minfo ATTRIBUTE_UNUSED, + const char **pp, const char **pstart) +{ + const char *orig; + unsigned int n; + + orig = *pp; + + n = stab_demangle_count (pp); + if (strlen (*pp) < n) + { + stab_bad_demangle (orig); + return FALSE; + } + + if (pstart != NULL) + *pstart = *pp; + + *pp += n; + + return TRUE; +} + +/* Demangle function arguments. If the pargs argument is not NULL, it + is set to a NULL terminated array holding the arguments. */ + +static bfd_boolean +stab_demangle_args (struct stab_demangle_info *minfo, const char **pp, + debug_type **pargs, bfd_boolean *pvarargs) +{ + const char *orig; + unsigned int alloc, count; + + orig = *pp; + + alloc = 10; + if (pargs != NULL) + { + *pargs = (debug_type *) xmalloc (alloc * sizeof **pargs); + *pvarargs = FALSE; + } + count = 0; + + while (**pp != '_' && **pp != '\0' && **pp != 'e') + { + if (**pp == 'N' || **pp == 'T') + { + char temptype; + unsigned int r, t; + + temptype = **pp; + ++*pp; + + if (temptype == 'T') + r = 1; + else + { + if (! stab_demangle_get_count (pp, &r)) + { + stab_bad_demangle (orig); + return FALSE; + } + } + + if (! stab_demangle_get_count (pp, &t)) + { + stab_bad_demangle (orig); + return FALSE; + } + + if (t >= minfo->typestring_count) + { + stab_bad_demangle (orig); + return FALSE; + } + while (r-- > 0) + { + const char *tem; + + tem = minfo->typestrings[t].typestring; + if (! stab_demangle_arg (minfo, &tem, pargs, &count, &alloc)) + return FALSE; + } + } + else + { + if (! stab_demangle_arg (minfo, pp, pargs, &count, &alloc)) + return FALSE; + } + } + + if (pargs != NULL) + (*pargs)[count] = DEBUG_TYPE_NULL; + + if (**pp == 'e') + { + if (pargs != NULL) + *pvarargs = TRUE; + ++*pp; + } + + return TRUE; +} + +/* Demangle a single argument. */ + +static bfd_boolean +stab_demangle_arg (struct stab_demangle_info *minfo, const char **pp, + debug_type **pargs, unsigned int *pcount, + unsigned int *palloc) +{ + const char *start; + debug_type type; + + start = *pp; + if (! stab_demangle_type (minfo, pp, + pargs == NULL ? (debug_type *) NULL : &type) + || ! stab_demangle_remember_type (minfo, start, *pp - start)) + return FALSE; + + if (pargs != NULL) + { + if (type == DEBUG_TYPE_NULL) + return FALSE; + + if (*pcount + 1 >= *palloc) + { + *palloc += 10; + *pargs = ((debug_type *) + xrealloc (*pargs, *palloc * sizeof **pargs)); + } + (*pargs)[*pcount] = type; + ++*pcount; + } + + return TRUE; +} + +/* Demangle a type. If the ptype argument is not NULL, *ptype is set + to the newly allocated type. */ + +static bfd_boolean +stab_demangle_type (struct stab_demangle_info *minfo, const char **pp, + debug_type *ptype) +{ + const char *orig; + + orig = *pp; + + switch (**pp) + { + case 'P': + case 'p': + /* A pointer type. */ + ++*pp; + if (! stab_demangle_type (minfo, pp, ptype)) + return FALSE; + if (ptype != NULL) + *ptype = debug_make_pointer_type (minfo->dhandle, *ptype); + break; + + case 'R': + /* A reference type. */ + ++*pp; + if (! stab_demangle_type (minfo, pp, ptype)) + return FALSE; + if (ptype != NULL) + *ptype = debug_make_reference_type (minfo->dhandle, *ptype); + break; + + case 'A': + /* An array. */ + { + unsigned long high; + + ++*pp; + high = 0; + while (**pp != '\0' && **pp != '_') + { + if (! ISDIGIT (**pp)) + { + stab_bad_demangle (orig); + return FALSE; + } + high *= 10; + high += **pp - '0'; + ++*pp; + } + if (**pp != '_') + { + stab_bad_demangle (orig); + return FALSE; + } + ++*pp; + + if (! stab_demangle_type (minfo, pp, ptype)) + return FALSE; + if (ptype != NULL) + { + debug_type int_type; + + int_type = debug_find_named_type (minfo->dhandle, "int"); + if (int_type == NULL) + int_type = debug_make_int_type (minfo->dhandle, 4, FALSE); + *ptype = debug_make_array_type (minfo->dhandle, *ptype, int_type, + 0, high, FALSE); + } + } + break; + + case 'T': + /* A back reference to a remembered type. */ + { + unsigned int i; + const char *p; + + ++*pp; + if (! stab_demangle_get_count (pp, &i)) + { + stab_bad_demangle (orig); + return FALSE; + } + if (i >= minfo->typestring_count) + { + stab_bad_demangle (orig); + return FALSE; + } + p = minfo->typestrings[i].typestring; + if (! stab_demangle_type (minfo, &p, ptype)) + return FALSE; + } + break; + + case 'F': + /* A function. */ + { + debug_type *args; + bfd_boolean varargs; + + ++*pp; + if (! stab_demangle_args (minfo, pp, + (ptype == NULL + ? (debug_type **) NULL + : &args), + (ptype == NULL + ? (bfd_boolean *) NULL + : &varargs))) + return FALSE; + if (**pp != '_') + { + /* cplus_demangle will accept a function without a return + type, but I don't know when that will happen, or what + to do if it does. */ + stab_bad_demangle (orig); + return FALSE; + } + ++*pp; + if (! stab_demangle_type (minfo, pp, ptype)) + return FALSE; + if (ptype != NULL) + *ptype = debug_make_function_type (minfo->dhandle, *ptype, args, + varargs); + + } + break; + + case 'M': + case 'O': + { + bfd_boolean memberp; + debug_type class_type = DEBUG_TYPE_NULL; + debug_type *args; + bfd_boolean varargs; + unsigned int n; + const char *name; + + memberp = **pp == 'M'; + args = NULL; + varargs = FALSE; + + ++*pp; + if (ISDIGIT (**pp)) + { + n = stab_demangle_count (pp); + if (strlen (*pp) < n) + { + stab_bad_demangle (orig); + return FALSE; + } + name = *pp; + *pp += n; + + if (ptype != NULL) + { + class_type = stab_find_tagged_type (minfo->dhandle, + minfo->info, + name, (int) n, + DEBUG_KIND_CLASS); + if (class_type == DEBUG_TYPE_NULL) + return FALSE; + } + } + else if (**pp == 'Q') + { + if (! stab_demangle_qualified (minfo, pp, + (ptype == NULL + ? (debug_type *) NULL + : &class_type))) + return FALSE; + } + else + { + stab_bad_demangle (orig); + return FALSE; + } + + if (memberp) + { + if (**pp == 'C') + { + ++*pp; + } + else if (**pp == 'V') + { + ++*pp; + } + if (**pp != 'F') + { + stab_bad_demangle (orig); + return FALSE; + } + ++*pp; + if (! stab_demangle_args (minfo, pp, + (ptype == NULL + ? (debug_type **) NULL + : &args), + (ptype == NULL + ? (bfd_boolean *) NULL + : &varargs))) + return FALSE; + } + + if (**pp != '_') + { + stab_bad_demangle (orig); + return FALSE; + } + ++*pp; + + if (! stab_demangle_type (minfo, pp, ptype)) + return FALSE; + + if (ptype != NULL) + { + if (! memberp) + *ptype = debug_make_offset_type (minfo->dhandle, class_type, + *ptype); + else + { + /* FIXME: We have no way to record constp or + volatilep. */ + *ptype = debug_make_method_type (minfo->dhandle, *ptype, + class_type, args, varargs); + } + } + } + break; + + case 'G': + ++*pp; + if (! stab_demangle_type (minfo, pp, ptype)) + return FALSE; + break; + + case 'C': + ++*pp; + if (! stab_demangle_type (minfo, pp, ptype)) + return FALSE; + if (ptype != NULL) + *ptype = debug_make_const_type (minfo->dhandle, *ptype); + break; + + case 'Q': + { + if (! stab_demangle_qualified (minfo, pp, ptype)) + return FALSE; + } + break; + + default: + if (! stab_demangle_fund_type (minfo, pp, ptype)) + return FALSE; + break; + } + + return TRUE; +} + +/* Demangle a fundamental type. If the ptype argument is not NULL, + *ptype is set to the newly allocated type. */ + +static bfd_boolean +stab_demangle_fund_type (struct stab_demangle_info *minfo, const char **pp, + debug_type *ptype) +{ + const char *orig; + bfd_boolean constp, volatilep, unsignedp, signedp; + bfd_boolean done; + + orig = *pp; + + constp = FALSE; + volatilep = FALSE; + unsignedp = FALSE; + signedp = FALSE; + + done = FALSE; + while (! done) + { + switch (**pp) + { + case 'C': + constp = TRUE; + ++*pp; + break; + + case 'U': + unsignedp = TRUE; + ++*pp; + break; + + case 'S': + signedp = TRUE; + ++*pp; + break; + + case 'V': + volatilep = TRUE; + ++*pp; + break; + + default: + done = TRUE; + break; + } + } + + switch (**pp) + { + case '\0': + case '_': + /* cplus_demangle permits this, but I don't know what it means. */ + stab_bad_demangle (orig); + break; + + case 'v': /* void */ + if (ptype != NULL) + { + *ptype = debug_find_named_type (minfo->dhandle, "void"); + if (*ptype == DEBUG_TYPE_NULL) + *ptype = debug_make_void_type (minfo->dhandle); + } + ++*pp; + break; + + case 'x': /* long long */ + if (ptype != NULL) + { + *ptype = debug_find_named_type (minfo->dhandle, + (unsignedp + ? "long long unsigned int" + : "long long int")); + if (*ptype == DEBUG_TYPE_NULL) + *ptype = debug_make_int_type (minfo->dhandle, 8, unsignedp); + } + ++*pp; + break; + + case 'l': /* long */ + if (ptype != NULL) + { + *ptype = debug_find_named_type (minfo->dhandle, + (unsignedp + ? "long unsigned int" + : "long int")); + if (*ptype == DEBUG_TYPE_NULL) + *ptype = debug_make_int_type (minfo->dhandle, 4, unsignedp); + } + ++*pp; + break; + + case 'i': /* int */ + if (ptype != NULL) + { + *ptype = debug_find_named_type (minfo->dhandle, + (unsignedp + ? "unsigned int" + : "int")); + if (*ptype == DEBUG_TYPE_NULL) + *ptype = debug_make_int_type (minfo->dhandle, 4, unsignedp); + } + ++*pp; + break; + + case 's': /* short */ + if (ptype != NULL) + { + *ptype = debug_find_named_type (minfo->dhandle, + (unsignedp + ? "short unsigned int" + : "short int")); + if (*ptype == DEBUG_TYPE_NULL) + *ptype = debug_make_int_type (minfo->dhandle, 2, unsignedp); + } + ++*pp; + break; + + case 'b': /* bool */ + if (ptype != NULL) + { + *ptype = debug_find_named_type (minfo->dhandle, "bool"); + if (*ptype == DEBUG_TYPE_NULL) + *ptype = debug_make_bool_type (minfo->dhandle, 4); + } + ++*pp; + break; + + case 'c': /* char */ + if (ptype != NULL) + { + *ptype = debug_find_named_type (minfo->dhandle, + (unsignedp + ? "unsigned char" + : (signedp + ? "signed char" + : "char"))); + if (*ptype == DEBUG_TYPE_NULL) + *ptype = debug_make_int_type (minfo->dhandle, 1, unsignedp); + } + ++*pp; + break; + + case 'w': /* wchar_t */ + if (ptype != NULL) + { + *ptype = debug_find_named_type (minfo->dhandle, "__wchar_t"); + if (*ptype == DEBUG_TYPE_NULL) + *ptype = debug_make_int_type (minfo->dhandle, 2, TRUE); + } + ++*pp; + break; + + case 'r': /* long double */ + if (ptype != NULL) + { + *ptype = debug_find_named_type (minfo->dhandle, "long double"); + if (*ptype == DEBUG_TYPE_NULL) + *ptype = debug_make_float_type (minfo->dhandle, 8); + } + ++*pp; + break; + + case 'd': /* double */ + if (ptype != NULL) + { + *ptype = debug_find_named_type (minfo->dhandle, "double"); + if (*ptype == DEBUG_TYPE_NULL) + *ptype = debug_make_float_type (minfo->dhandle, 8); + } + ++*pp; + break; + + case 'f': /* float */ + if (ptype != NULL) + { + *ptype = debug_find_named_type (minfo->dhandle, "float"); + if (*ptype == DEBUG_TYPE_NULL) + *ptype = debug_make_float_type (minfo->dhandle, 4); + } + ++*pp; + break; + + case 'G': + ++*pp; + if (! ISDIGIT (**pp)) + { + stab_bad_demangle (orig); + return FALSE; + } + /* Fall through. */ + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + { + const char *hold; + + if (! stab_demangle_class (minfo, pp, &hold)) + return FALSE; + if (ptype != NULL) + { + char *name; + + name = savestring (hold, *pp - hold); + *ptype = debug_find_named_type (minfo->dhandle, name); + free (name); + if (*ptype == DEBUG_TYPE_NULL) + { + /* FIXME: It is probably incorrect to assume that + undefined types are tagged types. */ + *ptype = stab_find_tagged_type (minfo->dhandle, minfo->info, + hold, *pp - hold, + DEBUG_KIND_ILLEGAL); + if (*ptype == DEBUG_TYPE_NULL) + return FALSE; + } + } + } + break; + + case 't': + { + char *name; + + if (! stab_demangle_template (minfo, pp, + ptype != NULL ? &name : NULL)) + return FALSE; + if (ptype != NULL) + { + *ptype = stab_find_tagged_type (minfo->dhandle, minfo->info, + name, strlen (name), + DEBUG_KIND_CLASS); + free (name); + if (*ptype == DEBUG_TYPE_NULL) + return FALSE; + } + } + break; + + default: + stab_bad_demangle (orig); + return FALSE; + } + + if (ptype != NULL) + { + if (constp) + *ptype = debug_make_const_type (minfo->dhandle, *ptype); + if (volatilep) + *ptype = debug_make_volatile_type (minfo->dhandle, *ptype); + } + + return TRUE; +} + +/* Remember a type string in a demangled string. */ + +static bfd_boolean +stab_demangle_remember_type (struct stab_demangle_info *minfo, + const char *p, int len) +{ + if (minfo->typestring_count >= minfo->typestring_alloc) + { + minfo->typestring_alloc += 10; + minfo->typestrings = ((struct stab_demangle_typestring *) + xrealloc (minfo->typestrings, + (minfo->typestring_alloc + * sizeof *minfo->typestrings))); + } + + minfo->typestrings[minfo->typestring_count].typestring = p; + minfo->typestrings[minfo->typestring_count].len = (unsigned int) len; + ++minfo->typestring_count; + + return TRUE; +} + +/* Demangle names encoded using the g++ V3 ABI. The newer versions of + g++ which use this ABI do not encode ordinary method argument types + in a mangled name; they simply output the argument types. However, + for a static method, g++ simply outputs the return type and the + physical name. So in that case we need to demangle the name here. + Here PHYSNAME is the physical name of the function, and we set the + variable pointed at by PVARARGS to indicate whether this function + is varargs. This returns NULL, or a NULL terminated array of + argument types. */ + +static debug_type * +stab_demangle_v3_argtypes (void *dhandle, struct stab_handle *info, + const char *physname, bfd_boolean *pvarargs) +{ + struct demangle_component *dc; + void *mem; + debug_type *pargs; + + dc = cplus_demangle_v3_components (physname, DMGL_PARAMS | DMGL_ANSI, &mem); + if (dc == NULL) + { + stab_bad_demangle (physname); + return NULL; + } + + /* We expect to see TYPED_NAME, and the right subtree describes the + function type. */ + if (dc->type != DEMANGLE_COMPONENT_TYPED_NAME + || dc->u.s_binary.right->type != DEMANGLE_COMPONENT_FUNCTION_TYPE) + { + fprintf (stderr, _("Demangled name is not a function\n")); + free (mem); + return NULL; + } + + pargs = stab_demangle_v3_arglist (dhandle, info, + dc->u.s_binary.right->u.s_binary.right, + pvarargs); + + free (mem); + + return pargs; +} + +/* Demangle an argument list in a struct demangle_component tree. + Returns a DEBUG_TYPE_NULL terminated array of argument types, and + sets *PVARARGS to indicate whether this is a varargs function. */ + +static debug_type * +stab_demangle_v3_arglist (void *dhandle, struct stab_handle *info, + struct demangle_component *arglist, + bfd_boolean *pvarargs) +{ + struct demangle_component *dc; + unsigned int alloc, count; + debug_type *pargs; + + alloc = 10; + pargs = (debug_type *) xmalloc (alloc * sizeof *pargs); + *pvarargs = FALSE; + + count = 0; + + for (dc = arglist; + dc != NULL; + dc = dc->u.s_binary.right) + { + debug_type arg; + bfd_boolean varargs; + + if (dc->type != DEMANGLE_COMPONENT_ARGLIST) + { + fprintf (stderr, _("Unexpected type in v3 arglist demangling\n")); + free (pargs); + return NULL; + } + + /* PR 13925: Cope if the demangler returns an empty + context for a function with no arguments. */ + if (dc->u.s_binary.left == NULL) + break; + + arg = stab_demangle_v3_arg (dhandle, info, dc->u.s_binary.left, + NULL, &varargs); + if (arg == NULL) + { + if (varargs) + { + *pvarargs = TRUE; + continue; + } + free (pargs); + return NULL; + } + + if (count + 1 >= alloc) + { + alloc += 10; + pargs = (debug_type *) xrealloc (pargs, alloc * sizeof *pargs); + } + + pargs[count] = arg; + ++count; + } + + pargs[count] = DEBUG_TYPE_NULL; + + return pargs; +} + +/* Convert a struct demangle_component tree describing an argument + type into a debug_type. */ + +static debug_type +stab_demangle_v3_arg (void *dhandle, struct stab_handle *info, + struct demangle_component *dc, debug_type context, + bfd_boolean *pvarargs) +{ + debug_type dt; + + if (pvarargs != NULL) + *pvarargs = FALSE; + + switch (dc->type) + { + /* FIXME: These are demangle component types which we probably + need to handle one way or another. */ + case DEMANGLE_COMPONENT_LOCAL_NAME: + case DEMANGLE_COMPONENT_TYPED_NAME: + case DEMANGLE_COMPONENT_TEMPLATE_PARAM: + case DEMANGLE_COMPONENT_CTOR: + case DEMANGLE_COMPONENT_DTOR: + case DEMANGLE_COMPONENT_JAVA_CLASS: + case DEMANGLE_COMPONENT_RESTRICT_THIS: + case DEMANGLE_COMPONENT_VOLATILE_THIS: + case DEMANGLE_COMPONENT_CONST_THIS: + case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: + case DEMANGLE_COMPONENT_COMPLEX: + case DEMANGLE_COMPONENT_IMAGINARY: + case DEMANGLE_COMPONENT_VENDOR_TYPE: + case DEMANGLE_COMPONENT_ARRAY_TYPE: + case DEMANGLE_COMPONENT_PTRMEM_TYPE: + case DEMANGLE_COMPONENT_ARGLIST: + default: + fprintf (stderr, _("Unrecognized demangle component %d\n"), + (int) dc->type); + return NULL; + + case DEMANGLE_COMPONENT_NAME: + if (context != NULL) + { + const debug_field *fields; + + fields = debug_get_fields (dhandle, context); + if (fields != NULL) + { + /* Try to find this type by looking through the context + class. */ + for (; *fields != DEBUG_FIELD_NULL; fields++) + { + debug_type ft; + const char *dn; + + ft = debug_get_field_type (dhandle, *fields); + if (ft == NULL) + return NULL; + dn = debug_get_type_name (dhandle, ft); + if (dn != NULL + && (int) strlen (dn) == dc->u.s_name.len + && strncmp (dn, dc->u.s_name.s, dc->u.s_name.len) == 0) + return ft; + } + } + } + return stab_find_tagged_type (dhandle, info, dc->u.s_name.s, + dc->u.s_name.len, DEBUG_KIND_ILLEGAL); + + case DEMANGLE_COMPONENT_QUAL_NAME: + context = stab_demangle_v3_arg (dhandle, info, dc->u.s_binary.left, + context, NULL); + if (context == NULL) + return NULL; + return stab_demangle_v3_arg (dhandle, info, dc->u.s_binary.right, + context, NULL); + + case DEMANGLE_COMPONENT_TEMPLATE: + { + char *p; + size_t alc; + + /* We print this component to get a class name which we can + use. FIXME: This probably won't work if the template uses + template parameters which refer to an outer template. */ + p = cplus_demangle_print (DMGL_PARAMS | DMGL_ANSI, dc, 20, &alc); + if (p == NULL) + { + fprintf (stderr, _("Failed to print demangled template\n")); + return NULL; + } + dt = stab_find_tagged_type (dhandle, info, p, strlen (p), + DEBUG_KIND_CLASS); + free (p); + return dt; + } + + case DEMANGLE_COMPONENT_SUB_STD: + return stab_find_tagged_type (dhandle, info, dc->u.s_string.string, + dc->u.s_string.len, DEBUG_KIND_ILLEGAL); + + case DEMANGLE_COMPONENT_RESTRICT: + case DEMANGLE_COMPONENT_VOLATILE: + case DEMANGLE_COMPONENT_CONST: + case DEMANGLE_COMPONENT_POINTER: + case DEMANGLE_COMPONENT_REFERENCE: + dt = stab_demangle_v3_arg (dhandle, info, dc->u.s_binary.left, NULL, + NULL); + if (dt == NULL) + return NULL; + + switch (dc->type) + { + default: + abort (); + case DEMANGLE_COMPONENT_RESTRICT: + /* FIXME: We have no way to represent restrict. */ + return dt; + case DEMANGLE_COMPONENT_VOLATILE: + return debug_make_volatile_type (dhandle, dt); + case DEMANGLE_COMPONENT_CONST: + return debug_make_const_type (dhandle, dt); + case DEMANGLE_COMPONENT_POINTER: + return debug_make_pointer_type (dhandle, dt); + case DEMANGLE_COMPONENT_REFERENCE: + return debug_make_reference_type (dhandle, dt); + } + + case DEMANGLE_COMPONENT_FUNCTION_TYPE: + { + debug_type *pargs; + bfd_boolean varargs; + + if (dc->u.s_binary.left == NULL) + { + /* In this case the return type is actually unknown. + However, I'm not sure this will ever arise in practice; + normally an unknown return type would only appear at + the top level, which is handled above. */ + dt = debug_make_void_type (dhandle); + } + else + dt = stab_demangle_v3_arg (dhandle, info, dc->u.s_binary.left, NULL, + NULL); + if (dt == NULL) + return NULL; + + pargs = stab_demangle_v3_arglist (dhandle, info, + dc->u.s_binary.right, + &varargs); + if (pargs == NULL) + return NULL; + + return debug_make_function_type (dhandle, dt, pargs, varargs); + } + + case DEMANGLE_COMPONENT_BUILTIN_TYPE: + { + char *p; + size_t alc; + debug_type ret; + + /* We print this component in order to find out the type name. + FIXME: Should we instead expose the + demangle_builtin_type_info structure? */ + p = cplus_demangle_print (DMGL_PARAMS | DMGL_ANSI, dc, 20, &alc); + if (p == NULL) + { + fprintf (stderr, _("Couldn't get demangled builtin type\n")); + return NULL; + } + + /* The mangling is based on the type, but does not itself + indicate what the sizes are. So we have to guess. */ + if (strcmp (p, "signed char") == 0) + ret = debug_make_int_type (dhandle, 1, FALSE); + else if (strcmp (p, "bool") == 0) + ret = debug_make_bool_type (dhandle, 1); + else if (strcmp (p, "char") == 0) + ret = debug_make_int_type (dhandle, 1, FALSE); + else if (strcmp (p, "double") == 0) + ret = debug_make_float_type (dhandle, 8); + else if (strcmp (p, "long double") == 0) + ret = debug_make_float_type (dhandle, 8); + else if (strcmp (p, "float") == 0) + ret = debug_make_float_type (dhandle, 4); + else if (strcmp (p, "__float128") == 0) + ret = debug_make_float_type (dhandle, 16); + else if (strcmp (p, "unsigned char") == 0) + ret = debug_make_int_type (dhandle, 1, TRUE); + else if (strcmp (p, "int") == 0) + ret = debug_make_int_type (dhandle, 4, FALSE); + else if (strcmp (p, "unsigned int") == 0) + ret = debug_make_int_type (dhandle, 4, TRUE); + else if (strcmp (p, "long") == 0) + ret = debug_make_int_type (dhandle, 4, FALSE); + else if (strcmp (p, "unsigned long") == 0) + ret = debug_make_int_type (dhandle, 4, TRUE); + else if (strcmp (p, "__int128") == 0) + ret = debug_make_int_type (dhandle, 16, FALSE); + else if (strcmp (p, "unsigned __int128") == 0) + ret = debug_make_int_type (dhandle, 16, TRUE); + else if (strcmp (p, "short") == 0) + ret = debug_make_int_type (dhandle, 2, FALSE); + else if (strcmp (p, "unsigned short") == 0) + ret = debug_make_int_type (dhandle, 2, TRUE); + else if (strcmp (p, "void") == 0) + ret = debug_make_void_type (dhandle); + else if (strcmp (p, "wchar_t") == 0) + ret = debug_make_int_type (dhandle, 4, TRUE); + else if (strcmp (p, "long long") == 0) + ret = debug_make_int_type (dhandle, 8, FALSE); + else if (strcmp (p, "unsigned long long") == 0) + ret = debug_make_int_type (dhandle, 8, TRUE); + else if (strcmp (p, "...") == 0) + { + if (pvarargs == NULL) + fprintf (stderr, _("Unexpected demangled varargs\n")); + else + *pvarargs = TRUE; + ret = NULL; + } + else + { + fprintf (stderr, _("Unrecognized demangled builtin type\n")); + ret = NULL; + } + + free (p); + + return ret; + } + } +} diff --git a/support/sdbinutils/binutils/stamp-h.in b/support/sdbinutils/binutils/stamp-h.in new file mode 100644 index 0000000..9788f70 --- /dev/null +++ b/support/sdbinutils/binutils/stamp-h.in @@ -0,0 +1 @@ +timestamp diff --git a/support/sdbinutils/binutils/stamp-h1 b/support/sdbinutils/binutils/stamp-h1 new file mode 100644 index 0000000..4547fe1 --- /dev/null +++ b/support/sdbinutils/binutils/stamp-h1 @@ -0,0 +1 @@ +timestamp for config.h diff --git a/support/sdbinutils/binutils/strings.c b/support/sdbinutils/binutils/strings.c new file mode 100644 index 0000000..da044ac --- /dev/null +++ b/support/sdbinutils/binutils/strings.c @@ -0,0 +1,670 @@ +/* strings -- print the strings of printable characters in files + Copyright (C) 1993-2018 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 3, 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., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Usage: strings [options] file... + + Options: + --all + -a + - Scan each file in its entirety. + + --data + -d Scan only the initialized data section(s) of object files. + + --print-file-name + -f Print the name of the file before each string. + + --bytes=min-len + -n min-len + -min-len Print graphic char sequences, MIN-LEN or more bytes long, + that are followed by a NUL or a newline. Default is 4. + + --radix={o,x,d} + -t {o,x,d} Print the offset within the file before each string, + in octal/hex/decimal. + + --include-all-whitespace + -w By default tab and space are the only whitepace included in graphic + char sequences. This option considers all of isspace() valid. + + -o Like -to. (Some other implementations have -o like -to, + others like -td. We chose one arbitrarily.) + + --encoding={s,S,b,l,B,L} + -e {s,S,b,l,B,L} + Select character encoding: 7-bit-character, 8-bit-character, + bigendian 16-bit, littleendian 16-bit, bigendian 32-bit, + littleendian 32-bit. + + --target=BFDNAME + -T {bfdname} + Specify a non-default object file format. + + --output-separator=sep_string + -s sep_string String used to separate parsed strings in output. + Default is newline. + + --help + -h Print the usage message on the standard output. + + --version + -V + -v Print the program version number. + + Written by Richard Stallman + and David MacKenzie . */ + +#include "sysdep.h" +#include "bfd.h" +#include "getopt.h" +#include "libiberty.h" +#include "safe-ctype.h" +#include "bucomm.h" + +#define STRING_ISGRAPHIC(c) \ + ( (c) >= 0 \ + && (c) <= 255 \ + && ((c) == '\t' || ISPRINT (c) || (encoding == 'S' && (c) > 127) \ + || (include_all_whitespace && ISSPACE (c))) \ + ) + +#ifndef errno +extern int errno; +#endif + +/* The BFD section flags that identify an initialized data section. */ +#define DATA_FLAGS (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS) + +/* Radix for printing addresses (must be 8, 10 or 16). */ +static int address_radix; + +/* Minimum length of sequence of graphic chars to trigger output. */ +static int string_min; + +/* Whether or not we include all whitespace as a graphic char. */ +static bfd_boolean include_all_whitespace; + +/* TRUE means print address within file for each string. */ +static bfd_boolean print_addresses; + +/* TRUE means print filename for each string. */ +static bfd_boolean print_filenames; + +/* TRUE means for object files scan only the data section. */ +static bfd_boolean datasection_only; + +/* The BFD object file format. */ +static char *target; + +/* The character encoding format. */ +static char encoding; +static int encoding_bytes; + +/* Output string used to separate parsed strings */ +static char *output_separator; + +static struct option long_options[] = +{ + {"all", no_argument, NULL, 'a'}, + {"data", no_argument, NULL, 'd'}, + {"print-file-name", no_argument, NULL, 'f'}, + {"bytes", required_argument, NULL, 'n'}, + {"radix", required_argument, NULL, 't'}, + {"include-all-whitespace", required_argument, NULL, 'w'}, + {"encoding", required_argument, NULL, 'e'}, + {"target", required_argument, NULL, 'T'}, + {"output-separator", required_argument, NULL, 's'}, + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'v'}, + {NULL, 0, NULL, 0} +}; + +static bfd_boolean strings_file (char *); +static void print_strings (const char *, FILE *, file_ptr, int, int, char *); +static void usage (FILE *, int) ATTRIBUTE_NORETURN; + +int main (int, char **); + +int +main (int argc, char **argv) +{ + int optc; + int exit_status = 0; + bfd_boolean files_given = FALSE; + char *s; + int numeric_opt = 0; + +#if defined (HAVE_SETLOCALE) + setlocale (LC_ALL, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + program_name = argv[0]; + xmalloc_set_program_name (program_name); + bfd_set_error_program_name (program_name); + + expandargv (&argc, &argv); + + string_min = 4; + include_all_whitespace = FALSE; + print_addresses = FALSE; + print_filenames = FALSE; + if (DEFAULT_STRINGS_ALL) + datasection_only = FALSE; + else + datasection_only = TRUE; + target = NULL; + encoding = 's'; + output_separator = NULL; + + while ((optc = getopt_long (argc, argv, "adfhHn:wot:e:T:s:Vv0123456789", + long_options, (int *) 0)) != EOF) + { + switch (optc) + { + case 'a': + datasection_only = FALSE; + break; + + case 'd': + datasection_only = TRUE; + break; + + case 'f': + print_filenames = TRUE; + break; + + case 'H': + case 'h': + usage (stdout, 0); + + case 'n': + string_min = (int) strtoul (optarg, &s, 0); + if (s != NULL && *s != 0) + fatal (_("invalid integer argument %s"), optarg); + break; + + case 'w': + include_all_whitespace = TRUE; + break; + + case 'o': + print_addresses = TRUE; + address_radix = 8; + break; + + case 't': + print_addresses = TRUE; + if (optarg[1] != '\0') + usage (stderr, 1); + switch (optarg[0]) + { + case 'o': + address_radix = 8; + break; + + case 'd': + address_radix = 10; + break; + + case 'x': + address_radix = 16; + break; + + default: + usage (stderr, 1); + } + break; + + case 'T': + target = optarg; + break; + + case 'e': + if (optarg[1] != '\0') + usage (stderr, 1); + encoding = optarg[0]; + break; + + case 's': + output_separator = optarg; + break; + + case 'V': + case 'v': + print_version ("strings"); + break; + + case '?': + usage (stderr, 1); + + default: + numeric_opt = optind; + break; + } + } + + if (numeric_opt != 0) + { + string_min = (int) strtoul (argv[numeric_opt - 1] + 1, &s, 0); + if (s != NULL && *s != 0) + fatal (_("invalid integer argument %s"), argv[numeric_opt - 1] + 1); + } + if (string_min < 1) + fatal (_("invalid minimum string length %d"), string_min); + + switch (encoding) + { + case 'S': + case 's': + encoding_bytes = 1; + break; + case 'b': + case 'l': + encoding_bytes = 2; + break; + case 'B': + case 'L': + encoding_bytes = 4; + break; + default: + usage (stderr, 1); + } + + bfd_init (); + set_default_bfd_target (); + + if (optind >= argc) + { + datasection_only = FALSE; + SET_BINARY (fileno (stdin)); + print_strings ("{standard input}", stdin, 0, 0, 0, (char *) NULL); + files_given = TRUE; + } + else + { + for (; optind < argc; ++optind) + { + if (strcmp (argv[optind], "-") == 0) + datasection_only = FALSE; + else + { + files_given = TRUE; + exit_status |= !strings_file (argv[optind]); + } + } + } + + if (!files_given) + usage (stderr, 1); + + return (exit_status); +} + +/* Scan section SECT of the file ABFD, whose printable name is + FILENAME. If it contains initialized data set GOT_A_SECTION and + print the strings in it. */ + +static void +strings_a_section (bfd *abfd, asection *sect, const char *filename, + bfd_boolean *got_a_section) +{ + bfd_size_type sectsize; + bfd_byte *mem; + + if ((sect->flags & DATA_FLAGS) != DATA_FLAGS) + return; + + sectsize = bfd_get_section_size (sect); + if (sectsize == 0) + return; + + if (!bfd_malloc_and_get_section (abfd, sect, &mem)) + { + non_fatal (_("%s: Reading section %s failed: %s"), + filename, sect->name, bfd_errmsg (bfd_get_error ())); + return; + } + + *got_a_section = TRUE; + print_strings (filename, NULL, sect->filepos, 0, sectsize, (char *) mem); + free (mem); +} + +/* Scan all of the sections in FILE, and print the strings + in the initialized data section(s). + + Return TRUE if successful, + FALSE if not (such as if FILE is not an object file). */ + +static bfd_boolean +strings_object_file (const char *file) +{ + bfd *abfd; + asection *s; + bfd_boolean got_a_section; + + abfd = bfd_openr (file, target); + + if (abfd == NULL) + /* Treat the file as a non-object file. */ + return FALSE; + + /* This call is mainly for its side effect of reading in the sections. + We follow the traditional behavior of `strings' in that we don't + complain if we don't recognize a file to be an object file. */ + if (!bfd_check_format (abfd, bfd_object)) + { + bfd_close (abfd); + return FALSE; + } + + got_a_section = FALSE; + for (s = abfd->sections; s != NULL; s = s->next) + strings_a_section (abfd, s, file, &got_a_section); + + if (!bfd_close (abfd)) + { + bfd_nonfatal (file); + return FALSE; + } + + return got_a_section; +} + +/* Print the strings in FILE. Return TRUE if ok, FALSE if an error occurs. */ + +static bfd_boolean +strings_file (char *file) +{ + struct stat st; + + /* get_file_size does not support non-S_ISREG files. */ + + if (stat (file, &st) < 0) + { + if (errno == ENOENT) + non_fatal (_("'%s': No such file"), file); + else + non_fatal (_("Warning: could not locate '%s'. reason: %s"), + file, strerror (errno)); + return FALSE; + } + else if (S_ISDIR (st.st_mode)) + { + non_fatal (_("Warning: '%s' is a directory"), file); + return FALSE; + } + + /* If we weren't told to scan the whole file, + try to open it as an object file and only look at + initialized data sections. If that fails, fall back to the + whole file. */ + if (!datasection_only || !strings_object_file (file)) + { + FILE *stream; + + stream = fopen (file, FOPEN_RB); + if (stream == NULL) + { + fprintf (stderr, "%s: ", program_name); + perror (file); + return FALSE; + } + + print_strings (file, stream, (file_ptr) 0, 0, 0, (char *) 0); + + if (fclose (stream) == EOF) + { + fprintf (stderr, "%s: ", program_name); + perror (file); + return FALSE; + } + } + + return TRUE; +} + +/* Read the next character, return EOF if none available. + Assume that STREAM is positioned so that the next byte read + is at address ADDRESS in the file. + + If STREAM is NULL, do not read from it. + The caller can supply a buffer of characters + to be processed before the data in STREAM. + MAGIC is the address of the buffer and + MAGICCOUNT is how many characters are in it. */ + +static long +get_char (FILE *stream, file_ptr *address, int *magiccount, char **magic) +{ + int c, i; + long r = 0; + + for (i = 0; i < encoding_bytes; i++) + { + if (*magiccount) + { + (*magiccount)--; + c = *(*magic)++; + } + else + { + if (stream == NULL) + return EOF; + + /* Only use getc_unlocked if we found a declaration for it. + Otherwise, libc is not thread safe by default, and we + should not use it. */ + +#if defined(HAVE_GETC_UNLOCKED) && HAVE_DECL_GETC_UNLOCKED + c = getc_unlocked (stream); +#else + c = getc (stream); +#endif + if (c == EOF) + return EOF; + } + + (*address)++; + r = (r << 8) | (c & 0xff); + } + + switch (encoding) + { + default: + break; + case 'l': + r = ((r & 0xff) << 8) | ((r & 0xff00) >> 8); + break; + case 'L': + r = (((r & 0xff) << 24) | ((r & 0xff00) << 8) + | ((r & 0xff0000) >> 8) | ((r & 0xff000000) >> 24)); + break; + } + + return r; +} + +/* Find the strings in file FILENAME, read from STREAM. + Assume that STREAM is positioned so that the next byte read + is at address ADDRESS in the file. + Stop reading at address STOP_POINT in the file, if nonzero. + + If STREAM is NULL, do not read from it. + The caller can supply a buffer of characters + to be processed before the data in STREAM. + MAGIC is the address of the buffer and + MAGICCOUNT is how many characters are in it. + Those characters come at address ADDRESS and the data in STREAM follow. */ + +static void +print_strings (const char *filename, FILE *stream, file_ptr address, + int stop_point, int magiccount, char *magic) +{ + char *buf = (char *) xmalloc (sizeof (char) * (string_min + 1)); + + while (1) + { + file_ptr start; + int i; + long c; + + /* See if the next `string_min' chars are all graphic chars. */ + tryline: + if (stop_point && address >= stop_point) + break; + start = address; + for (i = 0; i < string_min; i++) + { + c = get_char (stream, &address, &magiccount, &magic); + if (c == EOF) + { + free (buf); + return; + } + if (! STRING_ISGRAPHIC (c)) + /* Found a non-graphic. Try again starting with next char. */ + goto tryline; + buf[i] = c; + } + + /* We found a run of `string_min' graphic characters. Print up + to the next non-graphic character. */ + + if (print_filenames) + printf ("%s: ", filename); + if (print_addresses) + switch (address_radix) + { + case 8: +#ifdef HAVE_LONG_LONG + if (sizeof (start) > sizeof (long)) + { +# ifndef __MSVCRT__ + printf ("%7llo ", (unsigned long long) start); +# else + printf ("%7I64o ", (unsigned long long) start); +# endif + } + else +#elif !BFD_HOST_64BIT_LONG + if (start != (unsigned long) start) + printf ("++%7lo ", (unsigned long) start); + else +#endif + printf ("%7lo ", (unsigned long) start); + break; + + case 10: +#ifdef HAVE_LONG_LONG + if (sizeof (start) > sizeof (long)) + { +# ifndef __MSVCRT__ + printf ("%7lld ", (unsigned long long) start); +# else + printf ("%7I64d ", (unsigned long long) start); +# endif + } + else +#elif !BFD_HOST_64BIT_LONG + if (start != (unsigned long) start) + printf ("++%7ld ", (unsigned long) start); + else +#endif + printf ("%7ld ", (long) start); + break; + + case 16: +#ifdef HAVE_LONG_LONG + if (sizeof (start) > sizeof (long)) + { +# ifndef __MSVCRT__ + printf ("%7llx ", (unsigned long long) start); +# else + printf ("%7I64x ", (unsigned long long) start); +# endif + } + else +#elif !BFD_HOST_64BIT_LONG + if (start != (unsigned long) start) + printf ("%lx%8.8lx ", (unsigned long) (start >> 32), + (unsigned long) (start & 0xffffffff)); + else +#endif + printf ("%7lx ", (unsigned long) start); + break; + } + + buf[i] = '\0'; + fputs (buf, stdout); + + while (1) + { + c = get_char (stream, &address, &magiccount, &magic); + if (c == EOF) + break; + if (! STRING_ISGRAPHIC (c)) + break; + putchar (c); + } + + if (output_separator) + fputs (output_separator, stdout); + else + putchar ('\n'); + } + free (buf); +} + +static void +usage (FILE *stream, int status) +{ + fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name); + fprintf (stream, _(" Display printable strings in [file(s)] (stdin by default)\n")); + fprintf (stream, _(" The options are:\n")); + + if (DEFAULT_STRINGS_ALL) + fprintf (stream, _("\ + -a - --all Scan the entire file, not just the data section [default]\n\ + -d --data Only scan the data sections in the file\n")); + else + fprintf (stream, _("\ + -a - --all Scan the entire file, not just the data section\n\ + -d --data Only scan the data sections in the file [default]\n")); + + fprintf (stream, _("\ + -f --print-file-name Print the name of the file before each string\n\ + -n --bytes=[number] Locate & print any NUL-terminated sequence of at\n\ + - least [number] characters (default 4).\n\ + -t --radix={o,d,x} Print the location of the string in base 8, 10 or 16\n\ + -w --include-all-whitespace Include all whitespace as valid string characters\n\ + -o An alias for --radix=o\n\ + -T --target= Specify the binary file format\n\ + -e --encoding={s,S,b,l,B,L} Select character size and endianness:\n\ + s = 7-bit, S = 8-bit, {b,l} = 16-bit, {B,L} = 32-bit\n\ + -s --output-separator= String used to separate strings in output.\n\ + @ Read options from \n\ + -h --help Display this information\n\ + -v -V --version Print the program's version number\n")); + list_supported_targets (program_name, stream); + if (REPORT_BUGS_TO[0] && status == 0) + fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); + exit (status); +} diff --git a/support/sdbinutils/binutils/sysdep.h b/support/sdbinutils/binutils/sysdep.h new file mode 100644 index 0000000..64ae1d0 --- /dev/null +++ b/support/sdbinutils/binutils/sysdep.h @@ -0,0 +1,204 @@ +/* sysdep.h -- handle host dependencies for binutils + Copyright (C) 1991-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _BIN_SYSDEP_H +#define _BIN_SYSDEP_H + +#include "alloca-conf.h" +#include "ansidecl.h" +#include +#include + +#include "bfdver.h" + +#include + +#ifdef USE_BINARY_FOPEN +#include "fopen-bin.h" +#else +#include "fopen-same.h" +#endif + +#include +#ifndef errno +extern int errno; +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef STRING_WITH_STRINGS +#include +#include +#else +#ifdef HAVE_STRING_H +#include +#else +#ifdef HAVE_STRINGS_H +#include +#else +extern char *strchr (); +extern char *strrchr (); +#endif +#endif +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_FCNTL_H +#include +#else +#ifdef HAVE_SYS_FILE_H +#include +#endif +#endif + +#ifdef HAVE_SYS_STAT_H +#include +#endif + +#include "binary-io.h" + +#if !HAVE_DECL_STPCPY +extern char *stpcpy (char *, const char *); +#endif + +#if !HAVE_DECL_STRSTR +extern char *strstr (); +#endif + +#ifdef HAVE_SBRK +#if !HAVE_DECL_SBRK +extern char *sbrk (); +#endif +#endif + +#if !HAVE_DECL_GETENV +extern char *getenv (); +#endif + +#if !HAVE_DECL_ENVIRON +extern char **environ; +#endif + +#if !HAVE_DECL_FPRINTF +extern int fprintf (FILE *, const char *, ...); +#endif + +#if !HAVE_DECL_SNPRINTF +extern int snprintf(char *, size_t, const char *, ...); +#endif + +#if !HAVE_DECL_VSNPRINTF +extern int vsnprintf(char *, size_t, const char *, va_list); +#endif + +#if !HAVE_DECL_STRNLEN +size_t strnlen (const char *, size_t); +#endif + +#ifndef O_RDONLY +#define O_RDONLY 0 +#endif + +#ifndef O_RDWR +#define O_RDWR 2 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif +#ifndef SEEK_END +#define SEEK_END 2 +#endif + +#ifdef HAVE_LOCALE_H +# ifndef ENABLE_NLS + /* The Solaris version of locale.h always includes libintl.h. If we have + been configured with --disable-nls then ENABLE_NLS will not be defined + and the dummy definitions of bindtextdomain (et al) below will conflict + with the defintions in libintl.h. So we define these values to prevent + the bogus inclusion of libintl.h. */ +# define _LIBINTL_H +# define _LIBGETTEXT_H +# endif +# include +#endif + +#ifdef ENABLE_NLS +# include +# define _(String) gettext (String) +# ifdef gettext_noop +# define N_(String) gettext_noop (String) +# else +# define N_(String) (String) +# endif +#else +# define gettext(Msgid) (Msgid) +# define dgettext(Domainname, Msgid) (Msgid) +# define dcgettext(Domainname, Msgid, Category) (Msgid) +# define ngettext(Msgid1, Msgid2, n) \ + (n == 1 ? Msgid1 : Msgid2) +# define dngettext(Domainname, Msgid1, Msgid2, n) \ + (n == 1 ? Msgid1 : Msgid2) +# define dcngettext(Domainname, Msgid1, Msgid2, n, Category) \ + (n == 1 ? Msgid1 : Msgid2) +# define textdomain(Domainname) do {} while (0) +# define bindtextdomain(Domainname, Dirname) do {} while (0) +# define _(String) (String) +# define N_(String) (String) +#endif + +/* Used by ar.c and objcopy.c. */ +#define BUFSIZE 8192 + +/* For PATH_MAX. */ +#ifdef HAVE_LIMITS_H +#include +#endif + +#ifndef PATH_MAX +/* For MAXPATHLEN. */ +# ifdef HAVE_SYS_PARAM_H +# include +# endif +# ifndef PATH_MAX +# ifdef MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# else +# define PATH_MAX 1024 +# endif +# endif +#endif + +#if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG +/* We can't use any bfd types here since readelf may define BFD64 and + objdump may not. */ +#define HOST_WIDEST_INT long long +#else +#define HOST_WIDEST_INT long +#endif + +#endif /* _BIN_SYSDEP_H */ diff --git a/support/sdbinutils/binutils/sysdump.c b/support/sdbinutils/binutils/sysdump.c new file mode 100644 index 0000000..be026f8 --- /dev/null +++ b/support/sdbinutils/binutils/sysdump.c @@ -0,0 +1,715 @@ +/* Sysroff object format dumper. + Copyright (C) 1994-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + + +/* Written by Steve Chamberlain . + + This program reads a SYSROFF object file and prints it in an + almost human readable form to stdout. */ + +#include "sysdep.h" +#include "bfd.h" +#include "safe-ctype.h" +#include "libiberty.h" +#include "getopt.h" +#include "bucomm.h" +#include "sysroff.h" + +static int dump = 1; +static int segmented_p; +static int code; +static int addrsize = 4; +static FILE *file; + +static void derived_type (void); + +static char * +getCHARS (unsigned char *ptr, int *idx, int size, int max) +{ + int oc = *idx / 8; + char *r; + int b = size; + + if (b >= max) + return _("*undefined*"); + + if (b == 0) + { + /* PR 17512: file: 13caced2. */ + if (oc >= max) + return _("*corrupt*"); + /* Got to work out the length of the string from self. */ + b = ptr[oc++]; + (*idx) += 8; + } + + *idx += b * 8; + r = xcalloc (b + 1, 1); + memcpy (r, ptr + oc, b); + r[b] = 0; + + return r; +} + +static void +dh (unsigned char *ptr, int size) +{ + int i; + int j; + int span = 16; + + printf ("\n************************************************************\n"); + + for (i = 0; i < size; i += span) + { + for (j = 0; j < span; j++) + { + if (j + i < size) + printf ("%02x ", ptr[i + j]); + else + printf (" "); + } + + for (j = 0; j < span && j + i < size; j++) + { + int c = ptr[i + j]; + + if (c < 32 || c > 127) + c = '.'; + printf ("%c", c); + } + + printf ("\n"); + } +} + +static int +fillup (unsigned char *ptr) +{ + int size; + int sum; + int i; + + size = getc (file); + if (size == EOF + || size <= 2) + return 0; + + size -= 2; + if (fread (ptr, size, 1, file) != 1) + return 0; + + sum = code + size + 2; + + for (i = 0; i < size; i++) + sum += ptr[i]; + + if ((sum & 0xff) != 0xff) + printf (_("SUM IS %x\n"), sum); + + if (dump) + dh (ptr, size); + + return size; +} + +static barray +getBARRAY (unsigned char *ptr, int *idx, int dsize ATTRIBUTE_UNUSED, + int max ATTRIBUTE_UNUSED) +{ + barray res; + int i; + int byte = *idx / 8; + int size = ptr[byte++]; + + res.len = size; + res.data = (unsigned char *) xmalloc (size); + + for (i = 0; i < size; i++) + res.data[i] = ptr[byte++]; + + return res; +} + +static int +getINT (unsigned char *ptr, int *idx, int size, int max) +{ + int n = 0; + int byte = *idx / 8; + + if (byte >= max) + { + /* PR 17512: file: id:000001,src:000002,op:flip1,pos:45. */ + /* Prevent infinite loops re-reading beyond the end of the buffer. */ + fatal (_("ICE: getINT: Out of buffer space")); + return 0; + } + + if (size == -2) + size = addrsize; + + if (size == -1) + size = 0; + + switch (size) + { + case 0: + return 0; + case 1: + n = (ptr[byte]); + break; + case 2: + n = (ptr[byte + 0] << 8) + ptr[byte + 1]; + break; + case 4: + n = (ptr[byte + 0] << 24) + (ptr[byte + 1] << 16) + (ptr[byte + 2] << 8) + (ptr[byte + 3]); + break; + default: + fatal (_("Unsupported read size: %d"), size); + } + + *idx += size * 8; + return n; +} + +static int +getBITS (unsigned char *ptr, int *idx, int size, int max) +{ + int byte = *idx / 8; + int bit = *idx % 8; + + if (byte >= max) + return 0; + + *idx += size; + + return (ptr[byte] >> (8 - bit - size)) & ((1 << size) - 1); +} + +static void +itheader (char *name, int icode) +{ + printf ("\n%s 0x%02x\n", name, icode); +} + +static int indent; + +static void +p (void) +{ + int i; + + for (i = 0; i < indent; i++) + printf ("| "); + + printf ("> "); +} + +static void +tabout (void) +{ + p (); +} + +static void +pbarray (barray *y) +{ + int x; + + printf ("%d (", y->len); + + for (x = 0; x < y->len; x++) + printf ("(%02x %c)", y->data[x], + ISPRINT (y->data[x]) ? y->data[x] : '.'); + + printf (")\n"); +} + +#define SYSROFF_PRINT +#define SYSROFF_SWAP_IN + +#include "sysroff.c" + +/* FIXME: sysinfo, which generates sysroff.[ch] from sysroff.info, can't + hack the special case of the tr block, which has no contents. So we + implement our own functions for reading in and printing out the tr + block. */ + +#define IT_tr_CODE 0x7f + +static void +sysroff_swap_tr_in (void) +{ + unsigned char raw[255]; + + memset (raw, 0, 255); + fillup (raw); +} + +static void +sysroff_print_tr_out (void) +{ + itheader ("tr", IT_tr_CODE); +} + +static int +getone (int type) +{ + int c = getc (file); + + code = c; + + if ((c & 0x7f) != type) + { + ungetc (c, file); + return 0; + } + + switch (c & 0x7f) + { + case IT_cs_CODE: + { + struct IT_cs dummy; + sysroff_swap_cs_in (&dummy); + sysroff_print_cs_out (&dummy); + } + break; + + case IT_dln_CODE: + { + struct IT_dln dummy; + sysroff_swap_dln_in (&dummy); + sysroff_print_dln_out (&dummy); + } + break; + + case IT_hd_CODE: + { + struct IT_hd dummy; + sysroff_swap_hd_in (&dummy); + addrsize = dummy.afl; + sysroff_print_hd_out (&dummy); + } + break; + + case IT_dar_CODE: + { + struct IT_dar dummy; + sysroff_swap_dar_in (&dummy); + sysroff_print_dar_out (&dummy); + } + break; + + case IT_dsy_CODE: + { + struct IT_dsy dummy; + sysroff_swap_dsy_in (&dummy); + sysroff_print_dsy_out (&dummy); + } + break; + + case IT_dfp_CODE: + { + struct IT_dfp dummy; + sysroff_swap_dfp_in (&dummy); + sysroff_print_dfp_out (&dummy); + } + break; + + case IT_dso_CODE: + { + struct IT_dso dummy; + sysroff_swap_dso_in (&dummy); + sysroff_print_dso_out (&dummy); + } + break; + + case IT_dpt_CODE: + { + struct IT_dpt dummy; + sysroff_swap_dpt_in (&dummy); + sysroff_print_dpt_out (&dummy); + } + break; + + case IT_den_CODE: + { + struct IT_den dummy; + sysroff_swap_den_in (&dummy); + sysroff_print_den_out (&dummy); + } + break; + + case IT_dbt_CODE: + { + struct IT_dbt dummy; + sysroff_swap_dbt_in (&dummy); + sysroff_print_dbt_out (&dummy); + } + break; + + case IT_dty_CODE: + { + struct IT_dty dummy; + sysroff_swap_dty_in (&dummy); + sysroff_print_dty_out (&dummy); + } + break; + + case IT_un_CODE: + { + struct IT_un dummy; + sysroff_swap_un_in (&dummy); + sysroff_print_un_out (&dummy); + } + break; + + case IT_sc_CODE: + { + struct IT_sc dummy; + sysroff_swap_sc_in (&dummy); + sysroff_print_sc_out (&dummy); + } + break; + + case IT_er_CODE: + { + struct IT_er dummy; + sysroff_swap_er_in (&dummy); + sysroff_print_er_out (&dummy); + } + break; + + case IT_ed_CODE: + { + struct IT_ed dummy; + sysroff_swap_ed_in (&dummy); + sysroff_print_ed_out (&dummy); + } + break; + + case IT_sh_CODE: + { + struct IT_sh dummy; + sysroff_swap_sh_in (&dummy); + sysroff_print_sh_out (&dummy); + } + break; + + case IT_ob_CODE: + { + struct IT_ob dummy; + sysroff_swap_ob_in (&dummy); + sysroff_print_ob_out (&dummy); + } + break; + + case IT_rl_CODE: + { + struct IT_rl dummy; + sysroff_swap_rl_in (&dummy); + sysroff_print_rl_out (&dummy); + } + break; + + case IT_du_CODE: + { + struct IT_du dummy; + sysroff_swap_du_in (&dummy); + + sysroff_print_du_out (&dummy); + } + break; + + case IT_dus_CODE: + { + struct IT_dus dummy; + sysroff_swap_dus_in (&dummy); + sysroff_print_dus_out (&dummy); + } + break; + + case IT_dul_CODE: + { + struct IT_dul dummy; + sysroff_swap_dul_in (&dummy); + sysroff_print_dul_out (&dummy); + } + break; + + case IT_dss_CODE: + { + struct IT_dss dummy; + sysroff_swap_dss_in (&dummy); + sysroff_print_dss_out (&dummy); + } + break; + + case IT_hs_CODE: + { + struct IT_hs dummy; + sysroff_swap_hs_in (&dummy); + sysroff_print_hs_out (&dummy); + } + break; + + case IT_dps_CODE: + { + struct IT_dps dummy; + sysroff_swap_dps_in (&dummy); + sysroff_print_dps_out (&dummy); + } + break; + + case IT_tr_CODE: + sysroff_swap_tr_in (); + sysroff_print_tr_out (); + break; + + case IT_dds_CODE: + { + struct IT_dds dummy; + + sysroff_swap_dds_in (&dummy); + sysroff_print_dds_out (&dummy); + } + break; + + default: + printf (_("GOT A %x\n"), c); + return 0; + break; + } + + return 1; +} + +static int +opt (int x) +{ + return getone (x); +} + +static void +must (int x) +{ + if (!getone (x)) + printf (_("WANTED %x!!\n"), x); +} + +static void +tab (int i, char *s) +{ + indent += i; + + if (s) + { + p (); + puts (s); + } +} + +static void +dump_symbol_info (void) +{ + tab (1, _("SYMBOL INFO")); + + while (opt (IT_dsy_CODE)) + { + if (opt (IT_dty_CODE)) + { + must (IT_dbt_CODE); + derived_type (); + must (IT_dty_CODE); + } + } + + tab (-1, ""); +} + +static void +derived_type (void) +{ + tab (1, _("DERIVED TYPE")); + + while (1) + { + if (opt (IT_dpp_CODE)) + { + dump_symbol_info (); + must (IT_dpp_CODE); + } + else if (opt (IT_dfp_CODE)) + { + dump_symbol_info (); + must (IT_dfp_CODE); + } + else if (opt (IT_den_CODE)) + { + dump_symbol_info (); + must (IT_den_CODE); + } + else if (opt (IT_den_CODE)) + { + dump_symbol_info (); + must (IT_den_CODE); + } + else if (opt (IT_dds_CODE)) + { + dump_symbol_info (); + must (IT_dds_CODE); + } + else if (opt (IT_dar_CODE)) + { + } + else if (opt (IT_dpt_CODE)) + { + } + else if (opt (IT_dul_CODE)) + { + } + else if (opt (IT_dse_CODE)) + { + } + else if (opt (IT_dot_CODE)) + { + } + else + break; + } + + tab (-1, ""); +} + +static void +module (void) +{ + int c = 0; + int l = 0; + + tab (1, _("MODULE***\n")); + + do + { + c = getc (file); + if (c == EOF) + break; + ungetc (c, file); + + c &= 0x7f; + } + while (getone (c) && c != IT_tr_CODE); + + tab (-1, ""); + + c = getc (file); + while (c != EOF) + { + printf ("%02x ", c); + l++; + if (l == 32) + { + printf ("\n"); + l = 0; + } + c = getc (file); + } +} + +char *program_name; + +ATTRIBUTE_NORETURN static void +show_usage (FILE *ffile, int status) +{ + fprintf (ffile, _("Usage: %s [option(s)] in-file\n"), program_name); + fprintf (ffile, _("Print a human readable interpretation of a SYSROFF object file\n")); + fprintf (ffile, _(" The options are:\n\ + -h --help Display this information\n\ + -v --version Print the program's version number\n")); + + if (REPORT_BUGS_TO[0] && status == 0) + fprintf (ffile, _("Report bugs to %s\n"), REPORT_BUGS_TO); + exit (status); +} + +int +main (int ac, char **av) +{ + char *input_file = NULL; + int option; + static struct option long_options[] = + { + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'V'}, + {NULL, no_argument, 0, 0} + }; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + program_name = av[0]; + xmalloc_set_program_name (program_name); + bfd_set_error_program_name (program_name); + + expandargv (&ac, &av); + + while ((option = getopt_long (ac, av, "HhVv", long_options, (int *) NULL)) != EOF) + { + switch (option) + { + case 'H': + case 'h': + show_usage (stdout, 0); + /*NOTREACHED*/ + case 'v': + case 'V': + print_version ("sysdump"); + exit (0); + /*NOTREACHED*/ + case 0: + break; + default: + show_usage (stderr, 1); + /*NOTREACHED*/ + } + } + + /* The input and output files may be named on the command line. */ + + if (optind < ac) + input_file = av[optind]; + + if (!input_file) + fatal (_("no input file specified")); + + file = fopen (input_file, FOPEN_RB); + + if (!file) + fatal (_("cannot open input file %s"), input_file); + + module (); + return 0; +} diff --git a/support/sdbinutils/binutils/sysinfo.c b/support/sdbinutils/binutils/sysinfo.c new file mode 100644 index 0000000..18ddb35 --- /dev/null +++ b/support/sdbinutils/binutils/sysinfo.c @@ -0,0 +1,1893 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "3.0.4" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* Copy the first part of user declarations. */ +#line 21 "sysinfo.y" /* yacc.c:339 */ + +#include +#include +#include + +static char writecode; +static char *it; +static int code; +static char * repeat; +static char *oldrepeat; +static char *name; +static int rdepth; +static char *names[] = {" ","[n]","[n][m]"}; +static char *pnames[]= {"","*","**"}; + +static int yyerror (char *s); +extern int yylex (void); + +#line 85 "sysinfo.c" /* yacc.c:339 */ + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* In a future release of Bison, this section will be replaced + by #include "y.tab.h". */ +#ifndef YY_YY_SYSINFO_H_INCLUDED +# define YY_YY_SYSINFO_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + COND = 258, + REPEAT = 259, + TYPE = 260, + NAME = 261, + NUMBER = 262, + UNIT = 263 + }; +#endif +/* Tokens. */ +#define COND 258 +#define REPEAT 259 +#define TYPE 260 +#define NAME 261 +#define NUMBER 262 +#define UNIT 263 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 41 "sysinfo.y" /* yacc.c:355 */ + + int i; + char *s; + +#line 146 "sysinfo.c" /* yacc.c:355 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_SYSINFO_H_INCLUDED */ + +/* Copy the second part of user declarations. */ + +#line 163 "sysinfo.c" /* yacc.c:358 */ + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 38 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 11 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 19 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 27 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 55 + +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 263 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 5, 6, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 7, 8, 9, 10 +}; + +#if YYDEBUG + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 55, 55, 55, 93, 94, 99, 98, 171, 172, + 173, 174, 178, 177, 228, 227, 257, 256, 367, 368, + 372, 377, 383, 384, 387, 388, 390, 392 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || 0 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "COND", "REPEAT", "'('", "')'", "TYPE", + "NAME", "NUMBER", "UNIT", "$accept", "top", "$@1", "it_list", "it", + "$@2", "it_field_list", "repeat_it_field", "$@3", "cond_it_field", "$@4", + "it_field", "$@5", "attr_type", "attr_desc", "attr_size", "attr_id", + "enums", "enum_list", YY_NULLPTR +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 40, 41, 260, 261, 262, + 263 +}; +# endif + +#define YYPACT_NINF -14 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-14))) + +#define YYTABLE_NINF -1 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int8 yypact[] = +{ + -14, 8, 4, -14, 2, -14, 4, 3, -14, -14, + 6, 0, 7, 6, 6, 6, 9, 10, 11, 15, + -14, -14, -14, -14, -14, -14, 16, 14, 6, 6, + -14, -14, 5, 17, 18, 19, 20, -14, -14, -14, + 22, 23, -14, 24, 27, -14, -14, 28, 1, -14, + 25, -14, 29, 30, -14 +}; + + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 0, 5, 1, 0, 3, 5, 0, 4, 6, + 11, 0, 0, 11, 11, 11, 0, 0, 0, 0, + 7, 10, 9, 8, 14, 12, 0, 19, 11, 11, + 20, 18, 0, 0, 0, 0, 0, 15, 13, 21, + 23, 0, 16, 0, 24, 22, 26, 0, 0, 17, + 0, 25, 0, 0, 27 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -14, -14, -14, 32, -14, -14, -13, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 1, 2, 5, 6, 10, 12, 13, 29, 14, + 28, 15, 44, 32, 19, 36, 42, 47, 48 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_uint8 yytable[] = +{ + 21, 22, 23, 16, 17, 18, 50, 51, 3, 4, + 7, 11, 9, 20, 35, 33, 34, 24, 25, 26, + 27, 31, 30, 37, 38, 0, 40, 41, 0, 39, + 45, 43, 46, 52, 49, 0, 54, 53, 8 +}; + +static const yytype_int8 yycheck[] = +{ + 13, 14, 15, 3, 4, 5, 5, 6, 0, 5, + 8, 5, 9, 6, 9, 28, 29, 8, 8, 8, + 5, 7, 6, 6, 6, -1, 6, 5, -1, 10, + 6, 8, 5, 8, 6, -1, 6, 8, 6 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 12, 13, 0, 5, 14, 15, 8, 14, 9, + 16, 5, 17, 18, 20, 22, 3, 4, 5, 25, + 6, 17, 17, 17, 8, 8, 8, 5, 21, 19, + 6, 7, 24, 17, 17, 9, 26, 6, 6, 10, + 6, 5, 27, 8, 23, 6, 5, 28, 29, 6, + 5, 6, 8, 8, 6 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 11, 13, 12, 14, 14, 16, 15, 17, 17, + 17, 17, 19, 18, 21, 20, 23, 22, 24, 24, + 25, 26, 27, 27, 28, 28, 29, 29 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 2, 2, 0, 0, 6, 2, 2, + 2, 0, 0, 6, 0, 6, 0, 10, 1, 0, + 3, 2, 3, 0, 0, 3, 0, 5 +}; + + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +{ + unsigned long int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +yystrlen (const char *yystr) +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +yystpcpy (char *yydest, const char *yysrc) +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +{ + YYUSE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 55 "sysinfo.y" /* yacc.c:1646 */ + { + switch (writecode) + { + case 'i': + printf("#ifdef SYSROFF_SWAP_IN\n"); + break; + case 'p': + printf("#ifdef SYSROFF_p\n"); + break; + case 'd': + break; + case 'g': + printf("#ifdef SYSROFF_SWAP_OUT\n"); + break; + case 'c': + printf("#ifdef SYSROFF_PRINT\n"); + printf("#include \n"); + printf("#include \n"); + printf("#include \n"); + break; + } + } +#line 1283 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 3: +#line 77 "sysinfo.y" /* yacc.c:1646 */ + { + switch (writecode) { + case 'i': + case 'p': + case 'g': + case 'c': + printf("#endif\n"); + break; + case 'd': + break; + } +} +#line 1300 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 6: +#line 99 "sysinfo.y" /* yacc.c:1646 */ + { + it = (yyvsp[-1].s); code = (yyvsp[0].i); + switch (writecode) + { + case 'd': + printf("\n\n\n#define IT_%s_CODE 0x%x\n", it,code); + printf("struct IT_%s;\n", it); + printf("extern void sysroff_swap_%s_in (struct IT_%s *);\n", + (yyvsp[-1].s), it); + printf("extern void sysroff_swap_%s_out (FILE *, struct IT_%s *);\n", + (yyvsp[-1].s), it); + printf("extern void sysroff_print_%s_out (struct IT_%s *);\n", + (yyvsp[-1].s), it); + printf("struct IT_%s { \n", it); + break; + case 'i': + printf("void sysroff_swap_%s_in (struct IT_%s * ptr)\n",(yyvsp[-1].s),it); + printf("{\n"); + printf("\tunsigned char raw[255];\n"); + printf("\tint idx = 0;\n"); + printf("\tint size;\n"); + printf("\tmemset(raw,0,255);\n"); + printf("\tmemset(ptr,0,sizeof(*ptr));\n"); + printf("\tsize = fillup(raw);\n"); + break; + case 'g': + printf("void sysroff_swap_%s_out (FILE * ffile, struct IT_%s * ptr)\n",(yyvsp[-1].s),it); + printf("{\n"); + printf("\tunsigned char raw[255];\n"); + printf("\tint idx = 16;\n"); + printf("\tmemset (raw, 0, 255);\n"); + printf("\tcode = IT_%s_CODE;\n", it); + break; + case 'o': + printf("void sysroff_swap_%s_out (bfd * abfd, struct IT_%s * ptr)\n",(yyvsp[-1].s), it); + printf("{\n"); + printf("\tint idx = 0;\n"); + break; + case 'c': + printf("void sysroff_print_%s_out (struct IT_%s *ptr)\n",(yyvsp[-1].s),it); + printf("{\n"); + printf("itheader(\"%s\", IT_%s_CODE);\n",(yyvsp[-1].s),(yyvsp[-1].s)); + break; + + case 't': + break; + } + + } +#line 1354 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 7: +#line 150 "sysinfo.y" /* yacc.c:1646 */ + { + switch (writecode) { + case 'd': + printf("};\n"); + break; + case 'g': + printf("\tchecksum(ffile,raw, idx, IT_%s_CODE);\n", it); + /* Fall through. */ + case 'i': + case 'o': + case 'c': + printf("}\n"); + } + + free (it); +} +#line 1375 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 12: +#line 178 "sysinfo.y" /* yacc.c:1646 */ + { + rdepth++; + switch (writecode) + { + case 'c': + if (rdepth==1) + printf("\tprintf(\"repeat %%d\\n\", %s);\n",(yyvsp[0].s)); + if (rdepth==2) + printf("\tprintf(\"repeat %%d\\n\", %s[n]);\n",(yyvsp[0].s)); + /* Fall through. */ + case 'i': + case 'g': + case 'o': + + if (rdepth==1) + { + printf("\t{ int n; for (n = 0; n < %s; n++) {\n", (yyvsp[0].s)); + } + if (rdepth == 2) { + printf("\t{ int m; for (m = 0; m < %s[n]; m++) {\n", (yyvsp[0].s)); + } + + break; + } + + oldrepeat = repeat; + repeat = (yyvsp[0].s); + } +#line 1408 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 13: +#line 209 "sysinfo.y" /* yacc.c:1646 */ + { + free (repeat); + + repeat = oldrepeat; + oldrepeat =0; + rdepth--; + switch (writecode) + { + case 'i': + case 'g': + case 'o': + case 'c': + printf("\t}}\n"); + } + } +#line 1428 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 14: +#line 228 "sysinfo.y" /* yacc.c:1646 */ + { + switch (writecode) + { + case 'i': + case 'g': + case 'o': + case 'c': + printf("\tif (%s) {\n", (yyvsp[0].s)); + break; + } + + free ((yyvsp[0].s)); + } +#line 1446 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 15: +#line 243 "sysinfo.y" /* yacc.c:1646 */ + { + switch (writecode) + { + case 'i': + case 'g': + case 'o': + case 'c': + printf("\t}\n"); + } + } +#line 1461 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 16: +#line 257 "sysinfo.y" /* yacc.c:1646 */ + {name = (yyvsp[0].s); } +#line 1467 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 17: +#line 259 "sysinfo.y" /* yacc.c:1646 */ + { + char *desc = (yyvsp[-8].s); + char *type = (yyvsp[-6].s); + int size = (yyvsp[-5].i); + char *id = (yyvsp[-3].s); +char *p = names[rdepth]; +char *ptr = pnames[rdepth]; + switch (writecode) + { + case 'g': + if (size % 8) + { + + printf("\twriteBITS(ptr->%s%s,raw,&idx,%d);\n", + id, + names[rdepth], size); + + } + else { + printf("\twrite%s(ptr->%s%s,raw,&idx,%d,ffile);\n", + type, + id, + names[rdepth],size/8); + } + break; + case 'i': + { + + if (rdepth >= 1) + + { + printf("if (!ptr->%s) ptr->%s = (%s*)xcalloc(%s, sizeof(ptr->%s[0]));\n", + id, + id, + type, + repeat, + id); + } + + if (rdepth == 2) + { + printf("if (!ptr->%s[n]) ptr->%s[n] = (%s**)xcalloc(%s[n], sizeof(ptr->%s[n][0]));\n", + id, + id, + type, + repeat, + id); + } + + } + + if (size % 8) + { + printf("\tptr->%s%s = getBITS(raw,&idx, %d,size);\n", + id, + names[rdepth], + size); + } + else { + printf("\tptr->%s%s = get%s(raw,&idx, %d,size);\n", + id, + names[rdepth], + type, + size/8); + } + break; + case 'o': + printf("\tput%s(raw,%d,%d,&idx,ptr->%s%s);\n", type,size/8,size%8,id,names[rdepth]); + break; + case 'd': + if (repeat) + printf("\t/* repeat %s */\n", repeat); + + if (type[0] == 'I') { + printf("\tint %s%s; \t/* %s */\n",ptr,id, desc); + } + else if (type[0] =='C') { + printf("\tchar %s*%s;\t /* %s */\n",ptr,id, desc); + } + else { + printf("\tbarray %s%s;\t /* %s */\n",ptr,id, desc); + } + break; + case 'c': + printf("tabout();\n"); + printf("\tprintf(\"/*%-30s*/ ptr->%s = \");\n", desc, id); + + if (type[0] == 'I') + printf("\tprintf(\"%%d\\n\",ptr->%s%s);\n", id,p); + else if (type[0] == 'C') + printf("\tprintf(\"%%s\\n\",ptr->%s%s);\n", id,p); + + else if (type[0] == 'B') + { + printf("\tpbarray(&ptr->%s%s);\n", id,p); + } + else abort(); + break; + } + + free (desc); + free (id); + } +#line 1575 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 18: +#line 367 "sysinfo.y" /* yacc.c:1646 */ + { (yyval.s) = (yyvsp[0].s); } +#line 1581 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 19: +#line 368 "sysinfo.y" /* yacc.c:1646 */ + { (yyval.s) = "INT";} +#line 1587 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 20: +#line 373 "sysinfo.y" /* yacc.c:1646 */ + { (yyval.s) = (yyvsp[-1].s); } +#line 1593 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 21: +#line 378 "sysinfo.y" /* yacc.c:1646 */ + { (yyval.i) = (yyvsp[-1].i) * (yyvsp[0].i); } +#line 1599 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 22: +#line 383 "sysinfo.y" /* yacc.c:1646 */ + { (yyval.s) = (yyvsp[-1].s); } +#line 1605 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 23: +#line 384 "sysinfo.y" /* yacc.c:1646 */ + { (yyval.s) = strdup ("dummy");} +#line 1611 "sysinfo.c" /* yacc.c:1646 */ + break; + + case 27: +#line 392 "sysinfo.y" /* yacc.c:1646 */ + { + switch (writecode) + { + case 'd': + printf("#define %s %s\n", (yyvsp[-2].s),(yyvsp[-1].s)); + break; + case 'c': + printf("if (ptr->%s%s == %s) { tabout(); printf(\"%s\\n\");}\n", name, names[rdepth],(yyvsp[-1].s),(yyvsp[-2].s)); + } + + free ((yyvsp[-2].s)); + free ((yyvsp[-1].s)); + } +#line 1629 "sysinfo.c" /* yacc.c:1646 */ + break; + + +#line 1633 "sysinfo.c" /* yacc.c:1646 */ + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} +#line 410 "sysinfo.y" /* yacc.c:1906 */ + +/* four modes + + -d write structure definitions for sysroff in host format + -i write functions to swap into sysroff format in + -o write functions to swap into sysroff format out + -c write code to print info in human form */ + +int yydebug; + +int +main (int ac, char **av) +{ + yydebug=0; + if (ac > 1) + writecode = av[1][1]; +if (writecode == 'd') + { + printf("typedef struct { unsigned char *data; int len; } barray; \n"); + printf("typedef int INT;\n"); + printf("typedef char * CHARS;\n"); + + } + yyparse(); +return 0; +} + +static int +yyerror (char *s) +{ + fprintf(stderr, "%s\n" , s); + return 0; +} diff --git a/support/sdbinutils/binutils/sysinfo.h b/support/sdbinutils/binutils/sysinfo.h new file mode 100644 index 0000000..3fb87c2 --- /dev/null +++ b/support/sdbinutils/binutils/sysinfo.h @@ -0,0 +1,87 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef YY_YY_SYSINFO_H_INCLUDED +# define YY_YY_SYSINFO_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + COND = 258, + REPEAT = 259, + TYPE = 260, + NAME = 261, + NUMBER = 262, + UNIT = 263 + }; +#endif +/* Tokens. */ +#define COND 258 +#define REPEAT 259 +#define TYPE 260 +#define NAME 261 +#define NUMBER 262 +#define UNIT 263 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 41 "sysinfo.y" /* yacc.c:1909 */ + + int i; + char *s; + +#line 75 "sysinfo.h" /* yacc.c:1909 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_SYSINFO_H_INCLUDED */ diff --git a/support/sdbinutils/binutils/sysinfo.y b/support/sdbinutils/binutils/sysinfo.y new file mode 100644 index 0000000..d0a0a63 --- /dev/null +++ b/support/sdbinutils/binutils/sysinfo.y @@ -0,0 +1,442 @@ +/* Copyright (C) 2001-2018 Free Software Foundation, Inc. + Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com). + + This file is part of GNU binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +%{ +#include +#include +#include + +static char writecode; +static char *it; +static int code; +static char * repeat; +static char *oldrepeat; +static char *name; +static int rdepth; +static char *names[] = {" ","[n]","[n][m]"}; +static char *pnames[]= {"","*","**"}; + +static int yyerror (char *s); +extern int yylex (void); +%} + + +%union { + int i; + char *s; +} +%token COND +%token REPEAT +%token '(' ')' +%token TYPE +%token NAME +%token NUMBER UNIT +%type attr_size +%type attr_desc attr_id attr_type +%% + +top: { + switch (writecode) + { + case 'i': + printf("#ifdef SYSROFF_SWAP_IN\n"); + break; + case 'p': + printf("#ifdef SYSROFF_p\n"); + break; + case 'd': + break; + case 'g': + printf("#ifdef SYSROFF_SWAP_OUT\n"); + break; + case 'c': + printf("#ifdef SYSROFF_PRINT\n"); + printf("#include \n"); + printf("#include \n"); + printf("#include \n"); + break; + } + } +it_list { + switch (writecode) { + case 'i': + case 'p': + case 'g': + case 'c': + printf("#endif\n"); + break; + case 'd': + break; + } +} + + ; + + +it_list: it it_list + | + ; + +it: + '(' NAME NUMBER + { + it = $2; code = $3; + switch (writecode) + { + case 'd': + printf("\n\n\n#define IT_%s_CODE 0x%x\n", it,code); + printf("struct IT_%s;\n", it); + printf("extern void sysroff_swap_%s_in (struct IT_%s *);\n", + $2, it); + printf("extern void sysroff_swap_%s_out (FILE *, struct IT_%s *);\n", + $2, it); + printf("extern void sysroff_print_%s_out (struct IT_%s *);\n", + $2, it); + printf("struct IT_%s { \n", it); + break; + case 'i': + printf("void sysroff_swap_%s_in (struct IT_%s * ptr)\n",$2,it); + printf("{\n"); + printf("\tunsigned char raw[255];\n"); + printf("\tint idx = 0;\n"); + printf("\tint size;\n"); + printf("\tmemset(raw,0,255);\n"); + printf("\tmemset(ptr,0,sizeof(*ptr));\n"); + printf("\tsize = fillup(raw);\n"); + break; + case 'g': + printf("void sysroff_swap_%s_out (FILE * ffile, struct IT_%s * ptr)\n",$2,it); + printf("{\n"); + printf("\tunsigned char raw[255];\n"); + printf("\tint idx = 16;\n"); + printf("\tmemset (raw, 0, 255);\n"); + printf("\tcode = IT_%s_CODE;\n", it); + break; + case 'o': + printf("void sysroff_swap_%s_out (bfd * abfd, struct IT_%s * ptr)\n",$2, it); + printf("{\n"); + printf("\tint idx = 0;\n"); + break; + case 'c': + printf("void sysroff_print_%s_out (struct IT_%s *ptr)\n",$2,it); + printf("{\n"); + printf("itheader(\"%s\", IT_%s_CODE);\n",$2,$2); + break; + + case 't': + break; + } + + } + it_field_list +')' +{ + switch (writecode) { + case 'd': + printf("};\n"); + break; + case 'g': + printf("\tchecksum(ffile,raw, idx, IT_%s_CODE);\n", it); + /* Fall through. */ + case 'i': + case 'o': + case 'c': + printf("}\n"); + } + + free (it); +} +; + + + +it_field_list: + it_field it_field_list + | cond_it_field it_field_list + | repeat_it_field it_field_list + | + ; + +repeat_it_field: '(' REPEAT NAME + { + rdepth++; + switch (writecode) + { + case 'c': + if (rdepth==1) + printf("\tprintf(\"repeat %%d\\n\", %s);\n",$3); + if (rdepth==2) + printf("\tprintf(\"repeat %%d\\n\", %s[n]);\n",$3); + /* Fall through. */ + case 'i': + case 'g': + case 'o': + + if (rdepth==1) + { + printf("\t{ int n; for (n = 0; n < %s; n++) {\n", $3); + } + if (rdepth == 2) { + printf("\t{ int m; for (m = 0; m < %s[n]; m++) {\n", $3); + } + + break; + } + + oldrepeat = repeat; + repeat = $3; + } + + it_field_list ')' + + { + free (repeat); + + repeat = oldrepeat; + oldrepeat =0; + rdepth--; + switch (writecode) + { + case 'i': + case 'g': + case 'o': + case 'c': + printf("\t}}\n"); + } + } + ; + + +cond_it_field: '(' COND NAME + { + switch (writecode) + { + case 'i': + case 'g': + case 'o': + case 'c': + printf("\tif (%s) {\n", $3); + break; + } + + free ($3); + } + + it_field_list ')' + { + switch (writecode) + { + case 'i': + case 'g': + case 'o': + case 'c': + printf("\t}\n"); + } + } + ; + +it_field: + '(' attr_desc '(' attr_type attr_size ')' attr_id + {name = $7; } + enums ')' + { + char *desc = $2; + char *type = $4; + int size = $5; + char *id = $7; +char *p = names[rdepth]; +char *ptr = pnames[rdepth]; + switch (writecode) + { + case 'g': + if (size % 8) + { + + printf("\twriteBITS(ptr->%s%s,raw,&idx,%d);\n", + id, + names[rdepth], size); + + } + else { + printf("\twrite%s(ptr->%s%s,raw,&idx,%d,ffile);\n", + type, + id, + names[rdepth],size/8); + } + break; + case 'i': + { + + if (rdepth >= 1) + + { + printf("if (!ptr->%s) ptr->%s = (%s*)xcalloc(%s, sizeof(ptr->%s[0]));\n", + id, + id, + type, + repeat, + id); + } + + if (rdepth == 2) + { + printf("if (!ptr->%s[n]) ptr->%s[n] = (%s**)xcalloc(%s[n], sizeof(ptr->%s[n][0]));\n", + id, + id, + type, + repeat, + id); + } + + } + + if (size % 8) + { + printf("\tptr->%s%s = getBITS(raw,&idx, %d,size);\n", + id, + names[rdepth], + size); + } + else { + printf("\tptr->%s%s = get%s(raw,&idx, %d,size);\n", + id, + names[rdepth], + type, + size/8); + } + break; + case 'o': + printf("\tput%s(raw,%d,%d,&idx,ptr->%s%s);\n", type,size/8,size%8,id,names[rdepth]); + break; + case 'd': + if (repeat) + printf("\t/* repeat %s */\n", repeat); + + if (type[0] == 'I') { + printf("\tint %s%s; \t/* %s */\n",ptr,id, desc); + } + else if (type[0] =='C') { + printf("\tchar %s*%s;\t /* %s */\n",ptr,id, desc); + } + else { + printf("\tbarray %s%s;\t /* %s */\n",ptr,id, desc); + } + break; + case 'c': + printf("tabout();\n"); + printf("\tprintf(\"/*%-30s*/ ptr->%s = \");\n", desc, id); + + if (type[0] == 'I') + printf("\tprintf(\"%%d\\n\",ptr->%s%s);\n", id,p); + else if (type[0] == 'C') + printf("\tprintf(\"%%s\\n\",ptr->%s%s);\n", id,p); + + else if (type[0] == 'B') + { + printf("\tpbarray(&ptr->%s%s);\n", id,p); + } + else abort(); + break; + } + + free (desc); + free (id); + } + + ; + + +attr_type: + TYPE { $$ = $1; } + | { $$ = "INT";} + ; + +attr_desc: + '(' NAME ')' + { $$ = $2; } + ; + +attr_size: + NUMBER UNIT + { $$ = $1 * $2; } + ; + + +attr_id: + '(' NAME ')' { $$ = $2; } + | { $$ = strdup ("dummy");} + ; + +enums: + | '(' enum_list ')' ; + +enum_list: + | + enum_list '(' NAME NAME ')' { + switch (writecode) + { + case 'd': + printf("#define %s %s\n", $3,$4); + break; + case 'c': + printf("if (ptr->%s%s == %s) { tabout(); printf(\"%s\\n\");}\n", name, names[rdepth],$4,$3); + } + + free ($3); + free ($4); + } + + ; + + + +%% +/* four modes + + -d write structure definitions for sysroff in host format + -i write functions to swap into sysroff format in + -o write functions to swap into sysroff format out + -c write code to print info in human form */ + +int yydebug; + +int +main (int ac, char **av) +{ + yydebug=0; + if (ac > 1) + writecode = av[1][1]; +if (writecode == 'd') + { + printf("typedef struct { unsigned char *data; int len; } barray; \n"); + printf("typedef int INT;\n"); + printf("typedef char * CHARS;\n"); + + } + yyparse(); +return 0; +} + +static int +yyerror (char *s) +{ + fprintf(stderr, "%s\n" , s); + return 0; +} diff --git a/support/sdbinutils/binutils/syslex.c b/support/sdbinutils/binutils/syslex.c new file mode 100644 index 0000000..0e26667 --- /dev/null +++ b/support/sdbinutils/binutils/syslex.c @@ -0,0 +1,1914 @@ + +#line 3 "syslex.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern int yyleng; + +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = NULL; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); + +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); + +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +#define yywrap() (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +FILE *yyin = NULL, *yyout = NULL; + +typedef int yy_state_type; + +extern int yylineno; +int yylineno = 1; + +extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; +#define YY_NUM_RULES 25 +#define YY_END_OF_BUFFER 26 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[81] = + { 0, + 0, 0, 26, 25, 7, 8, 5, 25, 1, 2, + 11, 11, 6, 3, 4, 25, 25, 25, 25, 25, + 25, 25, 0, 9, 11, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, + 13, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 12, 15, 0, 23, 0, 0, 0, 0, 0, + 0, 14, 18, 0, 0, 0, 0, 0, 17, 0, + 24, 0, 0, 0, 20, 22, 0, 21, 19, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 1, 5, 1, 1, 1, 1, 1, 6, + 7, 1, 1, 1, 1, 1, 1, 8, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 1, 10, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 11, 1, 12, 1, 1, 1, 13, 14, 15, 16, + + 17, 18, 19, 20, 21, 1, 1, 22, 1, 23, + 24, 25, 1, 26, 27, 28, 29, 30, 1, 31, + 32, 33, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static const YY_CHAR yy_meta[34] = + { 0, + 1, 1, 2, 1, 1, 1, 1, 3, 3, 1, + 1, 1, 3, 3, 3, 3, 3, 3, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1 + } ; + +static const flex_int16_t yy_base[84] = + { 0, + 0, 0, 100, 101, 101, 101, 101, 94, 101, 101, + 26, 28, 0, 101, 101, 82, 26, 18, 74, 79, + 78, 81, 88, 101, 32, 0, 0, 76, 65, 62, + 61, 75, 20, 59, 61, 66, 58, 0, 57, 56, + 54, 63, 53, 62, 54, 101, 59, 48, 53, 46, + 59, 101, 44, 43, 101, 41, 55, 46, 53, 44, + 31, 101, 101, 39, 27, 21, 39, 19, 101, 35, + 101, 33, 26, 29, 101, 101, 28, 101, 101, 101, + 58, 61, 41 + } ; + +static const flex_int16_t yy_def[84] = + { 0, + 80, 1, 80, 80, 80, 80, 80, 81, 80, 80, + 80, 80, 82, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 81, 80, 80, 83, 82, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 83, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 0, + 80, 80, 80 + } ; + +static const flex_int16_t yy_nxt[135] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 4, 4, 4, 4, 4, + 19, 4, 4, 4, 4, 20, 21, 4, 4, 22, + 4, 4, 4, 25, 25, 25, 25, 32, 29, 25, + 25, 33, 44, 38, 79, 78, 30, 77, 45, 76, + 75, 74, 73, 72, 71, 70, 26, 31, 23, 23, + 23, 27, 69, 27, 68, 67, 66, 65, 64, 63, + 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, + 52, 51, 50, 49, 48, 47, 46, 43, 42, 41, + 40, 39, 24, 37, 36, 35, 34, 28, 24, 80, + + 3, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80 + } ; + +static const flex_int16_t yy_chk[135] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 11, 11, 12, 12, 18, 17, 25, + 25, 18, 33, 83, 77, 74, 17, 73, 33, 72, + 70, 68, 67, 66, 65, 64, 11, 17, 81, 81, + 81, 82, 61, 82, 60, 59, 58, 57, 56, 54, + 53, 51, 50, 49, 48, 47, 45, 44, 43, 42, + 41, 40, 39, 37, 36, 35, 34, 32, 31, 30, + 29, 28, 23, 22, 21, 20, 19, 16, 8, 3, + + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int yy_flex_debug; +int yy_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "syslex.l" +#define YY_NO_INPUT 1 +#line 4 "syslex.l" +/* Copyright (C) 2001-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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 GLD; see the file COPYING. If not, write to the Free + Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Note: config.h is #included via syslex_wrap.c. */ + +#ifdef HAVE_STRING_H +#include +#else +#ifdef HAVE_STRINGS_H +#include +#endif +#endif + +#include "sysinfo.h" + +#ifndef YY_NO_UNPUT +#define YY_NO_UNPUT +#endif + +extern int yylex (void); +#line 534 "syslex.c" +#line 535 "syslex.c" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals ( void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( void ); + +int yyget_debug ( void ); + +void yyset_debug ( int debug_flag ); + +YY_EXTRA_TYPE yyget_extra ( void ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined ); + +FILE *yyget_in ( void ); + +void yyset_in ( FILE * _in_str ); + +FILE *yyget_out ( void ); + +void yyset_out ( FILE * _out_str ); + + int yyget_leng ( void ); + +char *yyget_text ( void ); + +int yyget_lineno ( void ); + +void yyset_lineno ( int _line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( void ); +#else +extern int yywrap ( void ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * ); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( void ); +#else +static int input ( void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + int n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex (void); + +#define YY_DECL int yylex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + { +#line 41 "syslex.l" + +#line 752 "syslex.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 81 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 101 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 42 "syslex.l" +{ return '(';} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 43 "syslex.l" +{ return ')';} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 44 "syslex.l" +{ return '[';} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 45 "syslex.l" +{ return ']';} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 46 "syslex.l" +{ ; } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 47 "syslex.l" +{ ; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 48 "syslex.l" +{ ; } + YY_BREAK +case 8: +/* rule 8 can match eol */ +YY_RULE_SETUP +#line 49 "syslex.l" +{ ; } + YY_BREAK +case 9: +/* rule 9 can match eol */ +YY_RULE_SETUP +#line 50 "syslex.l" +{ + yylval.s = malloc (yyleng - 1); + memcpy (yylval.s, yytext + 1, yyleng - 2); + yylval.s[yyleng - 2] = '\0'; + return NAME; + } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 57 "syslex.l" +{ + yylval.i = strtol(yytext,0,16); + return NUMBER; + } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 62 "syslex.l" +{ + yylval.i = atoi(yytext); + return NUMBER; + } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 68 "syslex.l" +{ yylval.i =1 ;return UNIT;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 69 "syslex.l" +{ yylval.i = 1; return UNIT;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 70 "syslex.l" +{ yylval.i= 8; return UNIT;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 71 "syslex.l" +{ yylval.i = 8; return UNIT;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 73 "syslex.l" +{ yylval.s = "INT"; return TYPE;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 74 "syslex.l" +{ yylval.s = "BARRAY"; return TYPE;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 75 "syslex.l" +{ yylval.s = "CHARS"; return TYPE;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 76 "syslex.l" +{ yylval.i = 0; return NUMBER;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 77 "syslex.l" +{ yylval.i = -4; return NUMBER;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 78 "syslex.l" +{ yylval.i = -2; return NUMBER; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 79 "syslex.l" +{ yylval.i = -1; return NUMBER; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 80 "syslex.l" +{ return COND;} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 81 "syslex.l" +{ return REPEAT;} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 82 "syslex.l" +ECHO; + YY_BREAK +#line 947 "syslex.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + yy_state_type yy_current_state; + char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 81 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + int yy_is_jam; + char *yy_cp = (yy_c_buf_p); + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 81 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 80); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yy_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf ); + + yyfree( (void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr ) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg ) +{ + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int yyget_lineno (void) +{ + + return yylineno; +} + +/** Get the input stream. + * + */ +FILE *yyget_in (void) +{ + return yyin; +} + +/** Get the output stream. + * + */ +FILE *yyget_out (void) +{ + return yyout; +} + +/** Get the length of the current token. + * + */ +int yyget_leng (void) +{ + return yyleng; +} + +/** Get the current token. + * + */ + +char *yyget_text (void) +{ + return yytext; +} + +/** Set the current line number. + * @param _line_number line number + * + */ +void yyset_lineno (int _line_number ) +{ + + yylineno = _line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str ) +{ + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str ) +{ + yyout = _out_str ; +} + +int yyget_debug (void) +{ + return yy_flex_debug; +} + +void yyset_debug (int _bdebug ) +{ + yy_flex_debug = _bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = NULL; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = NULL; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } + + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n ) +{ + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s ) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 82 "syslex.l" diff --git a/support/sdbinutils/binutils/syslex.l b/support/sdbinutils/binutils/syslex.l new file mode 100644 index 0000000..254f52e --- /dev/null +++ b/support/sdbinutils/binutils/syslex.l @@ -0,0 +1,81 @@ +%option noinput nounput noyywrap + +%{ +/* Copyright (C) 2001-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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 GLD; see the file COPYING. If not, write to the Free + Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Note: config.h is #included via syslex_wrap.c. */ + +#ifdef HAVE_STRING_H +#include +#else +#ifdef HAVE_STRINGS_H +#include +#endif +#endif + +#include "sysinfo.h" + +#ifndef YY_NO_UNPUT +#define YY_NO_UNPUT +#endif + +extern int yylex (void); +%} +%% +"(" { return '(';} +")" { return ')';} +"[" { return '[';} +"]" { return ']';} +" " { ; } +";".* { ; } +"\t" { ; } +"\n" { ; } +"\""[^\"]*"\"" { + yylval.s = malloc (yyleng - 1); + memcpy (yylval.s, yytext + 1, yyleng - 2); + yylval.s[yyleng - 2] = '\0'; + return NAME; + } + +0x[0-9a-f]+ { + yylval.i = strtol(yytext,0,16); + return NUMBER; + } + +[0-9]+ { + yylval.i = atoi(yytext); + return NUMBER; + } + + +"bits" { yylval.i =1 ;return UNIT;} +"bit" { yylval.i = 1; return UNIT;} +"bytes" { yylval.i= 8; return UNIT;} +"byte" { yylval.i = 8; return UNIT;} + +"int" { yylval.s = "INT"; return TYPE;} +"barray" { yylval.s = "BARRAY"; return TYPE;} +"chars" { yylval.s = "CHARS"; return TYPE;} +"variable" { yylval.i = 0; return NUMBER;} +"counted" { yylval.i = -4; return NUMBER;} +"addrsize" { yylval.i = -2; return NUMBER; } +"segsize" { yylval.i = -1; return NUMBER; } +"cond" { return COND;} +"repeat" { return REPEAT;} diff --git a/support/sdbinutils/binutils/syslex_wrap.c b/support/sdbinutils/binutils/syslex_wrap.c new file mode 100644 index 0000000..c5c07f6 --- /dev/null +++ b/support/sdbinutils/binutils/syslex_wrap.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2012-2018 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 3, 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., 51 Franklin Street - Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* Wrapper source to ensure that config.h is the first header file seen by + the compiler. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "syslex.c" diff --git a/support/sdbinutils/binutils/sysroff.h b/support/sdbinutils/binutils/sysroff.h new file mode 100644 index 0000000..8760153 --- /dev/null +++ b/support/sdbinutils/binutils/sysroff.h @@ -0,0 +1,684 @@ +typedef struct { unsigned char *data; int len; } barray; +typedef int INT; +typedef char * CHARS; + + + +#define IT_cs_CODE 0x0 +struct IT_cs; +extern void sysroff_swap_cs_in (struct IT_cs *); +extern void sysroff_swap_cs_out (FILE *, struct IT_cs *); +extern void sysroff_print_cs_out (struct IT_cs *); +struct IT_cs { + int size; /* size */ + int hd; /* hd */ + int hs; /* hs */ + int un; /* un */ + int us; /* us */ + int sc; /* sc */ + int ss; /* ss */ + int er; /* er */ + int ed; /* ed */ + int sh; /* sh */ + int ob; /* ob */ + int rl; /* rl */ + int du; /* du */ + int dps; /* dps */ + int dsy; /* dsy */ + int dty; /* dty */ + int dln; /* dln */ + int dso; /* dso */ + int dus; /* dus */ + int dss; /* dss */ + int dbt; /* dbt */ + int dpp; /* dpp */ + int dfp; /* dfp */ + int den; /* den */ + int dds; /* dds */ + int dar; /* dar */ + int dpt; /* dpt */ + int dul; /* dul */ + int dse; /* dse */ + int dot; /* dot */ +}; + + + +#define IT_hd_CODE 0x4 +struct IT_hd; +extern void sysroff_swap_hd_in (struct IT_hd *); +extern void sysroff_swap_hd_out (FILE *, struct IT_hd *); +extern void sysroff_print_hd_out (struct IT_hd *); +struct IT_hd { +#define MTYPE_ABS_LM 0 +#define MTYPE_REL_LM 1 +#define MTYPE_OMS_OR_LMS 2 +#define MTYPE_UNSPEC 0xf + int mt; /* module type */ + int spare1; /* spare */ + char *cd; /* creation date */ + int nu; /* number of units */ + int code; /* code */ + char *ver; /* version */ + int au; /* address update */ + int si; /* segment identifier */ + int afl; /* address field length */ + int spare2; /* spare */ + int spcsz; /* space size within segment */ + int segsz; /* segment size */ + int segsh; /* segment shift */ + int ep; /* entry point */ + int uan; /* unit appearance number */ + int sa; /* section appearance number */ + int sad; /* segment address */ + int address; /* address */ + char *os; /* os name */ + char *sys; /* sys name */ + char *mn; /* module name */ + char *cpu; /* cpu */ +}; + + + +#define IT_hs_CODE 0x5 +struct IT_hs; +extern void sysroff_swap_hs_in (struct IT_hs *); +extern void sysroff_swap_hs_out (FILE *, struct IT_hs *); +extern void sysroff_print_hs_out (struct IT_hs *); +struct IT_hs { + int neg; /* neg number */ +}; + + + +#define IT_un_CODE 0x6 +struct IT_un; +extern void sysroff_swap_un_in (struct IT_un *); +extern void sysroff_swap_un_out (FILE *, struct IT_un *); +extern void sysroff_print_un_out (struct IT_un *); +struct IT_un { +#define FORMAT_LM 0 +#define FORMAT_OM 1 +#define FORMAT_OMS_OR_LMS 2 + int format; /* format */ + int spare1; /* spare */ + int nsections; /* number of sections */ + int nextrefs; /* number of external refs */ + int nextdefs; /* number of external defs */ + char *name; /* unit name */ + char *tool; /* tool name */ + char *tcd; /* creation date */ + char *linker; /* linker name */ + char *lcd; /* creation date */ +}; + + + +#define IT_us_CODE 0x7 +struct IT_us; +extern void sysroff_swap_us_in (struct IT_us *); +extern void sysroff_swap_us_out (FILE *, struct IT_us *); +extern void sysroff_print_us_out (struct IT_us *); +struct IT_us { + int neg; /* negotiation number */ +}; + + + +#define IT_sc_CODE 0x8 +struct IT_sc; +extern void sysroff_swap_sc_in (struct IT_sc *); +extern void sysroff_swap_sc_out (FILE *, struct IT_sc *); +extern void sysroff_print_sc_out (struct IT_sc *); +struct IT_sc { + int format; /* format */ + int spare; /* spare */ + int segadd; /* segment address */ + int addr; /* address */ + int length; /* length */ + int align; /* alignment */ +#define CONTENTS_CODE 0 +#define CONTENTS_DATA 1 +#define CONTENTS_STACK 2 +#define CONTENTS_DUMMY 3 +#define CONTENTS_SPECIAL 4 +#define CONTENTS_NONSPEC 0xf + int contents; /* contents */ +#define CONCAT_SIMPLE 0 +#define CONCAT_SHAREDC 1 +#define CONCAT_DUMMY 2 +#define CONCAT_GROUP 3 +#define CONCAT_SHARED 4 +#define CONCAT_PRIVATE 5 +#define CONCAT_UNSPEC 0xf + int concat; /* concat */ + int read; /* read */ + int write; /* write */ + int exec; /* exec */ + int init; /* initialized */ + int mode; /* mode */ + int spare1; /* spare */ + char *name; /* name */ +}; + + + +#define IT_ss_CODE 0x9 +struct IT_ss; +extern void sysroff_swap_ss_in (struct IT_ss *); +extern void sysroff_swap_ss_out (FILE *, struct IT_ss *); +extern void sysroff_print_ss_out (struct IT_ss *); +struct IT_ss { + int neg; /* neg number */ +}; + + + +#define IT_er_CODE 0xc +struct IT_er; +extern void sysroff_swap_er_in (struct IT_er *); +extern void sysroff_swap_er_out (FILE *, struct IT_er *); +extern void sysroff_print_er_out (struct IT_er *); +struct IT_er { +#define ER_ENTRY 0 +#define ER_DATA 1 +#define ER_NOTDEF 2 +#define ER_NOTSPEC 3 + int type; /* symbol type */ + int spare; /* spare */ + char *name; /* symbol name */ +}; + + + +#define IT_ed_CODE 0x14 +struct IT_ed; +extern void sysroff_swap_ed_in (struct IT_ed *); +extern void sysroff_swap_ed_out (FILE *, struct IT_ed *); +extern void sysroff_print_ed_out (struct IT_ed *); +struct IT_ed { + int section; /* section appearance number */ +#define ED_TYPE_ENTRY 0 +#define ED_TYPE_DATA 1 +#define ED_TYPE_CONST 2 +#define ED_TYPE_NOTSPEC 7 + int type; /* symbol type */ + int spare; /* spare */ + int address; /* symbol address */ + int constant; /* constant value */ + char *name; /* symbol name */ +}; + + + +#define IT_sh_CODE 0x1a +struct IT_sh; +extern void sysroff_swap_sh_in (struct IT_sh *); +extern void sysroff_swap_sh_out (FILE *, struct IT_sh *); +extern void sysroff_print_sh_out (struct IT_sh *); +struct IT_sh { + int unit; /* unit appearance number */ + int section; /* section appearance number */ +}; + + + +#define IT_ob_CODE 0x1c +struct IT_ob; +extern void sysroff_swap_ob_in (struct IT_ob *); +extern void sysroff_swap_ob_out (FILE *, struct IT_ob *); +extern void sysroff_print_ob_out (struct IT_ob *); +struct IT_ob { + int saf; /* starting address flag */ + int cpf; /* compression flag */ + int spare; /* spare */ + int address; /* starting address */ + int compreps; /* comp reps */ + barray data; /* data */ +}; + + + +#define IT_rl_CODE 0x20 +struct IT_rl; +extern void sysroff_swap_rl_in (struct IT_rl *); +extern void sysroff_swap_rl_out (FILE *, struct IT_rl *); +extern void sysroff_print_rl_out (struct IT_rl *); +struct IT_rl { + int boundary; /* boundary of relocatable area */ + int apol; /* address polarity */ + int segment; /* segment number */ + int sign; /* sign of relocation */ + int check; /* check range */ + int addr; /* reloc address */ + int bitloc; /* bit loc */ + int flen; /* field length */ + int bcount; /* bcount */ +#define OP_RELOC_ADDR 1 +#define OP_SEC_REF 0 +#define OP_EXT_REF 2 + int op; /* operator */ + int symn; /* symbol number */ + int secn; /* section number */ + int copcode_is_3; /* const opcode */ + int alength_is_4; /* addend length */ + int addend; /* addend */ + int aopcode_is_0x20; /* plus opcode */ + int dunno; /* dunno */ + int end; /* end */ +}; + + + +#define IT_du_CODE 0x30 +struct IT_du; +extern void sysroff_swap_du_in (struct IT_du *); +extern void sysroff_swap_du_out (FILE *, struct IT_du *); +extern void sysroff_print_du_out (struct IT_du *); +struct IT_du { + int format; /* format */ + int optimized; /* optimized */ + int stackfrmt; /* stackfrmt */ + int spare; /* spare */ + int unit; /* unit number */ + int sections; /* sections */ + /* repeat ptr->sections */ + int *san; /* section appearance number */ + /* repeat ptr->sections */ + int *address; /* address */ + /* repeat ptr->sections */ + int *length; /* section length */ + char *tool; /* tool name */ + char *date; /* creation date */ +}; + + + +#define IT_dsy_CODE 0x34 +struct IT_dsy; +extern void sysroff_swap_dsy_in (struct IT_dsy *); +extern void sysroff_swap_dsy_out (FILE *, struct IT_dsy *); +extern void sysroff_print_dsy_out (struct IT_dsy *); +struct IT_dsy { +#define STYPE_VAR 0 +#define STYPE_LAB 1 +#define STYPE_PROC 2 +#define STYPE_FUNC 3 +#define STYPE_TYPE 4 +#define STYPE_CONST 5 +#define STYPE_ENTRY 6 +#define STYPE_MEMBER 7 +#define STYPE_ENUM 8 +#define STYPE_TAG 9 +#define STYPE_PACKAGE 10 +#define STYPE_GENERIC 11 +#define STYPE_TASK 12 +#define STYPE_EXCEPTION 13 +#define STYPE_PARAMETER 14 +#define STYPE_EQUATE 15 +#define STYPE_UNSPEC 0x7f + int type; /* symbol type */ + int assign; /* assignment info */ + int snumber; /* symbol id */ + char *sname; /* symbol name */ + int nesting; /* nesting level */ +#define AINFO_REG 1 +#define AINFO_STATIC_EXT_DEF 2 +#define AINFO_STATIC_EXT_REF 3 +#define AINFO_STATIC_INT 4 +#define AINFO_STATIC_COM 5 +#define AINFO_AUTO 6 +#define AINFO_CONST 7 +#define AINFO_UNSPEC 0xff + int ainfo; /* assignment type */ + int dlength; /* data length */ + int section; /* section number */ + int address; /* address */ + char *reg; /* register name */ + char *ename; /* external name */ + char *constant; /* constant */ + int bitunit; /* assignment unit */ + int spare2; /* spare */ + int field_len; /* field length */ + int field_off; /* field offset */ + int field_bitoff; /* bit offset */ + int evallen; /* value length */ + int evalue; /* value */ + char *cvalue; /* value */ + int qvallen; /* value length */ + int qvalue; /* value */ + int btype; /* basic type */ + int sizeinfo; /* size information */ + int sign; /* sign */ + int flt_type; /* floating point type */ + int sfn; /* source file number */ + int sln; /* source line number */ + int neg; /* negotiation number */ + int magic; /* magic */ +}; + + + +#define IT_dul_CODE 0x52 +struct IT_dul; +extern void sysroff_swap_dul_in (struct IT_dul *); +extern void sysroff_swap_dul_out (FILE *, struct IT_dul *); +extern void sysroff_print_dul_out (struct IT_dul *); +struct IT_dul { + int max_variable; /* max declaration type flag */ + int maxspare; /* max spare */ + int max; /* maximum */ + char *maxmode; /* max mode */ + int min_variable; /* min declaration type flag */ + int minspare; /* min spare */ + int min; /* minimum */ + char *minmode; /* min mode */ +}; + + + +#define IT_dty_CODE 0x36 +struct IT_dty; +extern void sysroff_swap_dty_in (struct IT_dty *); +extern void sysroff_swap_dty_out (FILE *, struct IT_dty *); +extern void sysroff_print_dty_out (struct IT_dty *); +struct IT_dty { + int end; /* end flag */ + int spare; /* spare */ + int neg; /* negotiation */ +}; + + + +#define IT_dbt_CODE 0x44 +struct IT_dbt; +extern void sysroff_swap_dbt_in (struct IT_dbt *); +extern void sysroff_swap_dbt_out (FILE *, struct IT_dbt *); +extern void sysroff_print_dbt_out (struct IT_dbt *); +struct IT_dbt { +#define BTYPE_VOID 0 +#define BTYPE_UNDEF 1 +#define BTYPE_CHAR 2 +#define BTYPE_INT 3 +#define BTYPE_FLOAT 4 +#define BTYPE_BIT 5 +#define BTYPE_STRING 6 +#define BTYPE_DECIMAL 7 +#define BTYPE_ENUM 8 +#define BTYPE_STRUCT 9 +#define BTYPE_TYPE 10 +#define BTYPE_TAG 11 +#define BTYPE_UNSPEC 0xff + int btype; /* basic type */ + int bitsize; /* size info */ +#define SIGN_SIGNED 0 +#define SIGN_UNSIGNED 1 +#define SIGN_UNSPEC 3 + int sign; /* sign */ +#define FPTYPE_SINGLE 0 +#define FPTYPE_DOUBLE 1 +#define FPTYPE_EXTENDED 2 +#define FPTYPE_NOTSPEC 0x3f + int fptype; /* floating point type */ + int sid; /* symbol id */ + int neg; /* negotiation */ +}; + + + +#define IT_dar_CODE 0x4e +struct IT_dar; +extern void sysroff_swap_dar_in (struct IT_dar *); +extern void sysroff_swap_dar_out (FILE *, struct IT_dar *); +extern void sysroff_print_dar_out (struct IT_dar *); +struct IT_dar { + int length; /* element length */ + int dims; /* dims */ +#define VARIABLE_FIXED 0 +#define VARIABLE_VARIABLE 1 + /* repeat ptr->dims */ + int *variable; /* variable flag */ +#define SUB_INTEGER 0 +#define SUB_TYPE 1 + /* repeat ptr->dims */ + int *subtype; /* subscript type */ + /* repeat ptr->dims */ + int *spare; /* spare */ + /* repeat ptr->dims */ + int *sid; /* sub symbol id */ + /* repeat ptr->dims */ + int *max_variable; /* max declaration type flag */ + /* repeat ptr->dims */ + int *maxspare; /* max spare */ + /* repeat ptr->dims */ + int *max; /* maximum */ + /* repeat ptr->dims */ + int *min_variable; /* min declaration type flag */ + /* repeat ptr->dims */ + int *minspare; /* min spare */ + /* repeat ptr->dims */ + int *min; /* minimum */ + int neg; /* negotiation */ +}; + + + +#define IT_dso_CODE 0x3a +struct IT_dso; +extern void sysroff_swap_dso_in (struct IT_dso *); +extern void sysroff_swap_dso_out (FILE *, struct IT_dso *); +extern void sysroff_print_dso_out (struct IT_dso *); +struct IT_dso { + int sid; /* function name */ + int spupdates; /* sp update count */ + /* repeat ptr->spupdates */ + int *address; /* update address */ + /* repeat ptr->spupdates */ + int *offset; /* offset */ +}; + + + +#define IT_dln_CODE 0x38 +struct IT_dln; +extern void sysroff_swap_dln_in (struct IT_dln *); +extern void sysroff_swap_dln_out (FILE *, struct IT_dln *); +extern void sysroff_print_dln_out (struct IT_dln *); +struct IT_dln { + int nln; /* number of lines */ + /* repeat ptr->nln */ + int *sfn; /* source file number */ + /* repeat ptr->nln */ + int *sln; /* source line number */ + /* repeat ptr->nln */ + int *section; /* section number */ + /* repeat ptr->nln */ + int *from_address; /* from address */ + /* repeat ptr->nln */ + int *to_address; /* to address */ + /* repeat ptr->nln */ + int *cc; /* call count */ + int neg; /* neg */ +}; + + + +#define IT_dpp_CODE 0x46 +struct IT_dpp; +extern void sysroff_swap_dpp_in (struct IT_dpp *); +extern void sysroff_swap_dpp_out (FILE *, struct IT_dpp *); +extern void sysroff_print_dpp_out (struct IT_dpp *); +struct IT_dpp { + int end; /* start/end */ + int spare; /* spare */ + int params; /* params */ + int neg; /* neg number */ +}; + + + +#define IT_den_CODE 0x4a +struct IT_den; +extern void sysroff_swap_den_in (struct IT_den *); +extern void sysroff_swap_den_out (FILE *, struct IT_den *); +extern void sysroff_print_den_out (struct IT_den *); +struct IT_den { + int end; /* start/end */ + int spare; /* spare */ + int neg; /* neg number */ +}; + + + +#define IT_dfp_CODE 0x48 +struct IT_dfp; +extern void sysroff_swap_dfp_in (struct IT_dfp *); +extern void sysroff_swap_dfp_out (FILE *, struct IT_dfp *); +extern void sysroff_print_dfp_out (struct IT_dfp *); +struct IT_dfp { + int end; /* start/end flag */ + int spare; /* spare */ + int nparams; /* number of parameters */ + int neg; /* neg number */ +}; + + + +#define IT_dds_CODE 0x4c +struct IT_dds; +extern void sysroff_swap_dds_in (struct IT_dds *); +extern void sysroff_swap_dds_out (FILE *, struct IT_dds *); +extern void sysroff_print_dds_out (struct IT_dds *); +struct IT_dds { + int end; /* start/end */ + int spare; /* spare */ + int neg; /* neg number */ +}; + + + +#define IT_dpt_CODE 0x50 +struct IT_dpt; +extern void sysroff_swap_dpt_in (struct IT_dpt *); +extern void sysroff_swap_dpt_out (FILE *, struct IT_dpt *); +extern void sysroff_print_dpt_out (struct IT_dpt *); +struct IT_dpt { + int neg; /* neg number */ + int dunno; /* dunno */ +}; + + + +#define IT_dse_CODE 0x54 +struct IT_dse; +extern void sysroff_swap_dse_in (struct IT_dse *); +extern void sysroff_swap_dse_out (FILE *, struct IT_dse *); +extern void sysroff_print_dse_out (struct IT_dse *); +struct IT_dse { + int neg; /* neg number */ + int dunno; /* dunno */ +}; + + + +#define IT_dot_CODE 0x56 +struct IT_dot; +extern void sysroff_swap_dot_in (struct IT_dot *); +extern void sysroff_swap_dot_out (FILE *, struct IT_dot *); +extern void sysroff_print_dot_out (struct IT_dot *); +struct IT_dot { + int unknown; /* unknown */ +}; + + + +#define IT_dss_CODE 0x42 +struct IT_dss; +extern void sysroff_swap_dss_in (struct IT_dss *); +extern void sysroff_swap_dss_out (FILE *, struct IT_dss *); +extern void sysroff_print_dss_out (struct IT_dss *); +struct IT_dss { + int type; /* type */ + int internal; /* external/internal */ + int spare; /* spare */ + char *package; /* package name */ + int id; /* symbol id */ + int record; /* record type */ + char *rules; /* rules */ + int nsymbols; /* number of symbols */ + int fixme; /* unknown */ +}; + + + +#define IT_pss_CODE 0x40 +struct IT_pss; +extern void sysroff_swap_pss_in (struct IT_pss *); +extern void sysroff_swap_pss_out (FILE *, struct IT_pss *); +extern void sysroff_print_pss_out (struct IT_pss *); +struct IT_pss { + int efn; /* negotiation number */ + int ns; /* number of source files */ + /* repeat ptr->ns */ + int *drb; /* directory reference bit */ + /* repeat ptr->ns */ + int *spare; /* spare */ + /* repeat ptr->ns */ + char **fname; /* completed file name */ + /* repeat ptr->ns */ + int *dan; /* directory apperance number */ + int ndir; /* number of directories */ + /* repeat ptr->ndir */ + char **dname; /* directory name */ +}; + + + +#define IT_dus_CODE 0x40 +struct IT_dus; +extern void sysroff_swap_dus_in (struct IT_dus *); +extern void sysroff_swap_dus_out (FILE *, struct IT_dus *); +extern void sysroff_print_dus_out (struct IT_dus *); +struct IT_dus { + int efn; /* negotiation number */ + int ns; /* number of source files */ + /* repeat ptr->ns */ + int *drb; /* directory reference bit */ + /* repeat ptr->ns */ + int *spare; /* spare */ + /* repeat ptr->ns */ + char **fname; /* completed file name */ + /* repeat ptr->ns */ + int *dan; /* directory apperance number */ + int ndir; /* number of directories */ + /* repeat ptr->ndir */ + char **dname; /* directory name */ +}; + + + +#define IT_dps_CODE 0x32 +struct IT_dps; +extern void sysroff_swap_dps_in (struct IT_dps *); +extern void sysroff_swap_dps_out (FILE *, struct IT_dps *); +extern void sysroff_print_dps_out (struct IT_dps *); +struct IT_dps { + int end; /* start/end flag */ +#define BLOCK_TYPE_COMPUNIT 0 +#define BLOCK_TYPE_PROCEDURE 2 +#define BLOCK_TYPE_FUNCTION 3 +#define BLOCK_TYPE_BLOCK 4 +#define BLOCK_TYPE_BASIC 9 + int type; /* block type */ + int opt; /* optimization */ + int san; /* section number */ + int address; /* address */ + int block_size; /* block size */ + int nesting; /* nesting */ + int retaddr; /* return address */ + int intrflag; /* interrupt function flag */ + int stackflag; /* stack update flag */ + int intrpagejmp; /* intra page JMP */ + int spare; /* spare */ + int neg; /* neg number */ +}; diff --git a/support/sdbinutils/binutils/sysroff.info b/support/sdbinutils/binutils/sysroff.info new file mode 100644 index 0000000..d821576 --- /dev/null +++ b/support/sdbinutils/binutils/sysroff.info @@ -0,0 +1,504 @@ +("cs" 0x0 + (("size") (1 byte) ("size")) + + (("hd") (1 byte) ("hd")) + (("hs") (1 byte) ("hs")) + (("un") (1 byte) ("un")) + (("us") (1 byte) ("us")) + + (("sc") (1 byte) ("sc")) + (("ss") (1 byte) ("ss")) + (("er") (1 byte) ("er")) + (("ed") (1 byte) ("ed")) + + (("sh") (1 byte) ("sh")) + (("ob") (1 byte) ("ob")) + (("rl") (1 byte) ("rl")) + (("du") (1 byte) ("du")) + + (("dps") (1 byte) ("dps")) + (("dsy") (1 byte) ("dsy")) + (("dty") (1 byte) ("dty")) + (("dln") (1 byte) ("dln")) + + (("dso") (1 byte) ("dso")) + (("dus") (1 byte) ("dus")) + (("dss") (1 byte) ("dss")) + (("dbt") (1 byte) ("dbt")) + + (("dpp") (1 byte) ("dpp")) + (("dfp") (1 byte) ("dfp")) + (("den") (1 byte) ("den")) + (("dds") (1 byte) ("dds")) + + (("dar") (1 byte) ("dar")) + (("dpt") (1 byte) ("dpt")) + (("dul") (1 byte) ("dul")) + (("dse") (1 byte) ("dse")) + + (("dot") (1 byte) ("dot"))) + + +("hd" 0x04 + (("module type") (4 bits) ("mt") + (("MTYPE_ABS_LM" "0") + ("MTYPE_REL_LM" "1") + ("MTYPE_OMS_OR_LMS" "2") + ("MTYPE_UNSPEC" "0xf"))) + (("spare")(4 bits) ("spare1")) + (("creation date")( chars 12 bytes)( "cd")) + (("number of units") (2 bytes) ("nu")) + (("code") (1 byte) ("code")) + (("version") (chars 4 bytes) ("ver")) + (("address update") (1 byte) ("au")) + (("segment identifier") (1 bit) ("si")) + (("address field length") (4 bits) ("afl")) + (("spare")(3 bits) ("spare2")) + (("space size within segment") (1 byte) ("spcsz")) + (("segment size") (1 byte) ("segsz")) + (("segment shift") (1 byte) ("segsh")) + (("entry point") (1 byte) ("ep")) + (cond "ptr->ep" + (cond "ptr->mt != MTYPE_ABS_LM" + (("unit appearance number") (2 bytes) ("uan")) + (("section appearance number") (2 bytes) ("sa"))) + (cond "segmented_p" + (("segment address") (segsize bytes) ("sad"))) + (("address") (addrsize bytes) ("address"))) + (("os name") (chars variable bytes) ("os")) + (("sys name") (chars variable bytes) ("sys")) + (("module name") (chars variable bytes) ("mn")) + (("cpu") (chars variable bytes) ("cpu"))) + + +("hs" 0x05 + (("neg number") (2 bytes) ("neg"))) + + +("un" 0x06 + (("format") (2 bits) ("format") + (("FORMAT_LM" "0") + ("FORMAT_OM" "1") + ("FORMAT_OMS_OR_LMS" "2"))) + (("spare") (6 bits) ("spare1")) + (("number of sections") (2 bytes) ("nsections")) + (("number of external refs") (2 bytes) ("nextrefs")) + (("number of external defs") (2 bytes) ("nextdefs")) + (("unit name") (chars variable byte) ("name")) + (("tool name") (chars variable byte) ("tool")) + (("creation date") (chars 12 bytes) ("tcd")) + (("linker name") (chars variable byte) ("linker")) + (("creation date") (chars 12 bytes) ("lcd"))) + + +("us" 0x07 + (("negotiation number") (2 bytes) ("neg"))) + + +("sc" 0x08 + (("format") (2 bits) ("format")) + (("spare") (6 bits) ("spare")) + (("segment address") (segsize bytes) ("segadd")) + (("address") (addrsize bytes) ("addr")) + (("length") (addrsize bytes) ("length")) + (("alignment") (addrsize bytes) ("align")) + (("contents") (4 bits) ("contents") + (("CONTENTS_CODE" "0") + ("CONTENTS_DATA" "1") + ("CONTENTS_STACK" "2") + ("CONTENTS_DUMMY" "3") + ("CONTENTS_SPECIAL" "4") + ("CONTENTS_NONSPEC" "0xf"))) + (("concat") (4 bits) ("concat") + (("CONCAT_SIMPLE" "0") + ("CONCAT_SHAREDC" "1") + ("CONCAT_DUMMY" "2") + ("CONCAT_GROUP" "3") + ("CONCAT_SHARED" "4") + ("CONCAT_PRIVATE" "5") + ("CONCAT_UNSPEC" "0xf"))) + (("read") (2 bits) ("read")) + (("write") (2 bits) ("write")) + (("exec") (2 bits) ("exec")) + (("initialized") (2 bits) ("init")) + (("mode") (2 bits) ("mode")) + (("spare") (6 bits) ("spare1")) + (("name") (chars variable byte) ("name"))) + + +("ss" 0x09 + (("neg number") (2 bytes) ("neg"))) + + +("er" 0x0c + (("symbol type") (2 bits) ("type") + (("ER_ENTRY" "0") + ("ER_DATA" "1") + ("ER_NOTDEF" "2") + ("ER_NOTSPEC" "3"))) + (("spare") (6 bits) ("spare")) + (("symbol name") (chars variable byte) ("name"))) + + +("ed" 0x14 + (("section appearance number") (2 bytes) ("section")) + (("symbol type") (3 bits) ("type") + (("ED_TYPE_ENTRY" "0") + ("ED_TYPE_DATA" "1") + ("ED_TYPE_CONST" "2") + ("ED_TYPE_NOTSPEC" "7"))) + (("spare") (5 bits) ("spare")) + (cond "ptr->type==ED_TYPE_ENTRY || ptr->type==ED_TYPE_DATA" + (("symbol address") (addrsize bytes) ("address"))) + (cond "ptr->type==ED_TYPE_CONST" + (("constant value") (addrsize bytes) ("constant"))) + (("symbol name") (chars variable byte) ("name"))) + + +("sh" 0x1a + (("unit appearance number") (2 bytes) ("unit")) + (("section appearance number") (2 bytes) ("section"))) + + +("ob" 0x1c + (("starting address flag") (1 bit) ("saf")) + (("compression flag") (1 bit) ("cpf")) + (("spare") (6 bits) ("spare")) + (cond "ptr->saf" + ( ("starting address") (addrsize bytes) ("address"))) + (cond "ptr->cpf" + (("comp reps") (addrsize bytes) ("compreps"))) + (("data") (barray counted byte) ("data"))) + + +("rl" 0x20 + (("boundary of relocatable area") (4 bits) ("boundary")) + (("address polarity") (1 bit) ("apol")) + (("segment number") (1 bit) ("segment")) + (("sign of relocation") (1 bit) ("sign")) + (("check range") (1 bit) ("check")) + (("reloc address") (addrsize bytes) ("addr")) + + (("bit loc") (1 byte) ("bitloc")) + (("field length") (1 byte) ("flen")) + (("bcount") (1 byte) ("bcount")) + (("operator") (1 byte) ("op") + (("OP_RELOC_ADDR" "1") + ("OP_SEC_REF" "0") + ("OP_EXT_REF" "2"))) + (cond "ptr->op == OP_EXT_REF" + (("symbol number") (2 bytes) ("symn")) ) + + (cond "ptr->op == OP_SEC_REF" + (("section number") (2 bytes) ("secn")) + (("const opcode") (1 byte) ("copcode_is_3")) + (("addend length") (1 byte) ("alength_is_4")) + (("addend") (4 byte) ("addend")) + (("plus opcode") (1 byte) ("aopcode_is_0x20"))) + + (cond "ptr->op == OP_RELOC_ADDR" + (("dunno") (2 bytes) ("dunno"))) + + (("end") (1 byte) ("end"))) + + +("du" 0x30 + (("format") (2 bits) ("format")) + (("optimized") (1 bit) ("optimized")) + (("stackfrmt") (2 bits) ("stackfrmt")) + (("spare") (3 bits) ("spare")) + (("unit number") (2 bytes) ("unit")) + (("sections") (2 bytes) ("sections")) + (repeat "ptr->sections" + (("section appearance number") (2 bytes) ("san")) + (("address") (addrsize bytes) ("address")) + (("section length") (addrsize bytes) ("length"))) + (("tool name") (chars variable byte) ("tool")) + (("creation date") (chars 12 bytes) ("date"))) + + +("dsy" 0x34 + (("symbol type") (7 bits) ("type") + (("STYPE_VAR" "0") + ("STYPE_LAB" "1") + ("STYPE_PROC" "2") + ("STYPE_FUNC" "3") + ("STYPE_TYPE" "4") + ("STYPE_CONST" "5") + ("STYPE_ENTRY" "6") + ("STYPE_MEMBER" "7") + ("STYPE_ENUM" "8") + ("STYPE_TAG" "9") + ("STYPE_PACKAGE" "10") + ("STYPE_GENERIC" "11") + ("STYPE_TASK" "12") + ("STYPE_EXCEPTION" "13") + ("STYPE_PARAMETER" "14") + ("STYPE_EQUATE" "15") + ("STYPE_UNSPEC" "0x7f"))) + (("assignment info") (1 bit) ("assign")) + (("symbol id") (2 bytes) ("snumber")) + (("symbol name") (chars variable bytes) ("sname")) + (("nesting level") (2 bytes) ("nesting")) + (cond "ptr->assign" + (("assignment type") (1 byte) ("ainfo") + (("AINFO_REG" "1") + ("AINFO_STATIC_EXT_DEF" "2") + ("AINFO_STATIC_EXT_REF" "3") + ("AINFO_STATIC_INT" "4") + ("AINFO_STATIC_COM" "5") + ("AINFO_AUTO" "6") + ("AINFO_CONST" "7") + ("AINFO_UNSPEC" "0xff"))) + (("data length") (addrsize bytes) ("dlength")) + (cond "ptr->ainfo == AINFO_STATIC_EXT_DEF + || ptr->ainfo == AINFO_STATIC_INT + || ptr->ainfo == AINFO_STATIC_COM" + (("section number") (2 bytes) ("section"))) + (cond "ptr->ainfo == AINFO_STATIC_EXT_DEF + || ptr->ainfo == AINFO_STATIC_INT + || ptr->ainfo == AINFO_STATIC_COM + || ptr->ainfo == AINFO_AUTO" + (("address") (addrsize bytes) ("address"))) + (cond "ptr->ainfo == AINFO_REG" + (("register name") (chars variable bytes) ("reg"))) + (cond "ptr->ainfo == AINFO_STATIC_EXT_DEF + || ptr->ainfo == AINFO_STATIC_EXT_REF" + (("external name") (chars variable bytes) ("ename"))) + (cond "ptr->ainfo == AINFO_CONST" + (("constant") (chars variable bytes) ("constant")))) + (cond "ptr->type == STYPE_MEMBER" + (("assignment unit") (1 bit) ("bitunit")) + (("spare") (7 bits) ("spare2")) + (("field length") (addrsize bytes) ("field_len")) + (("field offset") (addrsize bytes) ("field_off")) + (cond "ptr->bitunit" + (("bit offset") (addrsize bytes) ("field_bitoff")))) + (cond "ptr->type== STYPE_ENUM" + (("value length") (1 byte) ("evallen")) + (("value") (4 bytes) ("evalue"))) + (cond "ptr->type == STYPE_CONST" + (("value") (chars variable bytes) ("cvalue"))) + (cond "ptr->type == STYPE_EQUATE" + (("value length") (1 byte) ("qvallen")) + (("value") (4 bytes) ("qvalue")) + (("basic type") (1 byte) ("btype")) + (("size information") (addrsize bytes) ("sizeinfo")) + (("sign") (2 bits) ("sign")) + (("floating point type") (6 bits) ("flt_type"))) + (("source file number") (2 bytes) ("sfn")) + (("source line number") (2 bytes) ("sln")) + (("negotiation number") (2 bytes) ("neg")) + (cond "ptr->type == STYPE_TAG" + (("magic") (1 byte) ("magic")))) + + + +("dul" 0x52 + (("max declaration type flag") (1 bit) ("max_variable")) + (("max spare") (7 bits) ("maxspare")) + (cond "ptr->max_variable == 0" + (("maximum") (addrsize bytes) ("max")) + (("max mode") (chars variable bytes) ("maxmode"))) + + (("min declaration type flag") (1 bit) ("min_variable")) + (("min spare") (7 bits) ("minspare")) + (cond "ptr->min_variable == 0" + (("minimum") (addrsize bytes) ("min")) + (("min mode") (chars variable bytes) ("minmode")))) + + +("dty" 0x36 + (("end flag") (1 bit) ("end")) + (("spare") (7 bits) ("spare")) + (cond "!ptr->end" + (("negotiation") (2 bytes) ("neg")))) + + +("dbt" 0x44 + (("basic type") (1 byte) ("btype") + (("BTYPE_VOID" "0") + ("BTYPE_UNDEF" "1") + ("BTYPE_CHAR" "2") + ("BTYPE_INT" "3") + ("BTYPE_FLOAT" "4") + ("BTYPE_BIT" "5") + ("BTYPE_STRING" "6") + ("BTYPE_DECIMAL" "7") + ("BTYPE_ENUM" "8") + ("BTYPE_STRUCT" "9") + ("BTYPE_TYPE" "10") + ("BTYPE_TAG" "11") + ("BTYPE_UNSPEC" "0xff"))) + (("size info") (addrsize bytes) ("bitsize")) + (("sign") (2 bits) ("sign") + (("SIGN_SIGNED" "0") + ("SIGN_UNSIGNED" "1") + ("SIGN_UNSPEC" "3"))) + (("floating point type") (6 bits) ("fptype") + (("FPTYPE_SINGLE" "0") + ("FPTYPE_DOUBLE" "1") + ("FPTYPE_EXTENDED" "2") + ("FPTYPE_NOTSPEC" "0x3f"))) + (cond "ptr->btype==BTYPE_TAG || ptr->btype == BTYPE_TYPE" + (("symbol id") (2 bytes) ("sid"))) + (("negotiation") (2 bytes) ("neg"))) + +("dar" 0x4e + (("element length" ) (addrsize bytes) ("length")) + (("dims") (1 byte) ("dims")) + (repeat "ptr->dims" + (("variable flag") (1 bit) ("variable") + (("VARIABLE_FIXED" "0") + ("VARIABLE_VARIABLE" "1"))) + + (("subscript type") (1 bit) ("subtype") + (("SUB_INTEGER" "0") + ("SUB_TYPE" "1"))) + + (("spare") (6 bits) ("spare")) + + (cond "ptr->subtype[n] == SUB_TYPE" + (("sub symbol id") (2 bytes) ("sid"))) + + (cond "ptr->subtype[n] == SUB_INTEGER" + (("max declaration type flag") (1 bit) ("max_variable")) + (("max spare") (7 bits) ("maxspare")) + ;; FIXME: next field should be conditional on max_variable, + (("maximum") (addrsize bytes) ("max")) + + (("min declaration type flag") (1 bit) ("min_variable")) + (("min spare") (7 bits) ("minspare")) + ;; FIXME: next field should be conditional on min_variable + (("minimum") (addrsize bytes) ("min")))) + (("negotiation") (2 bytes) ("neg"))) + + +("dso" 0x3a + (("function name") (2 bytes) ("sid")) + (("sp update count") (4 bytes) ("spupdates")) + (repeat "ptr->spupdates" + (("update address") (addrsize bytes) ("address")) + (("offset") (addrsize bytes) ("offset")))) + +("dln" 0x38 + (("number of lines") (2 bytes) ("nln")) + (repeat "ptr->nln" + (("source file number") (2 bytes) ("sfn")) + (("source line number") (2 bytes) ("sln")) + (("section number") (2 bytes) ("section")) + (("from address") (addrsize bytes) ("from_address")) + (("to address") (addrsize bytes) ("to_address")) + (("call count") (2 bytes) ("cc")) + ) + (("neg") (2 bytes) ("neg"))) + +("dpp" 0x46 + (("start/end") (1 bit) ("end")) + (("spare") (7 bits) ("spare")) + (cond "!ptr->end" + (("params") (1 byte) ("params")) + (("neg number") (2 bytes) ("neg")))) + +("den" 0x4a + (("start/end") (1 bit) ("end")) + (("spare") (7 bits) ("spare")) + (cond "!ptr->end" + (("neg number") (2 bytes) ("neg")))) + +("dfp" 0x48 + (("start/end flag") (1 bit) ("end")) + (("spare") (7 bits) ("spare")) + (cond "!ptr->end" + (("number of parameters") (1 byte) ("nparams")) + (("neg number") (2 bytes) ("neg")))) + +("dds" 0x4c + (("start/end") (1 bit) ("end")) + (("spare") (7 bits) ("spare")) + (cond "!ptr->end" + (("neg number") (2 bytes) ("neg")))) + +("dpt" 0x50 + (("neg number") (2 bytes) ("neg")) + (("dunno") (1 byte) ("dunno"))) + +("dse" 0x54 + (("neg number") (2 bytes) ("neg")) + (("dunno") (1 byte) ("dunno"))) + +("dot" 0x56 + (("unknown") (1 byte) ("unknown"))) +; FIXME: unknown field should be repeated symbol number? + + +("dss" 0x42 + (("type") (1 byte) ("type")) + (("external/internal") (1 bit) ("internal")) + (("spare") (7 bits) ("spare")) + (cond "!ptr->internal" + ( ("package name") (chars variable byte) ("package"))) + (cond "ptr->internal" + (("symbol id") (2 bytes) ("id"))) + (("record type") (2 bytes) ("record")) + (("rules") (chars variable byte) ("rules")) + (("number of symbols") (2 bytes) ("nsymbols")) + (("unknown" ) (2 bytes) ("fixme"))) + +("pss" 0x40 + (("negotiation number") (2 bytes) ("efn")) + (("number of source files") (2 bytes) ("ns")) + (repeat "ptr->ns" + (("directory reference bit") (1 bit) ("drb")) + (("spare") (7 bits) ("spare")) + (("completed file name") (chars variable byte) ("fname")) + (cond "ptr->drb[n]" + (("directory apperance number") (2 bytes) ("dan")))) + + (("number of directories") (2 bytes) ("ndir")) + (repeat "ptr->ndir" + (("directory name") (chars variable bytes) ("dname")))) + + +; FIXME: the tr block has no contents. sysinfo, etc. aren't prepared +; to deal with that. +; ("tr" 0x7f) + + +("dus" 0x40 + (("negotiation number") (2 bytes) ("efn")) + (("number of source files") (2 bytes) ("ns")) + (repeat "ptr->ns" + (("directory reference bit") (1 bit) ("drb")) + (("spare") (7 bits) ("spare")) + (("completed file name") (chars variable byte) ("fname")) + (cond "ptr->drb[n]" + (("directory apperance number") (2 bytes) ("dan")))) + (("number of directories") (2 bytes) ("ndir")) + (repeat "ptr->ndir" + (("directory name") (chars variable bytes) ("dname")))) + + +("dps" 0x32 + (("start/end flag") (1 bit) ("end")) + (("block type") (7 bits) ("type") + (("BLOCK_TYPE_COMPUNIT" "0") + ("BLOCK_TYPE_PROCEDURE" "2") + ("BLOCK_TYPE_FUNCTION" "3") + ("BLOCK_TYPE_BLOCK" "4") + ("BLOCK_TYPE_BASIC" "9"))) + (cond "!ptr->end" + (("optimization") (1 byte) ("opt")) + (("section number") (2 bytes) ("san")) + (("address") (addrsize bytes) ("address")) + (("block size") (addrsize bytes) ("block_size")) + (("nesting") (1 byte) ("nesting")) + (cond "ptr->type == BLOCK_TYPE_PROCEDURE + || ptr->type == BLOCK_TYPE_FUNCTION" + (("return address") (1 bit) ("retaddr")) + (("interrupt function flag") (1 bit) ("intrflag")) + (("stack update flag") (1 bit) ("stackflag")) + (("intra page JMP") (1 bit) ("intrpagejmp")) + (("spare") (4 bits) ("spare"))) + (("neg number") (2 bytes) ("neg")))) + diff --git a/support/sdbinutils/binutils/unwind-ia64.c b/support/sdbinutils/binutils/unwind-ia64.c new file mode 100644 index 0000000..e98f9d3 --- /dev/null +++ b/support/sdbinutils/binutils/unwind-ia64.c @@ -0,0 +1,1073 @@ +/* unwind-ia64.c -- utility routines to dump IA-64 unwind info for readelf. + Copyright (C) 2000-2018 Free Software Foundation, Inc. + + Contributed by David Mosberger-Tang + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "config.h" +#include "unwind-ia64.h" +#include +#include + +#if __GNUC__ >= 2 +/* Define BFD64 here, even if our default architecture is 32 bit ELF + as this will allow us to read in and parse 64bit and 32bit ELF files. + Only do this if we believe that the compiler can support a 64 bit + data type. For now we only rely on GCC being able to do this. */ +#define BFD64 +#endif +#include "bfd.h" + +static bfd_vma unw_rlen = 0; + +static void unw_print_brmask (char *, unsigned int); +static void unw_print_grmask (char *, unsigned int); +static void unw_print_frmask (char *, unsigned int); +static void unw_print_abreg (char *, unsigned int); +static void unw_print_xyreg (char *, unsigned int, unsigned int); + +static void +unw_print_brmask (char *cp, unsigned int mask) +{ + int sep = 0; + int i; + + for (i = 0; mask && (i < 5); ++i) + { + if (mask & 1) + { + if (sep) + *cp++ = ','; + *cp++ = 'b'; + *cp++ = i + 1 + '0'; + sep = 1; + } + mask >>= 1; + } + *cp = '\0'; +} + +static void +unw_print_grmask (char *cp, unsigned int mask) +{ + int sep = 0; + int i; + + for (i = 0; i < 4; ++i) + { + if (mask & 1) + { + if (sep) + *cp++ = ','; + *cp++ = 'r'; + *cp++ = i + 4 + '0'; + sep = 1; + } + mask >>= 1; + } + *cp = '\0'; +} + +static void +unw_print_frmask (char *cp, unsigned int mask) +{ + int sep = 0; + int i; + + for (i = 0; i < 20; ++i) + { + if (mask & 1) + { + if (sep) + *cp++ = ','; + *cp++ = 'f'; + if (i < 4) + *cp++ = i + 2 + '0'; + else + { + *cp++ = (i + 2) / 10 + 1 + '0'; + *cp++ = (i + 2) % 10 + '0'; + } + sep = 1; + } + mask >>= 1; + } + *cp = '\0'; +} + +static void +unw_print_abreg (char *cp, unsigned int abreg) +{ + static const char * const special_reg[16] = + { + "pr", "psp", "@priunat", "rp", "ar.bsp", "ar.bspstore", "ar.rnat", + "ar.unat", "ar.fpsr", "ar.pfs", "ar.lc", + "Unknown11", "Unknown12", "Unknown13", "Unknown14", "Unknown15" + }; + + switch ((abreg >> 5) & 0x3) + { + case 0: /* gr */ + sprintf (cp, "r%u", (abreg & 0x1f)); + break; + + case 1: /* fr */ + sprintf (cp, "f%u", (abreg & 0x1f)); + break; + + case 2: /* br */ + sprintf (cp, "b%u", (abreg & 0x1f)); + break; + + case 3: /* special */ + strcpy (cp, special_reg[abreg & 0xf]); + break; + } +} + +static void +unw_print_xyreg (char *cp, unsigned int x, unsigned int ytreg) +{ + switch ((x << 1) | ((ytreg >> 7) & 1)) + { + case 0: /* gr */ + sprintf (cp, "r%u", (ytreg & 0x1f)); + break; + + case 1: /* fr */ + sprintf (cp, "f%u", (ytreg & 0x1f)); + break; + + case 2: /* br */ + sprintf (cp, "b%u", (ytreg & 0x1f)); + break; + } +} + +#define UNW_REG_BSP "bsp" +#define UNW_REG_BSPSTORE "bspstore" +#define UNW_REG_FPSR "fpsr" +#define UNW_REG_LC "lc" +#define UNW_REG_PFS "pfs" +#define UNW_REG_PR "pr" +#define UNW_REG_PSP "psp" +#define UNW_REG_RNAT "rnat" +#define UNW_REG_RP "rp" +#define UNW_REG_UNAT "unat" + +typedef bfd_vma unw_word; + +#define UNW_DEC_BAD_CODE(code) \ + printf ("Unknown code 0x%02x\n", code) + +#define UNW_DEC_PROLOGUE(fmt, body, rlen, arg) \ + do \ + { \ + unw_rlen = rlen; \ + *(int *)arg = body; \ + printf (" %s:%s(rlen=%lu)\n", \ + fmt, body ? "body" : "prologue", (unsigned long) rlen); \ + } \ + while (0) + +#define UNW_DEC_PROLOGUE_GR(fmt, rlen, mask, grsave, arg) \ + do \ + { \ + char regname[16], maskstr[64], *sep; \ + \ + unw_rlen = rlen; \ + *(int *)arg = 0; \ + \ + maskstr[0] = '\0'; \ + sep = ""; \ + if (mask & 0x8) \ + { \ + strcat (maskstr, "rp"); \ + sep = ","; \ + } \ + if (mask & 0x4) \ + { \ + strcat (maskstr, sep); \ + strcat (maskstr, "ar.pfs"); \ + sep = ","; \ + } \ + if (mask & 0x2) \ + { \ + strcat (maskstr, sep); \ + strcat (maskstr, "psp"); \ + sep = ","; \ + } \ + if (mask & 0x1) \ + { \ + strcat (maskstr, sep); \ + strcat (maskstr, "pr"); \ + } \ + sprintf (regname, "r%u", grsave); \ + printf (" %s:prologue_gr(mask=[%s],grsave=%s,rlen=%lu)\n", \ + fmt, maskstr, regname, (unsigned long) rlen); \ + } \ + while (0) + +#define UNW_DEC_FR_MEM(fmt, frmask, arg) \ + do \ + { \ + char frstr[200]; \ + \ + unw_print_frmask (frstr, frmask); \ + printf ("\t%s:fr_mem(frmask=[%s])\n", fmt, frstr); \ + } \ + while (0) + +#define UNW_DEC_GR_MEM(fmt, grmask, arg) \ + do \ + { \ + char grstr[200]; \ + \ + unw_print_grmask (grstr, grmask); \ + printf ("\t%s:gr_mem(grmask=[%s])\n", fmt, grstr); \ + } \ + while (0) + +#define UNW_DEC_FRGR_MEM(fmt, grmask, frmask, arg) \ + do \ + { \ + char frstr[200], grstr[20]; \ + \ + unw_print_grmask (grstr, grmask); \ + unw_print_frmask (frstr, frmask); \ + printf ("\t%s:frgr_mem(grmask=[%s],frmask=[%s])\n", fmt, grstr, frstr); \ + } \ + while (0) + +#define UNW_DEC_BR_MEM(fmt, brmask, arg) \ + do \ + { \ + char brstr[20]; \ + \ + unw_print_brmask (brstr, brmask); \ + printf ("\t%s:br_mem(brmask=[%s])\n", fmt, brstr); \ + } \ + while (0) + +#define UNW_DEC_BR_GR(fmt, brmask, gr, arg) \ + do \ + { \ + char brstr[20]; \ + \ + unw_print_brmask (brstr, brmask); \ + printf ("\t%s:br_gr(brmask=[%s],gr=r%u)\n", fmt, brstr, gr); \ + } \ + while (0) + +#define UNW_DEC_REG_GR(fmt, src, dst, arg) \ + printf ("\t%s:%s_gr(reg=r%u)\n", fmt, src, dst) + +#define UNW_DEC_RP_BR(fmt, dst, arg) \ + printf ("\t%s:rp_br(reg=b%u)\n", fmt, dst) + +#define UNW_DEC_REG_WHEN(fmt, reg, t, arg) \ + printf ("\t%s:%s_when(t=%lu)\n", fmt, reg, (unsigned long) t) + +#define UNW_DEC_REG_SPREL(fmt, reg, spoff, arg) \ + printf ("\t%s:%s_sprel(spoff=0x%lx)\n", \ + fmt, reg, 4*(unsigned long)spoff) + +#define UNW_DEC_REG_PSPREL(fmt, reg, pspoff, arg) \ + printf ("\t%s:%s_psprel(pspoff=0x10-0x%lx)\n", \ + fmt, reg, 4*(unsigned long)pspoff) + +#define UNW_DEC_GR_GR(fmt, grmask, gr, arg) \ + do \ + { \ + char grstr[20]; \ + \ + unw_print_grmask (grstr, grmask); \ + printf ("\t%s:gr_gr(grmask=[%s],r%u)\n", fmt, grstr, gr); \ + } \ + while (0) + +#define UNW_DEC_ABI(fmt, abi, context, arg) \ + do \ + { \ + static const char * const abiname[] = \ + { \ + "@svr4", "@hpux", "@nt" \ + }; \ + char buf[20]; \ + const char *abistr = buf; \ + \ + if (abi < 3) \ + abistr = abiname[abi]; \ + else \ + sprintf (buf, "0x%x", abi); \ + printf ("\t%s:unwabi(abi=%s,context=0x%02x)\n", \ + fmt, abistr, context); \ + } \ + while (0) + +#define UNW_DEC_PRIUNAT_GR(fmt, r, arg) \ + printf ("\t%s:priunat_gr(reg=r%u)\n", fmt, r) + +#define UNW_DEC_PRIUNAT_WHEN_GR(fmt, t, arg) \ + printf ("\t%s:priunat_when_gr(t=%lu)\n", fmt, (unsigned long) t) + +#define UNW_DEC_PRIUNAT_WHEN_MEM(fmt, t, arg) \ + printf ("\t%s:priunat_when_mem(t=%lu)\n", fmt, (unsigned long) t) + +#define UNW_DEC_PRIUNAT_PSPREL(fmt, pspoff, arg) \ + printf ("\t%s:priunat_psprel(pspoff=0x10-0x%lx)\n", \ + fmt, 4*(unsigned long)pspoff) + +#define UNW_DEC_PRIUNAT_SPREL(fmt, spoff, arg) \ + printf ("\t%s:priunat_sprel(spoff=0x%lx)\n", \ + fmt, 4*(unsigned long)spoff) + +#define UNW_DEC_MEM_STACK_F(fmt, t, size, arg) \ + printf ("\t%s:mem_stack_f(t=%lu,size=%lu)\n", \ + fmt, (unsigned long) t, 16*(unsigned long)size) + +#define UNW_DEC_MEM_STACK_V(fmt, t, arg) \ + printf ("\t%s:mem_stack_v(t=%lu)\n", fmt, (unsigned long) t) + +#define UNW_DEC_SPILL_BASE(fmt, pspoff, arg) \ + printf ("\t%s:spill_base(pspoff=0x10-0x%lx)\n", \ + fmt, 4*(unsigned long)pspoff) + +#define UNW_DEC_SPILL_MASK(fmt, dp, arg, end) \ + do \ + { \ + static const char *spill_type = "-frb"; \ + unsigned const char *imaskp = dp; \ + unsigned char mask = 0; \ + bfd_vma insn = 0; \ + \ + /* PR 18420. */ \ + if ((dp + (unw_rlen / 4)) > end) \ + { \ + printf ("\nERROR: unwind length too long (0x%lx > 0x%lx)\n\n",\ + (long) (unw_rlen / 4), (long)(end - dp)); \ + /* FIXME: Should we reset unw_rlen ? */ \ + break; \ + } \ + printf ("\t%s:spill_mask(imask=[", fmt); \ + for (insn = 0; insn < unw_rlen; ++insn) \ + { \ + if ((insn % 4) == 0) \ + mask = *imaskp++; \ + if (insn > 0 && (insn % 3) == 0) \ + putchar (','); \ + putchar (spill_type[(mask >> (2 * (3 - (insn & 0x3)))) & 0x3]); \ + } \ + printf ("])\n"); \ + dp = imaskp; \ + } \ + while (0) + +#define UNW_DEC_SPILL_SPREL(fmt, t, abreg, spoff, arg) \ + do \ + { \ + char regname[20]; \ + \ + unw_print_abreg (regname, abreg); \ + printf ("\t%s:spill_sprel(reg=%s,t=%lu,spoff=0x%lx)\n", \ + fmt, regname, (unsigned long) t, 4*(unsigned long)off); \ + } \ + while (0) + +#define UNW_DEC_SPILL_PSPREL(fmt, t, abreg, pspoff, arg) \ + do \ + { \ + char regname[20]; \ + \ + unw_print_abreg (regname, abreg); \ + printf ("\t%s:spill_psprel(reg=%s,t=%lu,pspoff=0x10-0x%lx)\n", \ + fmt, regname, (unsigned long) t, 4*(unsigned long)pspoff); \ + } \ + while (0) + +#define UNW_DEC_RESTORE(fmt, t, abreg, arg) \ + do \ + { \ + char regname[20]; \ + \ + unw_print_abreg (regname, abreg); \ + printf ("\t%s:restore(t=%lu,reg=%s)\n", \ + fmt, (unsigned long) t, regname); \ + } \ + while (0) + +#define UNW_DEC_SPILL_REG(fmt, t, abreg, x, ytreg, arg) \ + do \ + { \ + char abregname[20], tregname[20]; \ + \ + unw_print_abreg (abregname, abreg); \ + unw_print_xyreg (tregname, x, ytreg); \ + printf ("\t%s:spill_reg(t=%lu,reg=%s,treg=%s)\n", \ + fmt, (unsigned long) t, abregname, tregname); \ + } \ + while (0) + +#define UNW_DEC_SPILL_SPREL_P(fmt, qp, t, abreg, spoff, arg) \ + do \ + { \ + char regname[20]; \ + \ + unw_print_abreg (regname, abreg); \ + printf ("\t%s:spill_sprel_p(qp=p%u,t=%lu,reg=%s,spoff=0x%lx)\n", \ + fmt, qp, (unsigned long) t, regname, 4 * (unsigned long)spoff); \ + } \ + while (0) + +#define UNW_DEC_SPILL_PSPREL_P(fmt, qp, t, abreg, pspoff, arg) \ + do \ + { \ + char regname[20]; \ + \ + unw_print_abreg (regname, abreg); \ + printf ("\t%s:spill_psprel_p(qp=p%u,t=%lu,reg=%s,pspoff=0x10-0x%lx)\n",\ + fmt, qp, (unsigned long) t, regname, 4*(unsigned long)pspoff);\ + } \ + while (0) + +#define UNW_DEC_RESTORE_P(fmt, qp, t, abreg, arg) \ + do \ + { \ + char regname[20]; \ + \ + unw_print_abreg (regname, abreg); \ + printf ("\t%s:restore_p(qp=p%u,t=%lu,reg=%s)\n", \ + fmt, qp, (unsigned long) t, regname); \ + } \ + while (0) + +#define UNW_DEC_SPILL_REG_P(fmt, qp, t, abreg, x, ytreg, arg) \ + do \ + { \ + char regname[20], tregname[20]; \ + \ + unw_print_abreg (regname, abreg); \ + unw_print_xyreg (tregname, x, ytreg); \ + printf ("\t%s:spill_reg_p(qp=p%u,t=%lu,reg=%s,treg=%s)\n", \ + fmt, qp, (unsigned long) t, regname, tregname); \ + } \ + while (0) + +#define UNW_DEC_LABEL_STATE(fmt, label, arg) \ + printf ("\t%s:label_state(label=%lu)\n", fmt, (unsigned long) label) + +#define UNW_DEC_COPY_STATE(fmt, label, arg) \ + printf ("\t%s:copy_state(label=%lu)\n", fmt, (unsigned long) label) + +#define UNW_DEC_EPILOGUE(fmt, t, ecount, arg) \ + printf ("\t%s:epilogue(t=%lu,ecount=%lu)\n", \ + fmt, (unsigned long) t, (unsigned long) ecount) + +/* + * Generic IA-64 unwind info decoder. + * + * This file is used both by the Linux kernel and objdump. Please + * keep the two copies of this file in sync (modulo differences in the + * prototypes...). + * + * You need to customize the decoder by defining the following + * macros/constants before including this file: + * + * Types: + * unw_word Unsigned integer type with at least 64 bits + * + * Register names: + * UNW_REG_BSP + * UNW_REG_BSPSTORE + * UNW_REG_FPSR + * UNW_REG_LC + * UNW_REG_PFS + * UNW_REG_PR + * UNW_REG_RNAT + * UNW_REG_PSP + * UNW_REG_RP + * UNW_REG_UNAT + * + * Decoder action macros: + * UNW_DEC_BAD_CODE(code) + * UNW_DEC_ABI(fmt,abi,context,arg) + * UNW_DEC_BR_GR(fmt,brmask,gr,arg) + * UNW_DEC_BR_MEM(fmt,brmask,arg) + * UNW_DEC_COPY_STATE(fmt,label,arg) + * UNW_DEC_EPILOGUE(fmt,t,ecount,arg) + * UNW_DEC_FRGR_MEM(fmt,grmask,frmask,arg) + * UNW_DEC_FR_MEM(fmt,frmask,arg) + * UNW_DEC_GR_GR(fmt,grmask,gr,arg) + * UNW_DEC_GR_MEM(fmt,grmask,arg) + * UNW_DEC_LABEL_STATE(fmt,label,arg) + * UNW_DEC_MEM_STACK_F(fmt,t,size,arg) + * UNW_DEC_MEM_STACK_V(fmt,t,arg) + * UNW_DEC_PRIUNAT_GR(fmt,r,arg) + * UNW_DEC_PRIUNAT_WHEN_GR(fmt,t,arg) + * UNW_DEC_PRIUNAT_WHEN_MEM(fmt,t,arg) + * UNW_DEC_PRIUNAT_WHEN_PSPREL(fmt,pspoff,arg) + * UNW_DEC_PRIUNAT_WHEN_SPREL(fmt,spoff,arg) + * UNW_DEC_PROLOGUE(fmt,body,rlen,arg) + * UNW_DEC_PROLOGUE_GR(fmt,rlen,mask,grsave,arg) + * UNW_DEC_REG_PSPREL(fmt,reg,pspoff,arg) + * UNW_DEC_REG_REG(fmt,src,dst,arg) + * UNW_DEC_REG_SPREL(fmt,reg,spoff,arg) + * UNW_DEC_REG_WHEN(fmt,reg,t,arg) + * UNW_DEC_RESTORE(fmt,t,abreg,arg) + * UNW_DEC_RESTORE_P(fmt,qp,t,abreg,arg) + * UNW_DEC_SPILL_BASE(fmt,pspoff,arg) + * UNW_DEC_SPILL_MASK(fmt,imaskp,arg) + * UNW_DEC_SPILL_PSPREL(fmt,t,abreg,pspoff,arg) + * UNW_DEC_SPILL_PSPREL_P(fmt,qp,t,abreg,pspoff,arg) + * UNW_DEC_SPILL_REG(fmt,t,abreg,x,ytreg,arg) + * UNW_DEC_SPILL_REG_P(fmt,qp,t,abreg,x,ytreg,arg) + * UNW_DEC_SPILL_SPREL(fmt,t,abreg,spoff,arg) + * UNW_DEC_SPILL_SPREL_P(fmt,qp,t,abreg,pspoff,arg) + */ + +static unw_word +unw_decode_uleb128 (const unsigned char **dpp) +{ + unsigned shift = 0; + unw_word byte, result = 0; + const unsigned char *bp = *dpp; + + while (1) + { + byte = *bp++; + result |= (byte & 0x7f) << shift; + + if ((byte & 0x80) == 0) + break; + + shift += 7; + } + + *dpp = bp; + + return result; +} + +static const unsigned char * +unw_decode_x1 (const unsigned char *dp, unsigned int code ATTRIBUTE_UNUSED, + void *arg ATTRIBUTE_UNUSED) +{ + unsigned char byte1, abreg; + unw_word t, off; + + byte1 = *dp++; + t = unw_decode_uleb128 (&dp); + off = unw_decode_uleb128 (&dp); + abreg = (byte1 & 0x7f); + if (byte1 & 0x80) + UNW_DEC_SPILL_SPREL ("X1", t, abreg, off, arg); + else + UNW_DEC_SPILL_PSPREL ("X1", t, abreg, off, arg); + return dp; +} + +static const unsigned char * +unw_decode_x2 (const unsigned char *dp, unsigned int code ATTRIBUTE_UNUSED, + void *arg ATTRIBUTE_UNUSED) +{ + unsigned char byte1, byte2, abreg, x, ytreg; + unw_word t; + + byte1 = *dp++; + byte2 = *dp++; + t = unw_decode_uleb128 (&dp); + abreg = (byte1 & 0x7f); + ytreg = byte2; + x = (byte1 >> 7) & 1; + if ((byte1 & 0x80) == 0 && ytreg == 0) + UNW_DEC_RESTORE ("X2", t, abreg, arg); + else + UNW_DEC_SPILL_REG ("X2", t, abreg, x, ytreg, arg); + return dp; +} + +static const unsigned char * +unw_decode_x3 (const unsigned char *dp, unsigned int code ATTRIBUTE_UNUSED, + void *arg ATTRIBUTE_UNUSED) +{ + unsigned char byte1, byte2, abreg, qp; + unw_word t, off; + + byte1 = *dp++; + byte2 = *dp++; + t = unw_decode_uleb128 (&dp); + off = unw_decode_uleb128 (&dp); + + qp = (byte1 & 0x3f); + abreg = (byte2 & 0x7f); + + if (byte1 & 0x80) + UNW_DEC_SPILL_SPREL_P ("X3", qp, t, abreg, off, arg); + else + UNW_DEC_SPILL_PSPREL_P ("X3", qp, t, abreg, off, arg); + return dp; +} + +static const unsigned char * +unw_decode_x4 (const unsigned char *dp, unsigned int code ATTRIBUTE_UNUSED, + void *arg ATTRIBUTE_UNUSED) +{ + unsigned char byte1, byte2, byte3, qp, abreg, x, ytreg; + unw_word t; + + byte1 = *dp++; + byte2 = *dp++; + byte3 = *dp++; + t = unw_decode_uleb128 (&dp); + + qp = (byte1 & 0x3f); + abreg = (byte2 & 0x7f); + x = (byte2 >> 7) & 1; + ytreg = byte3; + + if ((byte2 & 0x80) == 0 && byte3 == 0) + UNW_DEC_RESTORE_P ("X4", qp, t, abreg, arg); + else + UNW_DEC_SPILL_REG_P ("X4", qp, t, abreg, x, ytreg, arg); + return dp; +} + +static const unsigned char * +unw_decode_r1 (const unsigned char *dp, unsigned int code, void *arg, + const unsigned char * end ATTRIBUTE_UNUSED) +{ + int body = (code & 0x20) != 0; + unw_word rlen; + + rlen = (code & 0x1f); + UNW_DEC_PROLOGUE ("R1", body, rlen, arg); + return dp; +} + +static const unsigned char * +unw_decode_r2 (const unsigned char *dp, unsigned int code, void *arg, + const unsigned char * end ATTRIBUTE_UNUSED) +{ + unsigned char byte1, mask, grsave; + unw_word rlen; + + byte1 = *dp++; + + mask = ((code & 0x7) << 1) | ((byte1 >> 7) & 1); + grsave = (byte1 & 0x7f); + rlen = unw_decode_uleb128 (& dp); + UNW_DEC_PROLOGUE_GR ("R2", rlen, mask, grsave, arg); + return dp; +} + +static const unsigned char * +unw_decode_r3 (const unsigned char *dp, unsigned int code, void *arg, + const unsigned char * end ATTRIBUTE_UNUSED) +{ + unw_word rlen; + + rlen = unw_decode_uleb128 (& dp); + UNW_DEC_PROLOGUE ("R3", ((code & 0x3) == 1), rlen, arg); + return dp; +} + +static const unsigned char * +unw_decode_p1 (const unsigned char *dp, unsigned int code, + void *arg ATTRIBUTE_UNUSED, + const unsigned char * end ATTRIBUTE_UNUSED) +{ + unsigned char brmask = (code & 0x1f); + + UNW_DEC_BR_MEM ("P1", brmask, arg); + return dp; +} + +static const unsigned char * +unw_decode_p2_p5 (const unsigned char *dp, unsigned int code, + void *arg ATTRIBUTE_UNUSED, + const unsigned char * end) +{ + if ((code & 0x10) == 0) + { + unsigned char byte1 = *dp++; + + UNW_DEC_BR_GR ("P2", ((code & 0xf) << 1) | ((byte1 >> 7) & 1), + (byte1 & 0x7f), arg); + } + else if ((code & 0x08) == 0) + { + unsigned char byte1 = *dp++, r, dst; + + r = ((code & 0x7) << 1) | ((byte1 >> 7) & 1); + dst = (byte1 & 0x7f); + switch (r) + { + case 0: + UNW_DEC_REG_GR ("P3", UNW_REG_PSP, dst, arg); + break; + case 1: + UNW_DEC_REG_GR ("P3", UNW_REG_RP, dst, arg); + break; + case 2: + UNW_DEC_REG_GR ("P3", UNW_REG_PFS, dst, arg); + break; + case 3: + UNW_DEC_REG_GR ("P3", UNW_REG_PR, dst, arg); + break; + case 4: + UNW_DEC_REG_GR ("P3", UNW_REG_UNAT, dst, arg); + break; + case 5: + UNW_DEC_REG_GR ("P3", UNW_REG_LC, dst, arg); + break; + case 6: + UNW_DEC_RP_BR ("P3", dst, arg); + break; + case 7: + UNW_DEC_REG_GR ("P3", UNW_REG_RNAT, dst, arg); + break; + case 8: + UNW_DEC_REG_GR ("P3", UNW_REG_BSP, dst, arg); + break; + case 9: + UNW_DEC_REG_GR ("P3", UNW_REG_BSPSTORE, dst, arg); + break; + case 10: + UNW_DEC_REG_GR ("P3", UNW_REG_FPSR, dst, arg); + break; + case 11: + UNW_DEC_PRIUNAT_GR ("P3", dst, arg); + break; + default: + UNW_DEC_BAD_CODE (r); + break; + } + } + else if ((code & 0x7) == 0) + UNW_DEC_SPILL_MASK ("P4", dp, arg, end); + else if ((code & 0x7) == 1) + { + unw_word grmask, frmask, byte1, byte2, byte3; + + byte1 = *dp++; + byte2 = *dp++; + byte3 = *dp++; + grmask = ((byte1 >> 4) & 0xf); + frmask = ((byte1 & 0xf) << 16) | (byte2 << 8) | byte3; + UNW_DEC_FRGR_MEM ("P5", grmask, frmask, arg); + } + else + UNW_DEC_BAD_CODE (code); + + return dp; +} + +static const unsigned char * +unw_decode_p6 (const unsigned char *dp, unsigned int code, + void *arg ATTRIBUTE_UNUSED, + const unsigned char * end ATTRIBUTE_UNUSED) +{ + int gregs = (code & 0x10) != 0; + unsigned char mask = (code & 0x0f); + + if (gregs) + UNW_DEC_GR_MEM ("P6", mask, arg); + else + UNW_DEC_FR_MEM ("P6", mask, arg); + return dp; +} + +static const unsigned char * +unw_decode_p7_p10 (const unsigned char *dp, unsigned int code, void *arg, + const unsigned char * end ATTRIBUTE_UNUSED) +{ + unsigned char r, byte1, byte2; + unw_word t, size; + + if ((code & 0x10) == 0) + { + r = (code & 0xf); + t = unw_decode_uleb128 (&dp); + switch (r) + { + case 0: + size = unw_decode_uleb128 (&dp); + UNW_DEC_MEM_STACK_F ("P7", t, size, arg); + break; + + case 1: + UNW_DEC_MEM_STACK_V ("P7", t, arg); + break; + case 2: + UNW_DEC_SPILL_BASE ("P7", t, arg); + break; + case 3: + UNW_DEC_REG_SPREL ("P7", UNW_REG_PSP, t, arg); + break; + case 4: + UNW_DEC_REG_WHEN ("P7", UNW_REG_RP, t, arg); + break; + case 5: + UNW_DEC_REG_PSPREL ("P7", UNW_REG_RP, t, arg); + break; + case 6: + UNW_DEC_REG_WHEN ("P7", UNW_REG_PFS, t, arg); + break; + case 7: + UNW_DEC_REG_PSPREL ("P7", UNW_REG_PFS, t, arg); + break; + case 8: + UNW_DEC_REG_WHEN ("P7", UNW_REG_PR, t, arg); + break; + case 9: + UNW_DEC_REG_PSPREL ("P7", UNW_REG_PR, t, arg); + break; + case 10: + UNW_DEC_REG_WHEN ("P7", UNW_REG_LC, t, arg); + break; + case 11: + UNW_DEC_REG_PSPREL ("P7", UNW_REG_LC, t, arg); + break; + case 12: + UNW_DEC_REG_WHEN ("P7", UNW_REG_UNAT, t, arg); + break; + case 13: + UNW_DEC_REG_PSPREL ("P7", UNW_REG_UNAT, t, arg); + break; + case 14: + UNW_DEC_REG_WHEN ("P7", UNW_REG_FPSR, t, arg); + break; + case 15: + UNW_DEC_REG_PSPREL ("P7", UNW_REG_FPSR, t, arg); + break; + default: + UNW_DEC_BAD_CODE (r); + break; + } + } + else + { + switch (code & 0xf) + { + case 0x0: /* p8 */ + { + r = *dp++; + t = unw_decode_uleb128 (&dp); + switch (r) + { + case 1: + UNW_DEC_REG_SPREL ("P8", UNW_REG_RP, t, arg); + break; + case 2: + UNW_DEC_REG_SPREL ("P8", UNW_REG_PFS, t, arg); + break; + case 3: + UNW_DEC_REG_SPREL ("P8", UNW_REG_PR, t, arg); + break; + case 4: + UNW_DEC_REG_SPREL ("P8", UNW_REG_LC, t, arg); + break; + case 5: + UNW_DEC_REG_SPREL ("P8", UNW_REG_UNAT, t, arg); + break; + case 6: + UNW_DEC_REG_SPREL ("P8", UNW_REG_FPSR, t, arg); + break; + case 7: + UNW_DEC_REG_WHEN ("P8", UNW_REG_BSP, t, arg); + break; + case 8: + UNW_DEC_REG_PSPREL ("P8", UNW_REG_BSP, t, arg); + break; + case 9: + UNW_DEC_REG_SPREL ("P8", UNW_REG_BSP, t, arg); + break; + case 10: + UNW_DEC_REG_WHEN ("P8", UNW_REG_BSPSTORE, t, arg); + break; + case 11: + UNW_DEC_REG_PSPREL ("P8", UNW_REG_BSPSTORE, t, arg); + break; + case 12: + UNW_DEC_REG_SPREL ("P8", UNW_REG_BSPSTORE, t, arg); + break; + case 13: + UNW_DEC_REG_WHEN ("P8", UNW_REG_RNAT, t, arg); + break; + case 14: + UNW_DEC_REG_PSPREL ("P8", UNW_REG_RNAT, t, arg); + break; + case 15: + UNW_DEC_REG_SPREL ("P8", UNW_REG_RNAT, t, arg); + break; + case 16: + UNW_DEC_PRIUNAT_WHEN_GR ("P8", t, arg); + break; + case 17: + UNW_DEC_PRIUNAT_PSPREL ("P8", t, arg); + break; + case 18: + UNW_DEC_PRIUNAT_SPREL ("P8", t, arg); + break; + case 19: + UNW_DEC_PRIUNAT_WHEN_MEM ("P8", t, arg); + break; + default: + UNW_DEC_BAD_CODE (r); + break; + } + } + break; + + case 0x1: + byte1 = *dp++; + byte2 = *dp++; + UNW_DEC_GR_GR ("P9", (byte1 & 0xf), (byte2 & 0x7f), arg); + break; + + case 0xf: /* p10 */ + byte1 = *dp++; + byte2 = *dp++; + UNW_DEC_ABI ("P10", byte1, byte2, arg); + break; + + case 0x9: + return unw_decode_x1 (dp, code, arg); + + case 0xa: + return unw_decode_x2 (dp, code, arg); + + case 0xb: + return unw_decode_x3 (dp, code, arg); + + case 0xc: + return unw_decode_x4 (dp, code, arg); + + default: + UNW_DEC_BAD_CODE (code); + break; + } + } + return dp; +} + +static const unsigned char * +unw_decode_b1 (const unsigned char *dp, unsigned int code, + void *arg ATTRIBUTE_UNUSED, + const unsigned char * end ATTRIBUTE_UNUSED) +{ + unw_word label = (code & 0x1f); + + if ((code & 0x20) != 0) + UNW_DEC_COPY_STATE ("B1", label, arg); + else + UNW_DEC_LABEL_STATE ("B1", label, arg); + return dp; +} + +static const unsigned char * +unw_decode_b2 (const unsigned char *dp, unsigned int code, + void *arg ATTRIBUTE_UNUSED, + const unsigned char * end ATTRIBUTE_UNUSED) +{ + unw_word t; + + t = unw_decode_uleb128 (& dp); + UNW_DEC_EPILOGUE ("B2", t, (code & 0x1f), arg); + return dp; +} + +static const unsigned char * +unw_decode_b3_x4 (const unsigned char *dp, unsigned int code, void *arg, + const unsigned char * end ATTRIBUTE_UNUSED) +{ + unw_word t, ecount, label; + + if ((code & 0x10) == 0) + { + t = unw_decode_uleb128 (&dp); + ecount = unw_decode_uleb128 (&dp); + UNW_DEC_EPILOGUE ("B3", t, ecount, arg); + } + else if ((code & 0x07) == 0) + { + label = unw_decode_uleb128 (&dp); + if ((code & 0x08) != 0) + UNW_DEC_COPY_STATE ("B4", label, arg); + else + UNW_DEC_LABEL_STATE ("B4", label, arg); + } + else + switch (code & 0x7) + { + case 1: + return unw_decode_x1 (dp, code, arg); + case 2: + return unw_decode_x2 (dp, code, arg); + case 3: + return unw_decode_x3 (dp, code, arg); + case 4: + return unw_decode_x4 (dp, code, arg); + default: + UNW_DEC_BAD_CODE (code); + break; + } + return dp; +} + +typedef const unsigned char *(*unw_decoder) + (const unsigned char *, unsigned int, void *, const unsigned char *); + +static const unw_decoder unw_decode_table[2][8] = + { + /* prologue table: */ + { + unw_decode_r1, /* 0 */ + unw_decode_r1, + unw_decode_r2, + unw_decode_r3, + unw_decode_p1, /* 4 */ + unw_decode_p2_p5, + unw_decode_p6, + unw_decode_p7_p10 + }, + { + unw_decode_r1, /* 0 */ + unw_decode_r1, + unw_decode_r2, + unw_decode_r3, + unw_decode_b1, /* 4 */ + unw_decode_b1, + unw_decode_b2, + unw_decode_b3_x4 + } + }; + +/* Decode one descriptor and return address of next descriptor. */ +const unsigned char * +unw_decode (const unsigned char *dp, int inside_body, + void *ptr_inside_body, const unsigned char * end) +{ + unw_decoder decoder; + unsigned char code; + + code = *dp++; + decoder = unw_decode_table[inside_body][code >> 5]; + return (*decoder) (dp, code, ptr_inside_body, end); +} diff --git a/support/sdbinutils/binutils/unwind-ia64.h b/support/sdbinutils/binutils/unwind-ia64.h new file mode 100644 index 0000000..b62fe4a --- /dev/null +++ b/support/sdbinutils/binutils/unwind-ia64.h @@ -0,0 +1,32 @@ +/* unwind-ia64.h -- dump IA-64 unwind info. + Copyright (C) 2000-2018 Free Software Foundation, Inc. + Contributed by David Mosberger-Tang + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "elf/ia64.h" +#include "ansidecl.h" + +#define UNW_VER(x) ((x) >> 48) +#define UNW_FLAG_MASK 0x0000ffff00000000LL +#define UNW_FLAG_OSMASK 0x0000f00000000000LL +#define UNW_FLAG_EHANDLER(x) ((x) & 0x0000000100000000LL) +#define UNW_FLAG_UHANDLER(x) ((x) & 0x0000000200000000LL) +#define UNW_LENGTH(x) ((x) & 0x00000000ffffffffLL) + +extern const unsigned char *unw_decode (const unsigned char *, int, void *, const unsigned char *); diff --git a/support/sdbinutils/binutils/version.c b/support/sdbinutils/binutils/version.c new file mode 100644 index 0000000..ac63a81 --- /dev/null +++ b/support/sdbinutils/binutils/version.c @@ -0,0 +1,40 @@ +/* version.c -- binutils version information + Copyright (C) 1991-2018 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "sysdep.h" +#include "bfd.h" +#include "bucomm.h" + +/* Print the version number and copyright information, and exit. + This implements the --version option for the various programs. */ + +void +print_version (const char *name) +{ + /* This output is intended to follow the GNU standards document. */ + /* xgettext:c-format */ + printf ("GNU %s %s\n", name, BFD_VERSION_STRING); + printf (_("Copyright (C) 2018 Free Software Foundation, Inc.\n")); + printf (_("\ +This program is free software; you may redistribute it under the terms of\n\ +the GNU General Public License version 3 or (at your option) any later version.\n\ +This program has absolutely no warranty.\n")); + exit (0); +} diff --git a/support/sdbinutils/binutils/windint.h b/support/sdbinutils/binutils/windint.h new file mode 100644 index 0000000..1b83882 --- /dev/null +++ b/support/sdbinutils/binutils/windint.h @@ -0,0 +1,1097 @@ +/* windint.h -- internal header file for windres program. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + Written by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "winduni.h" + +#ifndef WINDINT_H +#define WINDINT_H + +/* Use bfd_size_type to ensure a sufficient number of bits. */ +#ifndef DEFINED_RC_UINT_TYPE +#define DEFINED_RC_UINT_TYPE +typedef bfd_size_type rc_uint_type; +#endif + +/* Resource directory structure. */ + +typedef struct res_hdr +{ + rc_uint_type data_size; + rc_uint_type header_size; +} res_hdr; + +struct __attribute__ ((__packed__)) bin_res_hdr +{ + bfd_byte data_size[4]; + bfd_byte header_size[4]; +}; +#define BIN_RES_HDR_SIZE 8 + +struct __attribute__ ((__packed__)) bin_res_id +{ + bfd_byte sig[2]; /* Has to be 0xffff for unnamed ids. */ + bfd_byte id[2]; +}; +#define BIN_RES_ID 4 + +/* This structure is used when converting resource information to + binary. */ + +typedef struct bindata +{ + /* Next data. */ + struct bindata *next; + /* Length of data. */ + rc_uint_type length; + /* Data. */ + bfd_byte *data; +} bindata; + +/* This structure is used when converting resource information to + coff. */ +typedef struct coff_res_data +{ + /* Next data. */ + struct coff_res_data *next; + /* Length of data. */ + rc_uint_type length; + /* Data. */ + const struct rc_res_resource *res; +} coff_res_data; + +/* We represent resources internally as a tree, similar to the tree + used in the .rsrc section of a COFF file. The root is a + rc_res_directory structure. */ + +typedef struct rc_res_directory +{ + /* Resource flags. According to the MS docs, this is currently + always zero. */ + rc_uint_type characteristics; + /* Time/date stamp. */ + rc_uint_type time; + /* Major version number. */ + rc_uint_type major; + /* Minor version number. */ + rc_uint_type minor; + /* Directory entries. */ + struct rc_res_entry *entries; +} rc_res_directory; + +/* A resource ID is stored in a rc_res_id structure. */ + +typedef struct rc_res_id +{ + /* Non-zero if this entry has a name rather than an ID. */ + rc_uint_type named : 1; + union + { + /* If the named field is non-zero, this is the name. */ + struct + { + /* Length of the name. */ + rc_uint_type length; + /* Pointer to the name, which is a Unicode string. */ + unichar *name; + } n; + /* If the named field is zero, this is the ID. */ + rc_uint_type id; + } u; +} rc_res_id; + +/* Each entry in the tree is a rc_res_entry structure. We mix + directories and resources because in a COFF file all entries in a + directory are sorted together, whether the entries are + subdirectories or resources. */ + +typedef struct rc_res_entry +{ + /* Next entry. */ + struct rc_res_entry *next; + /* Resource ID. */ + rc_res_id id; + /* Non-zero if this entry is a subdirectory rather than a leaf. */ + rc_uint_type subdir : 1; + union + { + /* If the subdir field is non-zero, this is a pointer to the + subdirectory. */ + rc_res_directory *dir; + /* If the subdir field is zero, this is a pointer to the resource + data. */ + struct rc_res_resource *res; + } u; +} rc_res_entry; + +/* Types of resources. */ + +enum rc_res_type +{ + RES_TYPE_UNINITIALIZED, + RES_TYPE_ACCELERATOR, + RES_TYPE_BITMAP, + RES_TYPE_CURSOR, + RES_TYPE_GROUP_CURSOR, + RES_TYPE_DIALOG, + RES_TYPE_FONT, + RES_TYPE_FONTDIR, + RES_TYPE_ICON, + RES_TYPE_GROUP_ICON, + RES_TYPE_MENU, + RES_TYPE_MESSAGETABLE, + RES_TYPE_RCDATA, + RES_TYPE_STRINGTABLE, + RES_TYPE_USERDATA, + RES_TYPE_VERSIONINFO, + RES_TYPE_DLGINCLUDE, + RES_TYPE_PLUGPLAY, + RES_TYPE_VXD, + RES_TYPE_ANICURSOR, + RES_TYPE_ANIICON, + RES_TYPE_DLGINIT, + RES_TYPE_TOOLBAR +}; + +/* A res file and a COFF file store information differently. The + res_info structures holds data which in a res file is stored with + each resource, but in a COFF file is stored elsewhere. */ + +typedef struct rc_res_res_info +{ + /* Language. In a COFF file, the third level of the directory is + keyed by the language, so the language of a resource is defined + by its location in the resource tree. */ + rc_uint_type language; + /* Characteristics of the resource. Entirely user defined. In a + COFF file, the rc_res_directory structure has a characteristics + field, but I don't know if it's related to the one in the res + file. */ + rc_uint_type characteristics; + /* Version of the resource. Entirely user defined. In a COFF file, + the rc_res_directory structure has a characteristics field, but I + don't know if it's related to the one in the res file. */ + rc_uint_type version; + /* Memory flags. This is a combination of the MEMFLAG values + defined below. Most of these values are historical, and are not + meaningful for win32. I don't think there is any way to store + this information in a COFF file. */ + rc_uint_type memflags; +} rc_res_res_info; + +/* Binary layout of rc_res_info. */ + +struct __attribute__ ((__packed__)) bin_res_info +{ + bfd_byte version[4]; + bfd_byte memflags[2]; + bfd_byte language[2]; + bfd_byte version2[4]; + bfd_byte characteristics[4]; +}; +#define BIN_RES_INFO_SIZE 16 + +/* Each resource in a COFF file has some information which can does + not appear in a res file. */ + +typedef struct rc_res_coff_info +{ + /* The code page used for the data. I don't really know what this + should be. It has something todo with ASCII to Unicode encoding. */ + rc_uint_type codepage; + /* A resource entry in a COFF file has a reserved field, which we + record here when reading a COFF file. When writing a COFF file, + we set this field to zero. */ + rc_uint_type reserved; +} rc_res_coff_info; + +/* Resource data is stored in a rc_res_resource structure. */ + +typedef struct rc_res_resource +{ + /* The type of resource. */ + enum rc_res_type type; + /* The data for the resource. */ + union + { + struct + { + rc_uint_type length; + const bfd_byte *data; + } data; + struct rc_accelerator *acc; + struct rc_cursor *cursor; + struct rc_group_cursor *group_cursor; + struct rc_dialog *dialog; + struct rc_fontdir *fontdir; + struct rc_group_icon *group_icon; + struct rc_menu *menu; + struct rc_rcdata_item *rcdata; + struct rc_stringtable *stringtable; + struct rc_rcdata_item *userdata; + struct rc_versioninfo *versioninfo; + struct rc_toolbar *toolbar; + } u; + /* Information from a res file. */ + struct rc_res_res_info res_info; + /* Information from a COFF file. */ + rc_res_coff_info coff_info; +} rc_res_resource; + +#define SUBLANG_SHIFT 10 + +/* Memory flags in the memflags field of a rc_res_resource. */ + +#define MEMFLAG_MOVEABLE 0x10 +#define MEMFLAG_PURE 0x20 +#define MEMFLAG_PRELOAD 0x40 +#define MEMFLAG_DISCARDABLE 0x1000 + +/* Standard resource type codes. These are used in the ID field of a + rc_res_entry structure. */ + +#define RT_CURSOR 1 +#define RT_BITMAP 2 +#define RT_ICON 3 +#define RT_MENU 4 +#define RT_DIALOG 5 +#define RT_STRING 6 +#define RT_FONTDIR 7 +#define RT_FONT 8 +#define RT_ACCELERATOR 9 +#define RT_RCDATA 10 +#define RT_MESSAGETABLE 11 +#define RT_GROUP_CURSOR 12 +#define RT_GROUP_ICON 14 +#define RT_VERSION 16 +#define RT_DLGINCLUDE 17 +#define RT_PLUGPLAY 19 +#define RT_VXD 20 +#define RT_ANICURSOR 21 +#define RT_ANIICON 22 +#define RT_HTML 23 +#define RT_MANIFEST 24 +#define RT_DLGINIT 240 +#define RT_TOOLBAR 241 + +/* An accelerator resource is a linked list of these structures. */ + +typedef struct rc_accelerator +{ + /* Next accelerator. */ + struct rc_accelerator *next; + /* Flags. A combination of the ACC values defined below. */ + rc_uint_type flags; + /* Key value. */ + rc_uint_type key; + /* Resource ID. */ + rc_uint_type id; +} rc_accelerator; + +struct __attribute__ ((__packed__)) bin_accelerator +{ + bfd_byte flags[2]; + bfd_byte key[2]; + bfd_byte id[2]; + bfd_byte pad[2]; +}; +#define BIN_ACCELERATOR_SIZE 8 + +/* Accelerator flags in the flags field of a rc_accelerator. + These are the same values that appear in a res file. I hope. */ + +#define ACC_VIRTKEY 0x01 +#define ACC_NOINVERT 0x02 +#define ACC_SHIFT 0x04 +#define ACC_CONTROL 0x08 +#define ACC_ALT 0x10 +#define ACC_LAST 0x80 + +/* A cursor resource. */ + +typedef struct rc_cursor +{ + /* X coordinate of hotspot. */ + bfd_signed_vma xhotspot; + /* Y coordinate of hotspot. */ + bfd_signed_vma yhotspot; + /* Length of bitmap data. */ + rc_uint_type length; + /* Data. */ + const bfd_byte *data; +} rc_cursor; + +struct __attribute__ ((__packed__)) bin_cursor +{ + bfd_byte xhotspot[2]; + bfd_byte yhotspot[2]; +}; +#define BIN_CURSOR_SIZE 4 + +/* A group_cursor resource is a list of rc_i_group_cursor structures. */ + +typedef struct rc_group_cursor +{ + /* Next cursor in group. */ + struct rc_group_cursor *next; + /* Width. */ + rc_uint_type width; + /* Height. */ + rc_uint_type height; + /* Planes. */ + rc_uint_type planes; + /* Bits per pixel. */ + rc_uint_type bits; + /* Number of bytes in cursor resource. */ + rc_uint_type bytes; + /* Index of cursor resource. */ + rc_uint_type index; +} rc_group_cursor; + +struct __attribute__ ((__packed__)) bin_group_cursor_item +{ + bfd_byte width[2]; + bfd_byte height[2]; + bfd_byte planes[2]; + bfd_byte bits[2]; + bfd_byte bytes[4]; + bfd_byte index[2]; +}; +#define BIN_GROUP_CURSOR_ITEM_SIZE 14 + +struct __attribute__ ((__packed__)) bin_group_cursor +{ + bfd_byte sig1[2]; + bfd_byte sig2[2]; + bfd_byte nitems[2]; + /* struct bin_group_cursor_item item[nitems]; */ +}; +#define BIN_GROUP_CURSOR_SIZE 6 + +/* A dialog resource. */ + +typedef struct rc_dialog +{ + /* Basic window style. */ + unsigned int style; + /* Extended window style. */ + rc_uint_type exstyle; + /* X coordinate. */ + rc_uint_type x; + /* Y coordinate. */ + rc_uint_type y; + /* Width. */ + rc_uint_type width; + /* Height. */ + rc_uint_type height; + /* Menu name. */ + rc_res_id menu; + /* Class name. */ + rc_res_id class; + /* Caption. */ + unichar *caption; + /* Font point size. */ + rc_uint_type pointsize; + /* Font name. */ + unichar *font; + /* Extended information for a dialogex. */ + struct rc_dialog_ex *ex; + /* Controls. */ + struct rc_dialog_control *controls; +} rc_dialog; + +struct __attribute__ ((__packed__)) bin_dialog +{ + bfd_byte style[4]; + bfd_byte exstyle[4]; + bfd_byte off[2]; + bfd_byte x[2]; + bfd_byte y[2]; + bfd_byte width[2]; + bfd_byte height[2]; +}; +#define BIN_DIALOG_SIZE 18 + +/* An extended dialog has additional information. */ + +typedef struct rc_dialog_ex +{ + /* Help ID. */ + rc_uint_type help; + /* Font weight. */ + rc_uint_type weight; + /* Whether the font is italic. */ + bfd_byte italic; + /* Character set. */ + bfd_byte charset; +} rc_dialog_ex; + +struct __attribute__ ((__packed__)) bin_dialogex +{ + bfd_byte sig1[2]; + bfd_byte sig2[2]; + bfd_byte help[4]; + bfd_byte exstyle[4]; + bfd_byte style[4]; + bfd_byte off[2]; + bfd_byte x[2]; + bfd_byte y[2]; + bfd_byte width[2]; + bfd_byte height[2]; +}; +#define BIN_DIALOGEX_SIZE 26 + +struct __attribute__ ((__packed__)) bin_dialogfont +{ + bfd_byte pointsize[2]; +}; +#define BIN_DIALOGFONT_SIZE 2 + +struct __attribute__ ((__packed__)) bin_dialogexfont +{ + bfd_byte pointsize[2]; + bfd_byte weight[2]; + bfd_byte italic[1]; + bfd_byte charset[1]; +}; +#define BIN_DIALOGEXFONT_SIZE 6 + +/* Window style flags, from the winsup Defines.h header file. These + can appear in the style field of a rc_dialog or a rc_dialog_control. */ + +#define CW_USEDEFAULT 0x80000000 +#define WS_BORDER 0x800000L +#define WS_CAPTION 0xc00000L +#define WS_CHILD 0x40000000L +#define WS_CHILDWINDOW 0x40000000L +#define WS_CLIPCHILDREN 0x2000000L +#define WS_CLIPSIBLINGS 0x4000000L +#define WS_DISABLED 0x8000000L +#define WS_DLGFRAME 0x400000L +#define WS_GROUP 0x20000L +#define WS_HSCROLL 0x100000L +#define WS_ICONIC 0x20000000L +#define WS_MAXIMIZE 0x1000000L +#define WS_MAXIMIZEBOX 0x10000L +#define WS_MINIMIZE 0x20000000L +#define WS_MINIMIZEBOX 0x20000L +#define WS_OVERLAPPED 0L +#define WS_OVERLAPPEDWINDOW 0xcf0000L +#define WS_POPUP 0x80000000L +#define WS_POPUPWINDOW 0x80880000L +#define WS_SIZEBOX 0x40000L +#define WS_SYSMENU 0x80000L +#define WS_TABSTOP 0x10000L +#define WS_THICKFRAME 0x40000L +#define WS_TILED 0L +#define WS_TILEDWINDOW 0xcf0000L +#define WS_VISIBLE 0x10000000L +#define WS_VSCROLL 0x200000L +#define MDIS_ALLCHILDSTYLES 0x1 +#define BS_3STATE 0x5L +#define BS_AUTO3STATE 0x6L +#define BS_AUTOCHECKBOX 0x3L +#define BS_AUTORADIOBUTTON 0x9L +#define BS_BITMAP 0x80L +#define BS_BOTTOM 0x800L +#define BS_CENTER 0x300L +#define BS_CHECKBOX 0x2L +#define BS_DEFPUSHBUTTON 0x1L +#define BS_GROUPBOX 0x7L +#define BS_ICON 0x40L +#define BS_LEFT 0x100L +#define BS_LEFTTEXT 0x20L +#define BS_MULTILINE 0x2000L +#define BS_NOTIFY 0x4000L +#define BS_OWNERDRAW 0xbL +#define BS_PUSHBOX 0xcL /* FIXME! What should this be? */ +#define BS_PUSHBUTTON 0L +#define BS_PUSHLIKE 0x1000L +#define BS_RADIOBUTTON 0x4L +#define BS_RIGHT 0x200L +#define BS_RIGHTBUTTON 0x20L +#define BS_TEXT 0L +#define BS_TOP 0x400L +#define BS_USERBUTTON 0x8L +#define BS_VCENTER 0xc00L +#define CBS_AUTOHSCROLL 0x40L +#define CBS_DISABLENOSCROLL 0x800L +#define CBS_DROPDOWN 0x2L +#define CBS_DROPDOWNLIST 0x3L +#define CBS_HASSTRINGS 0x200L +#define CBS_LOWERCASE 0x4000L +#define CBS_NOINTEGRALHEIGHT 0x400L +#define CBS_OEMCONVERT 0x80L +#define CBS_OWNERDRAWFIXED 0x10L +#define CBS_OWNERDRAWVARIABLE 0x20L +#define CBS_SIMPLE 0x1L +#define CBS_SORT 0x100L +#define CBS_UPPERCASE 0x2000L +#define ES_AUTOHSCROLL 0x80L +#define ES_AUTOVSCROLL 0x40L +#define ES_CENTER 0x1L +#define ES_LEFT 0L +#define ES_LOWERCASE 0x10L +#define ES_MULTILINE 0x4L +#define ES_NOHIDESEL 0x100L +#define ES_NUMBER 0x2000L +#define ES_OEMCONVERT 0x400L +#define ES_PASSWORD 0x20L +#define ES_READONLY 0x800L +#define ES_RIGHT 0x2L +#define ES_UPPERCASE 0x8L +#define ES_WANTRETURN 0x1000L +#define LBS_DISABLENOSCROLL 0x1000L +#define LBS_EXTENDEDSEL 0x800L +#define LBS_HASSTRINGS 0x40L +#define LBS_MULTICOLUMN 0x200L +#define LBS_MULTIPLESEL 0x8L +#define LBS_NODATA 0x2000L +#define LBS_NOINTEGRALHEIGHT 0x100L +#define LBS_NOREDRAW 0x4L +#define LBS_NOSEL 0x4000L +#define LBS_NOTIFY 0x1L +#define LBS_OWNERDRAWFIXED 0x10L +#define LBS_OWNERDRAWVARIABLE 0x20L +#define LBS_SORT 0x2L +#define LBS_STANDARD 0xa00003L +#define LBS_USETABSTOPS 0x80L +#define LBS_WANTKEYBOARDINPUT 0x400L +#define SBS_BOTTOMALIGN 0x4L +#define SBS_HORZ 0L +#define SBS_LEFTALIGN 0x2L +#define SBS_RIGHTALIGN 0x4L +#define SBS_SIZEBOX 0x8L +#define SBS_SIZEBOXBOTTOMRIGHTALIGN 0x4L +#define SBS_SIZEBOXTOPLEFTALIGN 0x2L +#define SBS_SIZEGRIP 0x10L +#define SBS_TOPALIGN 0x2L +#define SBS_VERT 0x1L +#define SS_BITMAP 0xeL +#define SS_BLACKFRAME 0x7L +#define SS_BLACKRECT 0x4L +#define SS_CENTER 0x1L +#define SS_CENTERIMAGE 0x200L +#define SS_ENHMETAFILE 0xfL +#define SS_ETCHEDFRAME 0x12L +#define SS_ETCHEDHORZ 0x10L +#define SS_ETCHEDVERT 0x11L +#define SS_GRAYFRAME 0x8L +#define SS_GRAYRECT 0x5L +#define SS_ICON 0x3L +#define SS_LEFT 0L +#define SS_LEFTNOWORDWRAP 0xcL +#define SS_NOPREFIX 0x80L +#define SS_NOTIFY 0x100L +#define SS_OWNERDRAW 0xdL +#define SS_REALSIZEIMAGE 0x800L +#define SS_RIGHT 0x2L +#define SS_RIGHTJUST 0x400L +#define SS_SIMPLE 0xbL +#define SS_SUNKEN 0x1000L +#define SS_USERITEM 0xaL +#define SS_WHITEFRAME 0x9L +#define SS_WHITERECT 0x6L +#define DS_3DLOOK 0x4L +#define DS_ABSALIGN 0x1L +#define DS_CENTER 0x800L +#define DS_CENTERMOUSE 0x1000L +#define DS_CONTEXTHELP 0x2000L +#define DS_CONTROL 0x400L +#define DS_FIXEDSYS 0x8L +#define DS_LOCALEDIT 0x20L +#define DS_MODALFRAME 0x80L +#define DS_NOFAILCREATE 0x10L +#define DS_NOIDLEMSG 0x100L +#define DS_SETFONT 0x40L +#define DS_SETFOREGROUND 0x200L +#define DS_SYSMODAL 0x2L + +/* A dialog control. */ + +typedef struct rc_dialog_control +{ + /* Next control. */ + struct rc_dialog_control *next; + /* ID. */ + rc_uint_type id; + /* Style. */ + rc_uint_type style; + /* Extended style. */ + rc_uint_type exstyle; + /* X coordinate. */ + rc_uint_type x; + /* Y coordinate. */ + rc_uint_type y; + /* Width. */ + rc_uint_type width; + /* Height. */ + rc_uint_type height; + /* Class name. */ + rc_res_id class; + /* Associated text. */ + rc_res_id text; + /* Extra data for the window procedure. */ + struct rc_rcdata_item *data; + /* Help ID. Only used in an extended dialog. */ + rc_uint_type help; +} rc_dialog_control; + +struct __attribute__ ((__packed__)) bin_dialog_control +{ + bfd_byte style[4]; + bfd_byte exstyle[4]; + bfd_byte x[2]; + bfd_byte y[2]; + bfd_byte width[2]; + bfd_byte height[2]; + bfd_byte id[2]; +}; +#define BIN_DIALOG_CONTROL_SIZE 18 + +struct __attribute__ ((__packed__)) bin_dialogex_control +{ + bfd_byte help[4]; + bfd_byte exstyle[4]; + bfd_byte style[4]; + bfd_byte x[2]; + bfd_byte y[2]; + bfd_byte width[2]; + bfd_byte height[2]; + bfd_byte id[4]; +}; +#define BIN_DIALOGEX_CONTROL_SIZE 24 + +/* Control classes. These can be used as the ID field in a rc_dialog_control. */ + +#define CTL_BUTTON 0x80 +#define CTL_EDIT 0x81 +#define CTL_STATIC 0x82 +#define CTL_LISTBOX 0x83 +#define CTL_SCROLLBAR 0x84 +#define CTL_COMBOBOX 0x85 + +/* A fontdir resource is a list of rc_fontdir. */ + +typedef struct rc_fontdir +{ + struct rc_fontdir *next; + /* Index of font entry. */ + rc_uint_type index; + /* Length of font information. */ + rc_uint_type length; + /* Font information. */ + const bfd_byte *data; +} rc_fontdir; + +struct __attribute__ ((__packed__)) bin_fontdir_item +{ + bfd_byte index[2]; + bfd_byte header[54]; + bfd_byte device_name[1]; + /* bfd_byte face_name[]; */ +}; + +/* A group_icon resource is a list of rc_group_icon. */ + +typedef struct rc_group_icon +{ + /* Next icon in group. */ + struct rc_group_icon *next; + /* Width. */ + bfd_byte width; + /* Height. */ + bfd_byte height; + /* Color count. */ + bfd_byte colors; + /* Planes. */ + rc_uint_type planes; + /* Bits per pixel. */ + rc_uint_type bits; + /* Number of bytes in cursor resource. */ + rc_uint_type bytes; + /* Index of cursor resource. */ + rc_uint_type index; +} rc_group_icon; + +struct __attribute__ ((__packed__)) bin_group_icon +{ + bfd_byte sig1[2]; + bfd_byte sig2[2]; + bfd_byte count[2]; +}; +#define BIN_GROUP_ICON_SIZE 6 + +struct __attribute__ ((__packed__)) bin_group_icon_item +{ + bfd_byte width[1]; + bfd_byte height[1]; + bfd_byte colors[1]; + bfd_byte pad[1]; + bfd_byte planes[2]; + bfd_byte bits[2]; + bfd_byte bytes[4]; + bfd_byte index[2]; +}; +#define BIN_GROUP_ICON_ITEM_SIZE 14 + +/* A menu resource. */ + +typedef struct rc_menu +{ + /* List of menuitems. */ + struct rc_menuitem *items; + /* Help ID. I don't think there is any way to set this in an rc + file, but it can appear in the binary format. */ + rc_uint_type help; +} rc_menu; + +struct __attribute__ ((__packed__)) bin_menu +{ + bfd_byte sig1[2]; + bfd_byte sig2[2]; +}; +#define BIN_MENU_SIZE 4 + +struct __attribute__ ((__packed__)) bin_menuex +{ + bfd_byte sig1[2]; + bfd_byte sig2[2]; + bfd_byte help[4]; +}; +#define BIN_MENUEX_SIZE 8 + +/* A menu resource is a list of rc_menuitem. */ + +typedef struct rc_menuitem +{ + /* Next menu item. */ + struct rc_menuitem *next; + /* Type. In a normal menu, rather than a menuex, this is the flags + field. */ + rc_uint_type type; + /* State. This is only used in a menuex. */ + rc_uint_type state; + /* Id. */ + rc_uint_type id; + /* Unicode text. */ + unichar *text; + /* Popup menu items for a popup. */ + struct rc_menuitem *popup; + /* Help ID. This is only used in a menuex. */ + rc_uint_type help; +} rc_menuitem; + +struct __attribute__ ((__packed__)) bin_menuitem +{ + bfd_byte flags[2]; + bfd_byte id[2]; +}; +#define BIN_MENUITEM_SIZE 4 +#define BIN_MENUITEM_POPUP_SIZE 2 + +struct __attribute__ ((__packed__)) bin_menuitemex +{ + bfd_byte type[4]; + bfd_byte state[4]; + bfd_byte id[4]; + bfd_byte flags[2]; + /* unicode text */ + /* if popup: align, bfd_byte help[4], align, bin_menuitemex[]; */ +}; +#define BIN_MENUITEMEX_SIZE 14 + +/* Menu item flags. These can appear in the flags field of a rc_menuitem. */ + +#define MENUITEM_GRAYED 0x001 +#define MENUITEM_INACTIVE 0x002 +#define MENUITEM_BITMAP 0x004 +#define MENUITEM_OWNERDRAW 0x100 +#define MENUITEM_CHECKED 0x008 +#define MENUITEM_POPUP 0x010 +#define MENUITEM_MENUBARBREAK 0x020 +#define MENUITEM_MENUBREAK 0x040 +#define MENUITEM_ENDMENU 0x080 +#define MENUITEM_HELP 0x4000 + +/* An rcdata resource is a pointer to a list of rc_rcdata_item. */ + +typedef struct rc_rcdata_item +{ + /* Next data item. */ + struct rc_rcdata_item *next; + /* Type of data. */ + enum + { + RCDATA_WORD, + RCDATA_DWORD, + RCDATA_STRING, + RCDATA_WSTRING, + RCDATA_BUFFER + } type; + union + { + rc_uint_type word; + rc_uint_type dword; + struct + { + rc_uint_type length; + const char *s; + } string; + struct + { + rc_uint_type length; + const unichar *w; + } wstring; + struct + { + rc_uint_type length; + const bfd_byte *data; + } buffer; + } u; +} rc_rcdata_item; + +/* A stringtable resource is a pointer to a rc_stringtable. */ + +typedef struct rc_stringtable +{ + /* Each stringtable resource is a list of 16 unicode strings. */ + struct + { + /* Length of string. */ + rc_uint_type length; + /* String data if length > 0. */ + unichar *string; + } strings[16]; +} rc_stringtable; + +/* A versioninfo resource points to a rc_versioninfo. */ + +typedef struct rc_versioninfo +{ + /* Fixed version information. */ + struct rc_fixed_versioninfo *fixed; + /* Variable version information. */ + struct rc_ver_info *var; +} rc_versioninfo; + +struct __attribute__ ((__packed__)) bin_versioninfo +{ + bfd_byte size[2]; + bfd_byte fixed_size[2]; + bfd_byte sig2[2]; +}; +#define BIN_VERSIONINFO_SIZE 6 + +/* The fixed portion of a versioninfo resource. */ + +typedef struct rc_fixed_versioninfo +{ + /* The file version, which is two 32 bit integers. */ + rc_uint_type file_version_ms; + rc_uint_type file_version_ls; + /* The product version, which is two 32 bit integers. */ + rc_uint_type product_version_ms; + rc_uint_type product_version_ls; + /* The file flags mask. */ + rc_uint_type file_flags_mask; + /* The file flags. */ + rc_uint_type file_flags; + /* The OS type. */ + rc_uint_type file_os; + /* The file type. */ + rc_uint_type file_type; + /* The file subtype. */ + rc_uint_type file_subtype; + /* The date, which in Windows is two 32 bit integers. */ + rc_uint_type file_date_ms; + rc_uint_type file_date_ls; +} rc_fixed_versioninfo; + +struct __attribute__ ((__packed__)) bin_fixed_versioninfo +{ + bfd_byte sig1[4]; + bfd_byte sig2[4]; + bfd_byte file_version[4]; + bfd_byte file_version_ls[4]; + bfd_byte product_version_ms[4]; + bfd_byte product_version_ls[4]; + bfd_byte file_flags_mask[4]; + bfd_byte file_flags[4]; + bfd_byte file_os[4]; + bfd_byte file_type[4]; + bfd_byte file_subtype[4]; + bfd_byte file_date_ms[4]; + bfd_byte file_date_ls[4]; +}; +#define BIN_FIXED_VERSIONINFO_SIZE 52 + +/* A list of string version information. */ + +typedef struct rc_ver_stringtable +{ + /* Next item. */ + struct rc_ver_stringtable *next; + /* Language. */ + unichar *language; + /* Strings. */ + struct rc_ver_stringinfo *strings; +} rc_ver_stringtable; + +/* A list of variable version information. */ + +typedef struct rc_ver_info +{ + /* Next item. */ + struct rc_ver_info *next; + /* Type of data. */ + enum { VERINFO_STRING, VERINFO_VAR } type; + union + { + /* StringFileInfo data. */ + struct + { + /* String tables. */ + struct rc_ver_stringtable *stringtables; + } string; + /* VarFileInfo data. */ + struct + { + /* Key. */ + unichar *key; + /* Values. */ + struct rc_ver_varinfo *var; + } var; + } u; +} rc_ver_info; + +struct __attribute__ ((__packed__)) bin_ver_info +{ + bfd_byte size[2]; + bfd_byte sig1[2]; + bfd_byte sig2[2]; +}; +#define BIN_VER_INFO_SIZE 6 + +/* A list of string version information. */ + +typedef struct rc_ver_stringinfo +{ + /* Next string. */ + struct rc_ver_stringinfo *next; + /* Key. */ + unichar *key; + /* Value. */ + unichar *value; +} rc_ver_stringinfo; + +/* A list of variable version information. */ + +typedef struct rc_ver_varinfo +{ + /* Next item. */ + struct rc_ver_varinfo *next; + /* Language ID. */ + rc_uint_type language; + /* Character set ID. */ + rc_uint_type charset; +} rc_ver_varinfo; + +typedef struct rc_toolbar_item +{ + struct rc_toolbar_item *next; + struct rc_toolbar_item *prev; + rc_res_id id; +} rc_toolbar_item; + +struct __attribute__ ((__packed__)) bin_messagetable_item +{ + bfd_byte length[2]; + bfd_byte flags[2]; + bfd_byte data[1]; +}; +#define BIN_MESSAGETABLE_ITEM_SIZE 4 + +#define MESSAGE_RESOURCE_UNICODE 0x0001 + +struct __attribute__ ((__packed__)) bin_messagetable_block +{ + bfd_byte lowid[4]; + bfd_byte highid[4]; + bfd_byte offset[4]; +}; +#define BIN_MESSAGETABLE_BLOCK_SIZE 12 + +struct __attribute__ ((__packed__)) bin_messagetable +{ + bfd_byte cblocks[4]; + struct bin_messagetable_block items[1]; +}; +#define BIN_MESSAGETABLE_SIZE 8 + +typedef struct rc_toolbar +{ + rc_uint_type button_width; + rc_uint_type button_height; + rc_uint_type nitems; + rc_toolbar_item *items; +} rc_toolbar; + +struct __attribute__ ((__packed__)) bin_toolbar +{ + bfd_byte button_width[4]; + bfd_byte button_height[4]; + bfd_byte nitems[4]; + /* { bfd_byte id[4]; } * nitems; */ +}; +#define BIN_TOOLBAR_SIZE 12 + +extern int target_is_bigendian; + +typedef struct windres_bfd +{ + bfd *abfd; + asection *sec; + rc_uint_type kind : 4; +} windres_bfd; + +#define WR_KIND_TARGET 0 +#define WR_KIND_BFD 1 +#define WR_KIND_BFD_BIN_L 2 +#define WR_KIND_BFD_BIN_B 3 + +#define WR_KIND(PTR) (PTR)->kind +#define WR_SECTION(PTR) (PTR)->sec +#define WR_BFD(PTR) (PTR)->abfd + +extern void set_windres_bfd_content (windres_bfd *, const void *, rc_uint_type, rc_uint_type); +extern void get_windres_bfd_content (windres_bfd *, void *, rc_uint_type, rc_uint_type); + +extern void windres_put_8 (windres_bfd *, void *, rc_uint_type); +extern void windres_put_16 (windres_bfd *, void *, rc_uint_type); +extern void windres_put_32 (windres_bfd *, void *, rc_uint_type); +extern rc_uint_type windres_get_8 (windres_bfd *, const void *, rc_uint_type); +extern rc_uint_type windres_get_16 (windres_bfd *, const void *, rc_uint_type); +extern rc_uint_type windres_get_32 (windres_bfd *, const void *, rc_uint_type); + +extern void set_windres_bfd (windres_bfd *, bfd *, asection *, rc_uint_type); +extern void set_windres_bfd_endianness (windres_bfd *, int); + +#endif diff --git a/support/sdbinutils/binutils/windmc.c b/support/sdbinutils/binutils/windmc.c new file mode 100644 index 0000000..f6171e4 --- /dev/null +++ b/support/sdbinutils/binutils/windmc.c @@ -0,0 +1,1172 @@ +/* windmc.c -- a program to compile Windows message files. + Copyright (C) 2007-2018 Free Software Foundation, Inc. + Written by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + + +/* This program can read and comile Windows message format. + + It is based on information taken from the following sources: + + * Microsoft documentation. + + * The wmc program, written by Bertho A. Stultiens (BS). */ + +#include "sysdep.h" +#include +#include +#include "bfd.h" +#include "getopt.h" +#include "bucomm.h" +#include "libiberty.h" +#include "safe-ctype.h" +#include "obstack.h" + +#include "windmc.h" +#include "windint.h" + +/* Defines a message compiler element item with length and offset + information. */ +typedef struct mc_msg_item +{ + rc_uint_type res_len; + rc_uint_type res_off; + struct bin_messagetable_item *res; +} mc_msg_item; + +int target_is_bigendian = 0; +const char *def_target_arch; + +/* Globals and static variable definitions. */ + +/* bfd global helper struct variable. */ +static struct +{ + bfd *abfd; + asection *sec; +} mc_bfd; + +/* Memory list. */ +mc_node *mc_nodes = NULL; +static mc_node_lang **mc_nodes_lang = NULL; +static int mc_nodes_lang_count = 0; +static mc_keyword **mc_severity_codes = NULL; +static int mc_severity_codes_count = 0; +static mc_keyword **mc_facility_codes = NULL; +static int mc_facility_codes_count = 0; + +/* When we are building a resource tree, we allocate everything onto + an obstack, so that we can free it all at once if we want. */ +#define obstack_chunk_alloc xmalloc +#define obstack_chunk_free free + +/* The resource building obstack. */ +static struct obstack res_obstack; + +/* Flag variables. */ +/* Set by -C. Set the default code page to be used for input text file. */ +static rc_uint_type mcset_codepage_in = 0; + +/* Set by -O. Set the default code page to be used for output text files. */ +static rc_uint_type mcset_codepage_out = 0; + +/* Set by -b. .BIN filename should have .mc filename_ included for uniqueness. */ +static int mcset_prefix_bin = 0; + +/* The base name of the .mc file. */ +static const char *mcset_mc_basename = "unknown"; + +/* Set by -e . Specify the extension for the header file. */ +static const char *mcset_header_ext = ".h"; + +/* Set by -h . Gives the path of where to create the C include file. */ +static const char *mcset_header_dir = "./"; + +/* Set by -r . Gives the path of where to create the RC include file + and the binary message resource files it includes. */ +static const char *mcset_rc_dir = "./"; + +/* Modified by -a & -u. By -u input file is unicode, by -a is ASCII (default). */ +static int mcset_text_in_is_unicode = 0; + +/* Modified by -A & -U. By -U bin file is unicode (default), by -A is ASCII. */ +static int mcset_bin_out_is_unicode = 1; + +/* Set by -c. Sets the Customer bit in all the message ID's. */ +int mcset_custom_bit = 0; + +/* Set by -o. Generate OLE2 header file. Use HRESULT definition instead of + status code definition. */ +static int mcset_use_hresult = 0; + +/* Set by -m . Generate a warning if the size of any message exceeds + maxmsglen characters. */ +rc_uint_type mcset_max_message_length = 0; + +/* Set by -d. Sets message values in header to decimal initially. */ +int mcset_out_values_are_decimal = 0; + +/* Set by -n. terminates all strings with null's in the message tables. */ +static int mcset_automatic_null_termination = 0; + +/* The type used for message id output in header. */ +unichar *mcset_msg_id_typedef = NULL; + +/* Set by -x path. Geberated debug C file for mapping ID's to text. */ +static const char *mcset_dbg_dir = NULL; + +/* getopt long name definitions. */ +static const struct option long_options[] = +{ + {"binprefix", no_argument, 0, 'b'}, + {"target", required_argument, 0, 'F'}, + {"extension", required_argument, 0, 'e'}, + {"headerdir", required_argument, 0, 'h'}, + {"rcdir", required_argument, 0, 'r'}, + {"verbose", no_argument, 0, 'v'}, + {"codepage_in", required_argument, 0, 'C'}, + {"codepage_out", required_argument, 0, 'O'}, + {"maxlength", required_argument, 0, 'm'}, + {"ascii_in", no_argument, 0, 'a'}, + {"ascii_out", no_argument, 0, 'A'}, + {"unicode_in", no_argument, 0, 'u'}, + {"unicode_out", no_argument, 0, 'U'}, + {"customflag", no_argument, 0, 'c'}, + {"decimal_values", no_argument, 0, 'd'}, + {"hresult_use", no_argument, 0, 'o'}, + {"nullterminate", no_argument, 0, 'n'}, + {"xdbg", required_argument, 0, 'x'}, + {"version", no_argument, 0, 'V'}, + {"help", no_argument, 0, 'H'}, + {0, no_argument, 0, 0} +}; + + +/* Initialize the resource building obstack. */ +static void +res_init (void) +{ + obstack_init (&res_obstack); +} + +/* Allocate space on the resource building obstack. */ +void * +res_alloc (rc_uint_type bytes) +{ + return obstack_alloc (&res_obstack, (size_t) bytes); +} + +static FILE * +mc_create_path_text_file (const char *path, const char *ext) +{ + FILE *ret; + size_t len = 1; + char *hsz; + + len += (path != NULL ? strlen (path) : 0); + len += strlen (mcset_mc_basename); + len += (ext != NULL ? strlen (ext) : 0); + hsz = xmalloc (len); + sprintf (hsz, "%s%s%s", (path != NULL ? path : ""), mcset_mc_basename, + (ext != NULL ? ext : "")); + if ((ret = fopen (hsz, "wb")) == NULL) + fatal (_("can't create %s file `%s' for output.\n"), (ext ? ext : "text"), hsz); + free (hsz); + return ret; +} + +static void +usage (FILE *stream, int status) +{ + fprintf (stream, _("Usage: %s [option(s)] [input-file]\n"), + program_name); + fprintf (stream, _(" The options are:\n\ + -a --ascii_in Read input file as ASCII file\n\ + -A --ascii_out Write binary messages as ASCII\n\ + -b --binprefix .bin filename is prefixed by .mc filename_ for uniqueness.\n\ + -c --customflag Set custom flags for messages\n\ + -C --codepage_in= Set codepage when reading mc text file\n\ + -d --decimal_values Print values to text files decimal\n\ + -e --extension= Set header extension used on export header file\n\ + -F --target Specify output target for endianness.\n\ + -h --headerdir= Set the export directory for headers\n\ + -u --unicode_in Read input file as UTF16 file\n\ + -U --unicode_out Write binary messages as UFT16\n\ + -m --maxlength= Set the maximal allowed message length\n\ + -n --nullterminate Automatic add a zero termination to strings\n\ + -o --hresult_use Use HRESULT definition instead of status code definition\n\ + -O --codepage_out= Set codepage used for writing text file\n\ + -r --rcdir= Set the export directory for rc files\n\ + -x --xdbg= Where to create the .dbg C include file\n\ + that maps message ID's to their symbolic name.\n\ +")); + fprintf (stream, _("\ + -H --help Print this help message\n\ + -v --verbose Verbose - tells you what it's doing\n\ + -V --version Print version information\n")); + + list_supported_targets (program_name, stream); + + if (REPORT_BUGS_TO[0] && status == 0) + fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); + + exit (status); +} + +static void +set_endianness (bfd *abfd, const char *target) +{ + const bfd_target *target_vec; + + def_target_arch = NULL; + target_vec = bfd_get_target_info (target, abfd, &target_is_bigendian, NULL, + &def_target_arch); + if (! target_vec) + fatal ("Can't detect target endianness and architecture."); + if (! def_target_arch) + fatal ("Can't detect architecture."); +} + +static int +probe_codepage (rc_uint_type *cp, int *is_uni, const char *pswitch, int defmode) +{ + if (*is_uni == -1) + { + if (*cp != CP_UTF16) + *is_uni = defmode; + else + *is_uni = 1; + } + if (*is_uni) + { + if (*cp != 0 && *cp != CP_UTF16) + { + fprintf (stderr, _("%s: warning: "), program_name); + fprintf (stderr, _("A codepage was specified switch `%s' and UTF16.\n"), pswitch); + fprintf (stderr, _("\tcodepage settings are ignored.\n")); + } + *cp = CP_UTF16; + return 1; + } + if (*cp == CP_UTF16) + { + *is_uni = 1; + return 1; + } + if (*cp == 0) + *cp = 1252; + if (! unicode_is_valid_codepage (*cp)) + fatal ("Code page 0x%x is unknown.", (unsigned int) *cp); + *is_uni = 0; + return 1; +} + +mc_node * +mc_add_node (void) +{ + mc_node *ret; + + ret = res_alloc (sizeof (mc_node)); + memset (ret, 0, sizeof (mc_node)); + if (! mc_nodes) + mc_nodes = ret; + else + { + mc_node *h = mc_nodes; + + while (h->next != NULL) + h = h->next; + h->next = ret; + } + return ret; +} + +mc_node_lang * +mc_add_node_lang (mc_node *root, const mc_keyword *lang, rc_uint_type vid) +{ + mc_node_lang *ret, *h, *p; + + if (! lang || ! root) + fatal (_("try to add a ill language.")); + ret = res_alloc (sizeof (mc_node_lang)); + memset (ret, 0, sizeof (mc_node_lang)); + ret->lang = lang; + ret->vid = vid; + if ((h = root->sub) == NULL) + root->sub = ret; + else + { + p = NULL; + while (h != NULL) + { + if (h->lang->nval > lang->nval) + break; + if (h->lang->nval == lang->nval) + { + if (h->vid > vid) + break; + if (h->vid == vid) + fatal ("double defined message id %ld.\n", (long) vid); + } + h = (p = h)->next; + } + ret->next = h; + if (! p) + root->sub = ret; + else + p->next = ret; + } + return ret; +} + +static char * +convert_unicode_to_ACP (const unichar *usz) +{ + char *s; + rc_uint_type l; + + if (! usz) + return NULL; + codepage_from_unicode (&l, usz, &s, mcset_codepage_out); + if (! s) + fatal ("unicode string not mappable to ASCII codepage 0x%lx.\n", + (unsigned long) mcset_codepage_out); + return s; +} + +static void +write_dbg_define (FILE *fp, const unichar *sym_name, const unichar *typecast) +{ + char *sym; + + if (!sym_name || sym_name[0] == 0) + return; + sym = convert_unicode_to_ACP (sym_name); + fprintf (fp, " {("); + if (typecast) + unicode_print (fp, typecast, unichar_len (typecast)); + else + fprintf (fp, "DWORD"); + fprintf (fp, ") %s, \"%s\" },\n", sym, sym); +} + +static void +write_header_define (FILE *fp, const unichar *sym_name, rc_uint_type vid, const unichar *typecast, mc_node_lang *nl) +{ + char *sym; + char *tdef = NULL; + + if (!sym_name || sym_name[0] == 0) + { + if (nl != NULL) + { + if (mcset_out_values_are_decimal) + fprintf (fp, "//\n// MessageId: 0x%lu\n//\n", (unsigned long) vid); + else + fprintf (fp, "//\n// MessageId: 0x%lx\n//\n", (unsigned long) vid); + } + return; + } + sym = convert_unicode_to_ACP (sym_name); + if (typecast && typecast[0] != 0) + tdef = convert_unicode_to_ACP (typecast); + fprintf (fp, "//\n// MessageId: %s\n//\n", sym); + if (! mcset_out_values_are_decimal) + fprintf (fp, "#define %s %s%s%s 0x%lx\n\n", sym, + (tdef ? "(" : ""), (tdef ? tdef : ""), (tdef ? ")" : ""), + (unsigned long) vid); + else + fprintf (fp, "#define %s %s%s%s 0x%lu\n\n", sym, + (tdef ? "(" : ""), (tdef ? tdef : ""), (tdef ? ")" : ""), + (unsigned long) vid); +} + +static int +sort_mc_node_lang (const void *l, const void *r) +{ + const mc_node_lang *l1 = *((const mc_node_lang **)l); + const mc_node_lang *r1 = *((const mc_node_lang **)r); + + if (l == r) + return 0; + if (l1->lang != r1->lang) + { + if (l1->lang->nval < r1->lang->nval) + return -1; + return 1; + } + if (l1->vid == r1->vid) + return 0; + if (l1->vid < r1->vid) + return -1; + return 1; +} + +static int +sort_keyword_by_nval (const void *l, const void *r) +{ + const mc_keyword *l1 = *((const mc_keyword **)l); + const mc_keyword *r1 = *((const mc_keyword **)r); + rc_uint_type len1, len2; + int e; + + if (l == r) + return 0; + if (l1->nval != r1->nval) + { + if (l1->nval < r1->nval) + return -1; + return 1; + } + len1 = unichar_len (l1->usz); + len2 = unichar_len (r1->usz); + if (len1 <= len2) + e = memcmp (l1->usz, r1->usz, sizeof (unichar) * len1); + else + e = memcmp (l1->usz, r1->usz, sizeof (unichar) * len2); + if (e) + return e; + if (len1 < len2) + return -1; + else if (len1 > len2) + return 1; + return 0; +} + +static void +do_sorts (void) +{ + mc_node *h; + mc_node_lang *n; + const mc_keyword *k; + int i; + + /* Sort message by their language and id ascending. */ + mc_nodes_lang_count = 0; + + h = mc_nodes; + while (h != NULL) + { + n = h->sub; + while (n != NULL) + { + mc_nodes_lang_count +=1; + n = n->next; + } + h = h->next; + } + + if (mc_nodes_lang_count != 0) + { + h = mc_nodes; + i = 0; + mc_nodes_lang = xmalloc (sizeof (mc_node_lang *) * mc_nodes_lang_count); + + while (h != NULL) + { + n = h->sub; + while (n != NULL) + { + mc_nodes_lang[i++] = n; + n = n->next; + } + h = h->next; + } + qsort (mc_nodes_lang, (size_t) mc_nodes_lang_count, sizeof (mc_node_lang *), sort_mc_node_lang); + } + /* Sort facility code definitions by there id ascending. */ + i = 0; + while ((k = enum_facility (i)) != NULL) + ++i; + mc_facility_codes_count = i; + if (i != 0) + { + mc_facility_codes = xmalloc (sizeof (mc_keyword *) * i); + i = 0; + while ((k = enum_facility (i)) != NULL) + mc_facility_codes[i++] = (mc_keyword *) k; + qsort (mc_facility_codes, (size_t) mc_facility_codes_count, sizeof (mc_keyword *), sort_keyword_by_nval); + } + + /* Sort severity code definitions by there id ascending. */ + i = 0; + while ((k = enum_severity (i)) != NULL) + ++i; + mc_severity_codes_count = i; + if (i != 0) + { + mc_severity_codes = xmalloc (sizeof (mc_keyword *) * i); + i = 0; + while ((k = enum_severity (i)) != NULL) + mc_severity_codes[i++] = (mc_keyword *) k; + qsort (mc_severity_codes, (size_t) mc_severity_codes_count, sizeof (mc_keyword *), sort_keyword_by_nval); + } +} + +static int +mc_get_block_count (mc_node_lang **nl, int elems) +{ + rc_uint_type exid; + int i, ret; + + if (! nl) + return 0; + i = 0; + ret = 0; + while (i < elems) + { + ret++; + exid = nl[i++]->vid; + while (i < elems && nl[i]->vid == exid + 1) + exid = nl[i++]->vid; + } + return ret; +} + +static bfd * +windmc_open_as_binary (const char *filename) +{ + bfd *abfd; + + abfd = bfd_openw (filename, "binary"); + if (! abfd) + fatal ("can't open `%s' for output", filename); + + return abfd; +} + +static void +target_put_16 (void *p, rc_uint_type value) +{ + assert (!! p); + + if (target_is_bigendian) + bfd_putb16 (value, p); + else + bfd_putl16 (value, p); +} + +static void +target_put_32 (void *p, rc_uint_type value) +{ + assert (!! p); + + if (target_is_bigendian) + bfd_putb32 (value, p); + else + bfd_putl32 (value, p); +} + +static struct bin_messagetable_item * +mc_generate_bin_item (mc_node_lang *n, rc_uint_type *res_len) +{ + struct bin_messagetable_item *ret = NULL; + rc_uint_type len; + + *res_len = 0; + if (mcset_bin_out_is_unicode == 1) + { + unichar *ht = n->message; + rc_uint_type txt_len; + + txt_len = unichar_len (n->message); + if (mcset_automatic_null_termination && txt_len != 0) + { + while (txt_len > 0 && ht[txt_len - 1] > 0 && ht[txt_len - 1] < 0x20) + ht[--txt_len] = 0; + } + txt_len *= sizeof (unichar); + len = BIN_MESSAGETABLE_ITEM_SIZE + txt_len + sizeof (unichar); + ret = res_alloc ((len + 3) & ~3); + memset (ret, 0, (len + 3) & ~3); + target_put_16 (ret->length, (len + 3) & ~3); + target_put_16 (ret->flags, MESSAGE_RESOURCE_UNICODE); + txt_len = 0; + while (*ht != 0) + { + target_put_16 (ret->data + txt_len, *ht++); + txt_len += 2; + } + } + else + { + rc_uint_type txt_len, l; + char *cvt_txt; + + codepage_from_unicode( &l, n->message, &cvt_txt, n->lang->lang_info.wincp); + if (! cvt_txt) + fatal ("Failed to convert message to language codepage.\n"); + txt_len = strlen (cvt_txt); + if (mcset_automatic_null_termination && txt_len > 0) + { + while (txt_len > 0 && cvt_txt[txt_len - 1] > 0 && cvt_txt[txt_len - 1] < 0x20) + cvt_txt[--txt_len] = 0; + } + len = BIN_MESSAGETABLE_ITEM_SIZE + txt_len + 1; + ret = res_alloc ((len + 3) & ~3); + memset (ret, 0, (len + 3) & ~3); + target_put_16 (ret->length, (len + 3) & ~3); + target_put_16 (ret->flags, 0); + strcpy ((char *) ret->data, cvt_txt); + } + *res_len = (len + 3) & ~3; + return ret; +} + +static void +mc_write_blocks (struct bin_messagetable *mtbl, mc_node_lang **nl, mc_msg_item *ml, int elems) +{ + int i, idx = 0; + rc_uint_type exid; + + if (! nl) + return; + i = 0; + while (i < elems) + { + target_put_32 (mtbl->items[idx].lowid, nl[i]->vid); + target_put_32 (mtbl->items[idx].highid, nl[i]->vid); + target_put_32 (mtbl->items[idx].offset, ml[i].res_off); + exid = nl[i++]->vid; + while (i < elems && nl[i]->vid == exid + 1) + { + target_put_32 (mtbl->items[idx].highid, nl[i]->vid); + exid = nl[i++]->vid; + } + ++idx; + } +} + +static void +set_windmc_bfd_content (const void *data, rc_uint_type off, rc_uint_type length) +{ + if (! bfd_set_section_contents (mc_bfd.abfd, mc_bfd.sec, data, off, length)) + bfd_fatal ("bfd_set_section_contents"); +} + +static void +windmc_write_bin (const char *filename, mc_node_lang **nl, int elems) +{ + unsigned long sec_length = 1; + int block_count, i; + mc_msg_item *mi; + struct bin_messagetable *mtbl; + rc_uint_type dta_off, dta_start; + + if (elems <= 0) + return; + mc_bfd.abfd = windmc_open_as_binary (filename); + mc_bfd.sec = bfd_make_section_with_flags (mc_bfd.abfd, ".data", + (SEC_HAS_CONTENTS | SEC_ALLOC + | SEC_LOAD | SEC_DATA)); + if (mc_bfd.sec == NULL) + bfd_fatal ("bfd_make_section"); + /* Requiring this is probably a bug in BFD. */ + mc_bfd.sec->output_section = mc_bfd.sec; + + block_count = mc_get_block_count (nl, elems); + + dta_off = (rc_uint_type) ((BIN_MESSAGETABLE_BLOCK_SIZE * block_count) + BIN_MESSAGETABLE_SIZE - 4); + dta_start = dta_off = (dta_off + 3) & ~3; + mi = xmalloc (sizeof (mc_msg_item) * elems); + mtbl = xmalloc (dta_start); + + /* Clear header region. */ + memset (mtbl, 0, dta_start); + target_put_32 (mtbl->cblocks, block_count); + /* Prepare items section for output. */ + for (i = 0; i < elems; i++) + { + mi[i].res_off = dta_off; + mi[i].res = mc_generate_bin_item (nl[i], &mi[i].res_len); + dta_off += mi[i].res_len; + } + sec_length = (dta_off + 3) & ~3; + if (! bfd_set_section_size (mc_bfd.abfd, mc_bfd.sec, sec_length)) + bfd_fatal ("bfd_set_section_size"); + /* Make sure we write the complete block. */ + set_windmc_bfd_content ("\0", sec_length - 1, 1); + + /* Write block information. */ + mc_write_blocks (mtbl, nl, mi, elems); + + set_windmc_bfd_content (mtbl, 0, dta_start); + + /* Write items. */ + for (i = 0; i < elems; i++) + set_windmc_bfd_content (mi[i].res, mi[i].res_off, mi[i].res_len); + + free (mtbl); + free (mi); + bfd_close (mc_bfd.abfd); + mc_bfd.abfd = NULL; + mc_bfd.sec = NULL; +} + +static void +write_bin (void) +{ + mc_node_lang *n = NULL; + int i, c; + + if (! mc_nodes_lang_count) + return; + + i = 0; + while (i < mc_nodes_lang_count) + { + char *nd; + char *filename; + + if (n && n->lang == mc_nodes_lang[i]->lang) + { + i++; + continue; + } + n = mc_nodes_lang[i]; + c = i + 1; + while (c < mc_nodes_lang_count && n->lang == mc_nodes_lang[c]->lang) + c++; + nd = convert_unicode_to_ACP (n->lang->sval); + + /* Prepare filename for binary output. */ + filename = xmalloc (strlen (nd) + 4 + 1 + strlen (mcset_mc_basename) + 1 + strlen (mcset_rc_dir)); + strcpy (filename, mcset_rc_dir); + if (mcset_prefix_bin) + sprintf (filename + strlen (filename), "%s_", mcset_mc_basename); + strcat (filename, nd); + strcat (filename, ".bin"); + + /* Write message file. */ + windmc_write_bin (filename, &mc_nodes_lang[i], (c - i)); + + free (filename); + i = c; + } +} + +static void +write_rc (FILE *fp) +{ + mc_node_lang *n; + int i, l; + + fprintf (fp, + "/* Do not edit this file manually.\n" + " This file is autogenerated by windmc. */\n\n"); + if (! mc_nodes_lang_count) + return; + n = NULL; + i = 0; + for (l = 0; l < mc_nodes_lang_count; l++) + { + if (n && n->lang == mc_nodes_lang[l]->lang) + continue; + ++i; + n = mc_nodes_lang[l]; + fprintf (fp, "\n// Country: %s\n// Language: %s\n#pragma code_page(%u)\n", + n->lang->lang_info.country, n->lang->lang_info.name, + (unsigned) n->lang->lang_info.wincp); + fprintf (fp, "LANGUAGE 0x%lx, 0x%lx\n", + (unsigned long) (n->lang->nval & 0x3ff), + (unsigned long) ((n->lang->nval & 0xffff) >> 10)); + fprintf (fp, "1 MESSAGETABLE \""); + if (mcset_prefix_bin) + fprintf (fp, "%s_", mcset_mc_basename); + unicode_print (fp, n->lang->sval, unichar_len (n->lang->sval)); + fprintf (fp, ".bin\"\n"); + } +} + +static void +write_dbg (FILE *fp) +{ + mc_node *h; + + fprintf (fp, + "/* Do not edit this file manually.\n" + " This file is autogenerated by windmc.\n\n" + " This file maps each message ID value in to a text string that contains\n" + " the symbolic name used for it. */\n\n"); + + fprintf (fp, + "struct %sSymbolicName\n" + "{\n ", mcset_mc_basename); + if (mcset_msg_id_typedef) + unicode_print (fp, mcset_msg_id_typedef, unichar_len (mcset_msg_id_typedef)); + else + fprintf (fp, "DWORD"); + fprintf (fp, + " MessageId;\n" + " char *SymbolicName;\n" + "} %sSymbolicNames[] =\n" + "{\n", mcset_mc_basename); + h = mc_nodes; + while (h != NULL) + { + if (h->symbol) + write_dbg_define (fp, h->symbol, mcset_msg_id_typedef); + h = h->next; + } + fprintf (fp, " { ("); + if (mcset_msg_id_typedef) + unicode_print (fp, mcset_msg_id_typedef, unichar_len (mcset_msg_id_typedef)); + else + fprintf (fp, "DWORD"); + fprintf (fp, + ") 0xffffffff, NULL }\n" + "};\n"); +} + +static void +write_header (FILE *fp) +{ + char *s; + int i; + const mc_keyword *key; + mc_node *h; + + fprintf (fp, + "/* Do not edit this file manually.\n" + " This file is autogenerated by windmc. */\n\n" + "//\n// The values are 32 bit layed out as follows:\n//\n" + "// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1\n" + "// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0\n" + "// +---+-+-+-----------------------+-------------------------------+\n" + "// |Sev|C|R| Facility | Code |\n" + "// +---+-+-+-----------------------+-------------------------------+\n//\n" + "// where\n//\n" + "// C - is the Customer code flag\n//\n" + "// R - is a reserved bit\n//\n" + "// Code - is the facility's status code\n//\n"); + + h = mc_nodes; + + fprintf (fp, "// Sev - is the severity code\n//\n"); + if (mc_severity_codes_count != 0) + { + for (i = 0; i < mc_severity_codes_count; i++) + { + key = mc_severity_codes[i]; + fprintf (fp, "// %s - %02lx\n", convert_unicode_to_ACP (key->usz), + (unsigned long) key->nval); + if (key->sval && key->sval[0] != 0) + { + if (! mcset_out_values_are_decimal) + fprintf (fp, "#define %s 0x%lx\n", convert_unicode_to_ACP (key->sval), + (unsigned long) key->nval); + else + fprintf (fp, "#define %s 0x%lu\n", convert_unicode_to_ACP (key->sval), + (unsigned long) key->nval); + } + } + fprintf (fp, "//\n"); + } + fprintf (fp, "// Facility - is the facility code\n//\n"); + if (mc_facility_codes_count != 0) + { + for (i = 0; i < mc_facility_codes_count; i++) + { + key = mc_facility_codes[i]; + fprintf (fp, "// %s - %04lx\n", convert_unicode_to_ACP (key->usz), + (unsigned long) key->nval); + if (key->sval && key->sval[0] != 0) + { + if (! mcset_out_values_are_decimal) + fprintf (fp, "#define %s 0x%lx\n", convert_unicode_to_ACP (key->sval), + (unsigned long) key->nval); + else + fprintf (fp, "#define %s 0x%lu\n", convert_unicode_to_ACP (key->sval), + (unsigned long) key->nval); + } + } + fprintf (fp, "//\n"); + } + fprintf (fp, "\n"); + while (h != NULL) + { + if (h->user_text) + { + s = convert_unicode_to_ACP (h->user_text); + if (s) + fprintf (fp, "%s", s); + } + if (h->symbol) + write_header_define (fp, h->symbol, h->vid, mcset_msg_id_typedef, h->sub); + h = h->next; + } +} + +static const char * +mc_unify_path (const char *path) +{ + char *end; + char *hsz; + + if (! path || *path == 0) + return "./"; + hsz = xmalloc (strlen (path) + 2); + strcpy (hsz, path); + end = hsz + strlen (hsz); + if (hsz[-1] != '/' && hsz[-1] != '\\') + strcpy (end, "/"); + while ((end = strchr (hsz, '\\')) != NULL) + *end = '/'; + return hsz; +} + +int main (int, char **); + +int +main (int argc, char **argv) +{ + FILE *h_fp; + int c; + char *target, *input_filename; + int verbose; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + program_name = argv[0]; + xmalloc_set_program_name (program_name); + bfd_set_error_program_name (program_name); + + expandargv (&argc, &argv); + + bfd_init (); + set_default_bfd_target (); + + target = NULL; + verbose = 0; + input_filename = NULL; + + res_init (); + + while ((c = getopt_long (argc, argv, "C:F:O:h:e:m:r:x:aAbcdHunoUvV", long_options, + (int *) 0)) != EOF) + { + switch (c) + { + case 'b': + mcset_prefix_bin = 1; + break; + case 'e': + { + mcset_header_ext = optarg; + if (mcset_header_ext[0] != '.' && mcset_header_ext[0] != 0) + { + char *hsz = xmalloc (strlen (mcset_header_ext) + 2); + + sprintf (hsz, ".%s", mcset_header_ext); + mcset_header_ext = hsz; + } + } + break; + case 'h': + mcset_header_dir = mc_unify_path (optarg); + break; + case 'r': + mcset_rc_dir = mc_unify_path (optarg); + break; + case 'a': + mcset_text_in_is_unicode = 0; + break; + case 'x': + if (*optarg != 0) + mcset_dbg_dir = mc_unify_path (optarg); + break; + case 'A': + mcset_bin_out_is_unicode = 0; + break; + case 'd': + mcset_out_values_are_decimal = 1; + break; + case 'u': + mcset_text_in_is_unicode = 1; + break; + case 'U': + mcset_bin_out_is_unicode = 1; + break; + case 'c': + mcset_custom_bit = 1; + break; + case 'n': + mcset_automatic_null_termination = 1; + break; + case 'o': + mcset_use_hresult = 1; + fatal ("option -o is not implemented until yet.\n"); + break; + case 'F': + target = optarg; + break; + case 'v': + verbose ++; + break; + case 'm': + mcset_max_message_length = strtol (optarg, (char **) NULL, 10); + break; + case 'C': + mcset_codepage_in = strtol (optarg, (char **) NULL, 10); + break; + case 'O': + mcset_codepage_out = strtol (optarg, (char **) NULL, 10); + break; + case '?': + case 'H': + usage (stdout, 0); + break; + case 'V': + print_version ("windmc"); + break; + + default: + usage (stderr, 1); + break; + } + } + if (input_filename == NULL && optind < argc) + { + input_filename = argv[optind]; + ++optind; + } + + set_endianness (NULL, target); + + if (input_filename == NULL) + { + fprintf (stderr, "Error: No input file was specified.\n"); + usage (stderr, 1); + } + mc_set_inputfile (input_filename); + + if (!probe_codepage (&mcset_codepage_in, &mcset_text_in_is_unicode, "codepage_in", 0)) + usage (stderr, 1); + if (mcset_codepage_out == 0) + mcset_codepage_out = 1252; + if (! unicode_is_valid_codepage (mcset_codepage_out)) + fatal ("Code page 0x%x is unknown.", (unsigned int) mcset_codepage_out); + if (mcset_codepage_out == CP_UTF16) + fatal ("UTF16 is no valid text output code page."); + if (verbose) + { + fprintf (stderr, "// Default target is %s and it is %s endian.\n", + def_target_arch, (target_is_bigendian ? "big" : "little")); + fprintf (stderr, "// Input codepage: 0x%x\n", (unsigned int) mcset_codepage_in); + fprintf (stderr, "// Output codepage: 0x%x\n", (unsigned int) mcset_codepage_out); + } + + if (argc != optind) + usage (stderr, 1); + + /* Initialize mcset_mc_basename. */ + { + const char *bn, *bn2; + char *hsz; + + bn = strrchr (input_filename, '/'); + bn2 = strrchr (input_filename, '\\'); + if (! bn) + bn = bn2; + if (bn && bn2 && bn < bn2) + bn = bn2; + if (! bn) + bn = input_filename; + else + bn++; + mcset_mc_basename = hsz = xstrdup (bn); + + /* Cut of right-hand extension. */ + if ((hsz = strrchr (hsz, '.')) != NULL) + *hsz = 0; + } + + /* Load the input file and do code page transformations to UTF16. */ + { + unichar *u; + rc_uint_type ul; + char *buff; + bfd_size_type flen; + FILE *fp = fopen (input_filename, "rb"); + + if (!fp) + fatal (_("unable to open file `%s' for input.\n"), input_filename); + + fseek (fp, 0, SEEK_END); + flen = ftell (fp); + fseek (fp, 0, SEEK_SET); + buff = malloc (flen + 3); + memset (buff, 0, flen + 3); + if (fread (buff, 1, flen, fp) < flen) + fatal (_("unable to read contents of %s"), input_filename); + fclose (fp); + if (mcset_text_in_is_unicode != 1) + { + unicode_from_codepage (&ul, &u, buff, mcset_codepage_in); + if (! u) + fatal ("Failed to convert input to UFT16\n"); + mc_set_content (u); + } + else + { + if ((flen & 1) != 0) + fatal (_("input file does not seems to be UFT16.\n")); + mc_set_content ((unichar *) buff); + } + free (buff); + } + + while (yyparse ()) + ; + + do_sorts (); + + h_fp = mc_create_path_text_file (mcset_header_dir, mcset_header_ext); + write_header (h_fp); + fclose (h_fp); + + h_fp = mc_create_path_text_file (mcset_rc_dir, ".rc"); + write_rc (h_fp); + fclose (h_fp); + + if (mcset_dbg_dir != NULL) + { + h_fp = mc_create_path_text_file (mcset_dbg_dir, ".dbg"); + write_dbg (h_fp); + fclose (h_fp); + } + write_bin (); + + if (mc_nodes_lang) + free (mc_nodes_lang); + if (mc_severity_codes) + free (mc_severity_codes); + if (mc_facility_codes) + free (mc_facility_codes); + + xexit (0); + return 0; +} diff --git a/support/sdbinutils/binutils/windmc.h b/support/sdbinutils/binutils/windmc.h new file mode 100644 index 0000000..cb6f453 --- /dev/null +++ b/support/sdbinutils/binutils/windmc.h @@ -0,0 +1,98 @@ +/* windmc.h -- header file for windmc program. + Copyright (C) 2007-2018 Free Software Foundation, Inc. + Written by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "ansidecl.h" + +/* This is the header file for the windmc program. It defines + structures and declares functions used within the program. */ + +#include "winduni.h" + +#ifndef WINDMC_HXX +#define WINDMC_HXX + +/* Global flag variables (set by windmc.c file. */ +extern int mcset_custom_bit; +extern int mcset_out_values_are_decimal; +extern rc_uint_type mcset_max_message_length; +extern unichar *mcset_msg_id_typedef; + +/* Lexer keyword definition and internal memory structures. */ + +typedef struct mc_keyword +{ + struct mc_keyword *next; + const char *group_name; + size_t len; + unichar *usz; + int rid; + rc_uint_type nval; + unichar *sval; + wind_language_t lang_info; +} mc_keyword; + +typedef struct mc_node_lang +{ + struct mc_node_lang *next; + rc_uint_type vid; + const mc_keyword *lang; + unichar *message; +} mc_node_lang; + +typedef struct mc_node +{ + struct mc_node *next; + unichar *user_text; + const mc_keyword *facility; + const mc_keyword *severity; + unichar *symbol; + rc_uint_type id; + rc_uint_type vid; + mc_node_lang *sub; +} mc_node; + +extern mc_node *mc_nodes; + +void mc_add_keyword (unichar *, int, const char *, rc_uint_type, unichar *); +const mc_keyword *enum_facility (int); +const mc_keyword *enum_severity (int); + +mc_node_lang *mc_add_node_lang (mc_node *, const mc_keyword *, rc_uint_type); +mc_node *mc_add_node (void); + +/* Standard yacc/flex stuff. */ +int yyerror (const char *, ...); +int yylex (void); +int yyparse (void); + +/* mclex.c */ +void mc_set_inputfile (const char *); +void mc_set_content (const unichar *); + +/* Lexer control variables. Used by mcparser.y file. */ +extern bfd_boolean mclex_want_nl; +extern bfd_boolean mclex_want_line; +extern bfd_boolean mclex_want_filename; + +void mc_fatal (const char *, ...); +void mc_warn (const char *, ...); + +#endif diff --git a/support/sdbinutils/binutils/windres.c b/support/sdbinutils/binutils/windres.c new file mode 100644 index 0000000..7655848 --- /dev/null +++ b/support/sdbinutils/binutils/windres.c @@ -0,0 +1,1408 @@ +/* windres.c -- a program to manipulate Windows resources + Copyright (C) 1997-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Support. + Rewritten by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* This program can read and write Windows resources in various + formats. In particular, it can act like the rc resource compiler + program, and it can act like the cvtres res to COFF conversion + program. + + It is based on information taken from the following sources: + + * Microsoft documentation. + + * The rcl program, written by Gunther Ebert + . + + * The res2coff program, written by Pedro A. Aranda . */ + +#include "sysdep.h" +#include +#include "bfd.h" +#include "getopt.h" +#include "bucomm.h" +#include "libiberty.h" +#include "safe-ctype.h" +#include "obstack.h" +#include "windres.h" + +/* Used by resrc.c at least. */ + +int verbose = 0; + +int target_is_bigendian = 0; +const char *def_target_arch; + +static void set_endianness (bfd *, const char *); + +/* An enumeration of format types. */ + +enum res_format +{ + /* Unknown format. */ + RES_FORMAT_UNKNOWN, + /* Textual RC file. */ + RES_FORMAT_RC, + /* Binary RES file. */ + RES_FORMAT_RES, + /* COFF file. */ + RES_FORMAT_COFF +}; + +/* A structure used to map between format types and strings. */ + +struct format_map +{ + const char *name; + enum res_format format; +}; + +/* A mapping between names and format types. */ + +static const struct format_map format_names[] = +{ + { "rc", RES_FORMAT_RC }, + { "res", RES_FORMAT_RES }, + { "coff", RES_FORMAT_COFF }, + { NULL, RES_FORMAT_UNKNOWN } +}; + +/* A mapping from file extensions to format types. */ + +static const struct format_map format_fileexts[] = +{ + { "rc", RES_FORMAT_RC }, + { "res", RES_FORMAT_RES }, + { "exe", RES_FORMAT_COFF }, + { "obj", RES_FORMAT_COFF }, + { "o", RES_FORMAT_COFF }, + { NULL, RES_FORMAT_UNKNOWN } +}; + +/* A list of include directories. */ + +struct include_dir +{ + struct include_dir *next; + char *dir; +}; + +static struct include_dir *include_dirs; + +/* Static functions. */ + +static void res_init (void); +static int extended_menuitems (const rc_menuitem *); +static enum res_format format_from_name (const char *, int); +static enum res_format format_from_filename (const char *, int); +static void usage (FILE *, int); +static int cmp_res_entry (const void *, const void *); +static rc_res_directory *sort_resources (rc_res_directory *); +static void reswr_init (void); +static const char * quot (const char *); + +static rc_uint_type target_get_8 (const void *, rc_uint_type); +static void target_put_8 (void *, rc_uint_type); +static rc_uint_type target_get_16 (const void *, rc_uint_type); +static void target_put_16 (void *, rc_uint_type); +static rc_uint_type target_get_32 (const void *, rc_uint_type); +static void target_put_32 (void *, rc_uint_type); + + +/* When we are building a resource tree, we allocate everything onto + an obstack, so that we can free it all at once if we want. */ + +#define obstack_chunk_alloc xmalloc +#define obstack_chunk_free free + +/* The resource building obstack. */ + +static struct obstack res_obstack; + +/* Initialize the resource building obstack. */ + +static void +res_init (void) +{ + obstack_init (&res_obstack); +} + +/* Allocate space on the resource building obstack. */ + +void * +res_alloc (rc_uint_type bytes) +{ + return obstack_alloc (&res_obstack, (size_t) bytes); +} + +/* We also use an obstack to save memory used while writing out a set + of resources. */ + +static struct obstack reswr_obstack; + +/* Initialize the resource writing obstack. */ + +static void +reswr_init (void) +{ + obstack_init (&reswr_obstack); +} + +/* Allocate space on the resource writing obstack. */ + +void * +reswr_alloc (rc_uint_type bytes) +{ + return obstack_alloc (&reswr_obstack, (size_t) bytes); +} + +/* Open a file using the include directory search list. */ + +FILE * +open_file_search (const char *filename, const char *mode, const char *errmsg, + char **real_filename) +{ + FILE *e; + struct include_dir *d; + + e = fopen (filename, mode); + if (e != NULL) + { + *real_filename = xstrdup (filename); + return e; + } + + if (errno == ENOENT) + { + for (d = include_dirs; d != NULL; d = d->next) + { + char *n; + + n = (char *) xmalloc (strlen (d->dir) + strlen (filename) + 2); + sprintf (n, "%s/%s", d->dir, filename); + e = fopen (n, mode); + if (e != NULL) + { + *real_filename = n; + return e; + } + free (n); + + if (errno != ENOENT) + break; + } + } + + fatal (_("can't open %s `%s': %s"), errmsg, filename, strerror (errno)); + + /* Return a value to avoid a compiler warning. */ + return NULL; +} + +/* Compare two resource ID's. We consider name entries to come before + numeric entries, because that is how they appear in the COFF .rsrc + section. */ + +int +res_id_cmp (rc_res_id a, rc_res_id b) +{ + if (! a.named) + { + if (b.named) + return 1; + if (a.u.id > b.u.id) + return 1; + else if (a.u.id < b.u.id) + return -1; + else + return 0; + } + else + { + unichar *as, *ase, *bs, *bse; + + if (! b.named) + return -1; + + as = a.u.n.name; + ase = as + a.u.n.length; + bs = b.u.n.name; + bse = bs + b.u.n.length; + + while (as < ase) + { + int i; + + if (bs >= bse) + return 1; + i = (int) *as - (int) *bs; + if (i != 0) + return i; + ++as; + ++bs; + } + + if (bs < bse) + return -1; + + return 0; + } +} + +/* Print a resource ID. */ + +void +res_id_print (FILE *stream, rc_res_id id, int quote) +{ + if (! id.named) + fprintf (stream, "%u", (int) id.u.id); + else + { + if (quote) + unicode_print_quoted (stream, id.u.n.name, id.u.n.length); + else + unicode_print (stream, id.u.n.name, id.u.n.length); + } +} + +/* Print a list of resource ID's. */ + +void +res_ids_print (FILE *stream, int cids, const rc_res_id *ids) +{ + int i; + + for (i = 0; i < cids; i++) + { + res_id_print (stream, ids[i], 1); + if (i + 1 < cids) + fprintf (stream, ": "); + } +} + +/* Convert an ASCII string to a resource ID. */ + +void +res_string_to_id (rc_res_id *res_id, const char *string) +{ + res_id->named = 1; + unicode_from_ascii (&res_id->u.n.length, &res_id->u.n.name, string); +} + +/* Convert an unicode string to a resource ID. */ +void +res_unistring_to_id (rc_res_id *res_id, const unichar *u) +{ + res_id->named = 1; + res_id->u.n.length = unichar_len (u); + res_id->u.n.name = unichar_dup_uppercase (u); +} + +/* Define a resource. The arguments are the resource tree, RESOURCES, + and the location at which to put it in the tree, CIDS and IDS. + This returns a newly allocated rc_res_resource structure, which the + caller is expected to initialize. If DUPOK is non-zero, then if a + resource with this ID exists, it is returned. Otherwise, a warning + is issued, and a new resource is created replacing the existing + one. */ + +rc_res_resource * +define_resource (rc_res_directory **resources, int cids, + const rc_res_id *ids, int dupok) +{ + rc_res_entry *re = NULL; + int i; + + assert (cids > 0); + for (i = 0; i < cids; i++) + { + rc_res_entry **pp; + + if (*resources == NULL) + { + *resources = ((rc_res_directory *) + res_alloc (sizeof (rc_res_directory))); + (*resources)->characteristics = 0; + /* Using a real timestamp only serves to create non-deterministic + results. Use zero instead. */ + (*resources)->time = 0; + (*resources)->major = 0; + (*resources)->minor = 0; + (*resources)->entries = NULL; + } + + for (pp = &(*resources)->entries; *pp != NULL; pp = &(*pp)->next) + if (res_id_cmp ((*pp)->id, ids[i]) == 0) + break; + + if (*pp != NULL) + re = *pp; + else + { + re = (rc_res_entry *) res_alloc (sizeof (rc_res_entry)); + re->next = NULL; + re->id = ids[i]; + if ((i + 1) < cids) + { + re->subdir = 1; + re->u.dir = NULL; + } + else + { + re->subdir = 0; + re->u.res = NULL; + } + + *pp = re; + } + + if ((i + 1) < cids) + { + if (! re->subdir) + { + fprintf (stderr, "%s: ", program_name); + res_ids_print (stderr, i, ids); + fprintf (stderr, _(": expected to be a directory\n")); + xexit (1); + } + + resources = &re->u.dir; + } + } + + if (re->subdir) + { + fprintf (stderr, "%s: ", program_name); + res_ids_print (stderr, cids, ids); + fprintf (stderr, _(": expected to be a leaf\n")); + xexit (1); + } + + if (re->u.res != NULL) + { + if (dupok) + return re->u.res; + + fprintf (stderr, _("%s: warning: "), program_name); + res_ids_print (stderr, cids, ids); + fprintf (stderr, _(": duplicate value\n")); + } + + re->u.res = ((rc_res_resource *) + res_alloc (sizeof (rc_res_resource))); + memset (re->u.res, 0, sizeof (rc_res_resource)); + + re->u.res->type = RES_TYPE_UNINITIALIZED; + return re->u.res; +} + +/* Define a standard resource. This is a version of define_resource + that just takes type, name, and language arguments. */ + +rc_res_resource * +define_standard_resource (rc_res_directory **resources, int type, + rc_res_id name, rc_uint_type language, int dupok) +{ + rc_res_id a[3]; + + a[0].named = 0; + a[0].u.id = type; + a[1] = name; + a[2].named = 0; + a[2].u.id = language; + return define_resource (resources, 3, a, dupok); +} + +/* Comparison routine for resource sorting. */ + +static int +cmp_res_entry (const void *p1, const void *p2) +{ + const rc_res_entry **re1, **re2; + + re1 = (const rc_res_entry **) p1; + re2 = (const rc_res_entry **) p2; + return res_id_cmp ((*re1)->id, (*re2)->id); +} + +/* Sort the resources. */ + +static rc_res_directory * +sort_resources (rc_res_directory *resdir) +{ + int c, i; + rc_res_entry *re; + rc_res_entry **a; + + if (resdir->entries == NULL) + return resdir; + + c = 0; + for (re = resdir->entries; re != NULL; re = re->next) + ++c; + + /* This is a recursive routine, so using xmalloc is probably better + than alloca. */ + a = (rc_res_entry **) xmalloc (c * sizeof (rc_res_entry *)); + + for (i = 0, re = resdir->entries; re != NULL; re = re->next, i++) + a[i] = re; + + qsort (a, c, sizeof (rc_res_entry *), cmp_res_entry); + + resdir->entries = a[0]; + for (i = 0; i < c - 1; i++) + a[i]->next = a[i + 1]; + a[i]->next = NULL; + + free (a); + + /* Now sort the subdirectories. */ + + for (re = resdir->entries; re != NULL; re = re->next) + if (re->subdir) + re->u.dir = sort_resources (re->u.dir); + + return resdir; +} + +/* Return whether the dialog resource DIALOG is a DIALOG or a + DIALOGEX. */ + +int +extended_dialog (const rc_dialog *dialog) +{ + const rc_dialog_control *c; + + if (dialog->ex != NULL) + return 1; + + for (c = dialog->controls; c != NULL; c = c->next) + if (c->data != NULL || c->help != 0) + return 1; + + return 0; +} + +/* Return whether MENUITEMS are a MENU or a MENUEX. */ + +int +extended_menu (const rc_menu *menu) +{ + return extended_menuitems (menu->items); +} + +static int +extended_menuitems (const rc_menuitem *menuitems) +{ + const rc_menuitem *mi; + + for (mi = menuitems; mi != NULL; mi = mi->next) + { + if (mi->help != 0 || mi->state != 0) + return 1; + if (mi->popup != NULL && mi->id != 0) + return 1; + if ((mi->type + & ~ (MENUITEM_CHECKED + | MENUITEM_GRAYED + | MENUITEM_HELP + | MENUITEM_INACTIVE + | MENUITEM_MENUBARBREAK + | MENUITEM_MENUBREAK)) + != 0) + return 1; + if (mi->popup != NULL) + { + if (extended_menuitems (mi->popup)) + return 1; + } + } + + return 0; +} + +/* Convert a string to a format type, or exit if it can't be done. */ + +static enum res_format +format_from_name (const char *name, int exit_on_error) +{ + const struct format_map *m; + + for (m = format_names; m->name != NULL; m++) + if (strcasecmp (m->name, name) == 0) + break; + + if (m->name == NULL && exit_on_error) + { + non_fatal (_("unknown format type `%s'"), name); + fprintf (stderr, _("%s: supported formats:"), program_name); + for (m = format_names; m->name != NULL; m++) + fprintf (stderr, " %s", m->name); + fprintf (stderr, "\n"); + xexit (1); + } + + return m->format; +} + +/* Work out a format type given a file name. If INPUT is non-zero, + it's OK to look at the file itself. */ + +static enum res_format +format_from_filename (const char *filename, int input) +{ + const char *ext; + FILE *e; + bfd_byte b1, b2, b3, b4, b5; + int magic; + + /* If we have an extension, see if we recognize it as implying a + particular format. */ + ext = strrchr (filename, '.'); + if (ext != NULL) + { + const struct format_map *m; + + ++ext; + for (m = format_fileexts; m->name != NULL; m++) + if (strcasecmp (m->name, ext) == 0) + return m->format; + } + + /* If we don't recognize the name of an output file, assume it's a + COFF file. */ + if (! input) + return RES_FORMAT_COFF; + + /* Read the first few bytes of the file to see if we can guess what + it is. */ + e = fopen (filename, FOPEN_RB); + if (e == NULL) + fatal ("%s: %s", filename, strerror (errno)); + + b1 = getc (e); + b2 = getc (e); + b3 = getc (e); + b4 = getc (e); + b5 = getc (e); + + fclose (e); + + /* A PE executable starts with 0x4d 0x5a. */ + if (b1 == 0x4d && b2 == 0x5a) + return RES_FORMAT_COFF; + + /* A COFF .o file starts with a COFF magic number. */ + magic = (b2 << 8) | b1; + switch (magic) + { + case 0x14c: /* i386 */ + case 0x166: /* MIPS */ + case 0x184: /* Alpha */ + case 0x268: /* 68k */ + case 0x1f0: /* PowerPC */ + case 0x290: /* PA */ + return RES_FORMAT_COFF; + } + + /* A RES file starts with 0x0 0x0 0x0 0x0 0x20 0x0 0x0 0x0. */ + if (b1 == 0 && b2 == 0 && b3 == 0 && b4 == 0 && b5 == 0x20) + return RES_FORMAT_RES; + + /* If every character is printable or space, assume it's an RC file. */ + if ((ISPRINT (b1) || ISSPACE (b1)) + && (ISPRINT (b2) || ISSPACE (b2)) + && (ISPRINT (b3) || ISSPACE (b3)) + && (ISPRINT (b4) || ISSPACE (b4)) + && (ISPRINT (b5) || ISSPACE (b5))) + return RES_FORMAT_RC; + + /* Otherwise, we give up. */ + fatal (_("can not determine type of file `%s'; use the -J option"), + filename); + + /* Return something to silence the compiler warning. */ + return RES_FORMAT_UNKNOWN; +} + +/* Print a usage message and exit. */ + +static void +usage (FILE *stream, int status) +{ + fprintf (stream, _("Usage: %s [option(s)] [input-file] [output-file]\n"), + program_name); + fprintf (stream, _(" The options are:\n\ + -i --input= Name input file\n\ + -o --output= Name output file\n\ + -J --input-format= Specify input format\n\ + -O --output-format= Specify output format\n\ + -F --target= Specify COFF target\n\ + --preprocessor= Program to use to preprocess rc file\n\ + --preprocessor-arg= Additional preprocessor argument\n\ + -I --include-dir= Include directory when preprocessing rc file\n\ + -D --define [=] Define SYM when preprocessing rc file\n\ + -U --undefine Undefine SYM when preprocessing rc file\n\ + -v --verbose Verbose - tells you what it's doing\n\ + -c --codepage= Specify default codepage\n\ + -l --language= Set language when reading rc file\n\ + --use-temp-file Use a temporary file instead of popen to read\n\ + the preprocessor output\n\ + --no-use-temp-file Use popen (default)\n")); +#ifdef YYDEBUG + fprintf (stream, _("\ + --yydebug Turn on parser debugging\n")); +#endif + fprintf (stream, _("\ + -r Ignored for compatibility with rc\n\ + @ Read options from \n\ + -h --help Print this help message\n\ + -V --version Print version information\n")); + fprintf (stream, _("\ +FORMAT is one of rc, res, or coff, and is deduced from the file name\n\ +extension if not specified. A single file name is an input file.\n\ +No input-file is stdin, default rc. No output-file is stdout, default rc.\n")); + + list_supported_targets (program_name, stream); + + if (REPORT_BUGS_TO[0] && status == 0) + fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); + + exit (status); +} + +/* Quote characters that will confuse the shell when we run the preprocessor. */ + +static const char * +quot (const char *string) +{ + static char *buf = 0; + static int buflen = 0; + int slen = strlen (string); + const char *src; + char *dest; + + if ((buflen < slen * 2 + 2) || ! buf) + { + buflen = slen * 2 + 2; + if (buf) + free (buf); + buf = (char *) xmalloc (buflen); + } + + for (src=string, dest=buf; *src; src++, dest++) + { + if (*src == '(' || *src == ')' || *src == ' ') + *dest++ = '\\'; + *dest = *src; + } + *dest = 0; + return buf; +} + +/* Long options. */ + +enum option_values +{ + /* 150 isn't special; it's just an arbitrary non-ASCII char value. */ + OPTION_PREPROCESSOR = 150, + OPTION_USE_TEMP_FILE, + OPTION_NO_USE_TEMP_FILE, + OPTION_YYDEBUG, + OPTION_INCLUDE_DIR, + OPTION_PREPROCESSOR_ARG +}; + +static const struct option long_options[] = +{ + {"input", required_argument, 0, 'i'}, + {"output", required_argument, 0, 'o'}, + {"input-format", required_argument, 0, 'J'}, + {"output-format", required_argument, 0, 'O'}, + {"target", required_argument, 0, 'F'}, + {"preprocessor", required_argument, 0, OPTION_PREPROCESSOR}, + {"preprocessor-arg", required_argument, 0, OPTION_PREPROCESSOR_ARG}, + {"include-dir", required_argument, 0, OPTION_INCLUDE_DIR}, + {"define", required_argument, 0, 'D'}, + {"undefine", required_argument, 0, 'U'}, + {"verbose", no_argument, 0, 'v'}, + {"codepage", required_argument, 0, 'c'}, + {"language", required_argument, 0, 'l'}, + {"use-temp-file", no_argument, 0, OPTION_USE_TEMP_FILE}, + {"no-use-temp-file", no_argument, 0, OPTION_NO_USE_TEMP_FILE}, + {"yydebug", no_argument, 0, OPTION_YYDEBUG}, + {"version", no_argument, 0, 'V'}, + {"help", no_argument, 0, 'h'}, + {0, no_argument, 0, 0} +}; + +void +windres_add_include_dir (const char *p) +{ + struct include_dir *n, **pp; + + /* Computing paths is often complicated and error prone. + The easiest way to check for mistakes is at the time + we add them to include_dirs. */ + assert (p != NULL); + assert (*p != '\0'); + + n = xmalloc (sizeof *n); + n->next = NULL; + n->dir = (char * ) p; + + for (pp = &include_dirs; *pp != NULL; pp = &(*pp)->next) + ; + *pp = n; +} + +/* This keeps gcc happy when using -Wmissing-prototypes -Wstrict-prototypes. */ +int main (int, char **); + +/* The main function. */ + +int +main (int argc, char **argv) +{ + int c; + char *input_filename; + char *output_filename; + enum res_format input_format; + enum res_format input_format_tmp; + enum res_format output_format; + char *target; + char *preprocessor; + char *preprocargs; + const char *quotedarg; + int language; + rc_res_directory *resources; + int use_temp_file; + +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + program_name = argv[0]; + xmalloc_set_program_name (program_name); + bfd_set_error_program_name (program_name); + + expandargv (&argc, &argv); + + bfd_init (); + set_default_bfd_target (); + + res_init (); + + input_filename = NULL; + output_filename = NULL; + input_format = RES_FORMAT_UNKNOWN; + output_format = RES_FORMAT_UNKNOWN; + target = NULL; + preprocessor = NULL; + preprocargs = NULL; + language = 0x409; /* LANG_ENGLISH, SUBLANG_ENGLISH_US. */ + use_temp_file = 0; + + while ((c = getopt_long (argc, argv, "c:f:i:l:o:I:J:O:F:D:U:rhHvV", long_options, + (int *) 0)) != EOF) + { + switch (c) + { + case 'c': + { + rc_uint_type ncp; + + if (optarg[0] == '0' && (optarg[1] == 'x' || optarg[1] == 'X')) + ncp = (rc_uint_type) strtol (optarg + 2, NULL, 16); + else + ncp = (rc_uint_type) strtol (optarg, NULL, 10); + if (ncp == CP_UTF16 || ! unicode_is_valid_codepage (ncp)) + fatal (_("invalid codepage specified.\n")); + wind_default_codepage = wind_current_codepage = ncp; + } + break; + + case 'i': + input_filename = optarg; + break; + + case 'f': + /* For compatibility with rc we accept "-fo " as being the + equivalent of "-o ". We do not advertise this fact + though, as we do not want users to use non-GNU like command + line switches. */ + if (*optarg != 'o') + fatal (_("invalid option -f\n")); + optarg++; + if (* optarg == 0) + { + if (optind == argc) + fatal (_("No filename following the -fo option.\n")); + optarg = argv [optind++]; + } + /* Fall through. */ + + case 'o': + output_filename = optarg; + break; + + case 'J': + input_format = format_from_name (optarg, 1); + break; + + case 'O': + output_format = format_from_name (optarg, 1); + break; + + case 'F': + target = optarg; + break; + + case OPTION_PREPROCESSOR: + preprocessor = optarg; + break; + + case OPTION_PREPROCESSOR_ARG: + if (preprocargs == NULL) + { + quotedarg = quot (optarg); + preprocargs = xstrdup (quotedarg); + } + else + { + char *n; + + quotedarg = quot (optarg); + n = xmalloc (strlen (preprocargs) + strlen (quotedarg) + 2); + sprintf (n, "%s %s", preprocargs, quotedarg); + free (preprocargs); + preprocargs = n; + } + break; + + case 'D': + case 'U': + if (preprocargs == NULL) + { + quotedarg = quot (optarg); + preprocargs = xmalloc (strlen (quotedarg) + 3); + sprintf (preprocargs, "-%c%s", c, quotedarg); + } + else + { + char *n; + + quotedarg = quot (optarg); + n = xmalloc (strlen (preprocargs) + strlen (quotedarg) + 4); + sprintf (n, "%s -%c%s", preprocargs, c, quotedarg); + free (preprocargs); + preprocargs = n; + } + break; + + case 'r': + /* Ignored for compatibility with rc. */ + break; + + case 'v': + verbose ++; + break; + + case 'I': + /* For backward compatibility, should be removed in the future. */ + input_format_tmp = format_from_name (optarg, 0); + if (input_format_tmp != RES_FORMAT_UNKNOWN) + { + struct stat statbuf; + char modebuf[11]; + + if (stat (optarg, & statbuf) == 0 + /* Coded this way to avoid importing knowledge of S_ISDIR into this file. */ + && (mode_string (statbuf.st_mode, modebuf), modebuf[0] == 'd')) + /* We have a -I option with a directory name that just happens + to match a format name as well. eg: -I res Assume that the + user knows what they are doing and do not complain. */ + ; + else + { + fprintf (stderr, + _("Option -I is deprecated for setting the input format, please use -J instead.\n")); + input_format = input_format_tmp; + break; + } + } + /* Fall through. */ + + case OPTION_INCLUDE_DIR: + if (preprocargs == NULL) + { + quotedarg = quot (optarg); + preprocargs = xmalloc (strlen (quotedarg) + 3); + sprintf (preprocargs, "-I%s", quotedarg); + } + else + { + char *n; + + quotedarg = quot (optarg); + n = xmalloc (strlen (preprocargs) + strlen (quotedarg) + 4); + sprintf (n, "%s -I%s", preprocargs, quotedarg); + free (preprocargs); + preprocargs = n; + } + + windres_add_include_dir (optarg); + + break; + + case 'l': + language = strtol (optarg, (char **) NULL, 16); + break; + + case OPTION_USE_TEMP_FILE: + use_temp_file = 1; + break; + + case OPTION_NO_USE_TEMP_FILE: + use_temp_file = 0; + break; + +#ifdef YYDEBUG + case OPTION_YYDEBUG: + yydebug = 1; + break; +#endif + + case 'h': + case 'H': + usage (stdout, 0); + break; + + case 'V': + print_version ("windres"); + break; + + default: + usage (stderr, 1); + break; + } + } + + if (input_filename == NULL && optind < argc) + { + input_filename = argv[optind]; + ++optind; + } + + if (output_filename == NULL && optind < argc) + { + output_filename = argv[optind]; + ++optind; + } + + if (argc != optind) + usage (stderr, 1); + + if (input_format == RES_FORMAT_UNKNOWN) + { + if (input_filename == NULL) + input_format = RES_FORMAT_RC; + else + input_format = format_from_filename (input_filename, 1); + } + + if (output_format == RES_FORMAT_UNKNOWN) + { + if (output_filename == NULL) + output_format = RES_FORMAT_RC; + else + output_format = format_from_filename (output_filename, 0); + } + + set_endianness (NULL, target); + + /* Read the input file. */ + switch (input_format) + { + default: + abort (); + case RES_FORMAT_RC: + resources = read_rc_file (input_filename, preprocessor, preprocargs, + language, use_temp_file); + break; + case RES_FORMAT_RES: + resources = read_res_file (input_filename); + break; + case RES_FORMAT_COFF: + resources = read_coff_rsrc (input_filename, target); + break; + } + + if (resources == NULL) + fatal (_("no resources")); + + /* Sort the resources. This is required for COFF, convenient for + rc, and unimportant for res. */ + resources = sort_resources (resources); + + /* Write the output file. */ + reswr_init (); + + switch (output_format) + { + default: + abort (); + case RES_FORMAT_RC: + write_rc_file (output_filename, resources); + break; + case RES_FORMAT_RES: + write_res_file (output_filename, resources); + break; + case RES_FORMAT_COFF: + write_coff_file (output_filename, target, resources); + break; + } + + xexit (0); + return 0; +} + +static void +set_endianness (bfd *abfd, const char *target) +{ + const bfd_target *target_vec; + + def_target_arch = NULL; + target_vec = bfd_get_target_info (target, abfd, &target_is_bigendian, NULL, + &def_target_arch); + if (! target_vec) + fatal ("Can't detect target endianness and architecture."); + if (! def_target_arch) + fatal ("Can't detect architecture."); +} + +bfd * +windres_open_as_binary (const char *filename, int rdmode) +{ + bfd *abfd; + + abfd = (rdmode ? bfd_openr (filename, "binary") : bfd_openw (filename, "binary")); + if (! abfd) + fatal ("can't open `%s' for %s", filename, (rdmode ? "input" : "output")); + + if (rdmode && ! bfd_check_format (abfd, bfd_object)) + fatal ("can't open `%s' for input.", filename); + + return abfd; +} + +void +set_windres_bfd_endianness (windres_bfd *wrbfd, int is_bigendian) +{ + assert (!! wrbfd); + switch (WR_KIND(wrbfd)) + { + case WR_KIND_BFD_BIN_L: + if (is_bigendian) + WR_KIND(wrbfd) = WR_KIND_BFD_BIN_B; + break; + case WR_KIND_BFD_BIN_B: + if (! is_bigendian) + WR_KIND(wrbfd) = WR_KIND_BFD_BIN_L; + break; + default: + /* only binary bfd can be overriden. */ + abort (); + } +} + +void +set_windres_bfd (windres_bfd *wrbfd, bfd *abfd, asection *sec, rc_uint_type kind) +{ + assert (!! wrbfd); + switch (kind) + { + case WR_KIND_TARGET: + abfd = NULL; + sec = NULL; + break; + case WR_KIND_BFD: + case WR_KIND_BFD_BIN_L: + case WR_KIND_BFD_BIN_B: + assert (!! abfd); + assert (!!sec); + break; + default: + abort (); + } + WR_KIND(wrbfd) = kind; + WR_BFD(wrbfd) = abfd; + WR_SECTION(wrbfd) = sec; +} + +void +set_windres_bfd_content (windres_bfd *wrbfd, const void *data, rc_uint_type off, + rc_uint_type length) +{ + if (WR_KIND(wrbfd) != WR_KIND_TARGET) + { + if (! bfd_set_section_contents (WR_BFD(wrbfd), WR_SECTION(wrbfd), data, off, length)) + bfd_fatal ("bfd_set_section_contents"); + } + else + abort (); +} + +void +get_windres_bfd_content (windres_bfd *wrbfd, void *data, rc_uint_type off, + rc_uint_type length) +{ + if (WR_KIND(wrbfd) != WR_KIND_TARGET) + { + if (! bfd_get_section_contents (WR_BFD(wrbfd), WR_SECTION(wrbfd), data, off, length)) + bfd_fatal ("bfd_get_section_contents"); + } + else + abort (); +} + +void +windres_put_8 (windres_bfd *wrbfd, void *p, rc_uint_type value) +{ + switch (WR_KIND(wrbfd)) + { + case WR_KIND_TARGET: + target_put_8 (p, value); + break; + case WR_KIND_BFD: + case WR_KIND_BFD_BIN_L: + case WR_KIND_BFD_BIN_B: + bfd_put_8 (WR_BFD(wrbfd), value, p); + break; + default: + abort (); + } +} + +void +windres_put_16 (windres_bfd *wrbfd, void *data, rc_uint_type value) +{ + switch (WR_KIND(wrbfd)) + { + case WR_KIND_TARGET: + target_put_16 (data, value); + break; + case WR_KIND_BFD: + case WR_KIND_BFD_BIN_B: + bfd_put_16 (WR_BFD(wrbfd), value, data); + break; + case WR_KIND_BFD_BIN_L: + bfd_putl16 (value, data); + break; + default: + abort (); + } +} + +void +windres_put_32 (windres_bfd *wrbfd, void *data, rc_uint_type value) +{ + switch (WR_KIND(wrbfd)) + { + case WR_KIND_TARGET: + target_put_32 (data, value); + break; + case WR_KIND_BFD: + case WR_KIND_BFD_BIN_B: + bfd_put_32 (WR_BFD(wrbfd), value, data); + break; + case WR_KIND_BFD_BIN_L: + bfd_putl32 (value, data); + break; + default: + abort (); + } +} + +rc_uint_type +windres_get_8 (windres_bfd *wrbfd, const void *data, rc_uint_type length) +{ + if (length < 1) + fatal ("windres_get_8: unexpected eob."); + switch (WR_KIND(wrbfd)) + { + case WR_KIND_TARGET: + return target_get_8 (data, length); + case WR_KIND_BFD: + case WR_KIND_BFD_BIN_B: + case WR_KIND_BFD_BIN_L: + return bfd_get_8 (WR_BFD(wrbfd), data); + default: + abort (); + } + return 0; +} + +rc_uint_type +windres_get_16 (windres_bfd *wrbfd, const void *data, rc_uint_type length) +{ + if (length < 2) + fatal ("windres_get_16: unexpected eob."); + switch (WR_KIND(wrbfd)) + { + case WR_KIND_TARGET: + return target_get_16 (data, length); + case WR_KIND_BFD: + case WR_KIND_BFD_BIN_B: + return bfd_get_16 (WR_BFD(wrbfd), data); + case WR_KIND_BFD_BIN_L: + return bfd_getl16 (data); + default: + abort (); + } + return 0; +} + +rc_uint_type +windres_get_32 (windres_bfd *wrbfd, const void *data, rc_uint_type length) +{ + if (length < 4) + fatal ("windres_get_32: unexpected eob."); + switch (WR_KIND(wrbfd)) + { + case WR_KIND_TARGET: + return target_get_32 (data, length); + case WR_KIND_BFD: + case WR_KIND_BFD_BIN_B: + return bfd_get_32 (WR_BFD(wrbfd), data); + case WR_KIND_BFD_BIN_L: + return bfd_getl32 (data); + default: + abort (); + } + return 0; +} + +static rc_uint_type +target_get_8 (const void *p, rc_uint_type length) +{ + rc_uint_type ret; + + if (length < 1) + fatal ("Resource too small for getting 8-bit value."); + + ret = (rc_uint_type) *((const bfd_byte *) p); + return ret & 0xff; +} + +static rc_uint_type +target_get_16 (const void *p, rc_uint_type length) +{ + if (length < 2) + fatal ("Resource too small for getting 16-bit value."); + + if (target_is_bigendian) + return bfd_getb16 (p); + else + return bfd_getl16 (p); +} + +static rc_uint_type +target_get_32 (const void *p, rc_uint_type length) +{ + if (length < 4) + fatal ("Resource too small for getting 32-bit value."); + + if (target_is_bigendian) + return bfd_getb32 (p); + else + return bfd_getl32 (p); +} + +static void +target_put_8 (void *p, rc_uint_type value) +{ + assert (!! p); + *((bfd_byte *) p)=(bfd_byte) value; +} + +static void +target_put_16 (void *p, rc_uint_type value) +{ + assert (!! p); + + if (target_is_bigendian) + bfd_putb16 (value, p); + else + bfd_putl16 (value, p); +} + +static void +target_put_32 (void *p, rc_uint_type value) +{ + assert (!! p); + + if (target_is_bigendian) + bfd_putb32 (value, p); + else + bfd_putl32 (value, p); +} + +static int isInComment = 0; + +int wr_printcomment (FILE *e, const char *fmt, ...) +{ + va_list arg; + int r = 0; + + if (isInComment) + r += fprintf (e, "\n "); + else + fprintf (e, "/* "); + isInComment = 1; + if (fmt == NULL) + return r; + va_start (arg, fmt); + r += vfprintf (e, fmt, arg); + va_end (arg); + return r; +} + +int wr_print (FILE *e, const char *fmt, ...) +{ + va_list arg; + int r = 0; + if (isInComment) + r += fprintf (e, ". */\n"); + isInComment = 0; + if (! fmt) + return r; + va_start (arg, fmt); + r += vfprintf (e, fmt, arg); + va_end (arg); + return r; +} diff --git a/support/sdbinutils/binutils/windres.h b/support/sdbinutils/binutils/windres.h new file mode 100644 index 0000000..a080c05 --- /dev/null +++ b/support/sdbinutils/binutils/windres.h @@ -0,0 +1,122 @@ +/* windres.h -- header file for windres program. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Support. + Rewritten by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "ansidecl.h" + +/* This is the header file for the windres program. It defines + structures and declares functions used within the program. */ + +#include "winduni.h" +#include "windint.h" + +extern int verbose; + +/* Function declarations. */ + +extern rc_res_directory *read_rc_file (const char *, const char *, const char *, int, int); +extern rc_res_directory *read_res_file (const char *); +extern rc_res_directory *read_coff_rsrc (const char *, const char *); +extern void write_rc_file (const char *, const rc_res_directory *); +extern void write_res_file (const char *, const rc_res_directory *); +extern void write_coff_file (const char *, const char *, const rc_res_directory *); + +extern rc_res_resource *bin_to_res (windres_bfd *, rc_res_id, const bfd_byte *, + rc_uint_type); +extern rc_uint_type res_to_bin (windres_bfd *, rc_uint_type, const rc_res_resource *); + +extern FILE *open_file_search (const char *, const char *, const char *, char **); + +extern void *res_alloc (rc_uint_type); +extern void *reswr_alloc (rc_uint_type); + +/* Resource ID handling. */ + +extern int res_id_cmp (rc_res_id, rc_res_id); +extern void res_id_print (FILE *, rc_res_id, int); +extern void res_ids_print (FILE *, int, const rc_res_id *); +extern void res_string_to_id (rc_res_id *, const char *); +extern void res_unistring_to_id (rc_res_id *, const unichar *); + +/* Manipulation of the resource tree. */ + +extern rc_res_resource *define_resource (rc_res_directory **, int, const rc_res_id *, + int); +extern rc_res_resource *define_standard_resource (rc_res_directory **, int, rc_res_id, + rc_uint_type, int); + +extern int extended_dialog (const rc_dialog *); +extern int extended_menu (const rc_menu *); + +/* Communication between the rc file support and the parser and lexer. */ + +extern int yydebug; +extern char *rc_filename; +extern int rc_lineno; + +extern int yyparse (void); +extern int yylex (void); +extern void yyerror (const char *); +extern void rcparse_warning (const char *); +extern void rcparse_set_language (int); +extern void rcparse_discard_strings (void); +extern void rcparse_rcdata (void); +extern void rcparse_normal (void); + +extern void define_accelerator (rc_res_id, const rc_res_res_info *, rc_accelerator *); +extern void define_bitmap (rc_res_id, const rc_res_res_info *, const char *); +extern void define_cursor (rc_res_id, const rc_res_res_info *, const char *); +extern void define_dialog (rc_res_id, const rc_res_res_info *, const rc_dialog *); +extern rc_dialog_control *define_control (const rc_res_id, rc_uint_type, rc_uint_type, + rc_uint_type, rc_uint_type, rc_uint_type, + const rc_res_id, rc_uint_type, rc_uint_type); +extern rc_dialog_control *define_icon_control (rc_res_id, rc_uint_type, rc_uint_type, + rc_uint_type, rc_uint_type, rc_uint_type, + rc_uint_type, rc_rcdata_item *, + rc_dialog_ex *); +extern void define_font (rc_res_id, const rc_res_res_info *, const char *); +extern void define_icon (rc_res_id, const rc_res_res_info *, const char *); +extern void define_menu (rc_res_id, const rc_res_res_info *, rc_menuitem *); +extern rc_menuitem *define_menuitem (const unichar *, rc_uint_type, rc_uint_type, + rc_uint_type, rc_uint_type, rc_menuitem *); +extern void define_messagetable (rc_res_id, const rc_res_res_info *, const char *); +extern void define_rcdata (rc_res_id, const rc_res_res_info *, rc_rcdata_item *); +extern void define_rcdata_file (rc_res_id, const rc_res_res_info *, const char *); +extern rc_rcdata_item *define_rcdata_string (const char *, rc_uint_type); +extern rc_rcdata_item *define_rcdata_unistring (const unichar *, rc_uint_type); +extern rc_rcdata_item *define_rcdata_number (rc_uint_type, int); +extern void define_stringtable (const rc_res_res_info *, rc_uint_type, const unichar *, int); +extern void define_user_data (rc_res_id, rc_res_id, const rc_res_res_info *, rc_rcdata_item *); +extern void define_toolbar (rc_res_id, rc_res_res_info *, rc_uint_type ,rc_uint_type ,rc_toolbar_item *); +extern void define_user_file (rc_res_id, rc_res_id, const rc_res_res_info *, const char *); +extern void define_versioninfo (rc_res_id, rc_uint_type, rc_fixed_versioninfo *, rc_ver_info *); +extern rc_ver_info *append_ver_stringfileinfo (rc_ver_info *, rc_ver_stringtable *); +extern rc_ver_stringtable *append_ver_stringtable (rc_ver_stringtable *, const char *, rc_ver_stringinfo *); +extern rc_ver_info *append_ver_varfileinfo (rc_ver_info *, const unichar *, rc_ver_varinfo *); +extern rc_ver_stringinfo *append_verval (rc_ver_stringinfo *, const unichar *, const unichar *); +extern rc_ver_varinfo *append_vertrans (rc_ver_varinfo *, rc_uint_type, rc_uint_type); + +extern bfd *windres_open_as_binary (const char *, int); +extern void windres_add_include_dir (const char *); + +extern int wr_printcomment (FILE *, const char *, ...); +extern int wr_print (FILE *, const char *, ...); +#define wr_print_flush(FP) wr_print ((FP),NULL) diff --git a/support/sdbinutils/binutils/winduni.c b/support/sdbinutils/binutils/winduni.c new file mode 100644 index 0000000..8112efb --- /dev/null +++ b/support/sdbinutils/binutils/winduni.c @@ -0,0 +1,907 @@ +/* winduni.c -- unicode support for the windres program. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Support. + Rewritten by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + + +/* This file contains unicode support routines for the windres + program. Ideally, we would have generic unicode support which + would work on all systems. However, we don't. Instead, on a + Windows host, we are prepared to call some Windows routines. This + means that we will generate different output on Windows and Unix + hosts, but that seems better than not really supporting unicode at + all. */ + +#include "sysdep.h" +#include "bfd.h" +#include "libiberty.h" /* for xstrdup */ +#include "bucomm.h" +/* Must be include before windows.h and winnls.h. */ +#if defined (_WIN32) || defined (__CYGWIN__) +#include +#include +#endif +#include "winduni.h" +#include "safe-ctype.h" + +#if HAVE_ICONV +#include +#endif + +static rc_uint_type wind_WideCharToMultiByte (rc_uint_type, const unichar *, char *, rc_uint_type); +static rc_uint_type wind_MultiByteToWideChar (rc_uint_type, const char *, unichar *, rc_uint_type); +static int unichar_isascii (const unichar *, rc_uint_type); + +/* Convert an ASCII string to a unicode string. We just copy it, + expanding chars to shorts, rather than doing something intelligent. */ + +#if !defined (_WIN32) && !defined (__CYGWIN__) + +/* Codepages mapped. */ +static local_iconv_map codepages[] = +{ + { 0, "cp1252" }, + { 1, "WINDOWS-1252" }, + { 437, "MS-ANSI" }, + { 737, "MS-GREEK" }, + { 775, "WINBALTRIM" }, + { 850, "MS-ANSI" }, + { 852, "MS-EE" }, + { 857, "MS-TURK" }, + { 862, "CP862" }, + { 864, "CP864" }, + { 866, "MS-CYRL" }, + { 874, "WINDOWS-874" }, + { 932, "CP932" }, + { 936, "CP936" }, + { 949, "CP949" }, + { 950, "CP950" }, + { 1250, "WINDOWS-1250" }, + { 1251, "WINDOWS-1251" }, + { 1252, "WINDOWS-1252" }, + { 1253, "WINDOWS-1253" }, + { 1254, "WINDOWS-1254" }, + { 1255, "WINDOWS-1255" }, + { 1256, "WINDOWS-1256" }, + { 1257, "WINDOWS-1257" }, + { 1258, "WINDOWS-1258" }, + { CP_UTF7, "UTF-7" }, + { CP_UTF8, "UTF-8" }, + { CP_UTF16, "UTF-16LE" }, + { (rc_uint_type) -1, NULL } +}; + +/* Languages supported. */ +static const wind_language_t languages[] = +{ + { 0x0000, 437, 1252, "Neutral", "Neutral" }, + { 0x0401, 864, 1256, "Arabic", "Saudi Arabia" }, { 0x0402, 866, 1251, "Bulgarian", "Bulgaria" }, + { 0x0403, 850, 1252, "Catalan", "Spain" }, { 0x0404, 950, 950, "Chinese", "Taiwan" }, + { 0x0405, 852, 1250, "Czech", "Czech Republic" }, { 0x0406, 850, 1252, "Danish", "Denmark" }, + { 0x0407, 850, 1252, "German", "Germany" }, { 0x0408, 737, 1253, "Greek", "Greece" }, + { 0x0409, 437, 1252, "English", "United States" }, { 0x040A, 850, 1252, "Spanish - Traditional Sort", "Spain" }, + { 0x040B, 850, 1252, "Finnish", "Finland" }, { 0x040C, 850, 1252, "French", "France" }, + { 0x040D, 862, 1255, "Hebrew", "Israel" }, { 0x040E, 852, 1250, "Hungarian", "Hungary" }, + { 0x040F, 850, 1252, "Icelandic", "Iceland" }, { 0x0410, 850, 1252, "Italian", "Italy" }, + { 0x0411, 932, 932, "Japanese", "Japan" }, { 0x0412, 949, 949, "Korean", "Korea (south)" }, + { 0x0413, 850, 1252, "Dutch", "Netherlands" }, { 0x0414, 850, 1252, "Norwegian (Bokm\345l)", "Norway" }, + { 0x0415, 852, 1250, "Polish", "Poland" }, { 0x0416, 850, 1252, "Portuguese", "Brazil" }, + { 0x0418, 852, 1250, "Romanian", "Romania" }, { 0x0419, 866, 1251, "Russian", "Russia" }, + { 0x041A, 852, 1250, "Croatian", "Croatia" }, { 0x041B, 852, 1250, "Slovak", "Slovakia" }, + { 0x041C, 852, 1250, "Albanian", "Albania" }, { 0x041D, 850, 1252, "Swedish", "Sweden" }, + { 0x041E, 874, 874, "Thai", "Thailand" }, { 0x041F, 857, 1254, "Turkish", "Turkey" }, + { 0x0421, 850, 1252, "Indonesian", "Indonesia" }, { 0x0422, 866, 1251, "Ukrainian", "Ukraine" }, + { 0x0423, 866, 1251, "Belarusian", "Belarus" }, { 0x0424, 852, 1250, "Slovene", "Slovenia" }, + { 0x0425, 775, 1257, "Estonian", "Estonia" }, { 0x0426, 775, 1257, "Latvian", "Latvia" }, + { 0x0427, 775, 1257, "Lithuanian", "Lithuania" }, + { 0x0429, 864, 1256, "Arabic", "Farsi" }, { 0x042A,1258, 1258, "Vietnamese", "Vietnam" }, + { 0x042D, 850, 1252, "Basque", "Spain" }, + { 0x042F, 866, 1251, "Macedonian", "Former Yugoslav Republic of Macedonia" }, + { 0x0436, 850, 1252, "Afrikaans", "South Africa" }, + { 0x0438, 850, 1252, "Faroese", "Faroe Islands" }, + { 0x043C, 437, 1252, "Irish", "Ireland" }, + { 0x043E, 850, 1252, "Malay", "Malaysia" }, + { 0x0801, 864, 1256, "Arabic", "Iraq" }, + { 0x0804, 936, 936, "Chinese (People's republic of China)", "People's republic of China" }, + { 0x0807, 850, 1252, "German", "Switzerland" }, + { 0x0809, 850, 1252, "English", "United Kingdom" }, { 0x080A, 850, 1252, "Spanish", "Mexico" }, + { 0x080C, 850, 1252, "French", "Belgium" }, + { 0x0810, 850, 1252, "Italian", "Switzerland" }, + { 0x0813, 850, 1252, "Dutch", "Belgium" }, { 0x0814, 850, 1252, "Norwegian (Nynorsk)", "Norway" }, + { 0x0816, 850, 1252, "Portuguese", "Portugal" }, + { 0x081A, 852, 1252, "Serbian (latin)", "Yugoslavia" }, + { 0x081D, 850, 1252, "Swedish (Finland)", "Finland" }, + { 0x0C01, 864, 1256, "Arabic", "Egypt" }, + { 0x0C04, 950, 950, "Chinese", "Hong Kong" }, + { 0x0C07, 850, 1252, "German", "Austria" }, + { 0x0C09, 850, 1252, "English", "Australia" }, { 0x0C0A, 850, 1252, "Spanish - International Sort", "Spain" }, + { 0x0C0C, 850, 1252, "French", "Canada"}, + { 0x0C1A, 855, 1251, "Serbian (Cyrillic)", "Serbia" }, + { 0x1001, 864, 1256, "Arabic", "Libya" }, + { 0x1004, 936, 936, "Chinese", "Singapore" }, + { 0x1007, 850, 1252, "German", "Luxembourg" }, + { 0x1009, 850, 1252, "English", "Canada" }, + { 0x100A, 850, 1252, "Spanish", "Guatemala" }, + { 0x100C, 850, 1252, "French", "Switzerland" }, + { 0x1401, 864, 1256, "Arabic", "Algeria" }, + { 0x1407, 850, 1252, "German", "Liechtenstein" }, + { 0x1409, 850, 1252, "English", "New Zealand" }, { 0x140A, 850, 1252, "Spanish", "Costa Rica" }, + { 0x140C, 850, 1252, "French", "Luxembourg" }, + { 0x1801, 864, 1256, "Arabic", "Morocco" }, + { 0x1809, 850, 1252, "English", "Ireland" }, { 0x180A, 850, 1252, "Spanish", "Panama" }, + { 0x180C, 850, 1252, "French", "Monaco" }, + { 0x1C01, 864, 1256, "Arabic", "Tunisia" }, + { 0x1C09, 437, 1252, "English", "South Africa" }, { 0x1C0A, 850, 1252, "Spanish", "Dominican Republic" }, + { 0x2001, 864, 1256, "Arabic", "Oman" }, + { 0x2009, 850, 1252, "English", "Jamaica" }, { 0x200A, 850, 1252, "Spanish", "Venezuela" }, + { 0x2401, 864, 1256, "Arabic", "Yemen" }, + { 0x2409, 850, 1252, "English", "Caribbean" }, { 0x240A, 850, 1252, "Spanish", "Colombia" }, + { 0x2801, 864, 1256, "Arabic", "Syria" }, + { 0x2809, 850, 1252, "English", "Belize" }, { 0x280A, 850, 1252, "Spanish", "Peru" }, + { 0x2C01, 864, 1256, "Arabic", "Jordan" }, + { 0x2C09, 437, 1252, "English", "Trinidad & Tobago" },{ 0x2C0A, 850, 1252, "Spanish", "Argentina" }, + { 0x3001, 864, 1256, "Arabic", "Lebanon" }, + { 0x3009, 437, 1252, "English", "Zimbabwe" }, { 0x300A, 850, 1252, "Spanish", "Ecuador" }, + { 0x3401, 864, 1256, "Arabic", "Kuwait" }, + { 0x3409, 437, 1252, "English", "Philippines" }, { 0x340A, 850, 1252, "Spanish", "Chile" }, + { 0x3801, 864, 1256, "Arabic", "United Arab Emirates" }, + { 0x380A, 850, 1252, "Spanish", "Uruguay" }, + { 0x3C01, 864, 1256, "Arabic", "Bahrain" }, + { 0x3C0A, 850, 1252, "Spanish", "Paraguay" }, + { 0x4001, 864, 1256, "Arabic", "Qatar" }, + { 0x400A, 850, 1252, "Spanish", "Bolivia" }, + { 0x440A, 850, 1252, "Spanish", "El Salvador" }, + { 0x480A, 850, 1252, "Spanish", "Honduras" }, + { 0x4C0A, 850, 1252, "Spanish", "Nicaragua" }, + { 0x500A, 850, 1252, "Spanish", "Puerto Rico" }, + { (unsigned) -1, 0, 0, NULL, NULL } +}; + +#endif + +/* Specifies the default codepage to be used for unicode + transformations. By default this is CP_ACP. */ +rc_uint_type wind_default_codepage = CP_ACP; + +/* Specifies the currently used codepage for unicode + transformations. By default this is CP_ACP. */ +rc_uint_type wind_current_codepage = CP_ACP; + +/* Convert an ASCII string to a unicode string. We just copy it, + expanding chars to shorts, rather than doing something intelligent. */ + +void +unicode_from_ascii (rc_uint_type *length, unichar **unicode, const char *ascii) +{ + unicode_from_codepage (length, unicode, ascii, wind_current_codepage); +} + +/* Convert an ASCII string with length A_LENGTH to a unicode string. We just + copy it, expanding chars to shorts, rather than doing something intelligent. + This routine converts also \0 within a string. */ + +void +unicode_from_ascii_len (rc_uint_type *length, unichar **unicode, const char *ascii, rc_uint_type a_length) +{ + char *tmp, *p; + rc_uint_type tlen, elen, idx = 0; + + *unicode = NULL; + + if (!a_length) + { + if (length) + *length = 0; + return; + } + + /* Make sure we have zero terminated string. */ + p = tmp = (char *) xmalloc (a_length + 1); + memcpy (tmp, ascii, a_length); + tmp[a_length] = 0; + + while (a_length > 0) + { + unichar *utmp, *up; + + tlen = strlen (p); + + if (tlen > a_length) + tlen = a_length; + if (*p == 0) + { + /* Make room for one more character. */ + utmp = (unichar *) res_alloc (sizeof (unichar) * (idx + 1)); + if (idx > 0) + { + memcpy (utmp, *unicode, idx * sizeof (unichar)); + } + *unicode = utmp; + utmp[idx++] = 0; + --a_length; + p++; + continue; + } + utmp = NULL; + elen = 0; + elen = wind_MultiByteToWideChar (wind_current_codepage, p, NULL, 0); + if (elen) + { + utmp = ((unichar *) res_alloc (elen + sizeof (unichar) * 2)); + wind_MultiByteToWideChar (wind_current_codepage, p, utmp, elen); + elen /= sizeof (unichar); + elen --; + } + else + { + /* Make room for one more character. */ + utmp = (unichar *) res_alloc (sizeof (unichar) * (idx + 1)); + if (idx > 0) + { + memcpy (utmp, *unicode, idx * sizeof (unichar)); + } + *unicode = utmp; + utmp[idx++] = ((unichar) *p) & 0xff; + --a_length; + p++; + continue; + } + p += tlen; + a_length -= tlen; + + up = (unichar *) res_alloc (sizeof (unichar) * (idx + elen)); + if (idx > 0) + memcpy (up, *unicode, idx * sizeof (unichar)); + + *unicode = up; + if (elen) + memcpy (&up[idx], utmp, sizeof (unichar) * elen); + + idx += elen; + } + + if (length) + *length = idx; + + free (tmp); +} + +/* Convert an unicode string to an ASCII string. We just copy it, + shrink shorts to chars, rather than doing something intelligent. + Shorts with not within the char range are replaced by '_'. */ + +void +ascii_from_unicode (rc_uint_type *length, const unichar *unicode, char **ascii) +{ + codepage_from_unicode (length, unicode, ascii, wind_current_codepage); +} + +/* Print the unicode string UNICODE to the file E. LENGTH is the + number of characters to print, or -1 if we should print until the + end of the string. FIXME: On a Windows host, we should be calling + some Windows function, probably WideCharToMultiByte. */ + +void +unicode_print (FILE *e, const unichar *unicode, rc_uint_type length) +{ + while (1) + { + unichar ch; + + if (length == 0) + return; + if ((bfd_signed_vma) length > 0) + --length; + + ch = *unicode; + + if (ch == 0 && (bfd_signed_vma) length < 0) + return; + + ++unicode; + + if ((ch & 0x7f) == ch) + { + if (ch == '\\') + fputs ("\\\\", e); + else if (ch == '"') + fputs ("\"\"", e); + else if (ISPRINT (ch)) + putc (ch, e); + else + { + switch (ch) + { + case ESCAPE_A: + fputs ("\\a", e); + break; + + case ESCAPE_B: + fputs ("\\b", e); + break; + + case ESCAPE_F: + fputs ("\\f", e); + break; + + case ESCAPE_N: + fputs ("\\n", e); + break; + + case ESCAPE_R: + fputs ("\\r", e); + break; + + case ESCAPE_T: + fputs ("\\t", e); + break; + + case ESCAPE_V: + fputs ("\\v", e); + break; + + default: + fprintf (e, "\\%03o", (unsigned int) ch); + break; + } + } + } + else if ((ch & 0xff) == ch) + fprintf (e, "\\%03o", (unsigned int) ch); + else + fprintf (e, "\\x%04x", (unsigned int) ch); + } +} + +/* Print a unicode string to a file. */ + +void +ascii_print (FILE *e, const char *s, rc_uint_type length) +{ + while (1) + { + char ch; + + if (length == 0) + return; + if ((bfd_signed_vma) length > 0) + --length; + + ch = *s; + + if (ch == 0 && (bfd_signed_vma) length < 0) + return; + + ++s; + + if ((ch & 0x7f) == ch) + { + if (ch == '\\') + fputs ("\\\\", e); + else if (ch == '"') + fputs ("\"\"", e); + else if (ISPRINT (ch)) + putc (ch, e); + else + { + switch (ch) + { + case ESCAPE_A: + fputs ("\\a", e); + break; + + case ESCAPE_B: + fputs ("\\b", e); + break; + + case ESCAPE_F: + fputs ("\\f", e); + break; + + case ESCAPE_N: + fputs ("\\n", e); + break; + + case ESCAPE_R: + fputs ("\\r", e); + break; + + case ESCAPE_T: + fputs ("\\t", e); + break; + + case ESCAPE_V: + fputs ("\\v", e); + break; + + default: + fprintf (e, "\\%03o", (unsigned int) ch); + break; + } + } + } + else + fprintf (e, "\\%03o", (unsigned int) ch & 0xff); + } +} + +rc_uint_type +unichar_len (const unichar *unicode) +{ + rc_uint_type r = 0; + + if (unicode) + while (unicode[r] != 0) + r++; + else + --r; + return r; +} + +unichar * +unichar_dup (const unichar *unicode) +{ + unichar *r; + int len; + + if (! unicode) + return NULL; + for (len = 0; unicode[len] != 0; ++len) + ; + ++len; + r = ((unichar *) res_alloc (len * sizeof (unichar))); + memcpy (r, unicode, len * sizeof (unichar)); + return r; +} + +unichar * +unichar_dup_uppercase (const unichar *u) +{ + unichar *r = unichar_dup (u); + int i; + + if (! r) + return NULL; + + for (i = 0; r[i] != 0; ++i) + { + if (r[i] >= 'a' && r[i] <= 'z') + r[i] &= 0xdf; + } + return r; +} + +static int +unichar_isascii (const unichar *u, rc_uint_type len) +{ + rc_uint_type i; + + if ((bfd_signed_vma) len < 0) + { + if (u) + len = (rc_uint_type) unichar_len (u); + else + len = 0; + } + + for (i = 0; i < len; i++) + if ((u[i] & 0xff80) != 0) + return 0; + return 1; +} + +void +unicode_print_quoted (FILE *e, const unichar *u, rc_uint_type len) +{ + if (! unichar_isascii (u, len)) + fputc ('L', e); + fputc ('"', e); + unicode_print (e, u, len); + fputc ('"', e); +} + +int +unicode_is_valid_codepage (rc_uint_type cp) +{ + if ((cp & 0xffff) != cp) + return 0; + if (cp == CP_UTF16 || cp == CP_ACP) + return 1; + +#if !defined (_WIN32) && !defined (__CYGWIN__) + if (! wind_find_codepage_info (cp)) + return 0; + return 1; +#else + return !! IsValidCodePage ((UINT) cp); +#endif +} + +#if defined (_WIN32) || defined (__CYGWIN__) + +#define max_cp_string_len 6 + +static unsigned int +codepage_from_langid (unsigned short langid) +{ + char cp_string [max_cp_string_len]; + int c; + + memset (cp_string, 0, max_cp_string_len); + /* LOCALE_RETURN_NUMBER flag would avoid strtoul conversion, + but is unavailable on Win95. */ + c = GetLocaleInfoA (MAKELCID (langid, SORT_DEFAULT), + LOCALE_IDEFAULTANSICODEPAGE, + cp_string, max_cp_string_len); + /* If codepage data for an LCID is not installed on users's system, + GetLocaleInfo returns an empty string. Fall back to system ANSI + default. */ + if (c == 0) + return CP_ACP; + return strtoul (cp_string, 0, 10); +} + +static unsigned int +wincodepage_from_langid (unsigned short langid) +{ + char cp_string [max_cp_string_len]; + int c; + + memset (cp_string, 0, max_cp_string_len); + /* LOCALE_RETURN_NUMBER flag would avoid strtoul conversion, + but is unavailable on Win95. */ + c = GetLocaleInfoA (MAKELCID (langid, SORT_DEFAULT), + LOCALE_IDEFAULTCODEPAGE, + cp_string, max_cp_string_len); + /* If codepage data for an LCID is not installed on users's system, + GetLocaleInfo returns an empty string. Fall back to system ANSI + default. */ + if (c == 0) + return CP_OEM; + return strtoul (cp_string, 0, 10); +} + +static char * +lang_from_langid (unsigned short langid) +{ + char cp_string[261]; + int c; + + memset (cp_string, 0, 261); + c = GetLocaleInfoA (MAKELCID (langid, SORT_DEFAULT), + LOCALE_SENGLANGUAGE, + cp_string, 260); + /* If codepage data for an LCID is not installed on users's system, + GetLocaleInfo returns an empty string. Fall back to system ANSI + default. */ + if (c == 0) + strcpy (cp_string, "Neutral"); + return xstrdup (cp_string); +} + +static char * +country_from_langid (unsigned short langid) +{ + char cp_string[261]; + int c; + + memset (cp_string, 0, 261); + c = GetLocaleInfoA (MAKELCID (langid, SORT_DEFAULT), + LOCALE_SENGCOUNTRY, + cp_string, 260); + /* If codepage data for an LCID is not installed on users's system, + GetLocaleInfo returns an empty string. Fall back to system ANSI + default. */ + if (c == 0) + strcpy (cp_string, "Neutral"); + return xstrdup (cp_string); +} + +#endif + +const wind_language_t * +wind_find_language_by_id (unsigned id) +{ +#if !defined (_WIN32) && !defined (__CYGWIN__) + int i; + + if (! id) + return NULL; + for (i = 0; languages[i].id != (unsigned) -1 && languages[i].id != id; i++) + ; + if (languages[i].id == id) + return &languages[i]; + return NULL; +#else + static wind_language_t wl; + + wl.id = id; + wl.doscp = codepage_from_langid ((unsigned short) id); + wl.wincp = wincodepage_from_langid ((unsigned short) id); + wl.name = lang_from_langid ((unsigned short) id); + wl.country = country_from_langid ((unsigned short) id); + + return & wl; +#endif +} + +const local_iconv_map * +wind_find_codepage_info (unsigned cp) +{ +#if !defined (_WIN32) && !defined (__CYGWIN__) + int i; + + for (i = 0; codepages[i].codepage != (rc_uint_type) -1 && codepages[i].codepage != cp; i++) + ; + if (codepages[i].codepage == (rc_uint_type) -1) + return NULL; + return &codepages[i]; +#else + static local_iconv_map lim; + if (!unicode_is_valid_codepage (cp)) + return NULL; + lim.codepage = cp; + lim.iconv_name = ""; + return & lim; +#endif +} + +/* Convert an Codepage string to a unicode string. */ + +void +unicode_from_codepage (rc_uint_type *length, unichar **u, const char *src, rc_uint_type cp) +{ + rc_uint_type len; + + len = wind_MultiByteToWideChar (cp, src, NULL, 0); + if (len) + { + *u = ((unichar *) res_alloc (len)); + wind_MultiByteToWideChar (cp, src, *u, len); + } + /* Discount the trailing '/0'. If MultiByteToWideChar failed, + this will set *length to -1. */ + len -= sizeof (unichar); + + if (length != NULL) + *length = len / sizeof (unichar); +} + +/* Convert an unicode string to an codepage string. */ + +void +codepage_from_unicode (rc_uint_type *length, const unichar *unicode, char **ascii, rc_uint_type cp) +{ + rc_uint_type len; + + len = wind_WideCharToMultiByte (cp, unicode, NULL, 0); + if (len) + { + *ascii = (char *) res_alloc (len * sizeof (char)); + wind_WideCharToMultiByte (cp, unicode, *ascii, len); + } + /* Discount the trailing '/0'. If MultiByteToWideChar failed, + this will set *length to -1. */ + len--; + + if (length != NULL) + *length = len; +} + +#if defined (HAVE_ICONV) && !defined (_WIN32) && !defined (__CYGWIN__) +static int +iconv_onechar (iconv_t cd, ICONV_CONST char *s, char *d, int d_len, const char **n_s, char **n_d) +{ + int i; + + for (i = 1; i <= 32; i++) + { + char *tmp_d = d; + ICONV_CONST char *tmp_s = s; + size_t ret; + size_t s_left = (size_t) i; + size_t d_left = (size_t) d_len; + + ret = iconv (cd, & tmp_s, & s_left, & tmp_d, & d_left); + + if (ret != (size_t) -1) + { + *n_s = tmp_s; + *n_d = tmp_d; + return 0; + } + } + + return 1; +} + +static const char * +wind_iconv_cp (rc_uint_type cp) +{ + const local_iconv_map *lim = wind_find_codepage_info (cp); + + if (!lim) + return NULL; + return lim->iconv_name; +} +#endif /* HAVE_ICONV */ + +static rc_uint_type +wind_MultiByteToWideChar (rc_uint_type cp, const char *mb, + unichar *u, rc_uint_type u_len) +{ + rc_uint_type ret = 0; + +#if defined (_WIN32) || defined (__CYGWIN__) + rc_uint_type conv_flags = MB_PRECOMPOSED; + + /* MB_PRECOMPOSED is not allowed for UTF-7 or UTF-8. + MultiByteToWideChar will set the last error to + ERROR_INVALID_FLAGS if we do. */ + if (cp == CP_UTF8 || cp == CP_UTF7) + conv_flags = 0; + + ret = (rc_uint_type) MultiByteToWideChar (cp, conv_flags, + mb, -1, u, u_len); + /* Convert to bytes. */ + ret *= sizeof (unichar); + +#elif defined (HAVE_ICONV) + int first = 1; + char tmp[32]; + char *p_tmp; + const char *iconv_name = wind_iconv_cp (cp); + + if (!mb || !iconv_name) + return 0; + iconv_t cd = iconv_open ("UTF-16LE", iconv_name); + + while (1) + { + int iret; + const char *n_mb = ""; + char *n_tmp = ""; + + p_tmp = tmp; + iret = iconv_onechar (cd, (ICONV_CONST char *) mb, p_tmp, 32, & n_mb, & n_tmp); + if (first) + { + first = 0; + continue; + } + if (!iret) + { + size_t l_tmp = (size_t) (n_tmp - p_tmp); + + if (u) + { + if ((size_t) u_len < l_tmp) + break; + memcpy (u, tmp, l_tmp); + u += l_tmp/2; + u_len -= l_tmp; + } + ret += l_tmp; + } + else + break; + if (tmp[0] == 0 && tmp[1] == 0) + break; + mb = n_mb; + } + iconv_close (cd); +#else + if (cp) + ret = 0; + ret = strlen (mb) + 1; + ret *= sizeof (unichar); + if (u != NULL && u_len != 0) + { + do + { + *u++ = ((unichar) *mb) & 0xff; + --u_len; mb++; + } + while (u_len != 0 && mb[-1] != 0); + } + if (u != NULL && u_len != 0) + *u = 0; +#endif + return ret; +} + +static rc_uint_type +wind_WideCharToMultiByte (rc_uint_type cp, const unichar *u, char *mb, rc_uint_type mb_len) +{ + rc_uint_type ret = 0; +#if defined (_WIN32) || defined (__CYGWIN__) + WINBOOL used_def = FALSE; + + ret = (rc_uint_type) WideCharToMultiByte (cp, 0, u, -1, mb, mb_len, + NULL, & used_def); +#elif defined (HAVE_ICONV) + int first = 1; + char tmp[32]; + char *p_tmp; + const char *iconv_name = wind_iconv_cp (cp); + + if (!u || !iconv_name) + return 0; + iconv_t cd = iconv_open (iconv_name, "UTF-16LE"); + + while (1) + { + int iret; + const char *n_u = ""; + char *n_tmp = ""; + + p_tmp = tmp; + iret = iconv_onechar (cd, (ICONV_CONST char *) u, p_tmp, 32, &n_u, & n_tmp); + if (first) + { + first = 0; + continue; + } + if (!iret) + { + size_t l_tmp = (size_t) (n_tmp - p_tmp); + + if (mb) + { + if ((size_t) mb_len < l_tmp) + break; + memcpy (mb, tmp, l_tmp); + mb += l_tmp; + mb_len -= l_tmp; + } + ret += l_tmp; + } + else + break; + if (u[0] == 0) + break; + u = (const unichar *) n_u; + } + iconv_close (cd); +#else + if (cp) + ret = 0; + + while (u[ret] != 0) + ++ret; + + ++ret; + + if (mb) + { + while (*u != 0 && mb_len != 0) + { + if (u[0] == (u[0] & 0x7f)) + *mb++ = (char) u[0]; + else + *mb++ = '_'; + ++u; --mb_len; + } + if (mb_len != 0) + *mb = 0; + } +#endif + return ret; +} diff --git a/support/sdbinutils/binutils/winduni.h b/support/sdbinutils/binutils/winduni.h new file mode 100644 index 0000000..69c5e63 --- /dev/null +++ b/support/sdbinutils/binutils/winduni.h @@ -0,0 +1,139 @@ +/* winduni.h -- header file for unicode support for windres program. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Support. + Rewritten by Kai Tietz, Onevision. + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "ansidecl.h" + +#ifndef WINDUNI_H +#define WINDUNI_H + +/* This header file declares the types and functions we use for + unicode support in windres. Our unicode support is very limited at + present. + + We don't put this stuff in windres.h so that winduni.c doesn't have + to include windres.h. winduni.c needs to includes windows.h, and + that would conflict with the definitions of Windows macros we + already have in windres.h. */ + +/* Use bfd_size_type to ensure a sufficient number of bits. */ +#ifndef DEFINED_RC_UINT_TYPE +#define DEFINED_RC_UINT_TYPE +typedef bfd_size_type rc_uint_type; +#endif + +/* We use this type to hold a unicode character. */ + +typedef unsigned short unichar; + +/* Escape character translations. */ + +#define ESCAPE_A 007 +#define ESCAPE_B 010 +#define ESCAPE_F 014 +#define ESCAPE_N 012 +#define ESCAPE_R 015 +#define ESCAPE_T 011 +#define ESCAPE_V 013 + +/* Convert an ASCII string to a unicode string. */ +extern void unicode_from_ascii (rc_uint_type *, unichar **, const char *); + +/* Convert an unicode string to an ASCII string. */ +extern void ascii_from_unicode (rc_uint_type *, const unichar *, char **); + +/* Duplicate a unicode string by using res_alloc. */ +extern unichar *unichar_dup (const unichar *); + +/* Duplicate a unicode string by using res_alloc and make it uppercase. */ +extern unichar *unichar_dup_uppercase (const unichar *); + +/* The count of unichar elements. */ +extern rc_uint_type unichar_len (const unichar *); + +/* Print a unicode string to a file. */ +extern void unicode_print (FILE *, const unichar *, rc_uint_type); + +/* Print a ascii string to a file. */ +extern void ascii_print (FILE *, const char *, rc_uint_type); + +/* Print a quoted unicode string to a file. */ +extern void unicode_print_quoted (FILE *, const unichar *, rc_uint_type); + +#ifndef CP_UTF8 +#define CP_UTF7 65000 /* UTF-7 translation. */ +#define CP_UTF8 65001 /* UTF-8 translation. */ +#endif + +#ifndef CP_UTF16 +#define CP_UTF16 65002 /* UTF-16 translation. */ +#endif + +#ifndef CP_ACP +#define CP_ACP 0 /* Default to ANSI code page. */ +#endif + +#ifndef CP_OEM +#define CP_OEM 1 /* Default OEM code page. */ +#endif + +/* Specifies the default codepage to be used for unicode + transformations. By default this is CP_ACP. */ +extern rc_uint_type wind_default_codepage; + +/* Specifies the currently used codepage for unicode + transformations. By default this is CP_ACP. */ +extern rc_uint_type wind_current_codepage; + +typedef struct wind_language_t +{ + unsigned id; + unsigned doscp; + unsigned wincp; + const char *name; + const char *country; +} wind_language_t; + +extern const wind_language_t *wind_find_language_by_id (unsigned); +extern int unicode_is_valid_codepage (rc_uint_type); + +typedef struct local_iconv_map +{ + rc_uint_type codepage; + const char * iconv_name; +} local_iconv_map; + +extern const local_iconv_map *wind_find_codepage_info (unsigned); + +/* Convert an Codepage string to a unicode string. */ +extern void unicode_from_codepage (rc_uint_type *, unichar **, const char *, rc_uint_type); +extern void unicode_from_ascii_len (rc_uint_type *, unichar **, const char *, rc_uint_type ); + +/* Convert an unicode string to an codepage string. */ +extern void codepage_from_unicode (rc_uint_type *, const unichar *, char **, rc_uint_type); + +/* Windres support routine called by unicode_from_ascii. This is both + here and in windres.h. It should probably be in a separate header + file, but it hardly seems worth it for one function. */ + +extern void * res_alloc (rc_uint_type); + +#endif diff --git a/support/sdbinutils/binutils/wrstabs.c b/support/sdbinutils/binutils/wrstabs.c new file mode 100644 index 0000000..1b8c311 --- /dev/null +++ b/support/sdbinutils/binutils/wrstabs.c @@ -0,0 +1,2271 @@ +/* wrstabs.c -- Output stabs debugging information + Copyright (C) 1996-2018 Free Software Foundation, Inc. + Written by Ian Lance Taylor . + + This file is part of GNU Binutils. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* This file contains code which writes out stabs debugging + information. */ + +#include "sysdep.h" +#include +#include "bfd.h" +#include "libiberty.h" +#include "filenames.h" +#include "safe-ctype.h" +#include "bucomm.h" +#include "debug.h" +#include "budbg.h" +#include "aout/aout64.h" +#include "aout/stab_gnu.h" + +/* The size of a stabs symbol. This presumes 32 bit values. */ + +#define STAB_SYMBOL_SIZE (12) + +/* An entry in a string hash table. */ + +struct string_hash_entry +{ + struct bfd_hash_entry root; + /* Next string in this table. */ + struct string_hash_entry *next; + /* Index in string table. */ + long index; + /* Size of type if this is a typedef. */ + unsigned int size; +}; + +/* A string hash table. */ + +struct string_hash_table +{ + struct bfd_hash_table table; +}; + +/* The type stack. Each element on the stack is a string. */ + +struct stab_type_stack +{ + /* The next element on the stack. */ + struct stab_type_stack *next; + /* This element as a string. */ + char *string; + /* The type index of this element. */ + long index; + /* The size of the type. */ + unsigned int size; + /* Whether type string defines a new type. */ + bfd_boolean definition; + /* String defining struct fields. */ + char *fields; + /* NULL terminated array of strings defining base classes for a + class. */ + char **baseclasses; + /* String defining class methods. */ + char *methods; + /* String defining vtable pointer for a class. */ + char *vtable; +}; + +/* This structure is used to keep track of type indices for tagged + types. */ + +struct stab_tag +{ + /* The type index. */ + long index; + /* The tag name. */ + const char *tag; + /* The kind of type. This is set to DEBUG_KIND_ILLEGAL when the + type is defined. */ + enum debug_type_kind kind; + /* The size of the struct. */ + unsigned int size; +}; + +/* We remember various sorts of type indices. They are not related, + but, for convenience, we keep all the information in this + structure. */ + +struct stab_type_cache +{ + /* The void type index. */ + long void_type; + /* Signed integer type indices, indexed by size - 1. */ + long signed_integer_types[8]; + /* Unsigned integer type indices, indexed by size - 1. */ + long unsigned_integer_types[8]; + /* Floating point types, indexed by size - 1. */ + long float_types[16]; + /* Pointers to types, indexed by the type index. */ + long *pointer_types; + size_t pointer_types_alloc; + /* Functions returning types, indexed by the type index. */ + long *function_types; + size_t function_types_alloc; + /* References to types, indexed by the type index. */ + long *reference_types; + size_t reference_types_alloc; + /* Struct/union/class type indices, indexed by the struct id. */ + struct stab_tag *struct_types; + size_t struct_types_alloc; +}; + +/* This is the handle passed through debug_write. */ + +struct stab_write_handle +{ + /* The BFD. */ + bfd *abfd; + /* This buffer holds the symbols. */ + bfd_byte *symbols; + size_t symbols_size; + size_t symbols_alloc; + /* This is a list of hash table entries for the strings. */ + struct string_hash_entry *strings; + /* The last string hash table entry. */ + struct string_hash_entry *last_string; + /* The size of the strings. */ + size_t strings_size; + /* This hash table eliminates duplicate strings. */ + struct string_hash_table strhash; + /* The type stack. */ + struct stab_type_stack *type_stack; + /* The next type index. */ + long type_index; + /* The type cache. */ + struct stab_type_cache type_cache; + /* A mapping from typedef names to type indices. */ + struct string_hash_table typedef_hash; + /* If this is not -1, it is the offset to the most recent N_SO + symbol, and the value of that symbol needs to be set. */ + long so_offset; + /* If this is not -1, it is the offset to the most recent N_FUN + symbol, and the value of that symbol needs to be set. */ + long fun_offset; + /* The last text section address seen. */ + bfd_vma last_text_address; + /* The block nesting depth. */ + unsigned int nesting; + /* The function address. */ + bfd_vma fnaddr; + /* A pending LBRAC symbol. */ + bfd_vma pending_lbrac; + /* The current line number file name. */ + const char *lineno_filename; +}; + +static struct bfd_hash_entry *string_hash_newfunc + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); +static bfd_boolean stab_write_symbol + (struct stab_write_handle *, int, int, bfd_vma, const char *); +static bfd_boolean stab_push_string + (struct stab_write_handle *, const char *, long, bfd_boolean, unsigned int); +static bfd_boolean stab_push_defined_type + (struct stab_write_handle *, long, unsigned int); +static char *stab_pop_type (struct stab_write_handle *); +static bfd_boolean stab_modify_type + (struct stab_write_handle *, int, unsigned int, long **, size_t *); +static long stab_get_struct_index + (struct stab_write_handle *, const char *, unsigned int, + enum debug_type_kind, unsigned int *); +static bfd_boolean stab_class_method_var + (struct stab_write_handle *, const char *, enum debug_visibility, + bfd_boolean, bfd_boolean, bfd_boolean, bfd_vma, bfd_boolean); +static bfd_boolean stab_start_compilation_unit (void *, const char *); +static bfd_boolean stab_start_source (void *, const char *); +static bfd_boolean stab_empty_type (void *); +static bfd_boolean stab_void_type (void *); +static bfd_boolean stab_int_type (void *, unsigned int, bfd_boolean); +static bfd_boolean stab_float_type (void *, unsigned int); +static bfd_boolean stab_complex_type (void *, unsigned int); +static bfd_boolean stab_bool_type (void *, unsigned int); +static bfd_boolean stab_enum_type + (void *, const char *, const char **, bfd_signed_vma *); +static bfd_boolean stab_pointer_type (void *); +static bfd_boolean stab_function_type (void *, int, bfd_boolean); +static bfd_boolean stab_reference_type (void *); +static bfd_boolean stab_range_type (void *, bfd_signed_vma, bfd_signed_vma); +static bfd_boolean stab_array_type + (void *, bfd_signed_vma, bfd_signed_vma, bfd_boolean); +static bfd_boolean stab_set_type (void *, bfd_boolean); +static bfd_boolean stab_offset_type (void *); +static bfd_boolean stab_method_type (void *, bfd_boolean, int, bfd_boolean); +static bfd_boolean stab_const_type (void *); +static bfd_boolean stab_volatile_type (void *); +static bfd_boolean stab_start_struct_type + (void *, const char *, unsigned int, bfd_boolean, unsigned int); +static bfd_boolean stab_struct_field + (void *, const char *, bfd_vma, bfd_vma, enum debug_visibility); +static bfd_boolean stab_end_struct_type (void *); +static bfd_boolean stab_start_class_type + (void *, const char *, unsigned int, bfd_boolean, unsigned int, + bfd_boolean, bfd_boolean); +static bfd_boolean stab_class_static_member + (void *, const char *, const char *, enum debug_visibility); +static bfd_boolean stab_class_baseclass + (void *, bfd_vma, bfd_boolean, enum debug_visibility); +static bfd_boolean stab_class_start_method (void *, const char *); +static bfd_boolean stab_class_method_variant + (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean, + bfd_vma, bfd_boolean); +static bfd_boolean stab_class_static_method_variant + (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean); +static bfd_boolean stab_class_end_method (void *); +static bfd_boolean stab_end_class_type (void *); +static bfd_boolean stab_typedef_type (void *, const char *); +static bfd_boolean stab_tag_type + (void *, const char *, unsigned int, enum debug_type_kind); +static bfd_boolean stab_typdef (void *, const char *); +static bfd_boolean stab_tag (void *, const char *); +static bfd_boolean stab_int_constant (void *, const char *, bfd_vma); +static bfd_boolean stab_float_constant (void *, const char *, double); +static bfd_boolean stab_typed_constant (void *, const char *, bfd_vma); +static bfd_boolean stab_variable + (void *, const char *, enum debug_var_kind, bfd_vma); +static bfd_boolean stab_start_function (void *, const char *, bfd_boolean); +static bfd_boolean stab_function_parameter + (void *, const char *, enum debug_parm_kind, bfd_vma); +static bfd_boolean stab_start_block (void *, bfd_vma); +static bfd_boolean stab_end_block (void *, bfd_vma); +static bfd_boolean stab_end_function (void *); +static bfd_boolean stab_lineno (void *, const char *, unsigned long, bfd_vma); + +static const struct debug_write_fns stab_fns = +{ + stab_start_compilation_unit, + stab_start_source, + stab_empty_type, + stab_void_type, + stab_int_type, + stab_float_type, + stab_complex_type, + stab_bool_type, + stab_enum_type, + stab_pointer_type, + stab_function_type, + stab_reference_type, + stab_range_type, + stab_array_type, + stab_set_type, + stab_offset_type, + stab_method_type, + stab_const_type, + stab_volatile_type, + stab_start_struct_type, + stab_struct_field, + stab_end_struct_type, + stab_start_class_type, + stab_class_static_member, + stab_class_baseclass, + stab_class_start_method, + stab_class_method_variant, + stab_class_static_method_variant, + stab_class_end_method, + stab_end_class_type, + stab_typedef_type, + stab_tag_type, + stab_typdef, + stab_tag, + stab_int_constant, + stab_float_constant, + stab_typed_constant, + stab_variable, + stab_start_function, + stab_function_parameter, + stab_start_block, + stab_end_block, + stab_end_function, + stab_lineno +}; + +/* Routine to create an entry in a string hash table. */ + +static struct bfd_hash_entry * +string_hash_newfunc (struct bfd_hash_entry *entry, + struct bfd_hash_table *table, const char *string) +{ + struct string_hash_entry *ret = (struct string_hash_entry *) entry; + + /* Allocate the structure if it has not already been allocated by a + subclass. */ + if (ret == (struct string_hash_entry *) NULL) + ret = ((struct string_hash_entry *) + bfd_hash_allocate (table, sizeof (struct string_hash_entry))); + if (ret == (struct string_hash_entry *) NULL) + return NULL; + + /* Call the allocation method of the superclass. */ + ret = ((struct string_hash_entry *) + bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); + + if (ret) + { + /* Initialize the local fields. */ + ret->next = NULL; + ret->index = -1; + ret->size = 0; + } + + return (struct bfd_hash_entry *) ret; +} + +/* Look up an entry in a string hash table. */ + +#define string_hash_lookup(t, string, create, copy) \ + ((struct string_hash_entry *) \ + bfd_hash_lookup (&(t)->table, (string), (create), (copy))) + +/* Add a symbol to the stabs debugging information we are building. */ + +static bfd_boolean +stab_write_symbol (struct stab_write_handle *info, int type, int desc, + bfd_vma value, const char *string) +{ + bfd_size_type strx; + bfd_byte sym[STAB_SYMBOL_SIZE]; + + if (string == NULL) + strx = 0; + else + { + struct string_hash_entry *h; + + h = string_hash_lookup (&info->strhash, string, TRUE, TRUE); + if (h == NULL) + { + non_fatal (_("string_hash_lookup failed: %s"), + bfd_errmsg (bfd_get_error ())); + return FALSE; + } + if (h->index != -1) + strx = h->index; + else + { + strx = info->strings_size; + h->index = strx; + if (info->last_string == NULL) + info->strings = h; + else + info->last_string->next = h; + info->last_string = h; + info->strings_size += strlen (string) + 1; + } + } + + /* This presumes 32 bit values. */ + bfd_put_32 (info->abfd, strx, sym); + bfd_put_8 (info->abfd, type, sym + 4); + bfd_put_8 (info->abfd, 0, sym + 5); + bfd_put_16 (info->abfd, desc, sym + 6); + bfd_put_32 (info->abfd, value, sym + 8); + + if (info->symbols_size + STAB_SYMBOL_SIZE > info->symbols_alloc) + { + info->symbols_alloc *= 2; + info->symbols = (bfd_byte *) xrealloc (info->symbols, + info->symbols_alloc); + } + + memcpy (info->symbols + info->symbols_size, sym, STAB_SYMBOL_SIZE); + + info->symbols_size += STAB_SYMBOL_SIZE; + + return TRUE; +} + +/* Push a string on to the type stack. */ + +static bfd_boolean +stab_push_string (struct stab_write_handle *info, const char *string, + long tindex, bfd_boolean definition, unsigned int size) +{ + struct stab_type_stack *s; + + s = (struct stab_type_stack *) xmalloc (sizeof *s); + s->string = xstrdup (string); + s->index = tindex; + s->definition = definition; + s->size = size; + + s->fields = NULL; + s->baseclasses = NULL; + s->methods = NULL; + s->vtable = NULL; + + s->next = info->type_stack; + info->type_stack = s; + + return TRUE; +} + +/* Push a type index which has already been defined. */ + +static bfd_boolean +stab_push_defined_type (struct stab_write_handle *info, long tindex, + unsigned int size) +{ + char buf[20]; + + sprintf (buf, "%ld", tindex); + return stab_push_string (info, buf, tindex, FALSE, size); +} + +/* Pop a type off the type stack. The caller is responsible for + freeing the string. */ + +static char * +stab_pop_type (struct stab_write_handle *info) +{ + struct stab_type_stack *s; + char *ret; + + s = info->type_stack; + assert (s != NULL); + + info->type_stack = s->next; + + ret = s->string; + + free (s); + + return ret; +} + +/* The general routine to write out stabs in sections debugging + information. This accumulates the stabs symbols and the strings in + two obstacks. We can't easily write out the information as we go + along, because we need to know the section sizes before we can + write out the section contents. ABFD is the BFD and DHANDLE is the + handle for the debugging information. This sets *PSYMS to point to + the symbols, *PSYMSIZE the size of the symbols, *PSTRINGS to the + strings, and *PSTRINGSIZE to the size of the strings. */ + +bfd_boolean +write_stabs_in_sections_debugging_info (bfd *abfd, void *dhandle, + bfd_byte **psyms, + bfd_size_type *psymsize, + bfd_byte **pstrings, + bfd_size_type *pstringsize) +{ + struct stab_write_handle info; + struct string_hash_entry *h; + bfd_byte *p; + + info.abfd = abfd; + + info.symbols_size = 0; + info.symbols_alloc = 500; + info.symbols = (bfd_byte *) xmalloc (info.symbols_alloc); + + info.strings = NULL; + info.last_string = NULL; + /* Reserve 1 byte for a null byte. */ + info.strings_size = 1; + + if (!bfd_hash_table_init (&info.strhash.table, string_hash_newfunc, + sizeof (struct string_hash_entry)) + || !bfd_hash_table_init (&info.typedef_hash.table, string_hash_newfunc, + sizeof (struct string_hash_entry))) + { + non_fatal ("bfd_hash_table_init_failed: %s", + bfd_errmsg (bfd_get_error ())); + return FALSE; + } + + info.type_stack = NULL; + info.type_index = 1; + memset (&info.type_cache, 0, sizeof info.type_cache); + info.so_offset = -1; + info.fun_offset = -1; + info.last_text_address = 0; + info.nesting = 0; + info.fnaddr = 0; + info.pending_lbrac = (bfd_vma) -1; + + /* The initial symbol holds the string size. */ + if (! stab_write_symbol (&info, 0, 0, 0, (const char *) NULL)) + return FALSE; + + /* Output an initial N_SO symbol. */ + info.so_offset = info.symbols_size; + if (! stab_write_symbol (&info, N_SO, 0, 0, bfd_get_filename (abfd))) + return FALSE; + + if (! debug_write (dhandle, &stab_fns, (void *) &info)) + return FALSE; + + assert (info.pending_lbrac == (bfd_vma) -1); + + /* Output a trailing N_SO. */ + if (! stab_write_symbol (&info, N_SO, 0, info.last_text_address, + (const char *) NULL)) + return FALSE; + + /* Put the string size in the initial symbol. */ + bfd_put_32 (abfd, info.strings_size, info.symbols + 8); + + *psyms = info.symbols; + *psymsize = info.symbols_size; + + *pstringsize = info.strings_size; + *pstrings = (bfd_byte *) xmalloc (info.strings_size); + + p = *pstrings; + *p++ = '\0'; + for (h = info.strings; h != NULL; h = h->next) + { + strcpy ((char *) p, h->root.string); + p += strlen ((char *) p) + 1; + } + + return TRUE; +} + +/* Start writing out information for a compilation unit. */ + +static bfd_boolean +stab_start_compilation_unit (void *p, const char *filename) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + /* We would normally output an N_SO symbol here. However, that + would force us to reset all of our type information. I think we + will be better off just outputting an N_SOL symbol, and not + worrying about splitting information between files. */ + + info->lineno_filename = filename; + + return stab_write_symbol (info, N_SOL, 0, 0, filename); +} + +/* Start writing out information for a particular source file. */ + +static bfd_boolean +stab_start_source (void *p, const char *filename) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + /* FIXME: The symbol's value is supposed to be the text section + address. However, we would have to fill it in later, and gdb + doesn't care, so we don't bother with it. */ + + info->lineno_filename = filename; + + return stab_write_symbol (info, N_SOL, 0, 0, filename); +} + +/* Push an empty type. This shouldn't normally happen. We just use a + void type. */ + +static bfd_boolean +stab_empty_type (void *p) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + /* We don't call stab_void_type if the type is not yet defined, + because that might screw up the typedef. */ + + if (info->type_cache.void_type != 0) + return stab_push_defined_type (info, info->type_cache.void_type, 0); + else + { + long tindex; + char buf[40]; + + tindex = info->type_index; + ++info->type_index; + + sprintf (buf, "%ld=%ld", tindex, tindex); + + return stab_push_string (info, buf, tindex, FALSE, 0); + } +} + +/* Push a void type. */ + +static bfd_boolean +stab_void_type (void *p) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + if (info->type_cache.void_type != 0) + return stab_push_defined_type (info, info->type_cache.void_type, 0); + else + { + long tindex; + char buf[40]; + + tindex = info->type_index; + ++info->type_index; + + info->type_cache.void_type = tindex; + + sprintf (buf, "%ld=%ld", tindex, tindex); + + return stab_push_string (info, buf, tindex, TRUE, 0); + } +} + +/* Push an integer type. */ + +static bfd_boolean +stab_int_type (void *p, unsigned int size, bfd_boolean unsignedp) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + long *cache; + + if (size <= 0 || (size > sizeof (long) && size != 8)) + { + non_fatal (_("stab_int_type: bad size %u"), size); + return FALSE; + } + + if (unsignedp) + cache = info->type_cache.signed_integer_types; + else + cache = info->type_cache.unsigned_integer_types; + + if (cache[size - 1] != 0) + return stab_push_defined_type (info, cache[size - 1], size); + else + { + long tindex; + char buf[100]; + + tindex = info->type_index; + ++info->type_index; + + cache[size - 1] = tindex; + + sprintf (buf, "%ld=r%ld;", tindex, tindex); + if (unsignedp) + { + strcat (buf, "0;"); + if (size < sizeof (long)) + sprintf (buf + strlen (buf), "%ld;", ((long) 1 << (size * 8)) - 1); + else if (size == sizeof (long)) + strcat (buf, "-1;"); + else if (size == 8) + strcat (buf, "01777777777777777777777;"); + else + abort (); + } + else + { + if (size <= sizeof (long)) + sprintf (buf + strlen (buf), "%ld;%ld;", + (long) - ((unsigned long) 1 << (size * 8 - 1)), + (long) (((unsigned long) 1 << (size * 8 - 1)) - 1)); + else if (size == 8) + strcat (buf, "01000000000000000000000;0777777777777777777777;"); + else + abort (); + } + + return stab_push_string (info, buf, tindex, TRUE, size); + } +} + +/* Push a floating point type. */ + +static bfd_boolean +stab_float_type (void *p, unsigned int size) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + if (size > 0 + && size - 1 < (sizeof info->type_cache.float_types + / sizeof info->type_cache.float_types[0]) + && info->type_cache.float_types[size - 1] != 0) + return stab_push_defined_type (info, + info->type_cache.float_types[size - 1], + size); + else + { + long tindex; + char *int_type; + char buf[50]; + + /* Floats are defined as a subrange of int. */ + if (! stab_int_type (info, 4, FALSE)) + return FALSE; + int_type = stab_pop_type (info); + + tindex = info->type_index; + ++info->type_index; + + if (size > 0 + && size - 1 < (sizeof info->type_cache.float_types + / sizeof info->type_cache.float_types[0])) + info->type_cache.float_types[size - 1] = tindex; + + sprintf (buf, "%ld=r%s;%u;0;", tindex, int_type, size); + + free (int_type); + + return stab_push_string (info, buf, tindex, TRUE, size); + } +} + +/* Push a complex type. */ + +static bfd_boolean +stab_complex_type (void *p, unsigned int size) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + char buf[50]; + long tindex; + + tindex = info->type_index; + ++info->type_index; + + sprintf (buf, "%ld=r%ld;%u;0;", tindex, tindex, size); + + return stab_push_string (info, buf, tindex, TRUE, size * 2); +} + +/* Push a bfd_boolean type. We use an XCOFF predefined type, since gdb + always recognizes them. */ + +static bfd_boolean +stab_bool_type (void *p, unsigned int size) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + long tindex; + + switch (size) + { + case 1: + tindex = -21; + break; + + case 2: + tindex = -22; + break; + + default: + case 4: + tindex = -16; + break; + + case 8: + tindex = -33; + break; + } + + return stab_push_defined_type (info, tindex, size); +} + +/* Push an enum type. */ + +static bfd_boolean +stab_enum_type (void *p, const char *tag, const char **names, + bfd_signed_vma *vals) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + size_t len; + const char **pn; + char *buf; + long tindex = 0; + bfd_signed_vma *pv; + + if (names == NULL) + { + assert (tag != NULL); + + buf = (char *) xmalloc (10 + strlen (tag)); + sprintf (buf, "xe%s:", tag); + /* FIXME: The size is just a guess. */ + if (! stab_push_string (info, buf, 0, FALSE, 4)) + return FALSE; + free (buf); + return TRUE; + } + + len = 10; + if (tag != NULL) + len += strlen (tag); + for (pn = names; *pn != NULL; pn++) + len += strlen (*pn) + 20; + + buf = (char *) xmalloc (len); + + if (tag == NULL) + strcpy (buf, "e"); + else + { + tindex = info->type_index; + ++info->type_index; + sprintf (buf, "%s:T%ld=e", tag, tindex); + } + + for (pn = names, pv = vals; *pn != NULL; pn++, pv++) + sprintf (buf + strlen (buf), "%s:%ld,", *pn, (long) *pv); + strcat (buf, ";"); + + if (tag == NULL) + { + /* FIXME: The size is just a guess. */ + if (! stab_push_string (info, buf, 0, FALSE, 4)) + return FALSE; + } + else + { + /* FIXME: The size is just a guess. */ + if (! stab_write_symbol (info, N_LSYM, 0, 0, buf) + || ! stab_push_defined_type (info, tindex, 4)) + return FALSE; + } + + free (buf); + + return TRUE; +} + +/* Push a modification of the top type on the stack. Cache the + results in CACHE and CACHE_ALLOC. */ + +static bfd_boolean +stab_modify_type (struct stab_write_handle *info, int mod, + unsigned int size, long **cache, size_t *cache_alloc) +{ + long targindex; + long tindex; + char *s, *buf; + + assert (info->type_stack != NULL); + targindex = info->type_stack->index; + + if (targindex <= 0 + || cache == NULL) + { + bfd_boolean definition; + + /* Either the target type has no index, or we aren't caching + this modifier. Either way we have no way of recording the + new type, so we don't bother to define one. */ + definition = info->type_stack->definition; + s = stab_pop_type (info); + buf = (char *) xmalloc (strlen (s) + 2); + sprintf (buf, "%c%s", mod, s); + free (s); + if (! stab_push_string (info, buf, 0, definition, size)) + return FALSE; + free (buf); + } + else + { + if ((size_t) targindex >= *cache_alloc) + { + size_t alloc; + + alloc = *cache_alloc; + if (alloc == 0) + alloc = 10; + while ((size_t) targindex >= alloc) + alloc *= 2; + *cache = (long *) xrealloc (*cache, alloc * sizeof (long)); + memset (*cache + *cache_alloc, 0, + (alloc - *cache_alloc) * sizeof (long)); + *cache_alloc = alloc; + } + + tindex = (*cache)[targindex]; + if (tindex != 0 && ! info->type_stack->definition) + { + /* We have already defined a modification of this type, and + the entry on the type stack is not a definition, so we + can safely discard it (we may have a definition on the + stack, even if we already defined a modification, if it + is a struct which we did not define at the time it was + referenced). */ + free (stab_pop_type (info)); + if (! stab_push_defined_type (info, tindex, size)) + return FALSE; + } + else + { + tindex = info->type_index; + ++info->type_index; + + s = stab_pop_type (info); + buf = (char *) xmalloc (strlen (s) + 20); + sprintf (buf, "%ld=%c%s", tindex, mod, s); + free (s); + + (*cache)[targindex] = tindex; + + if (! stab_push_string (info, buf, tindex, TRUE, size)) + return FALSE; + + free (buf); + } + } + + return TRUE; +} + +/* Push a pointer type. */ + +static bfd_boolean +stab_pointer_type (void *p) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + /* FIXME: The size should depend upon the architecture. */ + return stab_modify_type (info, '*', 4, &info->type_cache.pointer_types, + &info->type_cache.pointer_types_alloc); +} + +/* Push a function type. */ + +static bfd_boolean +stab_function_type (void *p, int argcount, + bfd_boolean varargs ATTRIBUTE_UNUSED) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + int i; + + /* We have no way to represent the argument types, so we just + discard them. However, if they define new types, we must output + them. We do this by producing empty typedefs. */ + for (i = 0; i < argcount; i++) + { + if (! info->type_stack->definition) + free (stab_pop_type (info)); + else + { + char *s, *buf; + + s = stab_pop_type (info); + + buf = (char *) xmalloc (strlen (s) + 3); + sprintf (buf, ":t%s", s); + free (s); + + if (! stab_write_symbol (info, N_LSYM, 0, 0, buf)) + return FALSE; + + free (buf); + } + } + + return stab_modify_type (info, 'f', 0, &info->type_cache.function_types, + &info->type_cache.function_types_alloc); +} + +/* Push a reference type. */ + +static bfd_boolean +stab_reference_type (void *p) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + /* FIXME: The size should depend upon the architecture. */ + return stab_modify_type (info, '&', 4, &info->type_cache.reference_types, + &info->type_cache.reference_types_alloc); +} + +/* Push a range type. */ + +static bfd_boolean +stab_range_type (void *p, bfd_signed_vma low, bfd_signed_vma high) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + bfd_boolean definition; + unsigned int size; + char *s, *buf; + + definition = info->type_stack->definition; + size = info->type_stack->size; + + s = stab_pop_type (info); + buf = (char *) xmalloc (strlen (s) + 100); + sprintf (buf, "r%s;%ld;%ld;", s, (long) low, (long) high); + free (s); + + if (! stab_push_string (info, buf, 0, definition, size)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Push an array type. */ + +static bfd_boolean +stab_array_type (void *p, bfd_signed_vma low, bfd_signed_vma high, + bfd_boolean stringp) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + bfd_boolean definition; + unsigned int element_size; + char *range, *element, *buf; + long tindex; + unsigned int size; + + definition = info->type_stack->definition; + range = stab_pop_type (info); + + definition = definition || info->type_stack->definition; + element_size = info->type_stack->size; + element = stab_pop_type (info); + + buf = (char *) xmalloc (strlen (range) + strlen (element) + 100); + + if (! stringp) + { + tindex = 0; + *buf = '\0'; + } + else + { + /* We need to define a type in order to include the string + attribute. */ + tindex = info->type_index; + ++info->type_index; + definition = TRUE; + sprintf (buf, "%ld=@S;", tindex); + } + + sprintf (buf + strlen (buf), "ar%s;%ld;%ld;%s", + range, (long) low, (long) high, element); + free (range); + free (element); + + if (high < low) + size = 0; + else + size = element_size * ((high - low) + 1); + if (! stab_push_string (info, buf, tindex, definition, size)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Push a set type. */ + +static bfd_boolean +stab_set_type (void *p, bfd_boolean bitstringp) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + bfd_boolean definition; + char *s, *buf; + long tindex; + + definition = info->type_stack->definition; + + s = stab_pop_type (info); + buf = (char *) xmalloc (strlen (s) + 30); + + if (! bitstringp) + { + *buf = '\0'; + tindex = 0; + } + else + { + /* We need to define a type in order to include the string + attribute. */ + tindex = info->type_index; + ++info->type_index; + definition = TRUE; + sprintf (buf, "%ld=@S;", tindex); + } + + sprintf (buf + strlen (buf), "S%s", s); + free (s); + + if (! stab_push_string (info, buf, tindex, definition, 0)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Push an offset type. */ + +static bfd_boolean +stab_offset_type (void *p) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + bfd_boolean definition; + char *target, *base, *buf; + + definition = info->type_stack->definition; + target = stab_pop_type (info); + + definition = definition || info->type_stack->definition; + base = stab_pop_type (info); + + buf = (char *) xmalloc (strlen (target) + strlen (base) + 3); + sprintf (buf, "@%s,%s", base, target); + free (base); + free (target); + + if (! stab_push_string (info, buf, 0, definition, 0)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Push a method type. */ + +static bfd_boolean +stab_method_type (void *p, bfd_boolean domainp, int argcount, + bfd_boolean varargs) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + bfd_boolean definition; + char *domain, *return_type, *buf; + char **args; + int i; + size_t len; + + /* We don't bother with stub method types, because that would + require a mangler for C++ argument types. This will waste space + in the debugging output. */ + + /* We need a domain. I'm not sure DOMAINP can ever be false, + anyhow. */ + if (! domainp) + { + if (! stab_empty_type (p)) + return FALSE; + } + + definition = info->type_stack->definition; + domain = stab_pop_type (info); + + /* A non-varargs function is indicated by making the last parameter + type be void. */ + + if (argcount < 0) + { + args = NULL; + argcount = 0; + } + else if (argcount == 0) + { + if (varargs) + args = NULL; + else + { + args = (char **) xmalloc (1 * sizeof (*args)); + if (! stab_empty_type (p)) + return FALSE; + definition = definition || info->type_stack->definition; + args[0] = stab_pop_type (info); + argcount = 1; + } + } + else + { + args = (char **) xmalloc ((argcount + 1) * sizeof (*args)); + for (i = argcount - 1; i >= 0; i--) + { + definition = definition || info->type_stack->definition; + args[i] = stab_pop_type (info); + } + if (! varargs) + { + if (! stab_empty_type (p)) + return FALSE; + definition = definition || info->type_stack->definition; + args[argcount] = stab_pop_type (info); + ++argcount; + } + } + + definition = definition || info->type_stack->definition; + return_type = stab_pop_type (info); + + len = strlen (domain) + strlen (return_type) + 10; + for (i = 0; i < argcount; i++) + len += strlen (args[i]); + + buf = (char *) xmalloc (len); + + sprintf (buf, "#%s,%s", domain, return_type); + free (domain); + free (return_type); + for (i = 0; i < argcount; i++) + { + strcat (buf, ","); + strcat (buf, args[i]); + free (args[i]); + } + strcat (buf, ";"); + + if (args != NULL) + free (args); + + if (! stab_push_string (info, buf, 0, definition, 0)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Push a const version of a type. */ + +static bfd_boolean +stab_const_type (void *p) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + return stab_modify_type (info, 'k', info->type_stack->size, + (long **) NULL, (size_t *) NULL); +} + +/* Push a volatile version of a type. */ + +static bfd_boolean +stab_volatile_type (void *p) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + return stab_modify_type (info, 'B', info->type_stack->size, + (long **) NULL, (size_t *) NULL); +} + +/* Get the type index to use for a struct/union/class ID. This should + return -1 if it fails. */ + +static long +stab_get_struct_index (struct stab_write_handle *info, const char *tag, + unsigned int id, enum debug_type_kind kind, + unsigned int *psize) +{ + if (id >= info->type_cache.struct_types_alloc) + { + size_t alloc; + + alloc = info->type_cache.struct_types_alloc; + if (alloc == 0) + alloc = 10; + while (id >= alloc) + alloc *= 2; + info->type_cache.struct_types = + (struct stab_tag *) xrealloc (info->type_cache.struct_types, + alloc * sizeof (struct stab_tag)); + memset ((info->type_cache.struct_types + + info->type_cache.struct_types_alloc), + 0, + ((alloc - info->type_cache.struct_types_alloc) + * sizeof (struct stab_tag))); + info->type_cache.struct_types_alloc = alloc; + } + + if (info->type_cache.struct_types[id].index == 0) + { + info->type_cache.struct_types[id].index = info->type_index; + ++info->type_index; + info->type_cache.struct_types[id].tag = tag; + info->type_cache.struct_types[id].kind = kind; + } + + if (kind == DEBUG_KIND_ILLEGAL) + { + /* This is a definition of the struct. */ + info->type_cache.struct_types[id].kind = kind; + info->type_cache.struct_types[id].size = *psize; + } + else + *psize = info->type_cache.struct_types[id].size; + + return info->type_cache.struct_types[id].index; +} + +/* Start outputting a struct. We ignore the tag, and handle it in + stab_tag. */ + +static bfd_boolean +stab_start_struct_type (void *p, const char *tag, unsigned int id, + bfd_boolean structp, unsigned int size) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + long tindex; + bfd_boolean definition; + char buf[40]; + + if (id == 0) + { + tindex = 0; + *buf = '\0'; + definition = FALSE; + } + else + { + tindex = stab_get_struct_index (info, tag, id, DEBUG_KIND_ILLEGAL, + &size); + if (tindex < 0) + return FALSE; + sprintf (buf, "%ld=", tindex); + definition = TRUE; + } + + sprintf (buf + strlen (buf), "%c%u", + structp ? 's' : 'u', + size); + + if (! stab_push_string (info, buf, tindex, definition, size)) + return FALSE; + + info->type_stack->fields = (char *) xmalloc (1); + info->type_stack->fields[0] = '\0'; + + return TRUE; +} + +/* Add a field to a struct. */ + +static bfd_boolean +stab_struct_field (void *p, const char *name, bfd_vma bitpos, + bfd_vma bitsize, enum debug_visibility visibility) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + bfd_boolean definition; + unsigned int size; + char *s, *n; + const char *vis; + + definition = info->type_stack->definition; + size = info->type_stack->size; + s = stab_pop_type (info); + + /* Add this field to the end of the current struct fields, which is + currently on the top of the stack. */ + + assert (info->type_stack->fields != NULL); + n = (char *) xmalloc (strlen (info->type_stack->fields) + + strlen (name) + + strlen (s) + + 50); + + switch (visibility) + { + default: + abort (); + + case DEBUG_VISIBILITY_PUBLIC: + vis = ""; + break; + + case DEBUG_VISIBILITY_PRIVATE: + vis = "/0"; + break; + + case DEBUG_VISIBILITY_PROTECTED: + vis = "/1"; + break; + } + + if (bitsize == 0) + { + bitsize = size * 8; + if (bitsize == 0) + non_fatal (_("%s: warning: unknown size for field `%s' in struct"), + bfd_get_filename (info->abfd), name); + } + + sprintf (n, "%s%s:%s%s,%ld,%ld;", info->type_stack->fields, name, vis, s, + (long) bitpos, (long) bitsize); + + free (info->type_stack->fields); + info->type_stack->fields = n; + + if (definition) + info->type_stack->definition = TRUE; + + return TRUE; +} + +/* Finish up a struct. */ + +static bfd_boolean +stab_end_struct_type (void *p) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + bfd_boolean definition; + long tindex; + unsigned int size; + char *fields, *first, *buf; + + assert (info->type_stack != NULL && info->type_stack->fields != NULL); + + definition = info->type_stack->definition; + tindex = info->type_stack->index; + size = info->type_stack->size; + fields = info->type_stack->fields; + first = stab_pop_type (info); + + buf = (char *) xmalloc (strlen (first) + strlen (fields) + 2); + sprintf (buf, "%s%s;", first, fields); + free (first); + free (fields); + + if (! stab_push_string (info, buf, tindex, definition, size)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Start outputting a class. */ + +static bfd_boolean +stab_start_class_type (void *p, const char *tag, unsigned int id, bfd_boolean structp, unsigned int size, bfd_boolean vptr, bfd_boolean ownvptr) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + bfd_boolean definition; + char *vstring; + + if (! vptr || ownvptr) + { + definition = FALSE; + vstring = NULL; + } + else + { + definition = info->type_stack->definition; + vstring = stab_pop_type (info); + } + + if (! stab_start_struct_type (p, tag, id, structp, size)) + return FALSE; + + if (vptr) + { + char *vtable; + + if (ownvptr) + { + assert (info->type_stack->index > 0); + vtable = (char *) xmalloc (20); + sprintf (vtable, "~%%%ld", info->type_stack->index); + } + else + { + vtable = (char *) xmalloc (strlen (vstring) + 3); + sprintf (vtable, "~%%%s", vstring); + free (vstring); + } + + info->type_stack->vtable = vtable; + } + + if (definition) + info->type_stack->definition = TRUE; + + return TRUE; +} + +/* Add a static member to the class on the type stack. */ + +static bfd_boolean +stab_class_static_member (void *p, const char *name, const char *physname, + enum debug_visibility visibility) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + bfd_boolean definition; + char *s, *n; + const char *vis; + + definition = info->type_stack->definition; + s = stab_pop_type (info); + + /* Add this field to the end of the current struct fields, which is + currently on the top of the stack. */ + + assert (info->type_stack->fields != NULL); + n = (char *) xmalloc (strlen (info->type_stack->fields) + + strlen (name) + + strlen (s) + + strlen (physname) + + 10); + + switch (visibility) + { + default: + abort (); + + case DEBUG_VISIBILITY_PUBLIC: + vis = ""; + break; + + case DEBUG_VISIBILITY_PRIVATE: + vis = "/0"; + break; + + case DEBUG_VISIBILITY_PROTECTED: + vis = "/1"; + break; + } + + sprintf (n, "%s%s:%s%s:%s;", info->type_stack->fields, name, vis, s, + physname); + + free (info->type_stack->fields); + info->type_stack->fields = n; + + if (definition) + info->type_stack->definition = TRUE; + + return TRUE; +} + +/* Add a base class to the class on the type stack. */ + +static bfd_boolean +stab_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean is_virtual, + enum debug_visibility visibility) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + bfd_boolean definition; + char *s; + char *buf; + unsigned int c; + char **baseclasses; + + definition = info->type_stack->definition; + s = stab_pop_type (info); + + /* Build the base class specifier. */ + + buf = (char *) xmalloc (strlen (s) + 25); + buf[0] = is_virtual ? '1' : '0'; + switch (visibility) + { + default: + abort (); + + case DEBUG_VISIBILITY_PRIVATE: + buf[1] = '0'; + break; + + case DEBUG_VISIBILITY_PROTECTED: + buf[1] = '1'; + break; + + case DEBUG_VISIBILITY_PUBLIC: + buf[1] = '2'; + break; + } + + sprintf (buf + 2, "%ld,%s;", (long) bitpos, s); + free (s); + + /* Add the new baseclass to the existing ones. */ + + assert (info->type_stack != NULL && info->type_stack->fields != NULL); + + if (info->type_stack->baseclasses == NULL) + c = 0; + else + { + c = 0; + while (info->type_stack->baseclasses[c] != NULL) + ++c; + } + + baseclasses = (char **) xrealloc (info->type_stack->baseclasses, + (c + 2) * sizeof (*baseclasses)); + baseclasses[c] = buf; + baseclasses[c + 1] = NULL; + + info->type_stack->baseclasses = baseclasses; + + if (definition) + info->type_stack->definition = TRUE; + + return TRUE; +} + +/* Start adding a method to the class on the type stack. */ + +static bfd_boolean +stab_class_start_method (void *p, const char *name) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + char *m; + + assert (info->type_stack != NULL && info->type_stack->fields != NULL); + + if (info->type_stack->methods == NULL) + { + m = (char *) xmalloc (strlen (name) + 3); + *m = '\0'; + } + else + { + m = (char *) xrealloc (info->type_stack->methods, + (strlen (info->type_stack->methods) + + strlen (name) + + 4)); + } + + sprintf (m + strlen (m), "%s::", name); + + info->type_stack->methods = m; + + return TRUE; +} + +/* Add a variant, either static or not, to the current method. */ + +static bfd_boolean +stab_class_method_var (struct stab_write_handle *info, const char *physname, + enum debug_visibility visibility, + bfd_boolean staticp, bfd_boolean constp, + bfd_boolean volatilep, bfd_vma voffset, + bfd_boolean contextp) +{ + bfd_boolean definition; + char *type; + char *context = NULL; + char visc, qualc, typec; + + definition = info->type_stack->definition; + type = stab_pop_type (info); + + if (contextp) + { + definition = definition || info->type_stack->definition; + context = stab_pop_type (info); + } + + assert (info->type_stack != NULL && info->type_stack->methods != NULL); + + switch (visibility) + { + default: + abort (); + + case DEBUG_VISIBILITY_PRIVATE: + visc = '0'; + break; + + case DEBUG_VISIBILITY_PROTECTED: + visc = '1'; + break; + + case DEBUG_VISIBILITY_PUBLIC: + visc = '2'; + break; + } + + if (constp) + { + if (volatilep) + qualc = 'D'; + else + qualc = 'B'; + } + else + { + if (volatilep) + qualc = 'C'; + else + qualc = 'A'; + } + + if (staticp) + typec = '?'; + else if (! contextp) + typec = '.'; + else + typec = '*'; + + info->type_stack->methods = + (char *) xrealloc (info->type_stack->methods, + (strlen (info->type_stack->methods) + + strlen (type) + + strlen (physname) + + (contextp ? strlen (context) : 0) + + 40)); + + sprintf (info->type_stack->methods + strlen (info->type_stack->methods), + "%s:%s;%c%c%c", type, physname, visc, qualc, typec); + free (type); + + if (contextp) + { + sprintf (info->type_stack->methods + strlen (info->type_stack->methods), + "%ld;%s;", (long) voffset, context); + free (context); + } + + if (definition) + info->type_stack->definition = TRUE; + + return TRUE; +} + +/* Add a variant to the current method. */ + +static bfd_boolean +stab_class_method_variant (void *p, const char *physname, + enum debug_visibility visibility, + bfd_boolean constp, bfd_boolean volatilep, + bfd_vma voffset, bfd_boolean contextp) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + return stab_class_method_var (info, physname, visibility, FALSE, constp, + volatilep, voffset, contextp); +} + +/* Add a static variant to the current method. */ + +static bfd_boolean +stab_class_static_method_variant (void *p, const char *physname, + enum debug_visibility visibility, + bfd_boolean constp, bfd_boolean volatilep) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + return stab_class_method_var (info, physname, visibility, TRUE, constp, + volatilep, 0, FALSE); +} + +/* Finish up a method. */ + +static bfd_boolean +stab_class_end_method (void *p) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + assert (info->type_stack != NULL && info->type_stack->methods != NULL); + + /* We allocated enough room on info->type_stack->methods to add the + trailing semicolon. */ + strcat (info->type_stack->methods, ";"); + + return TRUE; +} + +/* Finish up a class. */ + +static bfd_boolean +stab_end_class_type (void *p) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + size_t len; + unsigned int i = 0; + char *buf; + + assert (info->type_stack != NULL && info->type_stack->fields != NULL); + + /* Work out the size we need to allocate for the class definition. */ + + len = (strlen (info->type_stack->string) + + strlen (info->type_stack->fields) + + 10); + if (info->type_stack->baseclasses != NULL) + { + len += 20; + for (i = 0; info->type_stack->baseclasses[i] != NULL; i++) + len += strlen (info->type_stack->baseclasses[i]); + } + if (info->type_stack->methods != NULL) + len += strlen (info->type_stack->methods); + if (info->type_stack->vtable != NULL) + len += strlen (info->type_stack->vtable); + + /* Build the class definition. */ + + buf = (char *) xmalloc (len); + + strcpy (buf, info->type_stack->string); + + if (info->type_stack->baseclasses != NULL) + { + sprintf (buf + strlen (buf), "!%u,", i); + for (i = 0; info->type_stack->baseclasses[i] != NULL; i++) + { + strcat (buf, info->type_stack->baseclasses[i]); + free (info->type_stack->baseclasses[i]); + } + free (info->type_stack->baseclasses); + info->type_stack->baseclasses = NULL; + } + + strcat (buf, info->type_stack->fields); + free (info->type_stack->fields); + info->type_stack->fields = NULL; + + if (info->type_stack->methods != NULL) + { + strcat (buf, info->type_stack->methods); + free (info->type_stack->methods); + info->type_stack->methods = NULL; + } + + strcat (buf, ";"); + + if (info->type_stack->vtable != NULL) + { + strcat (buf, info->type_stack->vtable); + free (info->type_stack->vtable); + info->type_stack->vtable = NULL; + } + + /* Replace the string on the top of the stack with the complete + class definition. */ + free (info->type_stack->string); + info->type_stack->string = buf; + + return TRUE; +} + +/* Push a typedef which was previously defined. */ + +static bfd_boolean +stab_typedef_type (void *p, const char *name) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + struct string_hash_entry *h; + + h = string_hash_lookup (&info->typedef_hash, name, FALSE, FALSE); + assert (h != NULL && h->index > 0); + + return stab_push_defined_type (info, h->index, h->size); +} + +/* Push a struct, union or class tag. */ + +static bfd_boolean +stab_tag_type (void *p, const char *name, unsigned int id, + enum debug_type_kind kind) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + long tindex; + unsigned int size = 0; + + tindex = stab_get_struct_index (info, name, id, kind, &size); + if (tindex < 0) + return FALSE; + + return stab_push_defined_type (info, tindex, size); +} + +/* Define a typedef. */ + +static bfd_boolean +stab_typdef (void *p, const char *name) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + long tindex; + unsigned int size; + char *s, *buf; + struct string_hash_entry *h; + + tindex = info->type_stack->index; + size = info->type_stack->size; + s = stab_pop_type (info); + + buf = (char *) xmalloc (strlen (name) + strlen (s) + 20); + + if (tindex > 0) + sprintf (buf, "%s:t%s", name, s); + else + { + tindex = info->type_index; + ++info->type_index; + sprintf (buf, "%s:t%ld=%s", name, tindex, s); + } + + free (s); + + if (! stab_write_symbol (info, N_LSYM, 0, 0, buf)) + return FALSE; + + free (buf); + + h = string_hash_lookup (&info->typedef_hash, name, TRUE, FALSE); + if (h == NULL) + { + non_fatal (_("string_hash_lookup failed: %s"), + bfd_errmsg (bfd_get_error ())); + return FALSE; + } + + /* I don't think we care about redefinitions. */ + + h->index = tindex; + h->size = size; + + return TRUE; +} + +/* Define a tag. */ + +static bfd_boolean +stab_tag (void *p, const char *tag) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + char *s, *buf; + + s = stab_pop_type (info); + + buf = (char *) xmalloc (strlen (tag) + strlen (s) + 3); + + sprintf (buf, "%s:T%s", tag, s); + free (s); + + if (! stab_write_symbol (info, N_LSYM, 0, 0, buf)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Define an integer constant. */ + +static bfd_boolean +stab_int_constant (void *p, const char *name, bfd_vma val) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + char *buf; + + buf = (char *) xmalloc (strlen (name) + 20); + sprintf (buf, "%s:c=i%ld", name, (long) val); + + if (! stab_write_symbol (info, N_LSYM, 0, 0, buf)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Define a floating point constant. */ + +static bfd_boolean +stab_float_constant (void *p, const char *name, double val) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + char *buf; + + buf = (char *) xmalloc (strlen (name) + 20); + sprintf (buf, "%s:c=f%g", name, val); + + if (! stab_write_symbol (info, N_LSYM, 0, 0, buf)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Define a typed constant. */ + +static bfd_boolean +stab_typed_constant (void *p, const char *name, bfd_vma val) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + char *s, *buf; + + s = stab_pop_type (info); + + buf = (char *) xmalloc (strlen (name) + strlen (s) + 20); + sprintf (buf, "%s:c=e%s,%ld", name, s, (long) val); + free (s); + + if (! stab_write_symbol (info, N_LSYM, 0, 0, buf)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Record a variable. */ + +static bfd_boolean +stab_variable (void *p, const char *name, enum debug_var_kind kind, + bfd_vma val) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + char *s, *buf; + int stab_type; + const char *kindstr; + + s = stab_pop_type (info); + + switch (kind) + { + default: + abort (); + + case DEBUG_GLOBAL: + stab_type = N_GSYM; + kindstr = "G"; + break; + + case DEBUG_STATIC: + stab_type = N_STSYM; + kindstr = "S"; + break; + + case DEBUG_LOCAL_STATIC: + stab_type = N_STSYM; + kindstr = "V"; + break; + + case DEBUG_LOCAL: + stab_type = N_LSYM; + kindstr = ""; + + /* Make sure that this is a type reference or definition. */ + if (! ISDIGIT (*s)) + { + char *n; + long tindex; + + tindex = info->type_index; + ++info->type_index; + n = (char *) xmalloc (strlen (s) + 20); + sprintf (n, "%ld=%s", tindex, s); + free (s); + s = n; + } + break; + + case DEBUG_REGISTER: + stab_type = N_RSYM; + kindstr = "r"; + break; + } + + buf = (char *) xmalloc (strlen (name) + strlen (s) + 3); + sprintf (buf, "%s:%s%s", name, kindstr, s); + free (s); + + if (! stab_write_symbol (info, stab_type, 0, val, buf)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Start outputting a function. */ + +static bfd_boolean +stab_start_function (void *p, const char *name, bfd_boolean globalp) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + char *rettype, *buf; + + assert (info->nesting == 0 && info->fun_offset == -1); + + rettype = stab_pop_type (info); + + buf = (char *) xmalloc (strlen (name) + strlen (rettype) + 3); + sprintf (buf, "%s:%c%s", name, + globalp ? 'F' : 'f', + rettype); + + /* We don't know the value now, so we set it in start_block. */ + info->fun_offset = info->symbols_size; + + if (! stab_write_symbol (info, N_FUN, 0, 0, buf)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Output a function parameter. */ + +static bfd_boolean +stab_function_parameter (void *p, const char *name, enum debug_parm_kind kind, bfd_vma val) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + char *s, *buf; + int stab_type; + char kindc; + + s = stab_pop_type (info); + + switch (kind) + { + default: + abort (); + + case DEBUG_PARM_STACK: + stab_type = N_PSYM; + kindc = 'p'; + break; + + case DEBUG_PARM_REG: + stab_type = N_RSYM; + kindc = 'P'; + break; + + case DEBUG_PARM_REFERENCE: + stab_type = N_PSYM; + kindc = 'v'; + break; + + case DEBUG_PARM_REF_REG: + stab_type = N_RSYM; + kindc = 'a'; + break; + } + + buf = (char *) xmalloc (strlen (name) + strlen (s) + 3); + sprintf (buf, "%s:%c%s", name, kindc, s); + free (s); + + if (! stab_write_symbol (info, stab_type, 0, val, buf)) + return FALSE; + + free (buf); + + return TRUE; +} + +/* Start a block. */ + +static bfd_boolean +stab_start_block (void *p, bfd_vma addr) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + /* Fill in any slots which have been waiting for the first known + text address. */ + + if (info->so_offset != -1) + { + bfd_put_32 (info->abfd, addr, info->symbols + info->so_offset + 8); + info->so_offset = -1; + } + + if (info->fun_offset != -1) + { + bfd_put_32 (info->abfd, addr, info->symbols + info->fun_offset + 8); + info->fun_offset = -1; + } + + ++info->nesting; + + /* We will be called with a top level block surrounding the + function, but stabs information does not output that block, so we + ignore it. */ + + if (info->nesting == 1) + { + info->fnaddr = addr; + return TRUE; + } + + /* We have to output the LBRAC symbol after any variables which are + declared inside the block. We postpone the LBRAC until the next + start_block or end_block. */ + + /* If we have postponed an LBRAC, output it now. */ + if (info->pending_lbrac != (bfd_vma) -1) + { + if (! stab_write_symbol (info, N_LBRAC, 0, info->pending_lbrac, + (const char *) NULL)) + return FALSE; + } + + /* Remember the address and output it later. */ + + info->pending_lbrac = addr - info->fnaddr; + + return TRUE; +} + +/* End a block. */ + +static bfd_boolean +stab_end_block (void *p, bfd_vma addr) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + if (addr > info->last_text_address) + info->last_text_address = addr; + + /* If we have postponed an LBRAC, output it now. */ + if (info->pending_lbrac != (bfd_vma) -1) + { + if (! stab_write_symbol (info, N_LBRAC, 0, info->pending_lbrac, + (const char *) NULL)) + return FALSE; + info->pending_lbrac = (bfd_vma) -1; + } + + assert (info->nesting > 0); + + --info->nesting; + + /* We ignore the outermost block. */ + if (info->nesting == 0) + return TRUE; + + return stab_write_symbol (info, N_RBRAC, 0, addr - info->fnaddr, + (const char *) NULL); +} + +/* End a function. */ + +static bfd_boolean +stab_end_function (void *p ATTRIBUTE_UNUSED) +{ + return TRUE; +} + +/* Output a line number. */ + +static bfd_boolean +stab_lineno (void *p, const char *file, unsigned long lineno, bfd_vma addr) +{ + struct stab_write_handle *info = (struct stab_write_handle *) p; + + assert (info->lineno_filename != NULL); + + if (addr > info->last_text_address) + info->last_text_address = addr; + + if (filename_cmp (file, info->lineno_filename) != 0) + { + if (! stab_write_symbol (info, N_SOL, 0, addr, file)) + return FALSE; + info->lineno_filename = file; + } + + return stab_write_symbol (info, N_SLINE, lineno, addr - info->fnaddr, + (const char *) NULL); +} -- cgit v1.2.3